G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsConstantBasis.h
Go to the documentation of this file.
1 
15 #pragma once
16 
17 #include <gsCore/gsLinearAlgebra.h>
19 
20 namespace gismo
21 {
22 
23 
33 template <class T>
34 class gsConstantBasis : public gsBasis<T>
35 {
36 public:
38  typedef memory::shared_ptr< gsConstantBasis > Ptr;
39 
41  typedef memory::unique_ptr< gsConstantBasis > uPtr;
42 
44  : m_val(x), m_domainDim(domainDim)
45  { }
46 
47  // compatibility constructor for gsRationalBasis
48  gsConstantBasis(const gsBasis<T> * b, gsMatrix<T> weight)
49  : m_val( weight.value() ), m_domainDim(b->dim())
50  {
51  GISMO_ASSERT(weight.size() == 1, "Something seems wrong.");
52  }
53 
54  // compatibility constructor for gsTensorBasis
55  gsConstantBasis(const std::vector<gsBasis<T>*> & rr)
56  : m_val( 1.0 ), m_domainDim(1)
57  { }
58 
59  GISMO_CLONE_FUNCTION(gsConstantBasis)
60 
61  static gsConstantBasis * New(std::vector<gsBasis<T>*> & bb )
62  {
63  return new gsConstantBasis(bb);
64  }
65 
66 public:
67 
68  short_t domainDim() const { return m_domainDim; }
69 
70  index_t size() const { return 1; }
71 
72  void active_into(const gsMatrix<T> & u, gsMatrix<index_t>& result) const
73  {
74  result.setZero(1,u.cols());
75  }
76 
77  void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
78  {
79  GISMO_ASSERT(u.rows() == m_domainDim, "Wrong domain dimension "<< u.rows()
80  << ", expected "<< m_domainDim);
81  result.setConstant(1, u.cols(), m_val);
82  }
83 
84  void deriv_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
85  {
86  GISMO_ASSERT(u.rows() == m_domainDim, "Wrong domain dimension "<< u.rows()
87  << ", expected "<< m_domainDim);
88  result = gsMatrix<T>::Zero(m_domainDim, u.cols() );
89  }
90 
91  virtual void anchors_into(gsMatrix<T>& result) const
92  {
93  result.setZero(1,1);
94  }
95 
96  std::ostream &print(std::ostream &os) const
97  {
98  os << m_val;
99  return os;
100  }
101 
102  memory::unique_ptr<gsGeometry<T> > makeGeometry( gsMatrix<T> coefs ) const
103  {
104  coefs *= m_val;
105  return memory::unique_ptr<gsGeometry<T> >(new gsConstantFunction<T>(coefs.transpose(), m_domainDim));
106  }
107 
108 public:
109 
110  T value() const { return m_val;}
111 
112 private:
113 
114  T m_val;
115 
116  short_t m_domainDim;
117 };
118 
119 
120 } // namespace gismo
Class defining a dummy basis of constant functions. This is used for compatibility reasons...
Definition: gsConstantBasis.h:34
void active_into(const gsMatrix< T > &u, gsMatrix< index_t > &result) const
Returns the indices of active basis functions at points u, as a list of indices, in result...
Definition: gsConstantBasis.h:72
memory::shared_ptr< gsConstantBasis > Ptr
Shared pointer for gsConstantBasis.
Definition: gsConstantBasis.h:38
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition: gsConstantBasis.h:77
virtual void anchors_into(gsMatrix< T > &result) const
Returns the anchor points that represent the members of the basis in result. There is exactly one anc...
Definition: gsConstantBasis.h:91
#define short_t
Definition: gsConfig.h:35
Provides declaration of ConstantFunction class.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsConstantBasis.h:68
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition: gsConstantBasis.h:96
memory::unique_ptr< gsConstantBasis > uPtr
Unique pointer for gsConstantBasis.
Definition: gsConstantBasis.h:41
void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates the first partial derivatives of the nonzero basis function.
Definition: gsConstantBasis.h:84
index_t size() const
size
Definition: gsConstantBasis.h:70
This is the main header file that collects wrappers of Eigen for linear algebra.
memory::unique_ptr< gsGeometry< T > > makeGeometry(gsMatrix< T > coefs) const
Create a gsGeometry of proper type for this basis with the given coefficient matrix.
Definition: gsConstantBasis.h:102
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
Class defining a globally constant function.
Definition: gsConstantFunction.h:33