G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsPointGrid.h
Go to the documentation of this file.
1
14#pragma once
15
18
19namespace gismo {
20
21
22/* **************** Utility functions **************** */
23
24template<typename T> // gsMatrix<T> ab
25gsVector<unsigned> uniformSampleCount (const gsVector<T>& lower,
26 const gsVector<T>& upper,
27 int numPoints = 1000);
28
29template<typename T>
30void uniformIntervals(const gsVector<T>& lower, const gsVector<T>& upper,
31 std::vector< std::vector<T> >& intervals, int numIntervals = 1000);
32
33
34/* **************** Uniform grids described by limits/corners **************** */
35
36
52template<class T> // gsMatrix<T> ab
53gsMatrix<T> gsPointGrid( gsVector<T> const & a, gsVector<T> const & b,
54 gsVector<unsigned> const & np );
55
56// Specialization of the arguments for the 1D case
57template<class T> inline
58gsMatrix<T> gsPointGrid( T const & t1, T const & t2, unsigned const & n = 100)
59{
60 gsMatrix<T,1,2> ab(1,2); ab << t1, t2;
61 gsGridIterator<T,CUBE,1> pt(ab,n);
62 gsMatrix<T> rvo(ab.rows(), pt.numPoints() );
63 for(index_t c = 0; pt; ++pt, ++c)
64 rvo.col(c) = *pt;
65 return rvo;
66}
67
72template<typename T> // todo: remove, replace by next one
73gsMatrix<T>uniformPointGrid(const gsVector<T>& lower, // note: structure lost
74 const gsVector<T>& upper,
75 int numPoints = 1000);
76
83template<class T> inline
84gsMatrix<T> gsPointGrid(gsMatrix<T> const & ab, int numPoints)
85{ // Note: structure lost
86 gsGridIterator<T,CUBE> pt(ab,numPoints);
87 gsMatrix<T> rvo(ab.rows(), pt.numPoints() );
88 for(index_t c = 0; pt; ++pt, ++c)
89 rvo.col(c) = *pt;
90 return rvo;
91}
92
93
94/* **************** Cartesian grids **************** */
95
96
99template<class T, class CwiseContainer> inline
100void gsPointGrid(CwiseContainer const & cwise, gsMatrix<T>& res)
101{
102 gsGridIterator<T,CWISE> pt(cwise);
103 res.resize(cwise.size(), pt.numPoints() );
104 for(index_t c = 0; pt; ++pt, ++c)
105 res.col(c) = *pt;
106}
107
109template<class T, class CwiseContainer> inline
110gsMatrix<T> gsPointGrid(CwiseContainer const & cwise)
111{
112 gsMatrix<T> rvo;
113 gsPointGrid(cwise, rvo);
114 return rvo;
115}
116
117
118} // namespace gismo
119
120
121#ifndef GISMO_BUILD_LIB
122#include GISMO_HPP_HEADER(gsPointGrid.hpp)
123#endif
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
gsMatrix< T > gsPointGrid(gsVector< T > const &a, gsVector< T > const &b, gsVector< unsigned > const &np)
Construct a Cartesian grid of uniform points in a hypercube, using np[i] points in direction i.
Definition gsPointGrid.hpp:82
#define index_t
Definition gsConfig.h:32
Provides iteration over integer or numeric points in a (hyper-)cube.
This is the main header file that collects wrappers of Eigen for linear algebra.
The G+Smo namespace, containing all definitions for the library.
gsMatrix< T > uniformPointGrid(const gsVector< T > &lower, const gsVector< T > &upper, int numPoints=1000)
Definition gsPointGrid.hpp:94