23 template<
short_t d,
class T>
24 class gsContainerBasis :
public gsBasis<T>
29 typedef memory::shared_ptr< gsContainerBasis > Ptr;
32 typedef memory::unique_ptr< gsContainerBasis > uPtr;
34 gsContainerBasis(
index_t numSubspaces)
36 basisContainer.clear();
37 for (
index_t i = 0; i != numSubspaces; i++)
38 basisContainer.push_back(gsTensorBSplineBasis<d,T>());
42 ~gsContainerBasis() {};
49 static uPtr make(
const gsContainerBasis& other)
50 {
return uPtr(
new gsContainerBasis( other ) ); }
55 GISMO_CLONE_FUNCTION(gsContainerBasis)
62 void connectivity(
const gsMatrix<T> & nodes,
63 gsMesh<T> & mesh)
const
69 memory::unique_ptr<gsGeometry<T> > makeGeometry( gsMatrix<T> coefs )
const
75 std::ostream &print(std::ostream &os)
const
81 void uniformRefine(
int numKnots = 1,
int mul=1,
int dir=-1)
83 for (
size_t i=0; i< basisContainer.size(); ++i)
84 basisContainer[i].uniformRefine(numKnots,mul,dir);
91 for (
size_t i=0; i< basisContainer.size(); ++i)
92 if (basisContainer[i].degree(dir) > deg)
93 deg = basisContainer[i].degree(dir);
100 for (
size_t i=0; i< basisContainer.size(); ++i)
101 sz += basisContainer[i].size();
107 for (
size_t i=0; i< basisContainer.size(); ++i)
109 if (gsTensorBSplineBasis<d, T> * mb =
110 dynamic_cast<gsTensorBSplineBasis<d, T> *
>(&basisContainer[i]) )
112 gsTensorBSplineBasis<d, T> basis_temp =
dynamic_cast<gsTensorBSplineBasis<d,T>&
>(basisContainer[i]);
113 gsTensorBSplineBasis<d, T> newTensorBasis(basis_temp.knots(1),basis_temp.knots(0));
114 basisContainer[i] = newTensorBasis;
126 gsInfo <<
"Works for now just with gsTensorBSplineBasis<d, T> \n";
131 index_t nPieces()
const {
return basisContainer.size();}
133 typename gsBasis<T>::domainIter makeDomainIterator(
const boxSide & side)
const
136 return basisContainer[0].makeDomainIterator(side);
139 typename gsBasis<T>::domainIter makeDomainIterator()
const
142 return basisContainer[0].makeDomainIterator();
147 return basisContainer[0].component(i);
156 return basisContainer[0].support();
159 gsBasis<T>* boundaryBasis_impl(boxSide
const & s)
const
173 gsDebugVar(s.index());
175 typename gsBSplineTraits<d-1, T>::Basis* bBasis =
new typename gsBSplineTraits<d-1, T>::Basis(*basisContainer[0].
boundaryBasis(s));
180 void active_into(
const gsMatrix<T> & u, gsMatrix<index_t> & result)
const
182 GISMO_ASSERT(u.rows() == d,
"Dimension of the points in active_into is wrong");
186 std::vector<gsMatrix<index_t>> result_temp;
187 result_temp.resize(basisContainer.size());
188 for (
size_t i=0; i< basisContainer.size(); ++i)
190 basisContainer[i].active_into(u, result_temp[i]);
191 nr += result_temp[i].rows();
194 result.resize(nr,u.cols());
198 for (
size_t i=0; i< basisContainer.size(); ++i)
200 result_temp[i].array() += shift;
201 result.block(shift_rows, 0, result_temp[i].rows(), u.cols()) = result_temp[i];
202 shift += basisContainer[i].size();
203 shift_rows += result_temp[i].rows();
208 void eval_into(
const gsMatrix<T> & u, gsMatrix<T> & result)
const
210 result.resize(0, u.cols());
211 for (
size_t i=0; i< basisContainer.size(); ++i)
213 gsMatrix<T> result_temp;
214 basisContainer[i].eval_into(u, result_temp);
215 result.conservativeResize(result.rows()+result_temp.rows(), result.cols());
216 result.bottomRows(result_temp.rows()) = result_temp;
221 void deriv_into(
const gsMatrix<T> & u, gsMatrix<T> & result)
const
223 result.resize(0, u.cols());
224 for (
size_t i=0; i< basisContainer.size(); ++i)
226 gsMatrix<T> result_temp;
227 basisContainer[i].deriv_into(u, result_temp);
228 result.conservativeResize(result.rows()+result_temp.rows(), result.cols());
229 result.bottomRows(result_temp.rows()) = result_temp;
234 void deriv2_into(
const gsMatrix<T> & u, gsMatrix<T> & result)
const
236 result.resize(0, u.cols());
237 for (
size_t i=0; i< basisContainer.size(); ++i)
239 gsMatrix<T> result_temp;
240 basisContainer[i].deriv2_into(u, result_temp);
241 result.conservativeResize(result.rows()+result_temp.rows(), result.cols());
242 result.bottomRows(result_temp.rows()) = result_temp;
247 void matchWith(
const boundaryInterface &bi,
const gsBasis<T> &other, gsMatrix<index_t> &bndThis,
248 gsMatrix<index_t> &bndOther)
const {
251 gsDebug <<
"matchWith() function is not implemented yet \n";
275 gsMatrix<index_t> boundaryOffset(
const boxSide & bside,
index_t offset)
const
277 gsMatrix<index_t> result;
294 short_t side_id = bside.index();
295 if (basisContainer.size() != 1)
298 for (
index_t i=0; i< side_id; ++i)
299 shift += basisContainer[i].size();
300 result = basisContainer[side_id].boundaryOffset(bside, offset);
301 result.array() += shift;
303 else if (basisContainer.size() == 1)
304 result = basisContainer[0].boundaryOffset(bside, offset);
308 if (basisContainer.size() != 1)
310 std::vector<boxCorner> containedCorners;
311 bside.getContainedCorners(d, containedCorners);
313 GISMO_ASSERT(containedCorners.size() != 0,
"No contained corner");
316 for (
size_t nc = 0; nc < containedCorners.size(); nc++)
318 index_t corner_id = containedCorners[nc].m_index + 4;
321 for (
index_t i = 0; i < corner_id; ++i)
322 shift += basisContainer[i].size();
324 gsMatrix<index_t> result_temp;
325 result_temp = basisContainer[corner_id].boundaryOffset(bside, offset);
326 result_temp.array() += shift;
328 index_t r_rows = result.rows() + result_temp.rows();
329 result.conservativeResize(r_rows, 1);
330 result.bottomRows(result_temp.rows()) = result_temp;
336 index_t functionAtCorner(
const boxCorner & corner)
const
338 if (basisContainer.size() != 1)
340 index_t corner_id = corner.m_index + 4;
342 for (
index_t i = 0; i < corner_id; ++i)
343 shift += basisContainer[i].size();
345 return basisContainer[corner_id].functionAtCorner(corner) + shift;
348 return basisContainer[0].functionAtCorner(corner);
356 void setBasis(
index_t row, gsTensorBSplineBasis<d,T> basis) { basisContainer[row] = basis; }
358 const gsBasis<T> & piece(
const index_t k)
const {
return basisContainer[k]; }
367 std::vector<gsTensorBSplineBasis<d, T>> basisContainer;
gsBasis< T >::uPtr boundaryBasis(boxSide const &s)
Returns the boundary basis for side s.
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
#define gsDebug
Definition: gsDebug.h:61
#define short_t
Definition: gsConfig.h:35
Provides declaration of Basis abstract interface.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
#define gsInfo
Definition: gsDebug.h:43
virtual void matchWith(const boundaryInterface &bi, const gsBasis< T > &other, gsMatrix< index_t > &bndThis, gsMatrix< index_t > &bndOther, index_t offset=0) const
Computes the indices of DoFs that match on the interface bi. The interface is assumed to be a common ...
Definition: gsBasis.hpp:658
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
virtual gsMatrix< T > support(const index_t &i) const
Returns (a bounding box for) the support of the i-th basis function.
Definition: gsBasis.hpp:435
virtual gsBasis< T > & component(short_t i)
For a tensor product basis, return the 1-d basis for the i-th parameter component.
Definition: gsBasis.hpp:518