G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsField.hpp
Go to the documentation of this file.
1 
14 #pragma once
15 
19 
20 namespace gismo
21 {
22 
23 template <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 
43 template <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 
65 template <class T>
67  bool isFunc_param) const
68 {
69  const gsMultiPatch<T> & mp = this->patches();
70  gsMultiBasis<T> mb;
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 
77  ev.setIntegrationElements(mb);
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 
93 template <class T>
94 T gsField<T>::distanceL2(gsField<T> const & field, int numEvals) const
95 {
96  return distanceL2(*field.m_fields, field.m_parametric, numEvals);
97 }
98 
99 template <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 
110 template <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 
121 template <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
bool m_parametric
True iff this is an isogeometric field.
Definition: gsField.h:297
T integral(const expr::_expr< E > &expr)
Calculates the integral of the expression expr on the whole integration domain.
Definition: gsExprEvaluator.h:154
gsFunctionSet< T >::Ptr m_fields
Vector containing &quot;local fields&quot; for each patch/subdomain.
Definition: gsField.h:286
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
void setIntegrationElements(const gsMultiBasis< T > &mesh)
Sets the domain of integration.
Definition: gsExprEvaluator.h:110
A scalar of vector field defined on a m_parametric geometry.
Definition: gsField.h:54
T distanceH2(gsFunctionSet< T > const &func, bool isFunc_param=false) const
Definition: gsField.hpp:66
Generic expressions helper.
T distanceDG(gsFunctionSet< T > const &func, bool isFunc_param=false, int=1000) const
Definition: gsField.hpp:122
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
Generic expressions evaluator.
Holds a set of patch-wise bases and their topology information.
Definition: gsMultiBasis.h:36
Provides declaration of DomainIterator abstract interface.
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
Generic evaluator of isogeometric expressions.
Definition: gsExprEvaluator.h:38
T distanceH1(gsFunctionSet< T > const &func, bool isFunc_param=false, int=1000) const
Definition: gsField.hpp:111
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
#define GISMO_UNUSED(x)
Definition: gsDebug.h:112
EIGEN_STRONG_INLINE meas_expr< T > meas(const gsGeometryMap< T > &G)
The measure of a geometry map.
Definition: gsExpressions.h:4555
geometryMap getMap(const gsMultiPatch< T > &mp)
Registers mp as an isogeometric geometry map and return a handle to it.
Definition: gsExprEvaluator.h:116