G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsMappedSpline.h
Go to the documentation of this file.
1
14#pragma once
15#include <gsCore/gsGeometry.h>
16#include <gsCore/gsMultiPatch.h>
21
22namespace gismo
23{
24
25// forward declarations of the mapper classes
26template<short_t d,class T> class gsMappedSingleSpline;
27
28template<short_t d,class T>
29class gsMappedSpline : public gsFunctionSet<T>
30{
31 friend class gsMappedSingleSpline<d,T>;
32
33private:
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
43public:
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
102public:
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
134 std::map<std::array<size_t, 4>, internal::ElementBlock> BezierOperator() const;
135
137// Virtual base members with a new implementation
139
141// Virtual member functions required by the base class
143
144 GISMO_CLONE_FUNCTION(gsMappedSpline)
145
146 short_t domainDim() const
147 { return m_mbases->domainDim(); }
148
149 short_t targetDim() const
150 { return m_global.cols(); }
151
153 size_t nPatches() const
154 { return m_mbases->nPatches(); }
155
156 const gsMappedSingleSpline<d,T> & piece(const index_t k) const { return m_ss[k]; }
157
158 index_t size() const {return nPieces();}
159
161 std::ostream &print(std::ostream &os) const
162 { return m_mbases->print(os); }
163
164 const gsMappedBasis<d,T> & getMappedBasis() const
165 { return *m_mbases; }
166
167 const gsMatrix<T> & getMappedCoefs() const
168 { return m_global; }
169
170 gsMappedBasis<d,T> & getMappedBasis()
171 { return *m_mbases; }
172
173 gsMultiPatch<T> exportToPatches() const;
174
175 // support (domain of definition)
176 gsMatrix<T> supportOf(const index_t & k) const
177 { return m_mbases->getBase(k).support(); }
178
179 gsGeometry<T> * exportPatch(int i,gsMatrix<T> const & localCoef) const;
180
181private:
182 // Avoid warnings for hidden overloads w.r.t gsFunctionSet
183 void active_into(const gsMatrix<T> &,gsMatrix<index_t>&) const
185 void eval_into(const gsMatrix<T> &,gsMatrix<T>&) const
187 void deriv_into(const gsMatrix<T> &,gsMatrix<T>&) const
189 void deriv2_into(const gsMatrix<T> &,gsMatrix<T>&) const
191 void evalAllDers_into(const gsMatrix<T> &, int,
192 std::vector<gsMatrix<T> >&, bool) const
194
195public:
197 // functions for evaluating and derivatives
199
223 void eval_into(const unsigned patch, const gsMatrix<T> & u, gsMatrix<T>& result ) const;
224 void deriv_into(const unsigned patch, const gsMatrix<T> & u, gsMatrix<T>& result ) const;
225 void deriv2_into(const unsigned patch, const gsMatrix<T> & u, gsMatrix<T>& result ) const;
226
229 void evalAllDers_into(const unsigned patch, const gsMatrix<T> & u,
230 const int n, std::vector<gsMatrix<T> >& result,
231 bool sameElement = false) const;
232
233
234
235// Data members
236protected:
238 gsMappedBasis<d,T> * m_mbases;
240 gsMatrix<T> m_global;
242 std::vector<gsMappedSingleSpline<d,T> > m_ss;
243
244}; // class gsMappedSpline
245
246} // namespace gismo
247
248#ifndef GISMO_BUILD_LIB
249#include GISMO_HPP_HEADER(gsMappedSpline.hpp)
250#endif
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
Provides declaration of DomainIterator abstract interface.
Provides declaration of Geometry abstract interface.
Provides declaration of Basis abstract interface.
Implementation of a piece of the gsMappedBasis.
Provides declaration of Basis abstract interface.
Provides declaration of the MultiPatch class.
The G+Smo namespace, containing all definitions for the library.