G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsSmoothInterfaces.hpp
Go to the documentation of this file.
1 
14 // #define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148086513282306647
15 
17 
18 namespace gismo
19 {
20  // Constructors
21  template<short_t d,class T>
23  :
24  Base(patches)
25  {
26  this->defaultOptions();
27  }
28 
29  /*=====================================================================================
30  Coefficients
31  =====================================================================================*/
32  template<short_t d,class T>
34  {
35  GISMO_ASSERT(m_mapModified.isFinalized(),"Mapper is not finalized, run XXXX first");
36  GISMO_ASSERT(!patches.empty(),"The reference multipatch is empty!");
37 
38  gsMatrix<T> coefs(m_mapModified.freeSize(),patches.geoDim());
39 
40  index_t size;
41  for (size_t p=0; p!=m_bases.nBases(); p++) // patches
42  {
43  size = m_mapModified.patchSize(p);
44  for (index_t k=0; k!=size; k++)
45  {
46  if (m_mapModified.is_free(k,p))
47  coefs.row(m_mapModified.index(k,p,0)) = patches.patch(p).coefs().row(k);
48  }
49  }
50 
51  return coefs;
52  }
53 
54  /*=====================================================================================
55  Construction functions
56  =====================================================================================*/
57 
58  // template<short_t d,class T>
59  // gsGeometry<T>* gsSmoothInterfaces<d,T>::exportPatch(index_t patch, bool computeCoefs)
60  // {
61  // GISMO_ASSERT(m_computed,"The method has not been computed! Call compute().");
62  // ////////////////////////////////////////////////
63  // // This can be done more efficient!!
64  // // Do it once instead of for every patch
65  // ////////////////////////////////////////////////
66  // if (computeCoefs)
67  // {
68  // m_coefs = this->_preCoefficients(); // gets coefficients of the modified size
69  // m_coefs = m_matrix.transpose() * m_coefs; // maps to local size
70  // }
71 
72  // ////////////////////////////////////////////////
73  // index_t size,offset = 0;
74  // for (index_t p=0; p!=patch; p++)
75  // offset += m_mapOriginal.patchSize(p);
76 
77  // size = m_mapOriginal.patchSize(patch);
78  // gsMatrix<T> local = m_coefs.block(offset,0,size,m_patches.geoDim());
79 
80 
81  // bool check = dynamic_cast< gsTensorBSplineBasis<d,T> * > (&m_Bbases.basis(patch));
82  // gsDebugVar(check);
83 
84  // return m_Bbases[patch].makeGeometry( give(local) ).release();
85  // }
86 
87  template<short_t d,class T>
89  {
90  m_bases = m_Bbases;
91  }
92 
93  template<short_t d,class T>
95  {
96  }
97 
98  template<short_t d,class T>
100  {
101 
102  }
103 
104  template<short_t d,class T>
106  {
107  m_matrix.makeCompressed();
108  }
109 
110  template<short_t d,class T>
111  void gsSmoothInterfaces<d,T>::_countDoFs() // also initialize the mappers!
112  {
113  size_t tmp;
114  m_size = tmp = 0;
115  // number of interior basis functions
116  for (size_t p=0; p!=m_bases.nBases(); p++)
117  {
118  tmp += m_bases.basis(p).size();
119  for (index_t k=0; k!=2; k++)
120  {
121  tmp -= m_bases.basis(p).boundaryOffset(boxSide(1),k).size();
122  tmp -= m_bases.basis(p).boundaryOffset(boxSide(2),k).size();
123  tmp -= m_bases.basis(p).boundaryOffset(boxSide(3),k).size()-4;
124  tmp -= m_bases.basis(p).boundaryOffset(boxSide(4),k).size()-4;
125  }
126  }
127 
128  // gsDebug<<"Number of interior DoFs: "<<tmp<<"\n";
129  m_size += tmp;
130 
131  // interfaces
132  gsBasis<T> * basis1;
133  gsBasis<T> * basis2;
134  gsVector<index_t> indices1,indices2;
135  tmp = 0;
136  for(gsBoxTopology::const_iiterator iit = m_topology.iBegin(); iit!= m_topology.iEnd(); iit++)
137  {
138  basis1 = &m_bases.basis(iit->first().patch);
139  basis2 = &m_bases.basis(iit->second().patch);
140  tmp += basis1->boundary(iit->first().side()).size() - 4;
141  tmp += basis2->boundary(iit->second().side()).size() - 4;
142  }
143  // gsDebug<<"Number of interface DoFs: "<<tmp<<"\n";
144  m_size += tmp;
145 
146  // boundaries
147  tmp = 0;
148  for(gsBoxTopology::const_biterator bit = m_topology.bBegin(); bit!= m_topology.bEnd(); bit++)
149  {
150  basis1 = &m_bases.basis(bit->patch);
151  tmp += (basis1->boundaryOffset(bit->side(),0).size() - 4);
152  tmp += (basis1->boundaryOffset(bit->side(),1).size() - 4);
153  }
154  // gsDebug<<"Number of boundary DoFs: "<<tmp<<"\n";
155  m_size += tmp;
156 
157  // vertices
158  tmp = 0;
159  std::vector<bool> passed(m_bases.nBases()*4);
160  std::fill(passed.begin(), passed.end(), false);
161 
162  std::vector<patchCorner> corners;
163  // index_t corn = 0;
164  for (size_t p=0; p!=m_bases.nBases(); p++)
165  for (index_t c=1; c<5; c++)
166  {
167  index_t idx = this->_vertIndex(p,c);
168  if (!passed.at(idx))
169  {
170  m_topology.getCornerList(patchCorner(p,c),corners);
171 
172  for (size_t k=0; k!=corners.size(); k++)
173  passed.at(this->_vertIndex(corners[k].patch,corners[k])) = true;
174 
175  std::pair<index_t,bool> vdata = this->_vertexData(patchCorner(p,c)); // corner c
176  bool C0 = m_C0s[idx];
177  if ((!vdata.second) && vdata.first==1) // valence = 1, must be a boundary vertex
178  tmp += 4;
179  else if ((!vdata.second) && vdata.first==2 && !C0)
180  tmp += 4;
181  else if ((!vdata.second) && vdata.first>2 && !C0)
182  tmp += 2*vdata.first+2;
183  else if ((!vdata.second) && vdata.first==2 && C0)
184  tmp += 6;
185  else if ((!vdata.second) && vdata.first>2 && C0)
186  tmp += 2*vdata.first+2;
187  else
188  tmp += vdata.first; // valence;
189 
190  // corn +=1;
191  }
192  }
193  // gsDebug<<"Number of unique corners: "<<corn<<"\n";
194 
195  // gsDebug<<"Number of vertex DoFs: "<<tmp<<"\n";
196 
197  m_size += tmp;
198  }
199 
200 } // namespace gismo
void _makeTHB() override
Prints which DoFs have been handled and which have been eliminated.
Definition: gsSmoothInterfaces.hpp:94
short_t geoDim() const
Dimension of the geometry (must match for all patches).
Definition: gsMultiPatch.hpp:149
Provides declaration of THBSplineBasis class.
Constructs the D-Patch, from which the transformation matrix can be called.
Definition: gsSmoothInterfaces.h:28
#define index_t
Definition: gsConfig.h:32
void _initTHB() override
Initializes the matrix, the basis and the mappers.
Definition: gsSmoothInterfaces.hpp:99
Struct which represents a certain corner of a patch.
Definition: gsBoundary.h:392
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
gsGeometry< T > & patch(size_t i) const
Return the i-th patch.
Definition: gsMultiPatch.h:226
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
Constructs the D-Patch, from which the transformation matrix can be called.
Definition: gsDPatchBase.h:36
void _initBasis() override
Initializes the basis.
Definition: gsSmoothInterfaces.hpp:88
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
Struct which represents a certain side of a box.
Definition: gsBoundary.h:84
gsSmoothInterfaces()
Empty constructor.
Definition: gsSmoothInterfaces.h:41
virtual gsMatrix< index_t > boundaryOffset(boxSide const &s, index_t offset) const
Definition: gsBasis.hpp:316
void _countDoFs() override
Initializes the matrix, the basis and the mappers.
Definition: gsSmoothInterfaces.hpp:111
void _computeEVs() override
Corrects the EVs.
Definition: gsSmoothInterfaces.hpp:105
virtual void defaultOptions()
Sets the default options.
Definition: gsDPatchBase.hpp:39
bool empty() const
Returns true if gsMultiPatch is empty.
Definition: gsMultiPatch.h:202
gsMatrix< index_t > boundary(boxSide const &s) const
Returns the indices of the basis functions that are nonzero at the domain boundary as single-column-m...
Definition: gsBasis.h:520
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78