G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsAssembler.h
Go to the documentation of this file.
1 
14 #pragma once
15 
17 #include <gsCore/gsBasisRefs.h>
18 #include <gsCore/gsDofMapper.h>
19 #include <gsCore/gsStdVectorRef.h>
20 #include <gsCore/gsMultiBasis.h>
23 
24 #include <gsIO/gsOptionList.h>
25 
26 #include <gsPde/gsPde.h>
28 
29 #include <gsAssembler/gsQuadRule.h>
33 
34 
35 namespace gismo
36 {
37 
38 template <class T>
39 void transformGradients(const gsMapData<T> & md, index_t k, const gsMatrix<T>& allGrads, gsMatrix<T>& trfGradsK)
40 {
41  GISMO_ASSERT(allGrads.rows() % md.dim.first == 0, "Invalid size of gradient matrix");
42 
43  const index_t numGrads = allGrads.rows() / md.dim.first;
44  const gsAsConstMatrix<T> grads_k(allGrads.col(k).data(), md.dim.first, numGrads);
45  trfGradsK.noalias() = md.jacobian(k).cramerInverse().transpose() * grads_k;
46 }
47 
48 template <class T>
49 void transformLaplaceHgrad( const gsMapData<T> & md, index_t k,
50  const gsMatrix<T> & allGrads,
51  const gsMatrix<T> & allHessians,
52  gsMatrix<T> & result)
53 {
54  //todo: check me
55  gsMatrix<T> hessians;
56  transformDeriv2Hgrad(md, k, allGrads, allHessians, hessians);
57  result = hessians.leftCols(md.dim.first).rowwise().sum(); // trace of Hessian
58  result.transposeInPlace();
59 }
60 
61 template <class T>
62 void normal(const gsMapData<T> & md, index_t k, gsVector<T> & result)
63 {
64  GISMO_ASSERT( md.dim.first+1 == md.dim.second, "Codimension should be equal to one");
65  result.resize(md.dim.first+1);
66  const gsMatrix<T> Jk = md.jacobian(k);
67 
68  T alt_sgn(1.0);
69  typename gsMatrix<T>::RowMinorMatrixType minor;
70  for (short_t i = 0; i <= md.dim.first; ++i) // for all components of the normal vector
71  {
72  Jk.rowMinor(i, minor);
73  result[i] = alt_sgn * minor.determinant();
74  alt_sgn = -alt_sgn;
75  }
76 }
77 
78 template <class T>
79 void outerNormal(const gsMapData<T> & md, index_t k, boxSide s, gsVector<T> & result)
80 {
81  //todo: fix and check me
82  short_t m_orientation = md.jacobian(k).determinant() >= 0 ? 1 : -1;
83 
84  const T sgn = sideOrientation(s) * m_orientation; // TODO: fix me
85  const short_t dir = s.direction();
86 
87  // assumes points u on boundary "s"
88  result.resize(md.dim.second);
89  gsVector<T,3> tmp;
90  if (md.dim.first + 1 == md.dim.second) // surface case GeoDim == 3
91  {
92  auto Jk = md.jacobian(k).col(!dir);
93  // fixme: generalize to nD
94  normal(md, k, result);
95  tmp = result;
96  result = tmp.normalized().cross(sgn * Jk);
97 
98  /*
99  gsDebugVar(result.transpose()); // result 1
100  normal(k,result);
101  Jk.col(dir) = result.normalized();
102  gsMatrix<T, ParDim, md.dim.first> minor;
103  T alt_sgn = sgn;
104  for (short_t i = 0; i != GeoDim; ++i) // for all components of the normal
105  {
106  Jk.rowMinor(i, minor);
107  result[i] = alt_sgn * minor.determinant();
108  alt_sgn = -alt_sgn;
109  }
110  gsDebugVar(result.transpose()); // result 2
111  */
112  }
113  else // planar case
114  {
115  GISMO_ASSERT(md.dim.first == md.dim.second, "Codim different than zero/one");
116 
117  if (1 == md.dim.second)
118  {
119  result[0] = sgn;
120  return;
121  } // 1D case
122 
123  const gsMatrix<T> Jk = md.jacobian(k);
124 
125  T alt_sgn = sgn;
126  typename gsMatrix<T>::FirstMinorMatrixType minor;
127  for (short_t i = 0; i != md.dim.first; ++i) // for all components of the normal
128  {
129  Jk.firstMinor(i, dir, minor);
130  result[i] = alt_sgn * minor.determinant();
131  alt_sgn = -alt_sgn;
132  }
133  }
134 }
135 
136 template<typename T>
137 void secDerToHessian(typename gsMatrix<T>::constRef & secDers,
138  gsMatrix<T> & hessian,
139  short_t parDim)
140 {
141  switch (parDim)
142  {
143  case 1:
144  hessian.resize(1, 1);
145  hessian(0, 0) = secDers(0, 0);
146  break;
147  case 2:
148  hessian.resize(2, 2);
149  hessian(0, 0) = secDers(0, 0);
150  hessian(1, 1) = secDers(1, 0);
151  hessian(0, 1) =
152  hessian(1, 0) = secDers(2, 0);
153  break;
154  case 3:
155  hessian.resize(3, 3);
156  hessian(0, 0) = secDers(0, 0);
157  hessian(1, 1) = secDers(1, 0);
158  hessian(2, 2) = secDers(2, 0);
159  hessian(0, 1) =
160  hessian(1, 0) = secDers(3, 0);
161  hessian(0, 2) =
162  hessian(2, 0) = secDers(4, 0);
163  hessian(1, 2) =
164  hessian(2, 1) = secDers(5, 0);
165  break;
166  default:
167  GISMO_ERROR("Parametric dimension 1, 2 or 3 was expected.");
168  }
169 }
170 
171 template<typename T>
172 void hessianToSecDer (const gsMatrix<T> & hessian,
173  typename gsMatrix<T>::Row secDers,
174  short_t parDim)
175 {
176  switch (parDim)
177  {
178  case 1:
179  secDers(0, 0) = hessian(0, 0);
180  break;
181  case 2:
182  secDers(0, 0) = hessian(0, 0);
183  secDers(0, 1) = hessian(1, 1);
184  secDers(0, 2) = (hessian(1, 0) + hessian(0, 1)) / 2.0;
185  break;
186  case 3:
187  secDers(0, 0) = hessian(0, 0);
188  secDers(0, 1) = hessian(1, 1);
189  secDers(0, 2) = hessian(2, 2);
190  secDers(0, 3) = (hessian(0, 1) + hessian(1, 0)) / 2.0;
191  secDers(0, 4) = (hessian(0, 2) + hessian(2, 0)) / 2.0;
192  secDers(0, 5) = (hessian(1, 2) + hessian(2, 1)) / 2.0;
193  break;
194  default:
195  GISMO_ERROR("Parametric dimension 1, 2 or 3 was expected.");
196  }
197 }
198 
199 template<typename T>
200 void secDerToTensor(typename gsEigen::DenseBase<gsEigen::Map<const gsEigen::Matrix<T, -1, -1>, 0, gsEigen::Stride<0, 0> > >::ConstColXpr & secDers,
201  gsMatrix<T> * a,
202  short_t parDim, short_t geoDim)
203 {
204  const index_t dim = parDim * (parDim + 1) / 2;
205  for (short_t i = 0; i < geoDim; ++i)
206  secDerToHessian<T>(secDers.segment(i * dim, dim), a[i], parDim);
207 }
208 
209 template <class T>
210 void transformDeriv2Hgrad(const gsMapData<T> & md,
211  index_t k,
212  const gsMatrix<T> & funcGrad,
213  const gsMatrix<T> & funcSecDir,
214  gsMatrix<T> & result)
215 {
216  //todo: check me
217  const short_t ParDim = md.dim.first;
218  const short_t GeoDim = md.dim.second;
219  GISMO_ASSERT(
220  (ParDim == 1 && (GeoDim == 1 || GeoDim == 2 || GeoDim == 3))
221  || (ParDim == 2 && (GeoDim == 2 || GeoDim == 3))
222  || (ParDim == 3 && GeoDim == 3), "No implementation for this case");
223 
224  // important sizes
225  const index_t parSecDirSize = ParDim * (ParDim + 1) / 2;
226  const index_t fisSecDirSize = GeoDim * (GeoDim + 1) / 2;
227 
228  // allgrads
229  const index_t numGrads = funcGrad.rows() / ParDim;
230 
231  result.resize(numGrads, fisSecDirSize);
232 
233  gsMatrix<T> JMT = md.jacobian(k).cramerInverse(); // m_jacInvs.template block<GeoDim,ParDim>(0, k*ParDim).transpose();
234  typename gsMatrix<T>::Tr JM1 = JMT.transpose(); // m_jacInvs.template block<GeoDim,ParDim>(0, k*ParDim);
235 
236  // First part: J^-T H(u) J^-1
237  gsMatrix<T> parFuncHessian;
238  for (index_t i = 0; i < numGrads; ++i)
239  {
240  secDerToHessian<T>(funcSecDir.block(i * parSecDirSize, k, parSecDirSize, 1), parFuncHessian, ParDim);
241  hessianToSecDer<T>(JM1 * parFuncHessian * JMT, result.row(i), GeoDim);
242  }
243 
244  // Second part: sum_i[ J^-T H(G_i) J^-1 ( e_i^T J^-T grad(u) ) ]
245  const gsAsConstMatrix<T, -1, -1> & secDer = md.deriv2(k);
246  std::vector<gsMatrix<T> > DDG(GeoDim);
247  secDerToTensor<T>(secDer.col(0), DDG.data(), ParDim, GeoDim);
248  gsMatrix<T> HGT(GeoDim, fisSecDirSize);
249  for (short_t i = 0; i < GeoDim; ++i)
250  hessianToSecDer<T>(JM1 * DDG[i] * JMT, HGT.row(i), GeoDim);
251 
252  // Lastpart: substract part2 from part1
253  const gsAsConstMatrix<T> grads_k(funcGrad.col(k).data(), ParDim, numGrads);
254  result.noalias() -= grads_k.transpose() * JMT * HGT;
255  // 1 x d * d x d * d x d * d * s -> 1 x s
256 }
257 
264 template <class T>
266 {
267 private:
269 
270  typedef typename gsBoundaryConditions<T>::bcContainer bcContainer;
271 
272 protected: // *** Input data members ***
273 
276  memory::shared_ptr<gsPde<T> > m_pde_ptr;
277 
282  std::vector< gsMultiBasis<T> > m_bases;
283 
286 
287 protected: // *** Output data members ***
288 
291 
295  std::vector<gsMatrix<T> > m_ddof;
296 
297 public:
298 
300  { }
301 
302  virtual ~gsAssembler()
303  { }
304 
306  static gsOptionList defaultOptions();
307 
310  virtual gsAssembler * create() const;
311 
313  virtual gsAssembler * clone() const;
314 
317  void initialize(const gsPde<T> & pde,
318  const gsStdVectorRef<gsMultiBasis<T> > & bases,
319  //note: merge with initialize(.., const gsMultiBasis<T> ,..) ?
320  const gsOptionList & opt = defaultOptions() )
321  {
322  typename gsPde<T>::Ptr _pde = memory::make_shared_not_owned(&pde);
323  initialize(_pde,bases,opt);
324  }
325 
328  void initialize(typename gsPde<T>::Ptr pde,
329  const gsStdVectorRef<gsMultiBasis<T> > & bases,
330  //note: merge with initialize(.., const gsMultiBasis<T> ,..) ?
331  const gsOptionList & opt = defaultOptions() )
332  {
333  m_pde_ptr = pde;
334  m_bases = bases;
335  m_options = opt;
336  refresh(); // virtual call to derived
337  GISMO_ASSERT( check(), "Something went wrong in assembler initialization");
338  }
339 
342  void initialize(const gsPde<T> & pde,
343  const gsMultiBasis<T> & bases,
344  const gsOptionList & opt = defaultOptions() )
345  {
346  typename gsPde<T>::Ptr _pde = memory::make_shared_not_owned(&pde);
347  initialize(_pde,bases,opt);
348  }
349 
350  void initialize(typename gsPde<T>::Ptr pde,
351  const gsMultiBasis<T> & bases,
352  const gsOptionList & opt = defaultOptions() )
353  {
354  m_pde_ptr = pde;
355  m_bases.clear();
356  m_bases.push_back(bases);
357  m_options = opt;
358  refresh(); // virtual call to derived
359  GISMO_ASSERT( check(), "Something went wrong in assembler initialization");
360  }
361 
362 
365  void initialize(const gsPde<T> & pde,
366  const gsBasisRefs<T> & basis,
367  const gsOptionList & opt = defaultOptions() )
368  {
369  GISMO_ASSERT(pde.domain().nPatches() ==1,
370  "You cannot initialize a multipatch domain with bases on a single patch");
372 
373  m_bases.clear();
374  m_bases.reserve(basis.size());
375  for(size_t c=0;c<basis.size();c++)
376  m_bases.push_back(gsMultiBasis<T>(basis[c]));
377 
378  m_options = opt;
379  refresh(); // virtual call to derived
380  GISMO_ASSERT( check(), "Something went wrong in assembler initialization");
381  }
382 
384  bool check();
385 
388  void finalize() { m_system.matrix().makeCompressed(); }
389 
393  T penalty(index_t k) const
394  {
395  const short_t deg = m_bases[0][k].maxDegree();
396  return (deg + m_bases[0][k].dim()) * (deg + 1) * 2;
397  }
398 
403  {
404  return m_system.numColNz(m_bases.front()[0], m_options);
405  }
406 
407 public: /* Virtual assembly routines*/
408 
412  virtual void refresh();
413 
415  virtual void assemble();
416 
419  virtual void assemble(const gsMultiPatch<T> & curSolution);
420 
421  gsOptionList & options() {return m_options;}
422 
423 public: /* Element visitors */
424 
427  template<class ElementVisitor>
428  void push()
429  {
430  for (size_t np = 0; np < m_pde_ptr->domain().nPatches(); ++np)
431  {
432  ElementVisitor visitor(*m_pde_ptr);
433  //Assemble (fill m_matrix and m_rhs) on patch np
434  apply(visitor, np);
435  }
436  }
437 
440  template<class BElementVisitor>
441  void push(const bcContainer & BCs)
442  {
443  for (typename bcContainer::const_iterator it
444  = BCs.begin(); it!= BCs.end(); ++it)
445  {
446  BElementVisitor visitor(*m_pde_ptr, *it);
447  //Assemble (fill m_matrix and m_rhs) contribution from this BC
448  apply(visitor, it->patch(), it->side());
449  }
450  }
451 
454  template<class ElementVisitor>
455  void push(const ElementVisitor & visitor)
456  {
457  for (size_t np = 0; np < m_pde_ptr->domain().nPatches(); ++np)
458  {
459  ElementVisitor curVisitor = visitor;
460  //Assemble (fill m_matrix and m_rhs) on patch np
461  apply(curVisitor, np);
462  }
463  }
464 
466  template<class BElementVisitor>
467  void push(const BElementVisitor & visitor, const boundary_condition<T> & BC)
468  {
469  BElementVisitor curVisitor = visitor;
470  //Assemble (fill m_matrix and m_rhs) contribution from this BC
471  apply(curVisitor, BC.patch(), BC.side());
472  }
473 
476  template<class InterfaceVisitor>
478  {
479  InterfaceVisitor visitor(*m_pde_ptr);
480 
481  const gsMultiPatch<T> & mp = m_pde_ptr->domain();
482  for ( typename gsMultiPatch<T>::const_iiterator
483  it = mp.iBegin(); it != mp.iEnd(); ++it )
484  {
485  const boundaryInterface & iFace = //recover master element
486  ( m_bases[0][it->first() .patch].numElements(it->first() .side() ) <
487  m_bases[0][it->second().patch].numElements(it->second().side() ) ?
488  it->getInverse() : *it );
489 
490  this->apply(visitor, iFace);
491  }
492  }
493 
494 
495 public: /* Dirichlet degrees of freedom computation */
496 
499  void computeDirichletDofs(short_t unk = 0);
500 
506  void setFixedDofs(const gsMatrix<T> & coefMatrix, short_t unk = 0, size_t patch = 0);
507 
512  void setFixedDofVector(gsMatrix<T> vals, short_t unk = 0);
513 
516  void penalizeDirichletDofs(short_t unk = 0);
517 
521  {
522  if(unk==-1)
523  {
524  for(size_t i=0;i<m_ddof.size();++i)
525  m_ddof[i].setZero();
526  }
527  else
528  m_ddof[unk].setZero();
529  }
530 
531  // index_t numFixedDofs(short_t unk = 0) {return m_dofMappers[unk].boundarySize();}
532 
534  const std::vector<gsMatrix<T> > & allFixedDofs() const { return m_ddof; }
535 
538  const gsMatrix<T> & fixedDofs(short_t unk=0) const { return m_ddof[unk]; }
539 
540  GISMO_DEPRECATED
541  const gsMatrix<T> & dirValues(short_t unk=0) const { return m_ddof[unk]; }//remove
542 
543 protected: /* Helpers for Dirichlet degrees of freedom computation */
544 
549  void computeDirichletDofsIntpl(const gsDofMapper & mapper,
550  const gsMultiBasis<T> & mbasis,
551  const short_t unk_ = 0);
552 
557  void computeDirichletDofsL2Proj(const gsDofMapper & mapper,
558  const gsMultiBasis<T> & mbasis,
559  const short_t unk_ = 0);
560 
561 public: /* Solution reconstruction */
562 
567  virtual void constructSolution(const gsMatrix<T>& solVector,
568  gsMultiPatch<T>& result, short_t unk = 0) const;
569 
570 
571 
579  virtual void constructSolution(const gsMatrix<T>& solVector,
580  gsMultiPatch<T>& result,
581  const gsVector<index_t> & unknowns) const;
582 
583  gsField<T> constructSolution(const gsMatrix<T>& solVector, short_t unk = 0) const;
584 
592  virtual void updateSolution(const gsMatrix<T>& solVector,
593  gsMultiPatch<T>& result, T theta = (T)(1)) const;
594 
595 public: // *** Accessors ***
596 
598  const gsPde<T> & pde() const { return *m_pde_ptr; }
599 
601  const gsMultiPatch<T> & patches() const { return m_pde_ptr->patches(); }
602 
604  const gsMultiBasis<T> & multiBasis(index_t k = 0) const { return m_bases[k]; }
605 
608  gsMultiBasis<T> & multiBasis(index_t k = 0) { return m_bases[k]; }
609 
611  size_t numMultiBasis() const {return m_bases.size(); }
612 
614  const gsSparseMatrix<T> & matrix() const { return m_system.matrix(); }
615 
618  const gsMatrix<T> & rhs() const { return m_system.rhs(); }
619  gsMatrix<T> & rhs() { return m_system.rhs(); }
620 
622  const gsSparseSystem<T> & system() const { return m_system; }
623  gsSparseSystem<T> & system() { return m_system; }
624 
627  {
628  GISMO_ASSERT(sys.initialized(), "Sparse system must be initialized first");
629  m_system.swap(sys);
630  }
631 
633  index_t numDofs() const
634  {
635  index_t sum = 0;
636  for (index_t c = 0; c!= m_system.numColBlocks(); ++c)
637  sum += m_system.colMapper(c).freeSize();
638  return sum;
639  }
640 
641 protected:
642 
647 
648 protected:
649 
655  template<class ElementVisitor>
656  void apply(ElementVisitor & visitor,
657  size_t patchIndex = 0,
658  boxSide side = boundary::none);
659 
661  template<class InterfaceVisitor>
662  void apply(InterfaceVisitor & visitor,
663  const boundaryInterface & bi);
664 };
665 
666 template <class T>
667 template<class ElementVisitor>
668 void gsAssembler<T>::apply(ElementVisitor & visitor,
669  size_t patchIndex,
670  boxSide side)
671 {
672  //gsDebug<< "Apply to patch "<< patchIndex <<"("<< side <<")\n";
673 
674  const gsBasisRefs<T> bases(m_bases, patchIndex);
675 
676 #pragma omp parallel
677 {
678  gsQuadRule<T> quRule ; // Quadrature rule
679  gsMatrix<T> quNodes ; // Temp variable for mapped nodes
680  gsVector<T> quWeights; // Temp variable for mapped weights
681 
682  ElementVisitor
683 #ifdef _OPENMP
684  // Create thread-private visitor
685  visitor_(visitor);
686  const int tid = omp_get_thread_num();
687  const int nt = omp_get_num_threads();
688 #else
689  &visitor_ = visitor;
690 #endif
691 
692  // Initialize reference quadrature rule and visitor data
693  visitor_.initialize(bases, patchIndex, m_options, quRule);
694 
695  const gsGeometry<T> & patch = m_pde_ptr->patches()[patchIndex];
696 
697  // Initialize domain element iterator -- using unknown 0
698  typename gsBasis<T>::domainIter domIt = bases[0].makeDomainIterator(side);
699 
700  // Start iteration over elements
701 #ifdef _OPENMP
702  for ( domIt->next(tid); domIt->good(); domIt->next(nt) )
703 #else
704  for (; domIt->good(); domIt->next() )
705 #endif
706  {
707  // Map the Quadrature rule to the element
708  quRule.mapTo( domIt->lowerCorner(), domIt->upperCorner(), quNodes, quWeights );
709 
710  // Perform required evaluations on the quadrature nodes
711  visitor_.evaluate(bases, patch, quNodes);
712 
713  // Assemble on element
714  visitor_.assemble(*domIt, quWeights);
715 
716  // Push to global matrix and right-hand side vector
717 #pragma omp critical(localToGlobal)
718  visitor_.localToGlobal(patchIndex, m_ddof, m_system); // omp_locks inside
719  }
720 }//omp parallel
721 
722 }
723 
724 
725 template <class T>
726 template<class InterfaceVisitor>
727 void gsAssembler<T>::apply(InterfaceVisitor & visitor,
728  const boundaryInterface & bi)
729 {
730  gsRemapInterface<T> interfaceMap(m_pde_ptr->patches(), m_bases[0], bi);
731 
732  const index_t patchIndex1 = bi.first().patch;
733  const index_t patchIndex2 = bi.second().patch;
734  const gsBasis<T> & B1 = m_bases[0][patchIndex1];// (!) unknown 0
735  const gsBasis<T> & B2 = m_bases[0][patchIndex2];
736 
737  gsQuadRule<T> quRule ; // Quadrature rule
738  gsMatrix<T> quNodes1, quNodes2;// Mapped nodes
739  gsVector<T> quWeights; // Mapped weights
740 
741  // Initialize
742  visitor.initialize(B1, B2, bi, m_options, quRule);
743 
744  const gsGeometry<T> & patch1 = m_pde_ptr->patches()[patchIndex1];
745  const gsGeometry<T> & patch2 = m_pde_ptr->patches()[patchIndex2];
746 
747  // Initialize domain element iterators
748  typename gsBasis<T>::domainIter domIt = interfaceMap.makeDomainIterator();
749  //int count = 0;
750 
751  // iterate over all boundary grid cells on the "left"
752  for (; domIt->good(); domIt->next() )
753  {
754  //count++;
755 
756  // Compute the quadrature rule on both sides
757  quRule.mapTo( domIt->lowerCorner(), domIt->upperCorner(), quNodes1, quWeights);
758  interfaceMap.eval_into(quNodes1,quNodes2);
759 
760  // Perform required evaluations on the quadrature nodes
761  visitor.evaluate(B1, patch1, B2, patch2, quNodes1, quNodes2);
762 
763  // Assemble on element
764  visitor.assemble(*domIt,*domIt, quWeights);
765 
766  // Push to global patch matrix (m_rhs is filled in place)
767  visitor.localToGlobal(patchIndex1, patchIndex2, m_ddof, m_system);
768  }
769 
770 }
771 
772 
773 } // namespace gismo
774 
775 #ifndef GISMO_BUILD_LIB
776 #include GISMO_HPP_HEADER(gsAssembler.hpp)
777 #endif
gsMultiPatch< T > & domain()
Returns a reference to the Pde domain.
Definition: gsPde.h:66
Provides a base class for a quadrature rule.
memory::shared_ptr< gsPde< T > > m_pde_ptr
Definition: gsAssembler.h:276
Provides a mapping between the corresponding sides of two patches sharing an interface.
virtual gsAssembler * create() const
Create an empty Assembler of the derived type and return a pointer to it. Call the initialize functio...
Definition: gsAssembler.hpp:59
gsMultiBasis< T > & multiBasis(index_t k=0)
Return the multi-basis. Note: if the basis is altered, then refresh() should be called.
Definition: gsAssembler.h:608
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
Class representing a sparse linear system (with dense right-hand side(s)), indexed by sets of degrees...
Class representing a reference quadrature rule.
Definition: gsQuadRule.h:28
void computeDirichletDofsIntpl(const gsDofMapper &mapper, const gsMultiBasis< T > &mbasis, const short_t unk_=0)
calculates the values of the eliminated dofs based on Interpolation.
Definition: gsAssembler.hpp:315
shared_ptr< T > make_shared_not_owned(const T *x)
Creates a shared pointer which does not eventually delete the underlying raw pointer. Usefull to refer to objects which should not be destroyed.
Definition: gsMemory.h:189
void computeDirichletDofsL2Proj(const gsDofMapper &mapper, const gsMultiBasis< T > &mbasis, const short_t unk_=0)
calculates the values of the eliminated dofs based on L2 Projection.
Definition: gsAssembler.hpp:393
Provides a mapping between the corresponding sides of two patches sharing an interface, by means of a Closest Point Projection.
void push(const ElementVisitor &visitor)
Iterates over all elements of the domain and applies the ElementVisitor.
Definition: gsAssembler.h:455
virtual gsAssembler * clone() const
Clone this Assembler, making a deep copy.
Definition: gsAssembler.hpp:63
Simple wrapper class for a vector of objects.
Definition: gsStdVectorRef.h:27
#define short_t
Definition: gsConfig.h:35
void push()
Iterates over all elements of the domain and applies the ElementVisitor.
Definition: gsAssembler.h:428
virtual void updateSolution(const gsMatrix< T > &solVector, gsMultiPatch< T > &result, T theta=(T)(1)) const
Update solution by adding the computed solution vector to the current solution specified by...
Definition: gsAssembler.hpp:649
const_iiterator iBegin() const
Definition: gsBoxTopology.h:119
gsOptionList m_options
Options.
Definition: gsAssembler.h:285
std::vector< gsMultiBasis< T > > m_bases
Definition: gsAssembler.h:282
size_t numMultiBasis() const
Returns the number of multi-bases.
Definition: gsAssembler.h:611
boxSide side() const
Returns the side to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:269
Provides declaration of MultiBasis class.
void push(const bcContainer &BCs)
Iterates over all elements of the boundaries BCs and applies the BElementVisitor. ...
Definition: gsAssembler.h:441
const std::vector< gsMatrix< T > > & allFixedDofs() const
Returns all the Dirichlet values (if applicable)
Definition: gsAssembler.h:534
void initialize(const gsPde< T > &pde, const gsBasisRefs< T > &basis, const gsOptionList &opt=defaultOptions())
Intitialize function for, sets data fields using the pde, a vector of bases and assembler options...
Definition: gsAssembler.h:365
Implements an affine function.
void penalizeDirichletDofs(short_t unk=0)
Definition: gsAssembler.hpp:125
Abstract class representing a PDE (partial differential equation).
Definition: gsPde.h:43
const gsMatrix< T > & rhs() const
Returns the left-hand side vector(s) ( multiple right hand sides possible )
Definition: gsAssembler.h:618
index_t numColBlocks() const
returns the number of column blocks
Definition: gsSparseSystem.h:472
virtual void refresh()
Creates the mappers and setups the sparse system. to be implemented in derived classes, see scalarProblemGalerkinRefresh() for a possible implementation.
Definition: gsAssembler.hpp:45
#define index_t
Definition: gsConfig.h:32
Simple class to hold a list of gsBasis which discretize a PDE system on a given patch.
Definition: gsBasisRefs.h:25
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
index_t patch() const
Returns the patch to which this boundary condition refers to.
Definition: gsBoundaryConditions.h:266
Small class holding references to a list of gsBasis.
index_t numDofs() const
Returns the number of (free) degrees of freedom.
Definition: gsAssembler.h:633
void finalize()
finishes the assembling of the system matrix, i.e. calls its .makeCompressed() method.
Definition: gsAssembler.h:388
Provides the gsDofMapper class for re-indexing DoFs.
const gsMultiPatch< T > & patches() const
Return the multipatch.
Definition: gsAssembler.h:601
Provides a list of labeled parameters/options that can be set and accessed easily.
bool initialized() const
checks if the system was initialized
Definition: gsSparseSystem.h:532
Base class of descriptions of a PDE problem.
const gsSparseMatrix< T > & matrix() const
Access the system Matrix.
Definition: gsSparseSystem.h:394
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
const gsSparseSystem< T > & system() const
Returns the left-hand global matrix.
Definition: gsAssembler.h:622
void initialize(const gsPde< T > &pde, const gsStdVectorRef< gsMultiBasis< T > > &bases, const gsOptionList &opt=defaultOptions())
Intitialize function for, sets data fields using the pde, a vector of multi-basis and assembler optio...
Definition: gsAssembler.h:317
void setFixedDofs(const gsMatrix< T > &coefMatrix, short_t unk=0, size_t patch=0)
the user can manually set the dirichlet Dofs for a given patch and unknown, based on the Basis coeffi...
Definition: gsAssembler.hpp:176
Small wrapper for std::vector.
Provides declaration of DomainIterator abstract interface.
void scalarProblemGalerkinRefresh()
A prototype of the refresh function for a &quot;standard&quot; scalar problem. Creats one mapper based on the s...
Definition: gsAssembler.hpp:102
void initialize(typename gsPde< T >::Ptr pde, const gsStdVectorRef< gsMultiBasis< T > > &bases, const gsOptionList &opt=defaultOptions())
Intitialize function for, sets data fields using the pde, a vector of multi-basis and assembler optio...
Definition: gsAssembler.h:328
Provides a mapping between the corresponding sides of two patches sharing an interface.
Definition: gsRemapInterface.h:53
Provides forward declarations of types and structs.
const gsMultiBasis< T > & multiBasis(index_t k=0) const
Return the multi-basis.
Definition: gsAssembler.h:604
const_iiterator iEnd() const
Definition: gsBoxTopology.h:124
size_t size() const
Size.
Definition: gsBasisRefs.h:58
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
const gsPde< T > & pde() const
Return the Pde.
Definition: gsAssembler.h:598
int sideOrientation(short_t s)
Definition: gsBoundary.h:1029
gsSparseSystem< T > m_system
Global sparse linear system.
Definition: gsAssembler.h:290
virtual void mapTo(const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
Maps quadrature rule (i.e., points and weights) from the reference domain to an element.
Definition: gsQuadRule.h:177
void initialize(const gsPde< T > &pde, const gsMultiBasis< T > &bases, const gsOptionList &opt=defaultOptions())
Intitialize function for, sets data fields using the pde, a multi-basis and assembler options...
Definition: gsAssembler.h:342
const gsDofMapper & colMapper(const index_t c) const
colMapper returns the dofMapper for column block c
Definition: gsSparseSystem.h:498
Class that defines a boundary condition for a side of a patch for some unknown variable of a PDE...
Definition: gsBoundaryConditions.h:106
std::vector< gsMatrix< T > > m_ddof
Definition: gsAssembler.h:295
bool check()
checks for consistency and legal values of the stored members.
Definition: gsAssembler.hpp:67
void homogenizeFixedDofs(short_t unk=0)
Sets any Dirichlet values to homogeneous (if applicable)
Definition: gsAssembler.h:520
void setSparseSystem(gsSparseSystem< T > &sys)
Swaps the actual sparse system with the given one.
Definition: gsAssembler.h:626
Provides gsBoundaryConditions class.
index_t numColNz(const gsMultiBasis< T > &mb, const gsOptionList &opt) const
Provides an estimation of the number of non-zero matrix entries per column. This value can be used fo...
Definition: gsSparseSystem.h:359
#define GISMO_ERROR(message)
Definition: gsDebug.h:118
void pushInterface()
Iterates over all elements of interfaces and applies the InterfaceVisitor.
Definition: gsAssembler.h:477
patchSide & second()
second, returns the second patchSide of this interface
Definition: gsBoundary.h:782
T penalty(index_t k) const
Penalty constant for patch k, used for Nitsche and / Discontinuous Galerkin methods.
Definition: gsAssembler.h:393
Struct which represents an interface between two patches.
Definition: gsBoundary.h:649
virtual void constructSolution(const gsMatrix< T > &solVector, gsMultiPatch< T > &result, short_t unk=0) const
Construct solution from computed solution vector for a single unknows.
Definition: gsAssembler.hpp:537
Class which holds a list of parameters/options, and provides easy access to them. ...
Definition: gsOptionList.h:32
The assembler class provides generic routines for volume and boundary integrals that are used for for...
Definition: gsAssembler.h:265
const gsMatrix< T > & fixedDofs(short_t unk=0) const
Returns the Dirichlet values for a unknown (if applicable)
Definition: gsAssembler.h:538
const gsMatrix< T > & rhs() const
Access the right hand side.
Definition: gsSparseSystem.h:402
index_t freeSize() const
Returns the number of free (not eliminated) dofs.
Definition: gsDofMapper.h:436
virtual void assemble()
Main assemble routine, to be implemented in derived classes.
Definition: gsAssembler.hpp:51
void push(const BElementVisitor &visitor, const boundary_condition< T > &BC)
Applies the BElementVisitor to the boundary condition BC.
Definition: gsAssembler.h:467
void computeDirichletDofs(short_t unk=0)
Triggers computation of the Dirichlet dofs.
Definition: gsAssembler.hpp:232
static gsOptionList defaultOptions()
Returns the list of default options for assembly.
Definition: gsAssembler.hpp:30
void swap(gsSparseSystem &other)
swap swaps the content of the Sparse System with the other given one
Definition: gsSparseSystem.h:309
index_t patch
The index of the patch.
Definition: gsBoundary.h:234
void setFixedDofVector(gsMatrix< T > vals, short_t unk=0)
the user can manually set the dirichlet Dofs for a given patch and unknown.
Definition: gsAssembler.hpp:219
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
const gsSparseMatrix< T > & matrix() const
Returns the left-hand global matrix.
Definition: gsAssembler.h:614
void apply(ElementVisitor &visitor, size_t patchIndex=0, boxSide side=boundary::none)
Generic assembly routine for volume or boundary integrals.
Definition: gsAssembler.h:668
patchSide & first()
first, returns the first patchSide of this interface
Definition: gsBoundary.h:776
index_t numColNz() const
Provides an estimation of the number of non-zero matrix entries per column. This value can be used fo...
Definition: gsAssembler.h:402