21 template<
class T>
class gsFunctionPieceSum;
24 class gsFunctionSum :
public gsFunctionSet<T>
32 gsFunctionSum(
const std::vector<
const gsFunctionSet<T> * > & functions)
34 m_functions(functions),
35 m_size(functions.size())
40 gsFunctionSum(
const gsFunctionSet<T> * undeformed,
const gsFunctionSet<T> * deformation)
44 m_functions.push_back(undeformed);
45 m_functions.push_back(deformation);
50 index_t nPieces()
const {
return m_functions[0]->nPieces();}
53 {
return m_functions[0]->domainDim(); }
56 {
return m_functions[0]->targetDim(); }
58 const gsFunctionPieceSum<T> & piece(
const index_t k)
const {
return m_pieces[k]; }
60 index_t size()
const {
return nPieces();}
62 std::ostream &print(std::ostream &os)
const
64 for (
index_t p = 1; p!=m_size; p++)
65 gsInfo<<
"Piece "<<p<<
":\n"<<m_pieces[p]<<
"\n";
70 index_t funcSize()
const {
return m_functions.size();}
72 const gsFunctionSet<T> * func(
const index_t i)
const {
return m_functions[i]; }
75 void _init(
const std::vector<
const gsFunctionSet<T> * > & functions)
77 GISMO_ASSERT(functions.size()>0,
"Must give one or more function sets.");
78 for (
index_t p = 1; p!=m_size; p++)
80 GISMO_ASSERT(functions[p-1]->nPieces()==functions[p]->nPieces(),
"Number of pieces does not match for function "<<p-1<<
" and "<<p<<
"!");
81 GISMO_ASSERT(functions[p-1]->domainDim()==functions[p]->domainDim(),
"Domain dimension does not match for function "<<p-1<<
" and "<<p<<
"!");
82 GISMO_ASSERT(functions[p-1]->targetDim()==functions[p]->targetDim(),
"Target dimension does not match for function "<<p-1<<
" and "<<p<<
"!");
85 for (
index_t p = 0; p!=functions[0]->nPieces(); p++)
86 m_pieces.push_back(gsFunctionPieceSum<T>(
this,p));
90 std::vector<const gsFunctionSet<T> * > m_functions;
91 std::vector<gsFunctionPieceSum<T> > m_pieces;
93 gsMatrix<T> m_support;
98 class gsFunctionPieceSum :
public gsFunction<T>
101 typedef memory::shared_ptr< gsFunctionPieceSum<T> > Ptr;
104 typedef memory::unique_ptr< gsFunctionPieceSum<T> > uPtr;
107 gsFunctionPieceSum(
const gsFunctionSum<T> * geom,
const index_t index)
112 m_support = m_geom->func(0)->piece(m_index).support();
113 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
114 for (
index_t d=0; d!=m_support.rows(); d++)
116 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");
118 if (m_support(d,0) > m_geom->func(p)->piece(m_index).support()(d,0))
119 m_support(d,0) = m_geom->func(p)->piece(m_index).support()(d,0);
120 if (m_support(d,1) < m_geom->func(p)->piece(m_index).support()(d,1))
121 m_support(d,1) = m_geom->func(p)->piece(m_index).support()(d,1);
125 gsMatrix<T> support()
const
131 {
return m_geom->domainDim(); }
134 {
return m_geom->targetDim(); }
137 void eval_into(
const gsMatrix<T> & u, gsMatrix<T>& result)
const
140 m_geom->func(0)->piece(m_index).eval_into(u,result);
141 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
143 m_geom->func(p)->piece(m_index).eval_into(u,tmp);
149 void deriv_into(
const gsMatrix<T> & u, gsMatrix<T>& result )
const
152 m_geom->func(0)->piece(m_index).deriv_into(u,result);
153 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
155 m_geom->func(p)->piece(m_index).deriv_into(u,tmp);
162 void deriv2_into(
const gsMatrix<T> & u, gsMatrix<T>& result )
const
165 m_geom->func(0)->piece(m_index).deriv2_into(u,result);
166 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
168 m_geom->func(p)->piece(m_index).deriv2_into(u,tmp);
176 void evalAllDers_into(
const gsMatrix<T> & u,
int n, std::vector<gsMatrix<T> >& result)
const
178 std::vector<gsMatrix<T> > tmp;
179 m_geom->func(0)->piece(m_index).evalAllDers_into(u,n,result);
180 for (
index_t p = 1; p!=m_geom->funcSize(); p++)
182 m_geom->func(p)->piece(m_index).evalAllDers_into(u,n,tmp);
183 for (
size_t k = 0; k!=result.size(); k++)
190 GISMO_CLONE_FUNCTION(gsFunctionPieceSum)
192 std::ostream &print(std::ostream &os)
const
194 for (
index_t p = 0; p!= m_geom->funcSize(); p++)
195 gsInfo<<
" function "<<p<<
":\n"<<m_geom->func(p)->piece(m_index)<<
"\n";
200 const gsFunctionSum<T> * m_geom;
202 gsMatrix<T> m_support;
#define short_t
Definition: gsConfig.h:35
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 index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
#define gsInfo
Definition: gsDebug.h:43
This is the interface of all objects that computes functions on points like gsBasis, gsGeometry and gsFunctions.