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
83 for (
size_t i=0; i< basisContainer.size(); ++i)
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 override
136 return basisContainer[0].makeDomainIterator(side);
139 typename gsBasis<T>::domainIter makeDomainIterator()
const override
142 return basisContainer[0].makeDomainIterator();
145 gsBasis<T> & component(
short_t i)
override
147 return basisContainer[0].component(i);
150 const gsBasis<T> & component(
short_t i)
const override
152 return basisContainer[0].component(i);
159 gsMatrix<T> support()
const override
161 return basisContainer[0].support();
164 gsMatrix<T> support(
const index_t & i)
const override
166 return basisContainer[0].support(i);
169 gsBasis<T>* boundaryBasis_impl(boxSide
const & s)
const
183 gsDebugVar(s.index());
185 typename gsBSplineTraits<d-1, T>::Basis* bBasis =
new typename gsBSplineTraits<d-1, T>::Basis(*basisContainer[0].
boundaryBasis(s));
190 void active_into(
const gsMatrix<T> & u, gsMatrix<index_t> & result)
const
192 GISMO_ASSERT(u.rows() == d,
"Dimension of the points in active_into is wrong");
196 std::vector<gsMatrix<index_t>> result_temp;
197 result_temp.resize(basisContainer.size());
198 for (
size_t i=0; i< basisContainer.size(); ++i)
200 basisContainer[i].active_into(u, result_temp[i]);
201 nr += result_temp[i].rows();
204 result.resize(nr,u.cols());
208 for (
size_t i=0; i< basisContainer.size(); ++i)
210 result_temp[i].array() += shift;
211 result.block(shift_rows, 0, result_temp[i].rows(), u.cols()) = result_temp[i];
212 shift += basisContainer[i].size();
213 shift_rows += result_temp[i].rows();
218 void eval_into(
const gsMatrix<T> & u, gsMatrix<T> & result)
const
220 result.resize(0, u.cols());
221 for (
size_t i=0; i< basisContainer.size(); ++i)
223 gsMatrix<T> result_temp;
224 basisContainer[i].eval_into(u, result_temp);
225 result.conservativeResize(result.rows()+result_temp.rows(), result.cols());
226 result.bottomRows(result_temp.rows()) = result_temp;
231 void deriv_into(
const gsMatrix<T> & u, gsMatrix<T> & result)
const
233 result.resize(0, u.cols());
234 for (
size_t i=0; i< basisContainer.size(); ++i)
236 gsMatrix<T> result_temp;
237 basisContainer[i].deriv_into(u, result_temp);
238 result.conservativeResize(result.rows()+result_temp.rows(), result.cols());
239 result.bottomRows(result_temp.rows()) = result_temp;
244 void deriv2_into(
const gsMatrix<T> & u, gsMatrix<T> & result)
const
246 result.resize(0, u.cols());
247 for (
size_t i=0; i< basisContainer.size(); ++i)
249 gsMatrix<T> result_temp;
250 basisContainer[i].deriv2_into(u, result_temp);
251 result.conservativeResize(result.rows()+result_temp.rows(), result.cols());
252 result.bottomRows(result_temp.rows()) = result_temp;
257 void matchWith(
const boundaryInterface &bi,
const gsBasis<T> &other, gsMatrix<index_t> &bndThis,
258 gsMatrix<index_t> &bndOther,
int)
const override
263 gsDebug <<
"matchWith() function is not implemented yet \n";
287 gsMatrix<index_t> boundaryOffset(
const boxSide & bside,
index_t offset)
const
289 gsMatrix<index_t> result;
306 short_t side_id = bside.index();
307 if (basisContainer.size() != 1)
310 for (
index_t i=0; i< side_id; ++i)
311 shift += basisContainer[i].size();
312 result = basisContainer[side_id].boundaryOffset(bside, offset);
313 result.array() += shift;
315 else if (basisContainer.size() == 1)
316 result = basisContainer[0].boundaryOffset(bside, offset);
320 if (basisContainer.size() != 1)
322 std::vector<boxCorner> containedCorners;
323 bside.getContainedCorners(d, containedCorners);
325 GISMO_ASSERT(containedCorners.size() != 0,
"No contained corner");
328 for (
size_t nc = 0; nc < containedCorners.size(); nc++)
330 index_t corner_id = containedCorners[nc].m_index + 4;
333 for (
index_t i = 0; i < corner_id; ++i)
334 shift += basisContainer[i].size();
336 gsMatrix<index_t> result_temp;
337 result_temp = basisContainer[corner_id].boundaryOffset(bside, offset);
338 result_temp.array() += shift;
340 index_t r_rows = result.rows() + result_temp.rows();
341 result.conservativeResize(r_rows, 1);
342 result.bottomRows(result_temp.rows()) = result_temp;
348 index_t functionAtCorner(
const boxCorner & corner)
const
350 if (basisContainer.size() != 1)
352 index_t corner_id = corner.m_index + 4;
354 for (
index_t i = 0; i < corner_id; ++i)
355 shift += basisContainer[i].size();
357 return basisContainer[corner_id].functionAtCorner(corner) + shift;
360 return basisContainer[0].functionAtCorner(corner);
368 void setBasis(
index_t row, gsTensorBSplineBasis<d,T>
basis) { basisContainer[row] =
basis; }
370 const gsBasis<T> & piece(
const index_t k)
const {
return basisContainer[k]; }
379 std::vector<gsTensorBSplineBasis<d, T>> basisContainer;
virtual void uniformRefine(int numKnots=1, int mul=1, short_t dir=-1)
Refine the basis uniformly by inserting numKnots new knots with multiplicity mul on each knot span.
Definition gsBasis.hpp:603
gsBasis< T >::uPtr boundaryBasis(boxSide const &s)
Returns the boundary basis for side s.
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:707
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition gsFunctionSet.hpp:33
Provides declaration of Basis abstract interface.
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define gsDebug
Definition gsDebug.h:61
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
#define gsInfo
Definition gsDebug.h:43
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
The G+Smo namespace, containing all definitions for the library.