G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsPatchRule.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsAssembler/gsQuadRule.h>
17 #include <gsNurbs/gsKnotVector.h>
18 #include <gsNurbs/gsBSplineBasis.h>
19 
20 namespace gismo
21 {
22 
85 template<class T>
86 class gsPatchRule GISMO_FINAL : public gsQuadRule<T>
87 {
88 public:
89 
90  typedef memory::unique_ptr<gsPatchRule> uPtr;
91 
94  :
95  m_basis(nullptr),
96  m_deg(0),
97  m_reg(0),
98  m_over(false),
99  m_fixDir(-1)
100  {};
101 
110  gsPatchRule(const gsBasis<T> & basis,
111  const index_t degree,
112  const index_t regularity,
113  const bool overintegrate,
114  const short_t fixDir = -1);
115 
117 
128  static uPtr make( const gsBasis<T> & basis,
129  const index_t degree,
130  const index_t regularity,
131  const bool overintegrate,
132  const short_t fixDir = -1)
133  { return uPtr( new gsPatchRule(basis,degree,regularity,overintegrate,fixDir) ); }
134 
135 
140 
141 public:
142 
153  void mapTo( const gsVector<T>& lower, const gsVector<T>& upper,
154  gsMatrix<T> & nodes, gsVector<T> & weights ) const;
155 
157  void mapTo( T startVal, T endVal,
158  gsMatrix<T> & nodes, gsVector<T> & weights ) const;
159 
161  void mapToAll( const std::vector<T> &,
162  gsMatrix<T> &, gsVector<T> &) const
164 
165  index_t dim() const { return m_basis->dim(); }
166 
167  gsVector<T> nodes(const index_t d=0) const { return m_nodes.at(d); }
168  gsVector<T> weights(const index_t d=0) const { return m_weights.at(d); }
169 
170 protected:
171 
179  index_t _numQuads(const gsKnotVector<T> knots) const
180  {
181  index_t ndof = (m_deg + 1)*knots.numElements() - (m_reg+1)*(knots.numElements()-1);
182  ndof = static_cast<index_t>(std::ceil(ndof/2.0));
183  return ndof;
184  }
185 
193  bool _isSymmetric(const gsKnotVector<T> knots) const
194  {
195  gsKnotVector<T> copy = knots;
196  copy.reverse();
197  std::vector<T> result;
198  knots.symDifference(copy,result);
199  return result.size()==0 ? true : false;
200  }
201 
202 
214  gsKnotVector<T> _init(const gsBSplineBasis<T> * Bbasis) const;
215 
225  std::pair<gsMatrix<T>,gsVector<T> > _integrate(const gsKnotVector<T> & knots ) const;
226 
237  std::pair<gsVector<T>,gsVector<T> > _compute(const gsKnotVector<T> & knots,
238  const gsMatrix<T> & greville,
239  const gsVector<T> & integrals,
240  const T tol = 1e-10) const;
241 
242 private:
243  const gsBasis<T> * m_basis;
244  const index_t m_deg,m_reg;
245  const bool m_over;
246  const short_t m_fixDir;
247 
248  std::vector<gsVector<T> > m_nodes;
249  std::vector<gsVector<T> > m_weights;
250 
251  gsVector<T> m_end;
252 
253  mutable typename gsSparseSolver<T>::QR m_solver;
254 
255  size_t m_dim;
256 
257  std::vector<std::map<T,T> > m_maps;
258 }; // class gsPatchRule
259 
260 } // namespace gismo
261 
262 
263 #ifndef GISMO_BUILD_LIB
264 #include GISMO_HPP_HEADER(gsPatchRule.hpp)
265 #endif
Provides a base class for a quadrature rule.
Knot vector for B-splines.
Class representing a reference quadrature rule.
Definition: gsQuadRule.h:28
void mapToAll(const std::vector< T > &, gsMatrix< T > &, gsVector< T > &) const
Not implemented! See gsQuadRule for documentation.
Definition: gsPatchRule.h:161
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
#define short_t
Definition: gsConfig.h:35
size_t numElements() const
Number of knot intervals inside domain.
Definition: gsKnotVector.h:268
#define index_t
Definition: gsConfig.h:32
~gsPatchRule()
Destructor.
Definition: gsPatchRule.h:139
gsKnotVector< T > _init(const gsBSplineBasis< T > *Bbasis) const
Initializes the knot vector for the patch-rule implementation.
Definition: gsPatchRule.hpp:209
std::pair< gsMatrix< T >, gsVector< T > > _integrate(const gsKnotVector< T > &knots) const
Integrates all basis functions from a knot vector (numerically with Gauss)
Definition: gsPatchRule.hpp:291
A univariate B-spline basis.
Definition: gsBSplineBasis.h:694
std::pair< gsVector< T >, gsVector< T > > _compute(const gsKnotVector< T > &knots, const gsMatrix< T > &greville, const gsVector< T > &integrals, const T tol=1e-10) const
Computes the points and weights for the patch rule using Newton iterations.
Definition: gsPatchRule.hpp:324
Provides declaration of BSplineBasis class.
bool _isSymmetric(const gsKnotVector< T > knots) const
Determines whether the specified knot vector is symmetric.
Definition: gsPatchRule.h:193
void symDifference(const gsKnotVector< T > &other, std::vector< T > &result) const
Computes the symmetric difference between this knot-vector and other.
Definition: gsKnotVector.hpp:172
Class that represents the (tensor) patch quadrature rule.
Definition: gsPatchRule.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: gsPatchRule.hpp:133
gsPatchRule()
Default empty constructor.
Definition: gsPatchRule.h:93
index_t _numQuads(const gsKnotVector< T > knots) const
Computes the number of quadrature points to exactly integrate the space.
Definition: gsPatchRule.h:179
void reverse()
Better directly use affineTransformTo.
Definition: gsKnotVector.hpp:468
Class for representing a knot vector.
Definition: gsKnotVector.h:79
static uPtr make(const gsBasis< T > &basis, const index_t degree, const index_t regularity, const bool overintegrate, const short_t fixDir=-1)
Make function returning a smart pointer.
Definition: gsPatchRule.h:128
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
void copy(T begin, T end, U *result)
Small wrapper for std::copy mimicking std::copy for a raw pointer destination, copies n positions sta...
Definition: gsMemory.h:391