G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsConstantBasis.h
Go to the documentation of this file.
1
15#pragma once
16
19
20namespace gismo
21{
22
23
33template <class T>
34class gsConstantBasis : public gsBasis<T>
35{
36public:
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
66public:
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
108public:
109
110 T value() const { return m_val;}
111
112private:
113
114 T m_val;
115
116 short_t m_domainDim;
117};
118
119
120} // namespace gismo
A basis represents a family of scalar basis functions defined over a common parameter domain.
Definition gsBasis.h:79
Class defining a dummy basis of constant functions. This is used for compatibility reasons.
Definition gsConstantBasis.h:35
memory::unique_ptr< gsConstantBasis > uPtr
Unique pointer for gsConstantBasis.
Definition gsConstantBasis.h:41
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
void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluates nonzero basis functions at point u into result.
Definition gsConstantBasis.h:77
index_t size() const
size
Definition gsConstantBasis.h:70
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
short_t domainDim() const
Dimension of the (source) domain.
Definition gsConstantBasis.h:68
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
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
memory::shared_ptr< gsConstantBasis > Ptr
Shared pointer for gsConstantBasis.
Definition gsConstantBasis.h:38
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsConstantBasis.h:96
Class defining a globally constant function.
Definition gsConstantFunction.h:34
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
Provides declaration of ConstantFunction class.
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
This is the main header file that collects wrappers of Eigen for linear algebra.
The G+Smo namespace, containing all definitions for the library.