G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsField.h
Go to the documentation of this file.
1
14#pragma once
15
17#include <gsCore/gsGeometry.h>
18#include <gsCore/gsMultiPatch.h>
19#include <gsCore/gsMultiBasis.h>
20#include <gsUtils/gsPointGrid.h>
21
22namespace gismo
23{
53template<class T>
55{
56
57public:
58 typedef memory::shared_ptr< gsField > Ptr;// todo: remove
59 typedef memory::unique_ptr< gsField > uPtr;// todo: remove
60
61 gsField(): m_patches(NULL) { }
62
63 gsField( const gsFunctionSet<T> & mp,
64 typename gsFunctionSet<T>::Ptr fs,
65 const bool isparam)
66 : m_patches(&mp), m_fields(fs), m_parametric(isparam)
67 { }
68
69 gsField( const gsGeometry<T> & sp, const gsFunctionSet<T> & pf, const bool isparam = false)
71 { }
72
73 gsField( const gsGeometry<T> & sp, const gsGeometry<T> & pf)
75 { }
76
77 gsField( const gsMultiPatch<T> & mp, const gsFunctionSet<T> & f, const bool isparam = false)
79 { }
80
81 gsField( const gsMultiPatch<T> & mp, const gsMultiPatch<T> & f)
83 { }
84
85public:
86
87// TO DO:
88
89// EVAL_physical_position
90// Need to solve x = m_geometry(u) for u
91
92 // Return a point in the physical domain at parameter value u
104 gsMatrix<T> point(const gsMatrix<T>& u, int i = 0) const
105 {
106 return m_patches->piece(i).eval(u);
107 }
108
109 // Return the value of the Field at parameter value u
110 // TO DO: rename to evalParam()
122 gsMatrix<T> value(const gsMatrix<T>& u, int i = 0) const
123 {
124 return m_parametric
125 ? m_fields->piece(i).eval(u)
126 : m_fields->piece(i).eval( point(u, i) );
127 }
128
129 // Return the value of the Field at physical value u
130 // TO DO: rename to evalPhys()
131 gsMatrix<T> pvalue(const gsMatrix<T>& u, int i) const
132 {
133 GISMO_ASSERT(!m_parametric, "Cannot compute physical value");
134 return ( m_fields->piece(i).eval(u) );
135 }
136
138 T distanceL2(gsField<T> const & field, int numEvals= 1000) const;
139
141 T distanceL2(gsFunctionSet<T> const & func,
142 bool isFunc_param = false,
143 int numEvals=1000) const;
144
147 T distanceL2(gsFunctionSet<T> const & func,
148 gsMultiBasis<T> const & B,
149 bool isFunc_param = false,
150 int numEvals=1000) const;
151
154 T distanceH1(gsFunctionSet<T> const & func,
155 bool isFunc_param = false,
156 int = 1000) const;
157
160 T distanceH1(gsFunctionSet<T> const & func,
161 gsMultiBasis<T> const & B,
162 bool isFunc_param = false,
163 int = 1000) const;
164
167 T distanceH2(gsFunctionSet<T> const & func,
168 bool isFunc_param = false) const;
169
172 T distanceDG(gsFunctionSet<T> const & func,
173 bool isFunc_param = false,
174 int = 1000) const;
175
177 std::ostream &print(std::ostream &os) const
178 {
179 os << ( m_parametric ? "Parameterized f" : "F")
180 << "unction field.\n Defined on " << m_patches;
181 return os;
182 }
183
186 short_t parDim() const { return m_patches->domainDim(); }
187
190 short_t geoDim() const { return m_patches->targetDim(); }
191
194 short_t dim() const { return m_fields->targetDim(); }
195
197 GISMO_DEPRECATED index_t nPatches() const { return m_patches->nPieces(); }
198
200 int nPieces() const { return m_patches->nPieces(); }
201
202 const gsGeometry<T> & geometry() const
203 {
204 GISMO_ASSERT(dynamic_cast<const gsGeometry<T>*>(m_patches),
205 "No geometry in field. The domain is"<< *m_patches);
206 return *static_cast<const gsGeometry<T>*>(m_patches);
207 }
208
210 const gsMultiPatch<T> & patches() const
211 {
212 GISMO_ASSERT(dynamic_cast<const gsMultiPatch<T>*>(m_patches),
213 "No patches in field. The field domain is "<< *m_patches);
214 return *static_cast<const gsMultiPatch<T>*>(m_patches);
215 }
216
218 const gsFunctionSet<T> & fields() const { return *m_fields; }
219
221 const gsGeometry<T> & patch(int i=0) const
222 {
224 "gsField: Invalid patch index.");
225 GISMO_ASSERT(dynamic_cast<const gsGeometry<T>*>(&m_patches->piece(i)),
226 "No geometry in field. The domain is"<< m_patches->piece(i));
227 return static_cast<const gsGeometry<T>&>(m_patches->piece(i));
228 }
229
231 const gsFunction<T> & function(int i=0) const
232 {
233 GISMO_ASSERT(dynamic_cast<const gsFunction<T>*>(&m_fields->piece(i)),
234 "No function in field. The domain is"<< m_patches->piece(i));
235 return static_cast<const gsFunction<T>&>(m_fields->piece(i));
236 }
237
239 const gsGeometry<T> & igaFunction(int i=0) const
240 {
241 GISMO_ASSERT(i<m_fields->nPieces(),
242 "gsField: Invalid patch index.");
244 "Cannot get an IGA function from non-parametric field.");
245 GISMO_ASSERT(dynamic_cast<const gsGeometry<T>*>(&m_fields->piece(i)),
246 "Cannot return an igaFunction from a function of type: "<< m_fields->piece(i) );
247 return static_cast<const gsGeometry<T> &>(m_fields->piece(i));
248 }
249
252 bool isParametric() const { return m_parametric; }
253
257 bool isParametrized() const
258 { return m_parametric && dynamic_cast<const gsGeometry<T>*>(&m_fields->piece(0));}
259
268 const gsMatrix<T> & coefficientVector(int i=0) const
269 {
270 return igaFunction(i).coefs();
271 }
272
273// Data members
274private:
275
278
279 // If there are many patches, one field per patch
280
287
297 bool m_parametric;// True iff this is an Isogeometric field, living on parameter domain
298
299}; // class gsField
300
301
303template<class T>
304std::ostream &operator<<(std::ostream &os, const gsField<T>& b)
305{return b.print(os); }
306
307
308} // namespace gismo
309
310#ifndef GISMO_BUILD_LIB
311#include GISMO_HPP_HEADER(gsField.hpp)
312#endif
A scalar of vector field defined on a m_parametric geometry.
Definition gsField.h:55
const gsGeometry< T > & patch(int i=0) const
Returns the gsGeometry of patch i.
Definition gsField.h:221
gsFunctionSet< T >::Ptr m_fields
Vector containing "local fields" for each patch/subdomain.
Definition gsField.h:286
const gsFunction< T > & function(int i=0) const
Returns the gsFunction of patch i.
Definition gsField.h:231
bool isParametric() const
Definition gsField.h:252
const gsFunctionSet< T > * m_patches
The isogeometric field is defined on this multipatch domain.
Definition gsField.h:277
T distanceH1(gsFunctionSet< T > const &func, bool isFunc_param=false, int=1000) const
Definition gsField.hpp:111
bool m_parametric
True iff this is an isogeometric field.
Definition gsField.h:297
int nPieces() const
Returns the number of pieces.
Definition gsField.h:200
gsMatrix< T > point(const gsMatrix< T > &u, int i=0) const
Maps points u from the parameter domain to the physical domain.
Definition gsField.h:104
T distanceDG(gsFunctionSet< T > const &func, bool isFunc_param=false, int=1000) const
Definition gsField.hpp:122
const gsFunctionSet< T > & fields() const
Returns the fields (defined per patch)
Definition gsField.h:218
short_t dim() const
Returns the dimension of the physical domain (e.g., if the domain is a surface in three-dimensional s...
Definition gsField.h:194
T distanceL2(gsField< T > const &field, int numEvals=1000) const
Computes the L2-distance between the two fields, on the physical domain.
Definition gsField.hpp:94
short_t geoDim() const
Returns the dimension of the physical domain (e.g., if the domain is a surface in three-dimensional s...
Definition gsField.h:190
const gsMatrix< T > & coefficientVector(int i=0) const
Returns the coefficient vector (if it exists) corresponding to the function field for patch i.
Definition gsField.h:268
short_t parDim() const
Returns the dimension of the parameter domain (e.g., if the domain is a surface in three-dimensional ...
Definition gsField.h:186
bool isParametrized() const
Definition gsField.h:257
GISMO_DEPRECATED index_t nPatches() const
Returns the number of patches.
Definition gsField.h:197
std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsField.h:177
T distanceH2(gsFunctionSet< T > const &func, bool isFunc_param=false) const
Definition gsField.hpp:66
const gsMultiPatch< T > & patches() const
Returns gsMultiPatch containing the geometric information on the domain.
Definition gsField.h:210
const gsGeometry< T > & igaFunction(int i=0) const
Attempts to return an Isogeometric function for patch i.
Definition gsField.h:239
gsMatrix< T > value(const gsMatrix< T > &u, int i=0) const
Evaluation of the field at points u.
Definition gsField.h:122
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition gsFunctionSet.h:219
memory::shared_ptr< gsFunctionSet > Ptr
Shared pointer for gsFunctionSet.
Definition gsFunctionSet.h:223
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
virtual const gsFunction & piece(const index_t k) const
Returns the piece(s) of the function(s) at subdomain k.
Definition gsFunction.h:76
Abstract base class representing a geometry map.
Definition gsGeometry.h:93
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
#define GISMO_ASSERT(cond, message)
Definition gsDebug.h:89
This is the interface of all objects that computes functions on points like gsBasis,...
Provides declaration of Geometry abstract interface.
Provides declaration of MultiBasis class.
Provides declaration of the MultiPatch class.
Provides functions to generate structured point data.
shared_ptr< T > make_shared_not_owned(const T *x)
Creates a shared pointer which does not eventually delete the underlying raw pointer....
Definition gsMemory.h:189
The G+Smo namespace, containing all definitions for the library.