G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsOverIntegrateRule.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsAssembler/gsQuadRule.h>
17 #include <gsCore/gsBasis.h>
18 
19 namespace gismo
20 {
21 
29 template<class T>
30 class gsOverIntegrateRule GISMO_FINAL : public gsQuadRule<T>
31 {
32 public:
33 
34  typedef memory::unique_ptr<gsOverIntegrateRule> uPtr;
35 
38  :
39  m_basis(nullptr),
40  m_interior(),
41  m_boundary()
42  {}
43 
54  const std::vector<gsQuadRule<T> > & quadInterior,
55  const std::vector<gsQuadRule<T> > & quadBoundary)
56  :
57  m_basis(&basis),
58  m_interior(quadInterior),
59  m_boundary(quadBoundary)
60  {
61  std::vector< gsVector<T> > nodes(m_basis->dim());
62  m_start = m_basis->support().col(0);
63  m_end = m_basis->support().col(1);
64  };
65 
75  static uPtr make( const gsBasis<T> & basis,
76  const std::vector<gsQuadRule<T> > & quadInterior,
77  const std::vector<gsQuadRule<T> > & quadBoundary )
78  { return uPtr( new gsOverIntegrateRule(basis,quadInterior,quadBoundary) ); }
79 
80  //const unsigned digits = std::numeric_limits<T>::digits10 );
81 
82  ~gsOverIntegrateRule() { }
83 
84 public:
86  index_t dim() const { return m_basis->dim(); }
87 
96  void mapTo( const gsVector<T>& lower, const gsVector<T>& upper,
97  gsMatrix<T> & nodes, gsVector<T> & weights ) const
98  {
99 
100  gsVector<T> bot = lower-m_start;
101  gsVector<T> top = upper-m_end;
102  std::vector<gsVector<T> > elNodes(m_basis->dim());
103  std::vector<gsVector<T> > elWeights(m_basis->dim());
104  gsMatrix<T> tmp;
105  for (index_t d = 0; d!=dim(); d++)
106  {
107  if (bot[d]==0.0 || top[d]==0.0) // is the coordinate on a side?
108  {
109  m_boundary[d].mapTo( lower[d], upper[d], tmp, elWeights[d]);
110  GISMO_ASSERT(tmp.rows()==1,"Dimension of the nodes is wrong!");
111  elNodes[d] = tmp.transpose();
112  }
113  else
114  {
115  m_interior[d].mapTo( lower[d], upper[d], tmp, elWeights[d]);
116  GISMO_ASSERT(tmp.rows()==1,"Dimension of the nodes is wrong!");
117  elNodes[d] = tmp.transpose();
118  }
119  }
120  this->computeTensorProductRule_into(elNodes,elWeights,nodes,weights);
121  }
122 
123 private:
124  const gsBasis<T> * m_basis;
125  std::vector<gsQuadRule<T> > m_interior, m_boundary;
126  gsVector<T> m_start,m_end;
127 
128 }; // class gsOverIntegrateRule
129 
130 } // namespace gismo
Provides a base class for a quadrature rule.
static uPtr make(const gsBasis< T > &basis, const std::vector< gsQuadRule< T > > &quadInterior, const std::vector< gsQuadRule< T > > &quadBoundary)
Construct a smart-pointer to the rule.
Definition: gsOverIntegrateRule.h:75
Class representing a reference quadrature rule.
Definition: gsQuadRule.h:28
Provides declaration of Basis abstract interface.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
gsOverIntegrateRule()
Default empty constructor.
Definition: gsOverIntegrateRule.h:37
index_t dim() const
Dimension of the rule.
Definition: gsOverIntegrateRule.h:86
void mapTo(const gsVector< T > &lower, const gsVector< T > &upper, gsMatrix< T > &nodes, gsVector< T > &weights) const
Maps the points in the d-dimensional cube with points lower and upper.
Definition: gsOverIntegrateRule.h:96
Class that defines a mixed quadrature rule with different rules for the interior and the boundaries...
Definition: gsOverIntegrateRule.h:30
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
gsOverIntegrateRule(const gsBasis< T > &basis, const std::vector< gsQuadRule< T > > &quadInterior, const std::vector< gsQuadRule< T > > &quadBoundary)
Constructor.
Definition: gsOverIntegrateRule.h:53