G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsMappedSpline.h
Go to the documentation of this file.
1 
14 #pragma once
15 #include <gsCore/gsGeometry.h>
16 #include <gsCore/gsMultiPatch.h>
21 
22 namespace gismo
23 {
24 
25 // forward declarations of the mapper classes
26 template<short_t d,class T> class gsMappedSingleSpline;
27 
28 template<short_t d,class T>
29 class gsMappedSpline : public gsFunctionSet<T>
30 {
31  friend class gsMappedSingleSpline<d,T>;
32 
33 private:
34  typedef typename gsGeoTraits<d,T>::GeometryBase GeoType;
35  typedef gsBasis<T> BasisType;
36 
38  typedef memory::shared_ptr< gsMappedSpline > Ptr;
39 
41  typedef memory::unique_ptr< gsMappedSpline > uPtr;
42 
43 public:
45  gsMappedSpline() : m_mbases(nullptr) { }
46 
49  gsMappedSpline( const gsMultiPatch<T> & mp, const gsSparseMatrix<T> & m );
50 
52  gsMappedSpline( const gsMappedBasis<d,T> & mbases, const gsMatrix<T> & coefs );
53 
54  gsMappedSpline( const gsMappedSpline& other );
55 
56  gsMappedSpline<d,T> & operator=( const gsMappedSpline& other );
57 
58  ~gsMappedSpline()
59  { delete m_mbases; } //destructor
60 
61  void init(const gsMappedBasis<d,T> & mbasis)
62  {
63  GISMO_ASSERT(mbasis.domainDim()==d, "Error in dimensions");
64 
65  m_ss.clear();
66  m_ss.reserve(mbasis.nPieces());
67  for ( index_t k=0; k!=mbasis.nPieces(); k++ )
68  {
69  m_ss.push_back( gsMappedSingleSpline<d,T>(this,k) );
70  }
71  }
72 
73  void init(const gsMappedBasis<d,T> & mbasis, const gsMatrix<T> & coefs)
74  {
75  GISMO_ASSERT(mbasis.domainDim()==d, "Error in dimensions");
76 
77  m_global.clear();
78  m_global = coefs;
79 
80  m_mbases=mbasis.clone().release();
81 
82  m_ss.clear();
83  m_ss.reserve(mbasis.nPieces());
84  for ( index_t k=0; k!=mbasis.nPieces(); k++ )
85  {
86  m_ss.push_back( gsMappedSingleSpline<d,T>(this,k) );
87  }
88  }
89 
90  void init(const gsMultiPatch<T> & mp, const gsSparseMatrix<T> & m )
91  {
92  GISMO_ASSERT(mp.nPatches()>0,"MultiPatch is empty?");
93  m_mbases = new gsMappedBasis<d,T>(gsMultiBasis<T>(mp),m);
94 
95  // collect and transform the coefficients
96  gsMatrix<T> local = mp.coefs();
97  m_mbases->local_coef_to_global_coef(local,m_global);
98  init(*m_mbases);
99  }
100 
101 
102 public:
103 
104  index_t nPieces() const {return m_mbases->nPieces();}
105 
107  BasisType const & getBase(int i) const
108  { return m_mbases->getBase(i); }
109 
111  BasisType & getBase(int i)
112  { return m_mbases->getBase(i); }
113 
115  const std::vector<BasisType*> getBases() const
116  { return m_mbases->getBases(); }
117 
119  gsWeightMapper<T> const & getMapper() const
120  { return m_mbases->getMapper(); }
121 
123  gsWeightMapper<T> * getMapPointer() const
124  { return m_mbases->getMapPointer(); }
125 
127  gsBoxTopology const & getTopol() const
128  { return m_mbases->getTopol(); }
129 
131 // Virtual base members with a new implementation
133 
135 // Virtual member functions required by the base class
137 
138  GISMO_CLONE_FUNCTION(gsMappedSpline)
139 
140  short_t domainDim() const
141  { return m_mbases->domainDim(); }
142 
143  short_t targetDim() const
144  { return m_global.cols(); }
145 
147  size_t nPatches() const
148  { return m_mbases->nPatches(); }
149 
150  const gsMappedSingleSpline<d,T> & piece(const index_t k) const { return m_ss[k]; }
151 
152  index_t size() const {return nPieces();}
153 
155  std::ostream &print(std::ostream &os) const
156  { return m_mbases->print(os); }
157 
158  const gsMappedBasis<d,T> & getMappedBasis() const
159  { return *m_mbases; }
160 
161  const gsMatrix<T> & getMappedCoefs() const
162  { return m_global; }
163 
164  gsMappedBasis<d,T> & getMappedBasis()
165  { return *m_mbases; }
166 
167  gsMultiPatch<T> exportToPatches() const;
168 
169  // support (domain of definition)
170  gsMatrix<T> supportOf(const index_t & k) const
171  { return m_mbases->getBase(k).support(); }
172 
173  gsGeometry<T> * exportPatch(int i,gsMatrix<T> const & localCoef) const;
174 
175 private:
176  // Avoid warnings for hidden overloads w.r.t gsFunctionSet
177  void active_into(const gsMatrix<T> &,gsMatrix<index_t>&) const
179  void eval_into(const gsMatrix<T> &,gsMatrix<T>&) const
181  void deriv_into(const gsMatrix<T> &,gsMatrix<T>&) const
183  void deriv2_into(const gsMatrix<T> &,gsMatrix<T>&) const
185  void evalAllDers_into(const gsMatrix<T> &, int,
186  std::vector<gsMatrix<T> >&, bool) const
188 
189 public:
191  // functions for evaluating and derivatives
193 
217  void eval_into(const unsigned patch, const gsMatrix<T> & u, gsMatrix<T>& result ) const;
218  void deriv_into(const unsigned patch, const gsMatrix<T> & u, gsMatrix<T>& result ) const;
219  void deriv2_into(const unsigned patch, const gsMatrix<T> & u, gsMatrix<T>& result ) const;
220 
223  void evalAllDers_into(const unsigned patch, const gsMatrix<T> & u,
224  const int n, std::vector<gsMatrix<T> >& result,
225  bool sameElement = false) const;
226 
227 
228 
229 // Data members
230 protected:
232  gsMappedBasis<d,T> * m_mbases;
234  gsMatrix<T> m_global;
236  std::vector<gsMappedSingleSpline<d,T> > m_ss;
237 
238 }; // class gsMappedSpline
239 
240 } // namespace gismo
241 
242 #ifndef GISMO_BUILD_LIB
243 #include GISMO_HPP_HEADER(gsMappedSpline.hpp)
244 #endif
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
#define short_t
Definition: gsConfig.h:35
Provides declaration of Geometry abstract interface.
#define index_t
Definition: gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
Provides declaration of Basis abstract interface.
Provides declaration of the MultiPatch class.
Provides declaration of DomainIterator abstract interface.
Implementation of a piece of the gsMappedBasis.
Provides declaration of Basis abstract interface.