Extension: Geometries
#include "dg/geometries/geometries.h"
adaption.h
Go to the documentation of this file.
1#pragma once
2
3#include "fluxfunctions.h"
4
10namespace dg
11{
12namespace geo
13{
14
16namespace detail{
17
18struct LaplaceAdaptPsi: public aCylindricalFunctor<LaplaceAdaptPsi>
19{
20 LaplaceAdaptPsi( const CylindricalFunctorsLvl2& psi, const CylindricalFunctorsLvl1& chi) : psi_(psi), chi_(chi){}
21 double do_compute(double x, double y)const
22 {
23 return psi_.dfx()(x,y)*chi_.dfx()(x,y) +
24 psi_.dfy()(x,y)*chi_.dfy()(x,y) +
25 chi_.f()(x,y)*( psi_.dfxx()(x,y) + psi_.dfyy()(x,y));
26 }
27 private:
30};
31
32struct LaplaceChiPsi: public aCylindricalFunctor<LaplaceChiPsi>
33{
34 LaplaceChiPsi( const CylindricalFunctorsLvl2& psi, const CylindricalSymmTensorLvl1& chi):
35 psi_(psi), chi_(chi){}
36 double do_compute(double x, double y)const
37 {
38 return psi_.dfxx()(x,y)*chi_.xx()(x,y)+2.*psi_.dfxy()(x,y)*chi_.xy()(x,y)+psi_.dfyy()(x,y)*chi_.yy()(x,y)
39 + chi_.divX()(x,y)*psi_.dfx()(x,y) + chi_.divY()(x,y)*psi_.dfy()(x,y);
40 }
41 private:
42
45};
46
47struct LaplacePsi: public aCylindricalFunctor<LaplacePsi>
48{
49 LaplacePsi( const CylindricalFunctorsLvl2& psi): psi_(psi){}
50 double do_compute(double x, double y)const{return psi_.dfxx()(x,y)+psi_.dfyy()(x,y);}
51 private:
53};
54
55}//namespace detail
57
60
65struct NablaPsiInv: public aCylindricalFunctor<NablaPsiInv>
66{
72 NablaPsiInv( const CylindricalFunctorsLvl1& psi): psi_(psi){}
73 double do_compute(double x, double y)const
74 {
75 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y);
76 return 1./sqrt(psiX*psiX+psiY*psiY);
77 }
78 private:
80};
81
86struct NablaPsiInvX: public aCylindricalFunctor<NablaPsiInvX>
87{
88 NablaPsiInvX( const CylindricalFunctorsLvl2& psi):psi_(psi) {}
89 double do_compute(double x, double y)const
90 {
91 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y);
92 double psiXX = psi_.dfxx()(x,y), psiXY = psi_.dfxy()(x,y);
93 double psip = sqrt( psiX*psiX+psiY*psiY);
94 return -(psiX*psiXX+psiY*psiXY)/psip/psip/psip;
95 }
96 private:
97
99};
100
105struct NablaPsiInvY: public aCylindricalFunctor<NablaPsiInvY>
106{
107 NablaPsiInvY( const CylindricalFunctorsLvl2& psi):psi_(psi) {}
108 double do_compute(double x, double y)const
109 {
110 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y);
111 double psiYY = psi_.dfyy()(x,y), psiXY = psi_.dfxy()(x,y);
112 double psip = sqrt( psiX*psiX+psiY*psiY);
113 return -(psiX*psiXY+psiY*psiYY)/psip/psip/psip;
114 }
115 private:
116
118};
119
124{
126 NablaPsiInvY( psi));
127}
128
129
130
138struct Liseikin_XX: public aCylindricalFunctor<Liseikin_XX>
139{
140 Liseikin_XX(const CylindricalFunctorsLvl1& psi, double k, double eps):k_(k), eps_(eps), psi_(psi){}
141 double do_compute(double x, double y)const
142 {
143 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y), k2 = k_*k_;
144 double psip2 = psiX*psiX+psiY*psiY;
145 double sqrtG = sqrt((eps_+psip2)*(eps_+k2*psip2));
146 return (psiY*psiY+k2*psiX*psiX + eps_)/sqrtG;
147 }
148 private:
149
150 double k_, eps_;
152};
153
161struct Liseikin_XY: public aCylindricalFunctor<Liseikin_XY>
162{
163 Liseikin_XY(const CylindricalFunctorsLvl1& psi, double k, double eps):k_(k), eps_(eps), psi_(psi){}
164 double do_compute(double x, double y)const
165 {
166 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y), k2 = k_*k_;
167 double psip2 = psiX*psiX+psiY*psiY;
168 double sqrtG = sqrt((eps_+psip2)*(eps_+k2*psip2));
169 return (-psiX*psiY+k2*psiX*psiY)/sqrtG;
170 }
171 private:
172
173 double k_, eps_;
175};
176
184struct Liseikin_YY: public aCylindricalFunctor<Liseikin_YY>
185{
186 Liseikin_YY(const CylindricalFunctorsLvl1& psi, double k, double eps):k_(k), eps_(eps), psi_(psi){}
187 double do_compute(double x, double y)const
188 {
189 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y), k2 = k_*k_;
190 double psip2 = psiX*psiX+psiY*psiY;
191 double sqrtG = sqrt((eps_+psip2)*(eps_+k2*psip2));
192 return (eps_+psiX*psiX+k2*psiY*psiY)/sqrtG;
193 }
194 private:
195
196 double k_, eps_;
198};
199
204struct DivLiseikinX: public aCylindricalFunctor<DivLiseikinX>
205{
206 DivLiseikinX(const CylindricalFunctorsLvl2& psi, double k, double eps): k_(k), eps_(eps), psi_(psi){}
207 double do_compute(double x, double y)const
208 {
209 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y), k2 = k_*k_;
210 double psiXX = psi_.dfxx()(x,y), psiXY = psi_.dfxy()(x,y), psiYY=psi_.dfyy()(x,y);
211 double psiY2 = psiY*psiY, psiY3=psiY*psiY2, psiY4=psiY2*psiY2, psiY5=psiY4*psiY;
212 double psiX2 = psiX*psiX, psiX4=psiX2*psiX2;
213 double psip2 = psiX*psiX+psiY*psiY;
214 double sqrtG = sqrt((eps_+psip2)*(eps_+k2*psip2));
215 return (k2-1.)*(k2*psiY5*psiXY-k2*psiX*psiY4*(psiYY-2.*psiXX) +
216 psiX*(eps_+2.*eps_*k2+2.*k2*psiX2)*psiY2*psiXX +
217 psiX*(eps_+k2*psiX2)*((eps_+psiX2)*psiYY+eps_*psiXX)+
218 psiY*((eps_*eps_-k2*psiX4)*psiXY-(eps_+2*psiX2)*(eps_+k2*psiX2)*psiXY) +
219 psiY3*(eps_*(1.+k2)*psiXY-(eps_+2.*k2*psiX2)*psiXY))/sqrtG/sqrtG/sqrtG;
220 }
221 private:
222
223 double k_, eps_;
225};
226
231struct DivLiseikinY : public aCylindricalFunctor<DivLiseikinY>
232{
233 DivLiseikinY(const CylindricalFunctorsLvl2& psi, double k, double eps):k_(k), eps_(eps), psi_(psi){}
234 double do_compute(double x, double y)const
235 {
236 double psiX = psi_.dfx()(x,y), psiY = psi_.dfy()(x,y), k2 = k_*k_;
237 double psiXX = psi_.dfxx()(x,y), psiXY = psi_.dfxy()(x,y), psiYY=psi_.dfyy()(x,y);
238 double psiX2 = psiX*psiX, psiX3=psiX*psiX2, psiX4=psiX2*psiX2, psiX5=psiX4*psiX;
239 double psiY2 = psiY*psiY, psiY4 = psiY2*psiY2;
240 double psip2 = psiX*psiX+psiY*psiY;
241 double sqrtG = sqrt((eps_+psip2)*(eps_+k2*psip2));
242 return (k2-1.)*(psiX2*psiY*(eps_+2.*eps_*k2+2.*k2*psiY2)*psiYY +
243 k2*psiX4*psiY*(2.*psiYY-psiXX)+psiY*(eps_+k2*psiY2)
244 *(eps_*psiYY+(eps_+psiY2)*psiXX)+k2*psiX5*psiXY+
245 psiX3*(-(eps_+2.*k2*psiY2)*psiXY+eps_*(1.+k2)*psiXY) +
246 psiX*(-(eps_+2.*psiY2)*(eps_+k2*psiY2)*psiXY + (eps_*eps_-k2*psiY4)*psiXY))/sqrtG/sqrtG/sqrtG;
247 }
248 private:
249
250 double k_, eps_;
252};
253
254static inline CylindricalSymmTensorLvl1 make_LiseikinCollective( const CylindricalFunctorsLvl2& psi, double k, double eps)
255{
256 return CylindricalSymmTensorLvl1( Liseikin_XX(psi,k,eps),
257 Liseikin_XY(psi,k,eps), Liseikin_YY(psi,k,eps),
258 DivLiseikinX(psi,k,eps), DivLiseikinY(psi,k,eps));
259}
261
262}//namespace geo
263}//namespace dg
static CylindricalFunctorsLvl1 make_NablaPsiInvCollective(const CylindricalFunctorsLvl2 &psi)
A container class that contains all NablaPsiInv functors.
Definition: adaption.h:123
static CylindricalSymmTensorLvl1 make_LiseikinCollective(const CylindricalFunctorsLvl2 &psi, double k, double eps)
Definition: adaption.h:254
This struct bundles a function and its first derivatives.
Definition: fluxfunctions.h:182
const CylindricalFunctor & dfx() const
Definition: fluxfunctions.h:205
const CylindricalFunctor & dfy() const
Definition: fluxfunctions.h:207
This struct bundles a function and its first and second derivatives.
Definition: fluxfunctions.h:219
const CylindricalFunctor & dfxy() const
Definition: fluxfunctions.h:251
const CylindricalFunctor & dfy() const
Definition: fluxfunctions.h:247
const CylindricalFunctor & dfx() const
Definition: fluxfunctions.h:245
const CylindricalFunctor & dfxx() const
Definition: fluxfunctions.h:249
const CylindricalFunctor & dfyy() const
Definition: fluxfunctions.h:253
Definition: fluxfunctions.h:361
The x-component of the divergence of the Liseikin monitor metric.
Definition: adaption.h:205
DivLiseikinX(const CylindricalFunctorsLvl2 &psi, double k, double eps)
Definition: adaption.h:206
double do_compute(double x, double y) const
Definition: adaption.h:207
The y-component of the divergence of the Liseikin monitor metric.
Definition: adaption.h:232
DivLiseikinY(const CylindricalFunctorsLvl2 &psi, double k, double eps)
Definition: adaption.h:233
double do_compute(double x, double y) const
Definition: adaption.h:234
The xx-component of the Liseikin monitor metric.
Definition: adaption.h:139
Liseikin_XX(const CylindricalFunctorsLvl1 &psi, double k, double eps)
Definition: adaption.h:140
double do_compute(double x, double y) const
Definition: adaption.h:141
The xy-component of the Liseikin monitor metric.
Definition: adaption.h:162
double do_compute(double x, double y) const
Definition: adaption.h:164
Liseikin_XY(const CylindricalFunctorsLvl1 &psi, double k, double eps)
Definition: adaption.h:163
The yy-component of the Liseikin monitor metric.
Definition: adaption.h:185
Liseikin_YY(const CylindricalFunctorsLvl1 &psi, double k, double eps)
Definition: adaption.h:186
double do_compute(double x, double y) const
Definition: adaption.h:187
A weight function for the Hector algorithm.
Definition: adaption.h:66
double do_compute(double x, double y) const
Definition: adaption.h:73
NablaPsiInv(const CylindricalFunctorsLvl1 &psi)
Construct with function container.
Definition: adaption.h:72
Derivative of the weight function.
Definition: adaption.h:87
double do_compute(double x, double y) const
Definition: adaption.h:89
NablaPsiInvX(const CylindricalFunctorsLvl2 &psi)
Definition: adaption.h:88
Derivative of the weight function.
Definition: adaption.h:106
NablaPsiInvY(const CylindricalFunctorsLvl2 &psi)
Definition: adaption.h:107
double do_compute(double x, double y) const
Definition: adaption.h:108
Represent functions written in cylindrical coordinates that are independent of the angle phi serving ...
Definition: fluxfunctions.h:66