G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsMPBESHSplineBasis.hpp
Go to the documentation of this file.
1
15#include <gsCore/gsMultiBasis.h>
16
17namespace gismo
18{
19
20template<short_t d, class T>
21gsMPBESHSplineBasis<d,T>::gsMPBESHSplineBasis (std::vector<BasisType *> const & bases, gsBoxTopology const & topol,
22 index_t increaseSmoothnessLevel, index_t minEVDistance)
23{
24 typedef typename std::vector<BasisType *>::const_iterator tempBasisIter;
25 m_topol = topol;
26 for(tempBasisIter it = bases.begin();it!=bases.end();++it)
27 m_bases.push_back((BasisType*)(*it)->clone().release());
28 if(increaseSmoothnessLevel==-1)
29 m_incrSmoothnessDegree=this->maxDegree()-1;
30 else
31 m_incrSmoothnessDegree=increaseSmoothnessLevel;
32 m_minDist=static_cast<unsigned>(std::max<index_t>(std::min<index_t>(m_incrSmoothnessDegree+1,maxDegree()),minEVDistance));
33 _initVertices();
34 _setDistanceOfAllVertices();
35
36 repairPatches();
37
38 if(!_checkTopologyWithBases())
39 GISMO_ERROR("topology and bases not suitable for composite basis");
40 _setMapping();
41}
42
43template<short_t d, class T>
44gsMPBESHSplineBasis<d,T>::gsMPBESHSplineBasis (std::vector<BasisType *> const & bases, gsBoxTopology const & topol,
45 std::vector<gsMatrix<T> * > & coefs,index_t increaseSmoothnessLevel, index_t minEVDistance)
46{
47 m_topol = topol;
48 for(typename BasisContainer::const_iterator it = bases.begin();it!=bases.end();++it)
49 m_bases.push_back( (gsBasis<T>*)(*it)->clone().release());
50 if(increaseSmoothnessLevel==-1)
51 m_incrSmoothnessDegree=this->maxDegree()-1;
52 else
53 m_incrSmoothnessDegree=increaseSmoothnessLevel;
54 m_minDist=static_cast<unsigned>(std::max<index_t>(std::min<index_t>(m_incrSmoothnessDegree+1,maxDegree()),minEVDistance));
55 _initVertices();
56 _setDistanceOfAllVertices();
57
58 repairPatches(coefs);
59
60 if(!_checkTopologyWithBases())
61 GISMO_ERROR("topology and bases not suitable for composite basis");
62 _setMapping();
63}
64
65template<short_t d, class T>
66gsMPBESHSplineBasis<d,T>::gsMPBESHSplineBasis (BasisType const & base, gsBoxTopology const & topol)
67{
68 m_topol = topol;
69 m_bases.push_back((BasisType *)base.clone().release());
70 m_incrSmoothnessDegree=this->maxDegree()-1;
71 m_minDist=static_cast<unsigned>(std::min<index_t>(m_incrSmoothnessDegree+1,maxDegree()));
72 _initVertices();
73 _setDistanceOfAllVertices();
74
75 repairPatches();
76
77 _checkTopologyWithBases();
78 _setMapping();
79}
80
81template<short_t d, class T>
82gsMPBESHSplineBasis<d,T>::gsMPBESHSplineBasis( gsMultiPatch<T> const & mp, index_t increaseSmoothnessLevel,
83 index_t minEVDistance)
84{
85 //topol.computeAllVertices();
86 for (size_t i = 0; i < mp.nPatches(); i++)
87 {
88 GISMO_ASSERT(dynamic_cast<gsHTensorBasis<2> * >(& mp.basis(i))!=NULL,"Bases is not of type gsHTensorBasis<2>");
89 }
90 m_topol = mp;
91 m_bases = mp.basesCopy();
92 if(increaseSmoothnessLevel==-1)
93 m_incrSmoothnessDegree=this->maxDegree()-1;
94 else
95 m_incrSmoothnessDegree=increaseSmoothnessLevel;
96 m_minDist=static_cast<unsigned>(std::max<index_t>(std::min<index_t>(m_incrSmoothnessDegree+1,maxDegree()),minEVDistance));
97 _initVertices();
98 _setDistanceOfAllVertices(); // this is wrong, every vertex has distance according to degree_u or degree_V
99
100 repairPatches();
101
102 _checkTopologyWithBases();
103 _setMapping();
104}
105
106template<short_t d, class T>
107gsMPBESHSplineBasis<d,T>::gsMPBESHSplineBasis( gsMultiBasis<T> const & mb,gsBoxTopology const & topol, index_t increaseSmoothnessLevel,
108 index_t minEVDistance)
109{
110 //topol.computeAllVertices();
111 for (size_t i = 0; i < mb.nBases(); i++)
112 {
113 GISMO_ASSERT(dynamic_cast<const gsHTensorBasis<2> * >(&mb.basis(i))!=NULL,"Bases is not of type gsHTensorBasis<2>");
114 m_bases.push_back((BasisType *)mb.basis(i).clone().release());
115 }
116 m_topol = topol;
117 if(increaseSmoothnessLevel==-1)
118 m_incrSmoothnessDegree=this->maxDegree()-1;
119 else
120 m_incrSmoothnessDegree=increaseSmoothnessLevel;
121 m_minDist=static_cast<unsigned>(std::max<index_t>(std::min<index_t>(m_incrSmoothnessDegree+1,maxDegree()),minEVDistance));
122 _initVertices();
123 _setDistanceOfAllVertices(); // this is wrong, every vertex has distance according to degree_u or degree_V
124
125 repairPatches();
126
127 _checkTopologyWithBases();
128 _setMapping();
129}
130
131template<short_t d, class T>
132gsMPBESHSplineBasis<d,T>::gsMPBESHSplineBasis( const gsMPBESHSplineBasis& other )
133{
134 m_topol = other.m_topol;
135 m_vertices=other.m_vertices;
136 m_distances=other.m_distances;
137 m_minDist=other.m_minDist;
138 // clone all geometries
139 for(ConstBasisIter it = other.m_bases.begin();it!=other.m_bases.end();++it)
140 {
141 m_bases.push_back( (BasisType *)(*it)->clone().release() );
142 }
143 m_incrSmoothnessDegree=other.m_incrSmoothnessDegree;
144 this->_checkTopologyWithBases();
145 //_setMapping();
146 m_mapper=new gsWeightMapper<T>(*other.m_mapper);
147 //m_mapFactory= need a method to clone mapFactory
148}
149
150template<short_t d, class T>
151gsMPBESHSplineBasis<d,T>& gsMPBESHSplineBasis<d,T>::operator=( const gsMPBESHSplineBasis& other )
152{
153 m_topol=other.m_topol;
154 m_vertices=other.m_vertices;
155 m_distances=other.m_distances;
156 m_minDist=other.m_minDist;
157 freeAll(m_bases);
158 m_bases.clear();
159 for(ConstBasisIter it = other.m_bases.begin();it!=other.m_bases.end();++it)
160 m_bases.push_back((BasisType*)(*it)->clone().release());
161 if(m_mapper)
162 delete m_mapper;
163 m_mapper=NULL;//other.m_mapper->clone();
164 m_incrSmoothnessDegree=other.m_incrSmoothnessDegree;
165 //m_mapFactory= need a method to clone mapFactory
166 return *this;
167}
168
169template<short_t d, class T>
171{
172 // * Initializer mapper
173 gsMPBESMapHB2D<d,T> maker(m_incrSmoothnessDegree,& m_topol,this);
174 if(m_mapper)
175 delete m_mapper;
176 m_mapper = maker.makeMapper();
177}
178
179template<short_t d, class T>
181{
182 unsigned nr=0;
183 std::vector<bool> actives;
184 for(unsigned level = 0;level<=basis(ps.patch).maxLevel();++level)
185 {
186 basis(ps.patch).activeBoundaryFunctionsOfLevel(level,ps.side(),actives);
187 for(std::vector<bool>::const_iterator iter = actives.begin();iter!=actives.end();++iter)
188 if(*iter)
189 nr++;
190 }
191 return nr;
192}
193
194template<short_t d, class T>
195bool gsMPBESHSplineBasis<d,T>::isLocallyConnected(indexType i,indexType j) const
196{
197 unsigned patch_i = _getPatch(i), patch_j = _getPatch(j);
198 if( patch_i != patch_j )
199 return false;
200 indexType loc_i = _getPatchIndex(i), loc_j = _getPatchIndex(j);
201 unsigned level_i = basis(patch_i).levelOf(loc_i);
202 unsigned level_j = basis(patch_j).levelOf(loc_j);
203 if( level_i != level_j )
204 return false;
205 unsigned tensorIndex_i = basis(patch_i).flatTensorIndexOf(loc_i);
206 unsigned tensorIndex_j = basis(patch_j).flatTensorIndexOf(loc_j);
207 gsVector<index_t,d> vec_i = basis(patch_i).getBases()[level_i]->tensorIndex(tensorIndex_i);
208 gsVector<index_t,d> vec_j = basis(patch_j).getBases()[level_j]->tensorIndex(tensorIndex_j);
209 unsigned distance = 0;
210 for( unsigned i2=0; i2< d;++i2 )
211 if( vec_i[j]-vec_j[i2] != 0 )
212 distance++;
213 return distance==1;
214}
215
216template<short_t d, class T>
217void gsMPBESHSplineBasis<d,T>::refine(const index_t patch, gsMatrix<T> const & boxes, bool updateBasis)
218{
219 basis(patch).refine(boxes);
220 std::vector<gsMatrix<T> *> coefs;
221 for (size_t i = 0; i < nPatches(); ++i)
222 coefs.push_back(NULL);
223 if(updateBasis)
224 {
225 repairPatches(coefs,patch);
226 updateTopol();
227 }
228}
229
230template<short_t d, class T>
231void gsMPBESHSplineBasis<d,T>::refineElements(const index_t patch, std::vector<index_t> const & boxes, bool updateBasis)
232{
233 basis(patch).refineElements(boxes);
234 std::vector<gsMatrix<T> *> coefs;
235 for (size_t i = 0; i < nPatches(); ++i)
236 coefs.push_back(NULL);
237 if(updateBasis)
238 {
239 repairPatches(coefs,patch);
240 updateTopol();
241 }
242}
243
244template<short_t d, class T>
245void gsMPBESHSplineBasis<d,T>::refine_withCoefs(gsMatrix<T>& localCoef, const index_t patch, gsMatrix<T> const & boxes, bool updateBasis)
246{
247 //std::cout << localCoef << std::endl << std::endl;
248 std::vector<gsMatrix<T> *> coefs;
249 unsigned geoDim = localCoef.cols();
250 index_t start, end = -1;
251 for (size_t i = 0; i < nPatches(); ++i)
252 {
253 start=end+1;
254 end+=basis(i).size();
255 gsMatrix<T>* localMat = new gsMatrix<T>(end-start+1,geoDim);
256 *localMat << localCoef.block(start,0,end-start+1,geoDim);
257 coefs.push_back(localMat);
258 }
259 basis(patch).refine_withCoefs(*coefs[patch],boxes);
260 if(updateBasis)
261 repairPatches(coefs,patch);
262 unsigned totalSize=0;
263 for (size_t i = 0; i < nPatches(); ++i)
264 {
265 totalSize+=basis(i).size();
266 }
267 localCoef.resize(totalSize,geoDim);
268 end = -1;
269 for (size_t i = 0; i < nPatches(); i++)
270 {
271 start=end+1;
272 end+=basis(i).size();
273 localCoef.block(start,0,end-start+1,geoDim) << *coefs[i];
274 }
275 //std::cout << localCoef << std::endl << std::endl;
276 if(updateBasis)
277 updateTopol();
278 freeAll(coefs);
279}
280
281template<short_t d, class T>
282void gsMPBESHSplineBasis<d,T>::refineElements_withCoefs(gsMatrix<T>& localCoef, const index_t patch, std::vector<index_t> const & boxes, bool updateBasis)
283{
284 std::vector<gsMatrix<T> *> coefs;
285 unsigned geoDim = localCoef.cols();
286 index_t start, end = -1;
287 for (size_t i = 0; i < nPatches(); ++i)
288 {
289 start=end+1;
290 end+=basis(i).size();
291 gsMatrix<T>* localMat = new gsMatrix<T>(end-start+1,geoDim);
292 *localMat << localCoef.block(start,0,end-start+1,geoDim);
293 coefs.push_back(localMat);
294 }
295 basis(patch).refineElements_withCoefs(*coefs[patch],boxes);
296 if(updateBasis)
297 repairPatches(coefs,patch);
298 unsigned totalSize=0;
299 for (size_t i = 0; i < nPatches(); ++i)
300 {
301 totalSize+=basis(i).size();
302 }
303 localCoef.resize(totalSize,geoDim);
304 end = -1;
305 for (size_t i = 0; i < nPatches(); i++)
306 {
307 start=end+1;
308 end+=basis(i).size();
309 localCoef.block(start,0,end-start+1,geoDim) << *coefs[i];
310 }
311 if(updateBasis)
312 updateTopol();
313 freeAll(coefs);
314}
315
316template<short_t d, class T>
317void gsMPBESHSplineBasis<d,T>::refineWithExtension(const index_t patch,gsMatrix<T> const & boxes, index_t refExt,bool updateBasis)
318{
319 m_bases[patch]->refine( boxes, refExt);
320 std::vector<gsMatrix<T> *> coefs;
321 for (size_t i = 0; i < nPatches(); ++i)
322 coefs.push_back(NULL);
323 if(updateBasis)
324 {
325 repairPatches(coefs,patch);
326 updateTopol();
327 }
328}
329
330template<short_t d, class T>
331void gsMPBESHSplineBasis<d,T>::repairPatches(std::vector<gsMatrix<T> *> & coefs, index_t startFromPatch)
332{
333 std::vector<size_t> toCheck; //set of all indizes of patches, which have to be checked
334 if(startFromPatch==-1)
335 for(size_t i = 0; i < m_bases.size(); ++i)
336 toCheck.push_back(i);
337 else
338 toCheck.push_back(startFromPatch);
339 size_t curElement;
340 do
341 {
342 curElement=toCheck[0];
343 toCheck.erase(toCheck.begin());
344 std::vector<index_t> boxes;
345 std::vector<index_t> checkPatches(0);
346 bool matched = true;
347 matched = matched && _innerBoxesAreSuitable(curElement,boxes);
348 if(!matched)
349 {
350 if(coefs[curElement]!=NULL)
351 basis(curElement).refineElements_withCoefs(*(coefs[curElement]),boxes);
352 else
353 basis(curElement).refineElements(boxes);
354 toCheck.push_back(curElement);
355 continue;
356 }
357 matched = true;
358 boxes.clear();
359 matched = matched && _boxesMatchNeighbours(curElement,boxes,checkPatches);
360 if(!matched)
361 {
362 if(coefs[curElement]!=NULL)
363 basis(curElement).refineElements_withCoefs(*(coefs[curElement]),boxes);
364 else
365 basis(curElement).refineElements(boxes);
366 }
367 for(size_t i = 0; i < checkPatches.size(); ++i)
368 if(std::find(toCheck.begin(), toCheck.end(), checkPatches[i])==toCheck.end())
369 toCheck.push_back(checkPatches[i]);
370 }while(!toCheck.empty());
371}
372
373template<short_t d, class T>
375 std::vector<index_t>& boxes)
376{
377 size_t sz = boxes.size();
378 short_t dist_u = 2*std::min(m_bases[patch]->degree(0),(short_t)(m_incrSmoothnessDegree+1));
379 short_t dist_v = 2*std::min(m_bases[patch]->degree(1),(short_t)(m_incrSmoothnessDegree+1));
380 patchSide ps_north(patch,boundary::north);
381 patchSide ps_south(patch,boundary::south);
382 patchSide ps_east(patch,boundary::east);
383 patchSide ps_west(patch,boundary::west);
384 bool north = m_topol.isInterface(ps_north);
385 bool south = m_topol.isInterface(ps_south);
386 bool east = m_topol.isInterface(ps_east);
387 bool west = m_topol.isInterface(ps_west);
388 gsMatrix<index_t> b1,b2;
389 gsVector<index_t> level;
390 // make the interior of the patch ok
391 basis(patch).tree().getBoxesInLevelIndex(b1,b2,level); // sorted by level?!?!
392 for(index_t i = 0; i < level.rows(); i++)
393 {
394 index_t l = level(i);
395 if(l==0)
396 continue;
397 index_t b_uMin = b1(i,0),b_vMin = b1(i,1);
398 index_t b_uMax = b2(i,0),b_vMax = b2(i,1);
399 index_t uMin = 0, uMax = basis(patch).getBases()[l]->knots(0).uSize() - 1;
400 index_t vMin = 0, vMax = basis(patch).getBases()[l]->knots(1).uSize() - 1;
401 // if the box does not touch the boundary we have to do nothing
402 if( uMin < b_uMin && b_uMax < uMax && vMin < b_vMin && b_vMax < vMax )
403 continue;
404 // if the box touches the boundary, we have to check if goes far enough from
405 // the boundary, such that all the functions needed for gluing are there in the same level
406 if( west && uMin == b_uMin && b_uMax < uMin+dist_u )
407 _addBox(patch,b_uMin,b_vMin,uMin+dist_u,b_vMax,l,boxes);
408 if( east && uMax == b_uMax && b_uMin > uMax-dist_u )
409 _addBox(patch,uMax-dist_u,b_vMin,b_uMax,b_vMax,l,boxes);
410 if( south && vMin == b_vMin && b_vMax < vMin+dist_v )
411 _addBox(patch,b_uMin,b_vMin,b_uMax,vMin+dist_v,l,boxes);
412 if( north && vMax == b_vMax && b_vMin > vMax-dist_v )
413 _addBox(patch,b_uMin,vMax-dist_v,b_uMax,b_vMax,l,boxes);
414 }
415 return boxes.size()==sz;
416}
417
418template<short_t d, class T>
419bool gsMPBESHSplineBasis<d,T>::_boxesMatchNeighbours(const index_t patch,
420 std::vector<index_t>& boxes, std::vector<index_t>& checkPatches)
421{
422 unsigned sz = boxes.size();
423 //check if neighbour has the same refined boxes.
424 patchSide ps, ps_neigh;
425 std::vector<bool> sideToCheck(4,false);
426 std::vector<index_t> neighbours(4,-1);
427 gsVector<bool> orient;
428 index_t patch_max_level = basis(patch).maxLevel();
429 for(unsigned side=1;side<=4;++side)
430 {
431 ps=patchSide(patch,side);
432 if( !m_topol.getNeighbour(ps,ps_neigh) )
433 continue;
434 neighbours[side-1]=ps_neigh.patch; //fill with the patch numbers of the neighbours
435 unsigned neighbour_max_level = basis(ps_neigh.patch).maxLevel();
436 unsigned max_level = std::max<unsigned>(patch_max_level,neighbour_max_level);
437 for(unsigned l=1;l<=max_level;++l)
438 {
439 std::vector<bool> s_patch,s_neigh,s_res;
440 basis(patch).activeBoundaryFunctionsOfLevel(l,ps.side(),s_patch);
441 basis(ps_neigh.patch).activeBoundaryFunctionsOfLevel(l,ps_neigh.side(),s_neigh);
442 unsigned sz2 = s_patch.size();
443 boundaryInterface bf;
444 m_topol.getInterface(ps,bf);
445 if(!bf.dirOrientation(ps,1-ps.direction()))
446 std::reverse(s_neigh.begin(),s_neigh.end());
447 s_res.resize(sz2);
448 for(unsigned i = 0;i<sz2;i++)
449 {
450 s_res[i]=s_neigh[i]&&!s_patch[i];
451 if(s_patch[i]&&!s_neigh[i])
452 sideToCheck[side-1]=true; //set this side to true
453 }
454 unsigned start = 0, end=0;
455 do
456 {
457 if(!s_res[start])
458 {
459 start++;
460 end++;
461 }
462 else if(end<sz2&&s_res[end])
463 end++;
464 else
465 {
466 _addBoundaryBox(patch,ps.side(),start,end-1,l,boxes,sideToCheck);
467 start=end;
468 }
469 }while(start!=sz2);
470 }
471 }
472 //find the patches we will have to check again:
473 for(unsigned i = 0;i<4;i++)
474 {
475 if(sideToCheck[i]&&neighbours[i]!=-1)
476 checkPatches.push_back(neighbours[i]);
477 }
478 return boxes.size()==sz;
479}
480
481template<short_t d, class T>
482void gsMPBESHSplineBasis<d,T>::_addBoundaryBox(const index_t patch,const boxSide s,const index_t start, const index_t end,const unsigned level, std::vector<index_t> & boxes, std::vector<bool> & sideToCheck)
483{
484 short_t u_max = basis(patch).getBases()[level]->size(0)-1;
485 short_t v_max = basis(patch).getBases()[level]->size(1)-1;
486 short_t dist_u = 2*std::min(m_bases[patch]->degree(0),(short_t)(m_incrSmoothnessDegree+1));
487 short_t dist_v = 2*std::min(m_bases[patch]->degree(1),(short_t)(m_incrSmoothnessDegree+1));
488 switch(s)
489 {
490 case 1:
491 _addFunBox(patch,0,start,dist_u-1,end,level,boxes);
492 if(dist_u>=u_max)
493 sideToCheck[2-1]=true;
494 break;
495 case 2:
496 _addFunBox(patch,u_max-(dist_u-1),start,u_max,end,level,boxes);
497 if(dist_u>=u_max)
498 sideToCheck[1-1]=true;
499 break;
500 case 3:
501 _addFunBox(patch,start,0,end,dist_v-1,level,boxes);
502 if(dist_v>=v_max)
503 sideToCheck[4-1]=true;
504 break;
505 case 4:
506 _addFunBox(patch,start,v_max-(dist_v-1),end,v_max,level,boxes);
507 if(dist_v>=v_max)
508 sideToCheck[3-1]=true;
509 break;
510 default:
511 GISMO_ERROR("only 2D possible");
512 }
513 if(s==1||s==2)
514 {
515 if(start<=0)
516 sideToCheck[3-1]=true;
517 if(end>=static_cast<index_t>(v_max)-1)
518 sideToCheck[4-1]=true;
519 }
520 else
521 {
522 if(start<=0)
523 sideToCheck[1-1]=true;
524 if(end>=static_cast<index_t>(u_max)-1)
525 sideToCheck[2-1]=true;
526 }
527}
528
529template<short_t d, class T>
530void gsMPBESHSplineBasis<d,T>::_addFunBox(const index_t patch,const unsigned uMin,const unsigned vMin,const unsigned uMax,const unsigned vMax,const unsigned level, std::vector<index_t> & boxes)
531{
532 boxes.push_back(level);
533 gsMatrix<index_t> supportIndex;
534 basis(patch).getBases()[level]->knots(0).supportIndex_into(uMin,supportIndex);
535 boxes.push_back(supportIndex(0,0));
536 basis(patch).getBases()[level]->knots(1).supportIndex_into(vMin,supportIndex);
537 boxes.push_back(supportIndex(0,0));
538 basis(patch).getBases()[level]->knots(0).supportIndex_into(uMax,supportIndex);
539 boxes.push_back(supportIndex(0,1));
540 basis(patch).getBases()[level]->knots(1).supportIndex_into(vMax,supportIndex);
541 boxes.push_back(supportIndex(0,1));
542}
543
544template<short_t d, class T>
545void gsMPBESHSplineBasis<d,T>::_addBox(const index_t patch,const unsigned uMin,const unsigned vMin,const unsigned uMax,const unsigned vMax,const unsigned level, std::vector<index_t> & boxes)
546{
547 gsVector<index_t,d> lowerLeft;
548 lowerLeft(0)=uMin;
549 lowerLeft(1)=vMin;
550 gsVector<index_t,d> upperRight;
551 upperRight(0)=uMax;
552 upperRight(1)=vMax;
553 if( uMin<uMax && vMin<vMax && static_cast<index_t>(level)>basis(patch).tree().query3(lowerLeft,upperRight,level))
554 {
555 boxes.push_back(level);
556 boxes.push_back(uMin);
557 boxes.push_back(vMin);
558 boxes.push_back(uMax);
559 boxes.push_back(vMax);
560 }
561}
562
563template<short_t d, class T>
564void gsMPBESHSplineBasis<d,T>::_endpointsOfActiveBoundaryFunctions(patchSide const & ps,bool orient,std::vector<T>& endpoints) const
565{
566 index_t patch = ps.patch;
567 unsigned deg = degree(patch,1-(ps.direction()));
568 std::vector<bool> actives;
569 for(unsigned level = 0;level<=basis(patch).maxLevel();++level)
570 {
571 gsKnotVector<T> knots = basis(patch).getBases()[level]->knots(1-(ps.direction()));
572 basis(patch).activeBoundaryFunctionsOfLevel(level,ps.side(),actives);
573 if(orient)
574 {
575 knots.reverse();
576 std::reverse(actives.begin(), actives.end());
577 }
578 for(unsigned i = 0; i<actives.size();++i)
579 if(actives[i])
580 endpoints.push_back(knots.at(i+deg+1));
581 }
582 std::sort(endpoints.begin(),endpoints.end());
583}
584
585template<short_t d, class T>
586T gsMPBESHSplineBasis<d,T>::findParameter(patchSide const & ps,patchCorner const & pc,unsigned nrBasisFuncs) const
587{
588 if(nrBasisFuncs==0)
589 return 0.0;
590 std::vector<T> endpoints;
591 gsVector<bool> pars;
592 pc.parameters_into(d,pars);
593 _endpointsOfActiveBoundaryFunctions(ps,pars(1-ps.direction()),endpoints);
594 return endpoints[nrBasisFuncs-1];
595}
596
597}
short_t direction() const
Returns the parametric direction orthogonal to this side.
Definition gsBoundary.h:113
A univariate Lagrange basis.
Definition gsMPBESHSplineBasis.h:33
virtual void refineWithExtension(const index_t patch, gsMatrix< T > const &boxes, index_t refExt=0, bool updateBasis=true)
Refine the are defined by boxes on patch k with extension refExt.
Definition gsMPBESHSplineBasis.hpp:317
void refine(const index_t patch, gsMatrix< T > const &boxes, bool updateBasis=true)
Definition gsMPBESHSplineBasis.hpp:217
unsigned basisFunctionsOnSide(const patchSide &ps) const
Returns the amount of basis functions on a given side of a given patch.
Definition gsMPBESHSplineBasis.hpp:180
void refineElements_withCoefs(gsMatrix< T > &localCoef, const index_t patch, std::vector< index_t > const &boxes, bool updateBasis=true)
Definition gsMPBESHSplineBasis.hpp:282
void _setMapping()
create a new mapping of the local basisfunctions
Definition gsMPBESHSplineBasis.hpp:170
gsMPBESHSplineBasis()
Default empty constructor.
Definition gsMPBESHSplineBasis.h:77
void refineElements(const index_t patch, std::vector< index_t > const &boxes, bool updateBasis=true)
Definition gsMPBESHSplineBasis.hpp:231
T findParameter(patchSide const &ps, patchCorner const &pc, unsigned nrBasisFuncs) const
Definition gsMPBESHSplineBasis.hpp:586
void refine_withCoefs(gsMatrix< T > &localCoef, const index_t patch, gsMatrix< T > const &boxes, bool updateBasis=true)
Definition gsMPBESHSplineBasis.hpp:245
void repairPatches(std::vector< gsMatrix< T > * > &coefs, index_t startFromPatch=-1)
Definition gsMPBESHSplineBasis.hpp:331
A univariate Lagrange basis.
Definition gsMPBESMapHB2D.h:41
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ERROR(message)
Definition gsDebug.h:118
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of Basis abstract interface.
Provides declaration of MultiBasis class.
The G+Smo namespace, containing all definitions for the library.
T distance(gsMatrix< T > const &A, gsMatrix< T > const &B, index_t i=0, index_t j=0, bool cols=false)
compute a distance between the point number in the set and the point number <j> in the set ; by def...
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition gsMemory.h:312
void parameters_into(index_t dim, gsVector< bool > &param) const
returns a vector of parameters describing the position of the corner
Definition gsBoundary.h:322
Struct which represents a certain corner of a patch.
Definition gsBoundary.h:393
Struct which represents a certain side of a patch.
Definition gsBoundary.h:232
index_t patch
The index of the patch.
Definition gsBoundary.h:234