21template<
class T>
class gsFunctionPieceSum;
24class gsFunctionSum :
public gsFunctionSet<T>
27 typedef memory::shared_ptr< gsFunctionSum<T> > Ptr;
30 typedef memory::unique_ptr< gsFunctionSum<T> > uPtr;
38 gsFunctionSum(
const std::vector<
const gsFunctionSet<T> * > & functions)
40 m_functions(functions),
41 m_size(functions.size())
46 gsFunctionSum(
const gsFunctionSet<T> * undeformed,
const gsFunctionSet<T> * deformation)
50 m_functions.push_back(undeformed);
51 m_functions.push_back(deformation);
56 index_t nPieces()
const {
return m_functions[0]->nPieces();}
59 {
return m_functions[0]->domainDim(); }
62 {
return m_functions[0]->targetDim(); }
64 const gsFunctionPieceSum<T> & piece(
const index_t k)
const {
return m_pieces[k]; }
66 index_t size()
const {
return nPieces();}
68 std::ostream &print(std::ostream &os)
const
70 for (
index_t p = 1; p!=m_size; p++)
71 gsInfo<<
"Piece "<<p<<
":\n"<<m_pieces[p]<<
"\n";
76 index_t funcSize()
const {
return m_functions.size();}
78 const gsFunctionSet<T> * func(
const index_t i)
const {
return m_functions[i]; }
81 void _init(
const std::vector<
const gsFunctionSet<T> * > & functions)
83 GISMO_ASSERT(functions.size()>0,
"Must give one or more function sets.");
84 for (
index_t p = 1; p!=m_size; p++)
86 GISMO_ASSERT(functions[p-1]->nPieces()==functions[p]->nPieces(),
"Number of pieces does not match for function "<<p-1<<
" and "<<p<<
"!");
87 GISMO_ASSERT(functions[p-1]->domainDim()==functions[p]->domainDim(),
"Domain dimension does not match for function "<<p-1<<
" and "<<p<<
"!");
88 GISMO_ASSERT(functions[p-1]->targetDim()==functions[p]->targetDim(),
"Target dimension does not match for function "<<p-1<<
" and "<<p<<
"!");
91 for (
index_t p = 0; p!=functions[0]->nPieces(); p++)
92 m_pieces.push_back(gsFunctionPieceSum<T>(
this,p));
96 std::vector<const gsFunctionSet<T> * > m_functions;
97 std::vector<gsFunctionPieceSum<T> > m_pieces;
99 gsMatrix<T> m_support;
104class gsFunctionPieceSum :
public gsFunction<T>
107 typedef memory::shared_ptr< gsFunctionPieceSum<T> > Ptr;
110 typedef memory::unique_ptr< gsFunctionPieceSum<T> > uPtr;
112 using Base = gsFunction<T>;
115 gsFunctionPieceSum(
const gsFunctionSum<T> * geom,
const index_t index)
120 m_support = m_geom->func(0)->piece(m_index).support();
121 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
122 for (
index_t d=0; d!=m_support.rows(); d++)
124 GISMO_ASSERT(m_geom->func(p)->piece(m_index).support().rows()!=0 && m_geom->func(p)->piece(m_index).support().cols()!=0,
"Support is empty");
126 if (m_support(d,0) > m_geom->func(p)->piece(m_index).support()(d,0))
127 m_support(d,0) = m_geom->func(p)->piece(m_index).support()(d,0);
128 if (m_support(d,1) < m_geom->func(p)->piece(m_index).support()(d,1))
129 m_support(d,1) = m_geom->func(p)->piece(m_index).support()(d,1);
133 gsMatrix<T> support()
const
139 {
return m_geom->domainDim(); }
142 {
return m_geom->targetDim(); }
145 void eval_into(
const gsMatrix<T> & u, gsMatrix<T>& result)
const
148 m_geom->func(0)->piece(m_index).eval_into(u,result);
149 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
151 m_geom->func(p)->piece(m_index).eval_into(u,tmp);
157 void deriv_into(
const gsMatrix<T> & u, gsMatrix<T>& result )
const
160 m_geom->func(0)->piece(m_index).deriv_into(u,result);
161 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
163 m_geom->func(p)->piece(m_index).deriv_into(u,tmp);
170 void deriv2_into(
const gsMatrix<T> & u, gsMatrix<T>& result )
const
173 m_geom->func(0)->piece(m_index).deriv2_into(u,result);
174 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
176 m_geom->func(p)->piece(m_index).deriv2_into(u,tmp);
184 void evalAllDers_into(
const gsMatrix<T> & u,
int n, std::vector<gsMatrix<T> >& result)
const
186 std::vector<gsMatrix<T> > tmp;
187 m_geom->func(0)->piece(m_index).evalAllDers_into(u,n,result);
188 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
190 m_geom->func(p)->piece(m_index).evalAllDers_into(u,n,tmp);
191 for (
size_t k = 0; k!=result.size(); k++)
199 GISMO_CLONE_FUNCTION(gsFunctionPieceSum)
201 std::ostream &print(std::ostream &os)
const
203 for (
index_t p = 0; p!= m_geom->funcSize(); p++)
204 gsInfo<<
" function "<<p<<
":\n"<<m_geom->func(p)->piece(m_index)<<
"\n";
209 const gsFunctionSum<T> * m_geom;
211 gsMatrix<T> m_support;
virtual void evalAllDers_into(const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result, bool sameElement=false) const
Evaluate the nonzero functions and their derivatives up to order n at points u into result.
Definition gsFunctionSet.hpp:81
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define gsInfo
Definition gsDebug.h:43
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
This is the interface of all objects that computes functions on points like gsBasis,...
The G+Smo namespace, containing all definitions for the library.