G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsAlmostC1.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsBoxTopology.h>
17 #include <gsCore/gsMultiPatch.h>
18 #include <gsIO/gsOptionList.h>
20 // #include <gsUnstructuredSplines/src/gsDPatchBase.hpp>
21 namespace gismo
22 {
23 
24 
32 template<short_t d,class T>
33 class gsAlmostC1 : public gsDPatchBase<d,T>
34 {
35 protected:
36 
37 typedef typename std::vector<std::tuple<index_t,index_t,T>> sparseEntry_t;
38 
39 public:
40 
41  using Base = gsDPatchBase<d,T>;
42 
43 
45  typedef memory::shared_ptr< gsAlmostC1 > Ptr;
46 
48  typedef memory::unique_ptr< gsAlmostC1 > uPtr;
49 
52  :
53  Base()
54  {
55  }
56 
57  // using Base::compute;
58  // void compute();
59 
65  gsAlmostC1(gsMultiPatch<T> const & mp) ;
66 
67  // GISMO_CLONE_FUNCTION(gsAlmostC1)
68 
69  ~gsAlmostC1();
70 
72 
73  using Base::exportToPatches;
74 
75 protected:
84  {
85  GISMO_UNUSED(patches);
86  return _preCoefficients();
87  }
88 
96 
104  void setCoefficients(const gsMatrix<T> & coefs, gsMultiPatch<T> & mp) const;
105 
106 
114  // gsGeometry<T>* exportPatch(index_t patch, bool computeCoefs=true);
115  using Base::exportPatch;
116 
122  // gsMultiPatch<T> exportToPatches();
123  // using Base::exportPatch;
124 
130  // const void matrix_into(gsSparseMatrix<T> & matrix) const
131  // { matrix = m_matrix; }
132 
142  // const gsSparseMatrix<T> matrix() const
143  // {
144  // gsSparseMatrix<T> result; matrix_into(result);
145  // return result;
146  // }
147 
148 protected:
149 
150  using Base::getSharpCorners;
151 
152  gsMatrix<T> _getNormals(const std::vector<patchCorner> & corners) const;
153 
154  std::tuple<gsMatrix<T>,gsMatrix<T>,gsMatrix<index_t>> _makeTriangle(const patchCorner & corner) const;
155 
156  gsMatrix<T,3,3> _getRotationMatrix(const gsVector<T,3> & a, const gsVector<T,3> & b) const;
157 
158  using Base::_indexFromSides;
159  using Base::_indexFromVert;
160  using Base::_vertexData;
161  using Base::_sideIndex;
162  using Base::_vertIndex;
167  using Base::_getInterfaceIndices;
168  using Base::_getAllInterfaceIndices;
169 
170 protected:
171 
176  void _countDoFs();
177 
191  // void _computeMapper(); // also initialize the mappers!
192  using Base::_computeMapper;
193 
197  // void _computeSmoothMatrix();
199 
200  void _initBasis();
201 
202  void _initTHB();
203 
204  void _refBoxes(std::vector<std::vector<index_t>> & patchBoxes);
205 
211  void _makeTHB();
212 
218  void _computeEVs();
219 
220 protected:
221 
222  std::vector<std::vector<patchCorner> > _getSpecialCornerLists(const gsMultiPatch<T> & patches);
223 
224  using Base::_push;
225  using Base::_pushAndCheck;
226 
227 
228 protected:
229  // void _computeInterfaceMapper(boundaryInterface iface);
230  using Base::_computeInterfaceMapper;
231 
232  // void _computeBoundaryMapper(patchSide boundary);
233  using Base::_computeBoundaryMapper;
234 
235  void _computeVertexMapper(patchCorner pcorner);
236 
237 
238 private:
239  // // Boundary vertex of valence 1
240  // template<bool _boundary, index_t _v> // valence=2
241  // typename std::enable_if< _boundary && _v==1, void>::type
242  // _computeVertexMapperBoundary_v1(patchCorner pcorner, index_t valence);
243  using Base::_computeMapperRegularCorner_v1;
244 
245  // // Boundary vertex of valence 2 with C1 smoothness
246  // template<bool _boundary, index_t _v, bool _smooth> // valence=2
247  // typename std::enable_if< _boundary && _v==2 && _smooth, void>::type
248  // _computeVertexMapperBoundarySmooth_v2(patchCorner pcorner, index_t valence);
249  using Base::_computeMapperRegularBoundaryVertexSmooth_v2;
250 
251  // Boundary vertex of valence 2 with C0 smoothness
252  // template<bool _boundary, index_t _v, bool _smooth> // valence=2
253  // typename std::enable_if< _boundary && _v==2 && (!_smooth), void>::type
254  void _computeMapperRegularBoundaryVertexNonSmooth_v2(patchCorner pcorner, index_t valence);
255 
256  // Boundary vertex of valence !(1,2,3) with C1 smoothness
257  // template<bool _boundary, index_t _v, bool _smooth>
258  // typename std::enable_if< _boundary && _v==-1 && _smooth, void>::type
259  void _computeMapperIrregularBoundaryVertexSmooth_v(patchCorner pcorner, index_t valence);
260 
261  // Boundary vertex of valence !(1,2,3) with C0 smoothness
262  // template<bool _boundary, index_t _v, bool _smooth>
263  // typename std::enable_if< _boundary && _v==-1 && (!_smooth), void>::type
264  // void _computeVertexMapperBoundaryNonSmooth_v(patchCorner pcorner, index_t valence);
265  using Base::_computeMapperIrregularBoundaryVertexNonSmooth_v;
266 
267  // Ordinary interior vertex
268  // template<bool _boundary, index_t _v> // valence=2
269  // typename std::enable_if< (!_boundary) && _v==4, void>::type
270  void _computeMapperInteriorVertex_v4(patchCorner pcorner, index_t valence);
271 
272  // Extraordinary interior vertex
273  // template<bool _boundary, index_t _v>
274  // typename std::enable_if< (!_boundary) && _v==-1, void>::type
275  void _computeMapperInteriorVertex_v(patchCorner pcorner, index_t valence);
276 
277 
278 protected:
308  // void _handleVertex(patchCorner pcorner);
309 
310  // interior vertices
311  void _handleInteriorVertex(patchCorner pcorner, index_t valence);
312 
321  // void _handleInterface(boundaryInterface iface);
329  // void _handleBoundary(patchSide side);
335  // void _handleInterior();
336 
337 private:
343  // void _handleRegularCorner(patchCorner pcorner);
344 
345  // template<bool _regular, bool _smooth> // valence=2
346  // typename std::enable_if< _regular && _smooth , void>::type
347  // _handleBoundaryVertex(patchCorner pcorner, index_t valence);
348 
349  // template<bool _regular, bool _smooth> // valence=2
350  // typename std::enable_if< _regular && (!_smooth) , void>::type
351  // _handleBoundaryVertex(patchCorner pcorner, index_t valence);
352 
353  // template<bool _regular, bool _smooth> // valence > 2
354  // typename std::enable_if<(!_regular) && _smooth , void>::type
355  // _handleBoundaryVertex(patchCorner pcorner, index_t valence);
356 
357  // template<bool _regular, bool _smooth> // valence > 1
358  // typename std::enable_if<(!_regular) && (!_smooth) , void>::type
359  // _handleBoundaryVertex(patchCorner pcorner, index_t valence);
360 
361  // void _handleRegularBoundaryVertexSmooth(patchCorner pcorner, index_t valence);
362 
364 
365  void _handleIrregularBoundaryVertexSmooth(patchCorner pcorner, index_t valence);
366 
367  void _handleIrregularBoundaryVertexNonSmooth(patchCorner pcorner, index_t valence);
368 
369 protected:
370  using Base::_whichHandled;
371 
372 protected:
373  using Base::m_patches;
374  gsMultiPatch<T> m_RefPatches;
375  using Base::m_bases;
376  using Base::m_topology;
377 
378  using Base::m_Bbases;
379  using Base::m_tMatrix;
380  using Base::m_sideCheck;
381  using Base::m_vertCheck;
382  using Base::m_basisCheck;
383  using Base::m_C0s;
384 
385  using Base::m_mapModified;
386  using Base::m_mapOriginal;
387 
388  using Base::m_matrix;
389 
390  using Base::m_options;
391 
392  using Base::m_size;
393 
394  using Base::m_coefs;
395 
396  using Base::m_nSides;
397  using Base::m_nVerts;
398 };
399 
400 
401 
402 }
403 
404 #ifndef GISMO_BUILD_LIB
405 #include GISMO_HPP_HEADER(gsAlmostC1.hpp)
406 #endif
Constructs the D-Patch, from which the transformation matrix can be called.
Definition: gsAlmostC1.h:33
Creates the D-Patch smoothing matrix.
virtual void _computeMapper()
Calculates the mapper.
Definition: gsDPatchBase.hpp:1209
virtual gsGeometry< T > * exportPatch(index_t patch, bool computeCoefs=true)
Exports a single modified patch with index patch.
Definition: gsDPatchBase.hpp:186
Provides declaration of the BoxTopology class.
void _countDoFs()
Initializes the matrix, the basis and the mappers.
Definition: gsAlmostC1.hpp:685
virtual std::vector< bool > getSharpCorners(T tol=1e-2) const
Checks if corners are sharp or not.
Definition: gsDPatchBase.hpp:47
memory::unique_ptr< gsAlmostC1 > uPtr
Unique pointer for gsAlmostC1.
Definition: gsAlmostC1.h:48
#define index_t
Definition: gsConfig.h:32
virtual void _computeSmoothMatrix()
Calculates the smooth matrix.
Definition: gsDPatchBase.hpp:1177
Struct which represents a certain corner of a patch.
Definition: gsBoundary.h:392
virtual const index_t _sideIndex(index_t patch, boxSide bside) const
Computes global index of the side.
Definition: gsDPatchBase.h:557
memory::shared_ptr< gsAlmostC1 > Ptr
Shared pointer for gsAlmostC1.
Definition: gsAlmostC1.h:45
void _handleInteriorVertex(patchCorner pcorner, index_t valence)
Handles a vertex in the global matrix.
Definition: gsAlmostC1.hpp:1031
Provides a list of labeled parameters/options that can be set and accessed easily.
virtual void _removeLowestCorners(std::vector< patchCorner > &pcorners, index_t n=3) const
From a list of patchCorners pcorners, remove all but the lowest n corners.
Definition: gsDPatchBase.hpp:448
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition: gsVector.h:35
virtual void _whichHandled()
Prints which DoFs have been handled and which have been eliminated.
Definition: gsDPatchBase.hpp:857
Provides declaration of the MultiPatch class.
void setCoefficients(const gsMatrix< T > &coefs, gsMultiPatch< T > &mp) const
Set the coefficients of mp to coefs.
Definition: gsAlmostC1.hpp:374
void _initTHB()
Initializes the matrix, the basis and the mappers.
Definition: gsAlmostC1.hpp:406
gsMatrix< T > _preCoefficients(const gsMultiPatch< T > &patches)
Computes the C1 coefficients for pre-multiplication to make the multipatch.
Definition: gsAlmostC1.h:83
gsMatrix< T > freeCoefficients()
Computes the C1 coefficients for pre-multiplication to make the multipatch.
Definition: gsAlmostC1.hpp:261
Constructs the D-Patch, from which the transformation matrix can be called.
Definition: gsDPatchBase.h:36
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
virtual void _getLowestCorners(std::vector< patchCorner > &pcorners, index_t n=3) const
From a list of patchCorners pcorners, get the lowest n corners.
Definition: gsDPatchBase.hpp:435
virtual const index_t _vertIndex(index_t patch, boxCorner corner) const
Computes global index of the corner.
Definition: gsDPatchBase.h:577
gsAlmostC1()
Empty constructor.
Definition: gsAlmostC1.h:51
void _computeEVs()
Computes D-Patch smoothing.
Definition: gsAlmostC1.hpp:592
virtual void _getLowestIndices(std::vector< std::pair< index_t, index_t >> &indices, index_t n=3) const
From a list of tuples (patch,index), get the lowest n tuples.
Definition: gsDPatchBase.hpp:463
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
virtual const index_t _indexFromSides(index_t index1, const patchSide side1, index_t index2, const patchSide side2)
Computes the index of a basis function using sides as reference.
Definition: gsDPatchBase.hpp:227
gsMatrix< T > _preCoefficients()
Computes the C1 coefficients for pre-multiplication to make the multipatch.
Definition: gsAlmostC1.hpp:282
virtual void defaultOptions()
Sets the default options.
Definition: gsDPatchBase.hpp:39
virtual void _removeLowestIndices(std::vector< std::pair< index_t, index_t >> &indices, index_t n=3) const
From a list of tuples (patch,index), remove all but the lowest n tuples.
Definition: gsDPatchBase.hpp:484
void _initBasis()
Initializes the basis.
Definition: gsAlmostC1.hpp:400
virtual const std::pair< index_t, bool > _vertexData(const patchCorner corner) const
Returns the valence and whether a corner is interior or boundary.
Definition: gsDPatchBase.hpp:425
void _makeTHB()
Prepares the THB basis if needed.
Definition: gsAlmostC1.hpp:504
virtual const index_t _indexFromVert(const index_t index, const patchCorner corner, const patchSide side, const index_t offsets=0) const
Computes the index of a basis function taking one corner and one side as reference.
Definition: gsDPatchBase.hpp:269
void _handleRegularBoundaryVertexNonSmooth(patchCorner pcorner, index_t valence)
Handles an interface in the global matrix.
Definition: gsAlmostC1.hpp:899