21 template<
short_t d,
class T>
22 void gsC1SurfSpline<d,T>::defaultOptions()
33 template<
short_t d,
class T>
34 void gsC1SurfSpline<d,T>::init()
37 for (
size_t p=0; p!=m_multiBasis.nBases(); p++)
41 for (
short_t dd = 0; dd!=d; dd++)
43 degree = basis_patch->
component(dd).knots().degree();
44 GISMO_ENSURE((
index_t)(basis_patch->
component(dd).knots().size()-2*(degree+1))>=(
index_t)(5-degree),
"For a degree="<<degree<<
" basis, the knot vector should at least have "<<5-degree<<
" inner knots, but now it has "<<basis_patch->
component(dd).knots().size()-2*(degree+1)<<
" inner knots.");
52 m_patches.fixOrientation();
55 m_bases.reserve(m_patches.nPatches());
56 for (
size_t np = 0; np < m_patches.nPatches(); np++)
59 gsContainerBasis<d,T> containerBasis(1);
60 m_bases.push_back(containerBasis);
65 for (
size_t np = 0; np < m_patches.nPatches(); np++)
69 m_bases[np].setBasis(0, basis_patch);
74 for (
size_t np = 0; np < m_patches.nPatches(); np++)
76 index_t dim_u = m_bases[np].piece(0).component(0).size();
77 index_t dim_v = m_bases[np].piece(0).component(1).size();
78 row_dofs += (dim_u - 4) * (dim_v - 4);
82 for (
size_t numInt = 0; numInt < m_patches.interfaces().size(); numInt++)
84 index_t dir = m_patches.interfaces()[numInt].first().m_index < 3 ? 1 : 0;
88 basis_plus.elevateContinuity(1);
91 basis_minus.degreeReduce(1);
93 index_t numDofs = basis_plus.size() + basis_minus.size() - 10;
98 for (
size_t numBdy = 0; numBdy < m_patches.boundaries().size(); numBdy++)
100 const patchSide &bit = m_patches.boundaries()[numBdy];
105 index_t dir = side_1 < 3 ? 1 : 0;
109 basis_plus.elevateContinuity(1);
112 basis_minus.degreeReduce(1);
114 index_t numDofs = basis_plus.size() + basis_minus.size() - 10;
119 for (
size_t numVer = 0; numVer < m_patches.vertices().size(); numVer++)
127 for (
size_t i = 0; i < m_bases.size(); i++)
129 dim_col += m_bases[i].size();
132 m_matrix.resize(row_dofs, dim_col);
134 m_matrix.reserve(nz);
143 template<
short_t d,
class T>
144 void gsC1SurfSpline<d,T>::compute()
146 std::vector<gsEigen::Triplet<T,index_t>> tripletList;
148 index_t shift_row = 0, shift_col = 0;
149 for(
size_t np = 0; np < m_patches.nPatches(); ++np)
151 index_t dim_u = m_bases[np].piece(0).component(0).size();
152 index_t dim_v = m_bases[np].piece(0).component(1).size();
155 for (
index_t j = 2; j < dim_v-2; ++j)
156 for (
index_t i = 2; i < dim_u-2; ++i)
158 tripletList.push_back(gsEigen::Triplet<T,index_t>(shift_row + row_i, shift_col + j*dim_u+i,1));
162 shift_col += m_bases[np].size();
166 for (
size_t numInt = 0; numInt < m_patches.interfaces().size(); numInt++)
168 gsC1SurfEdge<d,T> smoothC1Edge(m_patches,m_patches.interfaces()[numInt]);
169 smoothC1Edge.computeG1InterfaceBasis();
170 std::vector<gsMultiPatch<T>> basisEdge = smoothC1Edge.getBasis();
179 index_t begin_col = 0, end_col = 0, shift_col = 0;
180 for (
index_t np = 0; np < patch_1; ++np)
181 shift_col += m_bases[np].size();
183 end_col += m_bases[patch_1].piece(0).size();
184 for (
size_t ii = 0; ii < basisEdge[0].nPatches(); ++ii)
187 for (
index_t j = begin_col; j < end_col; ++j, ++jj)
188 if (basisEdge[0].patch(ii).coef(jj, 0) * basisEdge[0].patch(ii).coef(jj, 0) > 1e-25)
189 tripletList.push_back(gsEigen::Triplet<T,index_t>(shift_row + ii, shift_col + j,basisEdge[0].patch(ii).coef(jj, 0)));
192 begin_col = 0, end_col = 0, shift_col = 0;
193 for (
index_t np = 0; np < patch_2; ++np)
194 shift_col += m_bases[np].size();
196 end_col += m_bases[patch_2].piece(0).size();
198 for (
size_t ii = 0; ii < basisEdge[1].nPatches(); ++ii)
201 for (
index_t j = begin_col; j < end_col; ++j, ++jj)
202 if (basisEdge[1].patch(ii).coef(jj, 0) * basisEdge[1].patch(ii).coef(jj, 0) > 1e-25)
203 tripletList.push_back(gsEigen::Triplet<T,index_t>(shift_row + ii, shift_col + j,basisEdge[1].patch(ii).coef(jj, 0)));
206 shift_row += basisEdge[0].nPatches();
210 for (
size_t numBdy = 0; numBdy < m_patches.boundaries().size(); numBdy++)
213 const patchSide & bit = m_patches.boundaries()[numBdy];
218 gsC1SurfEdge<d,T> smoothC1Edge(m_patches,bit);
219 smoothC1Edge.computeG1BoundaryBasis(side_1);
220 std::vector<gsMultiPatch<T>> basisEdge = smoothC1Edge.getBasis();
222 index_t begin_col = 0, end_col = 0, shift_col = 0;
223 for (
index_t np = 0; np < patch_1; ++np)
224 shift_col += m_bases[np].size();
226 end_col += m_bases[patch_1].piece(0).size();
227 for (
size_t ii = 0; ii < basisEdge[0].nPatches(); ++ii)
230 for (
index_t j = begin_col; j < end_col; ++j, ++jj)
231 if (basisEdge[0].patch(ii).coef(jj, 0) * basisEdge[0].patch(ii).coef(jj, 0) > 1e-25)
232 tripletList.push_back(gsEigen::Triplet<T,index_t>(shift_row + ii, shift_col + j,basisEdge[0].patch(ii).coef(jj, 0)));
235 shift_row += basisEdge[0].nPatches();
238 for (
size_t numVer = 0; numVer < m_patches.vertices().size(); numVer++)
240 std::vector<patchCorner> allcornerLists = m_patches.vertices()[numVer];
241 std::vector<index_t> patchIndex;
242 std::vector<index_t> vertIndex;
243 for (
size_t j = 0; j < allcornerLists.size(); j++)
245 patchIndex.push_back(allcornerLists[j].patch);
246 vertIndex.push_back(allcornerLists[j].m_index);
249 gsC1SurfVertex<d,T> smoothC1Vertex(m_patches, patchIndex, vertIndex);
250 smoothC1Vertex.computeG1InternalVertexBasis();
251 std::vector<gsMultiPatch<T>> basisVertex = smoothC1Vertex.getBasis();
253 for(
size_t pInd=0; pInd < patchIndex.size(); pInd++)
255 index_t begin_col = 0, end_col = 0, shift_col = 0;
256 for (
index_t np = 0; np < patchIndex[pInd]; ++np)
257 shift_col += m_bases[np].size();
259 end_col += m_bases[patchIndex[pInd]].piece(0).size();
260 for (
size_t ii = 0; ii < basisVertex[pInd].nPatches(); ++ii)
263 for (
index_t j = begin_col; j < end_col; ++j, ++jj)
264 if (basisVertex[pInd].patch(ii).coef(jj, 0) * basisVertex[pInd].patch(ii).coef(jj, 0) > 1e-25)
265 tripletList.push_back(gsEigen::Triplet<T,index_t>(shift_row + ii, shift_col + j,basisVertex[pInd].patch(ii).coef(jj, 0)));
270 m_matrix.setFromTriplets(tripletList.begin(),tripletList.end());
271 m_matrix.makeCompressed();
Struct which represents a certain side of a patch.
Definition: gsBoundary.h:231
#define short_t
Definition: gsConfig.h:35
#define index_t
Definition: gsConfig.h:32
#define GISMO_ENSURE(cond, message)
Definition: gsDebug.h:102
A tensor product B-spline basis.
Definition: gsTensorBSplineBasis.h:36
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
patchSide & second()
second, returns the second patchSide of this interface
Definition: gsBoundary.h:782
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
short_t index() const
Returns the index (as specified in boundary::side) of the box side.
Definition: gsBoundary.h:140
const Basis_t & component(short_t dir) const
For a tensor product basis, return the (const) 1-d basis for the i-th parameter component.
Definition: gsTensorBSplineBasis.h:202
index_t patch
The index of the patch.
Definition: gsBoundary.h:234
Creates the (approx) C1 Edge space.
patchSide & first()
first, returns the first patchSide of this interface
Definition: gsBoundary.h:776
Creates the (approx.) C1 Vertex space.