Overture  Version 25
OGTrigFunction.h
Go to the documentation of this file.
1 #ifndef OGTrigFunction_h
2 #define OGTrigFunction_h "OGTrigFunction.h"
3 
4 #include "OGFunction.h"
5 
6 //
7 // Define a Function and it derivatives
8 // This function can be used to define the "exact solution" for
9 // an Overlapping Grid Appliciation (aka. TwilightZone Flow)
10 //
11 // u_n(x,y,z,t) = a(n)*cos(fx(n)*Pi*(x-gx(n)))
12 // *cos(fy(n)*Pi*(y-gy(n)))
13 // *cos(fz(n)*Pi*(z-gz(n)))
14 // *cos(ft(n)*Pi*(t-gt(n))) + c(n)
15 //
16 
17 class OGTrigFunction : public OGFunction
18 {
19  RealArray a,cc;
20  RealArray fx,fy,fz,ft;
21  RealArray gx,gy,gz,gt;
22 
23  public:
24 
25  OGTrigFunction(const real & fx=1.,
26  const real & fy=1.,
27  const real & fz=0.,
28  const real & ft=0.,
29  const int & maximumNumberOfComponents=10);
30  OGTrigFunction(const RealArray & fx,
31  const RealArray & fy,
32  const RealArray & fz,
33  const RealArray & ft);
34  OGTrigFunction(const OGTrigFunction & ogp );
35  OGTrigFunction & operator=(const OGTrigFunction & ogp );
36 
38 
39  int setAmplitudes(const RealArray & a );
40  int setConstants(const RealArray & c );
41 
42  int setFrequencies(const RealArray & fx,
43  const RealArray & fy,
44  const RealArray & fz,
45  const RealArray & ft);
46  int setShifts(const RealArray & gx,
47  const RealArray & gy,
48  const RealArray & gz,
49  const RealArray & gt);
50 
51 
52  // Here are the member functions that you must define
53  // u(x,y,z,n,t) : function value at x,y,z for component n
54  // ux(x,y,z,n,t) : partial derivative of u with respect to x
55  // ...etc...
56 
57  inline real u(const real x, const real y, const real z, const int n=0, const real t=0. )
58  {
59  return cos(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n)+cc(n);
60  }
61  inline real ut(const real x, const real y, const real z, const int n=0, const real t=0. )
62  {
63  return -ft(n)*cos(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*sin(ft(n)*(t-gt(n)))*a(n);
64  }
65  inline real ux(const real x, const real y, const real z, const int n=0, const real t=0. )
66  {
67  return -fx(n)* sin(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
68  }
69  inline real uy(const real x, const real y, const real z, const int n=0, const real t=0. )
70  {
71  return -fy(n)* cos(fx(n)*(x-gx(n)))*sin(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
72  }
73  inline real uxx(const real x, const real y, const real z, const int n=0, const real t=0. )
74  {
75  return -fx(n)*fx(n)*cos(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
76  }
77  inline real uxy(const real x, const real y, const real z, const int n=0, const real t=0. )
78  {
79  return fx(n)*fy(n)*sin(fx(n)*(x-gx(n)))*sin(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
80  }
81  inline real uyy(const real x, const real y, const real z, const int n=0, const real t=0. )
82  {
83  return -fy(n)*fy(n)*cos(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
84  }
85  inline real uz(const real x, const real y, const real z, const int n=0, const real t=0. )
86  {
87  return -fz(n)* cos(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*sin(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
88  }
89  inline real uxz(const real x, const real y, const real z, const int n=0, const real t=0. )
90  {
91  return fx(n)*fz(n)*sin(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*sin(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
92  }
93  inline real uyz(const real x, const real y, const real z, const int n=0, const real t=0. )
94  {
95  return fy(n)*fz(n)*cos(fx(n)*(x-gx(n)))*sin(fy(n)*(y-gy(n)))*sin(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
96  }
97  inline real uzz(const real x, const real y, const real z, const int n=0, const real t=0. )
98  {
99  return -fz(n)*fz(n)*cos(fx(n)*(x-gx(n)))*cos(fy(n)*(y-gy(n)))*cos(fz(n)*(z-gz(n)))*cos(ft(n)*(t-gt(n)))*a(n);
100  }
101 
102  // ========= Here are versions with a new naming convention ===========
103 
104  // (default arguments not allowed on operators)
105  virtual real operator()(const real , const real , const real);
106  virtual real operator()(const real , const real , const real , const int);
107  virtual real operator()(const real , const real , const real , const int, const real );
108 
109  virtual real t(const real , const real , const real , const int=0, const real=0. );
110  virtual real x(const real , const real , const real , const int=0, const real=0. );
111  virtual real y(const real , const real , const real , const int=0, const real=0. );
112  virtual real xx(const real , const real , const real , const int=0, const real=0. );
113  virtual real xy(const real , const real , const real , const int=0, const real=0. );
114  virtual real yy(const real , const real , const real , const int=0, const real=0. );
115  virtual real z(const real , const real , const real , const int=0, const real=0. );
116  virtual real xz(const real , const real , const real , const int=0, const real=0. );
117  virtual real yz(const real , const real , const real , const int=0, const real=0. );
118  virtual real zz(const real , const real , const real , const int=0, const real=0. );
119  virtual real xxx(const real , const real , const real , const int=0, const real=0. );
120  virtual real xxxx(const real , const real , const real , const int=0, const real=0. );
121  // obtain a general derivative
122  virtual real gd(const int & ntd, const int & nxd, const int & nyd, const int & nzd,
123  const real , const real , const real , const int=0, const real=0. );
124 
125  virtual RealDistributedArray operator()(const MappedGrid & c, const Index & I1, const Index & I2,
126  const Index & I3, const Index & N);
127  virtual RealDistributedArray operator()(const MappedGrid & c, const Index & I1, const Index & I2,
128  const Index & I3, const Index & N, const real t,
130 
131  virtual RealDistributedArray t(const MappedGrid & c, const Index & I1, const Index & I2,
132  const Index & I3, const Index & N, const real t=0.,
134  virtual RealDistributedArray x(const MappedGrid & c, const Index & I1, const Index & I2,
135  const Index & I3, const Index & N, const real t=0.,
137  virtual RealDistributedArray y(const MappedGrid & c, const Index & I1, const Index & I2,
138  const Index & I3, const Index & N, const real t=0.,
140  virtual RealDistributedArray z(const MappedGrid & c, const Index & I1, const Index & I2,
141  const Index & I3, const Index & N, const real t=0.,
143  virtual RealDistributedArray xx(const MappedGrid & c, const Index & I1, const Index & I2,
144  const Index & I3, const Index & N, const real t=0.,
146  virtual RealDistributedArray yy(const MappedGrid & c, const Index & I1, const Index & I2,
147  const Index & I3, const Index & N, const real t=0.,
149  virtual RealDistributedArray zz(const MappedGrid & c, const Index & I1, const Index & I2,
150  const Index & I3, const Index & N, const real t=0.,
152  virtual RealDistributedArray xy(const MappedGrid & c, const Index & I1, const Index & I2,
153  const Index & I3, const Index & N, const real t=0.,
155  virtual RealDistributedArray xz(const MappedGrid & c, const Index & I1, const Index & I2,
156  const Index & I3, const Index & N, const real t=0.,
158  virtual RealDistributedArray yz(const MappedGrid & c, const Index & I1, const Index & I2,
159  const Index & I3, const Index & N, const real t=0.,
161  virtual RealDistributedArray laplacian(const MappedGrid & c, const Index & I1, const Index & I2,
162  const Index & I3, const Index & N, const real t=0.,
164  virtual RealDistributedArray xxx(const MappedGrid & c, const Index & I1, const Index & I2,
165  const Index & I3, const Index & N, const real t=0.,
167  virtual RealDistributedArray xxxx(const MappedGrid & c, const Index & I1, const Index & I2,
168  const Index & I3, const Index & N, const real t=0.,
170  virtual RealDistributedArray gd(const int & ntd, const int & nxd, const int & nyd, const int & nzd,
171  const MappedGrid & c, const Index & I1, const Index & I2,
172  const Index & I3, const Index & N, const real t=0.,
175 
176  // obtain a general derivative using serial arrays
177  virtual realSerialArray& gd( realSerialArray & result, // put result here
178  const realSerialArray & x, // coordinates to use if isRectangular==true
179  const int numberOfDimensions,
180  const bool isRectangular,
181  const int & ntd, const int & nxd, const int & nyd, const int & nzd,
182  const Index & I1, const Index & I2,
183  const Index & I3, const Index & N,
184  const real t=0., int option =0 );
185 
186 
189  realCompositeGridFunction operator()(CompositeGrid & cg, const Index & N, const real t,
191  realCompositeGridFunction t(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
193  realCompositeGridFunction x(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
195  realCompositeGridFunction y(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
197  realCompositeGridFunction z(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
199  realCompositeGridFunction xx(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
201  realCompositeGridFunction xy(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
203  realCompositeGridFunction xz(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
205  realCompositeGridFunction yy(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
207  realCompositeGridFunction yz(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
209  realCompositeGridFunction zz(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
211  realCompositeGridFunction laplacian(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
213  realCompositeGridFunction xxx(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
215  realCompositeGridFunction xxxx(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
217 
218  realCompositeGridFunction gd(const int & ntd, const int & nxd, const int & nyd, const int & nzd,
219  CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
222 
223 };
224 
225 #endif