G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsMPBESSpline.hpp
Go to the documentation of this file.
1
17#include <gsUnstructuredSplines/src/gsMPBESUtils.h>
18
19#define TO_INCRSMOOTHNESS(x) static_cast<gsMPBESBasis<d,T> *>(x)
20
21namespace gismo
22{
23
24template<short_t d,class T>
25gsMPBESSpline<d,T>::gsMPBESSpline( const gsMPBESBasis<d,T> & basis, const gsMatrix<T> & coefs )
26:
27Base(basis,coefs)
28{
29}
30
31template<short_t d,class T>
32gsMPBESSpline<d,T>::gsMPBESSpline( gsMultiPatch<T> const & mp,index_t incrSmoothness,index_t minEVDistance ) : Base()
33{
34 short_t geoDim = mp.geoDim();
35 std::vector<gsMatrix<T> * > coefs;
36 for(size_t i = 0;i<mp.nPatches();++i)
37 coefs.push_back( new gsMatrix<T>(mp.patch(i).coefs()) );
38 m_mbases=getCompBasisFromMultiPatch_withCoefs<d>(mp,coefs,incrSmoothness,minEVDistance);
39 if(m_mbases==NULL)
40 GISMO_ERROR("no known basis for gsMappedGeom");
41 index_t start = 0, end = -1;
42 gsMatrix<T> localCoefs;
43 localCoefs.resize(m_mbases->localSize(),geoDim);
44 for(size_t i = 0;i<mp.nPatches();i++)
45 {
46 start=end+1;
47 end+=m_mbases->localSize(i);
48 localCoefs.block(start,0,end-start+1,geoDim) << *(coefs[i]);
49 }
50 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
51 freeAll(coefs);
52}
53
54template<short_t d,class T>
55gsMPBESSpline<d,T>::gsMPBESSpline(gsMultiPatch<T> const & mp,
56 std::vector<patchCorner> C0List,
57 index_t /*incrSmoothness*/,
58 index_t /*minEVDistance*/)
59 : Base()
60{
61 short_t geoDim = mp.geoDim();
62 std::vector<gsMatrix<T> * > coefs;
63 for(size_t i = 0;i<mp.nPatches();++i)
64 coefs.push_back(new gsMatrix<T>(mp.patch(i).coefs()) );
65 m_mbases=getCompBasisFromMultiPatch<d,T>(mp);
66 if(m_mbases==NULL)
67 GISMO_ERROR("no known basis for gsMappedGeom");
68 for(unsigned i=0;i<C0List.size();i++)
69 {
70 TO_INCRSMOOTHNESS(m_mbases)->setC0(C0List[i]);
71 }
72 TO_INCRSMOOTHNESS(m_mbases)->updateTopol();
73 index_t start = 0, end = -1;
74 gsMatrix<T> localCoefs;
75 localCoefs.resize(m_mbases->localSize(),geoDim);
76 for(size_t i = 0;i<mp.nPatches();i++)
77 {
78 start=end+1;
79 end+=m_mbases->localSize(i);
80 localCoefs.block(start,0,end-start+1,geoDim) << *(coefs[i]);
81 }
82 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
83}
84
85template<short_t d,class T>
86void gsMPBESSpline<d,T>::setCornerC0(patchCorner const & pc)
87{
88 gsMatrix<T> localCoefs;
89 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
90 TO_INCRSMOOTHNESS(m_mbases)->setC0(pc);
91 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
92}
93
94template<short_t d,class T>
95void gsMPBESSpline<d,T>::smoothCornerEdge(const patchCorner& pc,const patchSide& ps,bool updateBasis)
96{
97 gsMatrix<T> localCoefs;
98 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
99 TO_INCRSMOOTHNESS(m_mbases)->smoothCornerEdge(pc,ps,updateBasis);
100 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
101}
102
103template<short_t d,class T>
104void gsMPBESSpline<d,T>::smoothEverything()
105{
106 gsMatrix<T> localCoefs;
107 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
108 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
109 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
110}
111
112template<short_t d,class T>
113void gsMPBESSpline<d,T>::uniformRefine(index_t numKnots, index_t mul)
114{
115 gsMatrix<T> localCoefs;
116 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
117 TO_INCRSMOOTHNESS(m_mbases)->uniformRefine_withCoefs(localCoefs, numKnots,mul,true);
118 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
119}
120
121template<short_t d,class T>
122void gsMPBESSpline<d,T>::refine(const index_t patch, const gsMatrix<T> &boxes)
123{
124 gsMatrix<T> localCoefs;
125 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
126 //std::cout << m_global << std::endl <<std::endl;
127 TO_INCRSMOOTHNESS(m_mbases)->refine_withCoefs(localCoefs, patch, boxes,true);
128 //std::cout << localCoefs << std::endl <<std::endl;
129 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
130 //std::cout << m_global << std::endl <<std::endl;
131}
132
133template<short_t d,class T>
134void gsMPBESSpline<d,T>::refineElements(const index_t patch, std::vector<index_t> const & boxes)
135{
136 gsMatrix<T> localCoefs;
137 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
138 TO_INCRSMOOTHNESS(m_mbases)->refineElements_withCoefs(localCoefs, patch, boxes,true);
139 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
140}
141
142template<short_t d,class T>
143void gsMPBESSpline<d,T>::refineElements(std::vector<std::vector<index_t> > const & boxes)
144{
145 GISMO_ASSERT(boxes.size()==m_mbases->nPatches(),"number of refinementvectors and number of patches must agree");
146 gsMatrix<T> localCoefs;
147 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
148 for(unsigned i = 0;i<boxes.size();++i)
149 {
150 TO_INCRSMOOTHNESS(m_mbases)->refineElements_withCoefs(localCoefs, i, boxes[i],false);
151 }
152 TO_INCRSMOOTHNESS(m_mbases)->repairPatches(localCoefs);
153 TO_INCRSMOOTHNESS(m_mbases)->updateTopol();
154 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
155}
156
157template<short_t d,class T>
158void gsMPBESSpline<d,T>::uniformRefineAndSmooth(index_t numKnots)
159{
160 gsMatrix<T> localCoefs;
161 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
162 TO_INCRSMOOTHNESS(m_mbases)->uniformRefine_withCoefs(localCoefs, numKnots,false);
163 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
164 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
165}
166
167template<short_t d,class T>
168void gsMPBESSpline<d,T>::refineAndSmooth(const index_t patch, const gsMatrix<T> &boxes)
169{
170 gsMatrix<T> localCoefs;
171 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
172 TO_INCRSMOOTHNESS(m_mbases)->refine_withCoefs(localCoefs, patch,boxes,false);
173 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
174 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
175}
176
177template<short_t d,class T>
178void gsMPBESSpline<d,T>::refineElementsAndSmooth(const index_t patch, std::vector<index_t> const & boxes)
179{
180 gsMatrix<T> localCoefs;
181 m_mbases->global_coef_to_local_coef(m_global,localCoefs);
182 TO_INCRSMOOTHNESS(m_mbases)->refineElements_withCoefs(localCoefs, patch,boxes,false);
183 TO_INCRSMOOTHNESS(m_mbases)->smoothEverything();
184 m_mbases->local_coef_to_global_coef(localCoefs,m_global);
185}
186
187} // namespace gismo
188
189#undef TO_INCRSMOOTHNESS
#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.
The G+Smo namespace, containing all definitions for the library.
void freeAll(It begin, It end)
Frees all pointers in the range [begin end)
Definition gsMemory.h:312