G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsField.hpp
Go to the documentation of this file.
1
14#pragma once
15
19
20namespace gismo
21{
22
23template <class T>
25 gsMultiBasis<T> const & B,
26 bool isFunc_param,
27 int numEvals) const
28{
29 GISMO_UNUSED(numEvals);// todo: subdivided quadrature elements
32 auto G = ev.getMap(this->patches());
33 auto f1a = ev.getVariable(*m_fields);
34 auto f1b = ev.getVariable(*m_fields, G);
35 auto f2a = ev.getVariable(func);
36 auto f2b = ev.getVariable(func, G);
37 if (m_parametric && isFunc_param) return math::sqrt( ev.integral((f1a-f2a).sqNorm() * meas(G)) );
38 if (m_parametric) return math::sqrt( ev.integral((f1a-f2b).sqNorm() * meas(G)) );
39 if (isFunc_param) return math::sqrt( ev.integral((f1b-f2a).sqNorm() * meas(G)) );
40 return math::sqrt( ev.integral((f1b-f2b).sqNorm() * meas(G)) );
41}
42
43template <class T>
45 gsMultiBasis<T> const & B,
46 bool isFunc_param,
47 int) const
48{
51 auto G = ev.getMap(this->patches());
52 auto f1a = ev.getVariable(*m_fields);
53 auto f1b = ev.getVariable(*m_fields, G);
54 auto f2a = ev.getVariable(func);
55 auto f2b = ev.getVariable(func, G);
56 if (m_parametric && isFunc_param)
57 return math::sqrt(ev.integral( ( igrad(f1a,G) - igrad(f2a,G)).sqNorm()*meas(G) ) );
58 if (m_parametric)
59 return math::sqrt(ev.integral( ( igrad(f1a,G) - igrad(f2b)).sqNorm()*meas(G) ) );
60 if (isFunc_param)
61 return math::sqrt(ev.integral( ( igrad(f1b) - igrad(f2a,G)).sqNorm()*meas(G) ) );
62 return math::sqrt(ev.integral( ( igrad(f1b) - igrad(f2b)).sqNorm()*meas(G) ) );
63}
64
65template <class T>
67 bool isFunc_param) const
68{
69 const gsMultiPatch<T> & mp = this->patches();
71 if (const gsMultiPatch<T>* imp = dynamic_cast<const gsMultiPatch<T>*>(m_fields.get()))
72 mb = gsMultiBasis<T>(*imp);
73 else
74 mb = gsMultiBasis<T>(mp);
75
78 auto G = ev.getMap(this->patches());
79 auto f1a = ev.getVariable(*m_fields);
80 auto f1b = ev.getVariable(*m_fields, G);
81 auto f2a = ev.getVariable(func);
82 auto f2b = ev.getVariable(func, G);
83
84 if (m_parametric && isFunc_param)
85 return math::sqrt(ev.integral( ( ihess(f1a,G) - ihess(f2a,G)).sqNorm()*meas(G) ) );
86 if (m_parametric)
87 return math::sqrt(ev.integral( (ihess(f1a,G) - ihess(f2b)).sqNorm()*meas(G) ) );
88 if (isFunc_param)
89 return math::sqrt(ev.integral( ( ihess(f1b) - ihess(f2a,G)).sqNorm()*meas(G) ) );
90 return math::sqrt(ev.integral( ( ihess(f1b) - ihess(f2b)).sqNorm()*meas(G) ) );
91}
92
93template <class T>
94T gsField<T>::distanceL2(gsField<T> const & field, int numEvals) const
95{
96 return distanceL2(*field.m_fields, field.m_parametric, numEvals);
97}
98
99template <class T>
101 bool isFunc_param,
102 int numEvals) const
103{
104 if (const gsMultiPatch<T>* mp = dynamic_cast<const gsMultiPatch<T>*>(m_fields.get()))
105 return distanceL2(func, gsMultiBasis<T>(*mp), isFunc_param, numEvals);
106 gsMultiBasis<T> mb(this->patches());
107 return distanceL2(func, mb, isFunc_param, numEvals);
108}
109
110template <class T>
112 bool isFunc_param,
113 int) const
114{
115 if (const gsMultiPatch<T>* mp = dynamic_cast<const gsMultiPatch<T>*>(m_fields.get()))
116 return distanceH1(func, gsMultiBasis<T>(*mp), isFunc_param);
117 gsMultiBasis<T> mb(this->patches());
118 return distanceH1(func, mb, isFunc_param);
119}
120
121template <class T>
123 const & ,
124 bool ,
125 int) const
126{
128 /*
129 if (m_parametric) // isogeometric field
130 return 0; //igaFieldDGDistance(*this, func, isFunc_param);
131 else
132 {
133 gsWarn << "DG norm not implemented.\n";
134 return -1;
135 }
136 */
137}
138
139} // namespace gismo
Generic evaluator of isogeometric expressions.
Definition gsExprEvaluator.h:39
void setIntegrationElements(const gsMultiBasis< T > &mesh)
Sets the domain of integration.
Definition gsExprEvaluator.h:110
T integral(const expr::_expr< E > &expr)
Calculates the integral of the expression expr on the whole integration domain.
Definition gsExprEvaluator.h:154
variable getVariable(const gsFunctionSet< T > &func, index_t dim=1)
Registers func as a variable and returns a handle to it.
Definition gsExprEvaluator.h:124
geometryMap getMap(const gsMultiPatch< T > &mp)
Registers mp as an isogeometric geometry map and return a handle to it.
Definition gsExprEvaluator.h:116
A scalar of vector field defined on a m_parametric geometry.
Definition gsField.h:55
gsFunctionSet< T >::Ptr m_fields
Vector containing "local fields" for each patch/subdomain.
Definition gsField.h:286
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
T distanceDG(gsFunctionSet< T > const &func, bool isFunc_param=false, int=1000) const
Definition gsField.hpp:122
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
T distanceH2(gsFunctionSet< T > const &func, bool isFunc_param=false) const
Definition gsField.hpp:66
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition gsFunctionSet.h:219
Holds a set of patch-wise bases and their topology information.
Definition gsMultiBasis.h:37
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition gsMultiPatch.h:100
#define GISMO_NO_IMPLEMENTATION
Definition gsDebug.h:129
#define GISMO_UNUSED(x)
Definition gsDebug.h:112
Provides declaration of DomainIterator abstract interface.
Generic expressions evaluator.
Generic expressions helper.
The G+Smo namespace, containing all definitions for the library.