Overture  Version 25
OGPolyFunction.h
Go to the documentation of this file.
1 #ifndef OGPolyFunction_h
2 #define OGPolyFunction_h "OGPolyFunction.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 // f(x,y,z,n,t)=[c(0,0,0,n)+x*(c(1,0,0,n)+x*(c(2,0,0,n)+x*(c(3,0,0,n)+c(4,0,0,n)*x)))
12 // +y*(c(0,1,0,n)+y*(c(0,2,0,n)+y*(c(0,3,0,n)+c(0,4,0,n)*y)))
13 // +z*(c(0,0,1,n)+z*(c(0,0,2,n)+z*(c(0,0,3,n)+c(0,0,4,n)*z)))]
14 // *(a(0,n)+t*(a(1,n)+t*(a(2,n)+t*(a(3,n)+t*(a(4,n))))));
15 //
16 // Here n is the component number and t is a parameter "time"
17 // The matrices "c" and "a" defining the coefficients can be assigned
18 // in the constructor or else default values can be used.
19 //
20 //===========================================================================================
21 class OGPolyFunction : public OGFunction
22 {
23 
24  private:
25  enum
26  {
27  maximumDegreeX=6,
28  maximumDegreeT=6
29  };
30  int numberOfComponents,degreeX,degreeY,degreeZ,degreeT,numberOfDimensions;
31 
32  RealArray cc;
33  RealArray a;
34  void checkArguments(const Index & N);
35 
36  public:
37 
38 
39  //
40  // Create a polynomial with the given degree, number Of Space Dimensions and for
41  // a maximum number of components
42  //
43  OGPolyFunction(const int & degreeSpaceOfPolynomial=2,
44  const int & numberOfDimensions=3,
45  const int & numberOfComponents=10,
46  const int & degreeOfTimePolynomial=1 );
47 
48  OGPolyFunction(const OGPolyFunction & ogp );
49  OGPolyFunction & operator=(const OGPolyFunction & ogp );
51 
52  //
53  // Supply coefficients to use
54  // note that arrays should be dimensioned
55  // c(0:4,0:4,0:4,0:nc-1) and a(0:4,0:nc-1) where nc=numberOfComponents
56  //
57  void setCoefficients( const RealArray & c, const RealArray & a );
58 
59  // get the current values of the coefficients
60  void getCoefficients( RealArray & c, RealArray & a ) const;
61 
62 // // Here are the member functions that you must define
63 // // u(x,y,z,n) : function value at x,y,z for component n
64 // // ux(x,y,z,n) : partial derivative of u with respect to x
65 // // ...etc...
66 
67 // #define TIME(n,t) ( a(0,n)+t*(a(1,n)+t*(a(2,n)+t*(a(3,n)+t*(a(4,n))))) )
68 
69 
70 // inline real u(const real x, const real y, const real z, const int n, const real t=0.)
71 // {
72 // return (cc(0,0,0,n)
73 // +x*(cc(1,0,0,n)+y*cc(1,1,0,n)+x*(cc(2,0,0,n)+x*(cc(3,0,0,n)+x*cc(4,0,0,n))))
74 // +y*(cc(0,1,0,n)+z*cc(0,1,1,n)+y*(cc(0,2,0,n)+y*(cc(0,3,0,n)+y*cc(0,4,0,n))))
75 // +z*(cc(0,0,1,n)+x*cc(1,0,1,n)+z*(cc(0,0,2,n)+z*(cc(0,0,3,n)+z*cc(0,0,4,n))))
76 // )
77 // *TIME(n,t);
78 // }
79 // inline real ut(const real x, const real y, const real z, const int n=0, const real t=0. )
80 // {
81 // return (cc(0,0,0,n)
82 // +x*(cc(1,0,0,n)+y*cc(1,1,0,n)+x*(cc(2,0,0,n)+x*(cc(3,0,0,n)+x*cc(4,0,0,n))))
83 // +y*(cc(0,1,0,n)+z*cc(0,1,1,n)+y*(cc(0,2,0,n)+y*(cc(0,3,0,n)+y*cc(0,4,0,n))))
84 // +z*(cc(0,0,1,n)+x*cc(1,0,1,n)+z*(cc(0,0,2,n)+z*(cc(0,0,3,n)+z*cc(0,0,4,n)))))
85 // *( a(1,n)+t*(2.*a(2,n)+t*(3.*a(3,n)+t*(4.*a(4,n)))) );
86 // }
87 // inline real ux(const real x, const real y, const real z, const int n=0, const real t=0.)
88 // {
89 // return (cc(1,0,0,n)+y*cc(1,1,0,n)+z*cc(1,0,1,n)+x*(2.*cc(2,0,0,n)+x*(3.*cc(3,0,0,n)+x*4.*cc(4,0,0,n)))
90 // )*TIME(n,t);
91 // }
92 // inline real uy(const real x, const real y, const real z, const int n=0, const real t=0.)
93 // {
94 // return (cc(0,1,0,n)+x*cc(1,1,0,n)+z*cc(0,1,1,n)+y*(2.*cc(0,2,0,n)+y*(3.*cc(0,3,0,n)+y*4.*cc(0,4,0,n)))
95 // )*TIME(n,t);
96 // }
97 // inline real uxx(const real x, const real , const real , const int n=0, const real t=0.)
98 // {
99 // return (2.*cc(2,0,0,n)+x*(6.*cc(3,0,0,n)+x*12.*cc(4,0,0,n)))*TIME(n,t);
100 // }
101 // inline real uxy(const real , const real , const real , const int n=0, const real t=0.)
102 // {
103 // return cc(1,1,0,n)*TIME(n,t);
104 // }
105 // inline real uyy(const real , const real y, const real , const int n=0, const real t=0.)
106 // {
107 // return (2.*cc(0,2,0,n)+y*(6.*cc(0,3,0,n)+y*12.*cc(0,4,0,n)))*TIME(n,t);
108 // }
109 // inline real uz(const real x, const real y, const real z, const int n=0, const real t=0.)
110 // {
111 // return (cc(0,0,1,n)+x*cc(1,0,1,n)+y*cc(0,1,1,n)+z*(2.*cc(0,0,2,n)+z*(3.*cc(0,0,3,n)+z*4.*cc(0,0,4,n)))
112 // )*TIME(n,t);
113 // }
114 // inline real uxz(const real , const real , const real , const int n=0, const real t=0.)
115 // {
116 // return cc(1,0,1,n)*TIME(n,t);
117 // }
118 // inline real uyz(const real , const real , const real , const int n=0, const real t=0.)
119 // {
120 // return cc(0,1,1,n)*TIME(n,t);
121 // }
122 // inline real uzz(const real , const real , const real z, const int n=0, const real t=0.)
123 // {
124 // return (2.*cc(0,0,2,n)+z*(6.*cc(0,0,3,n)+z*12.*cc(0,0,4,n)))*TIME(n,t);
125 // }
126 
127  // ========= Here are versions with a new naming convention ===========
128 
129  // (default arguments not allowed on operators)
130  virtual real operator()(const real , const real , const real);
131  virtual real operator()(const real , const real , const real , const int);
132  virtual real operator()(const real , const real , const real , const int, const real);
133 
134  virtual real t(const real , const real , const real , const int=0, const real=0.);
135  virtual real x(const real , const real , const real , const int=0, const real=0.);
136  virtual real y(const real , const real , const real , const int=0, const real=0.);
137  virtual real xx(const real , const real , const real , const int=0, const real=0.);
138  virtual real xy(const real , const real , const real , const int=0, const real=0.);
139  virtual real yy(const real , const real , const real , const int=0, const real=0.);
140  virtual real z(const real , const real , const real , const int=0, const real=0.);
141  virtual real xz(const real , const real , const real , const int=0, const real=0.);
142  virtual real yz(const real , const real , const real , const int=0, const real=0.);
143  virtual real zz(const real , const real , const real , const int=0, const real=0.);
144  virtual real xxx(const real , const real , const real , const int=0, const real=0.);
145  virtual real xxxx(const real , const real , const real , const int=0, const real=0.);
146  // obtain a general derivative
147  virtual real gd(const int & ntd, const int & nxd, const int & nyd, const int & nzd,
148  const real , const real , const real , const int=0, const real=0. );
149 
150 
151  virtual RealDistributedArray operator()(const MappedGrid & c, const Index & I1, const Index & I2,
152  const Index & I3, const Index & N);
153  virtual RealDistributedArray operator()(const MappedGrid & c, const Index & I1, const Index & I2,
154  const Index & I3, const Index & N, const real t,
156 /* ---
157  RealDistributedArray operator()(const MappedGrid & c, const Index & I1, const Index & I2,
158  const Index & I3);
159  RealDistributedArray operator()(const MappedGrid & c, const Index & I1, const Index & I2,
160  const Index & I3, const int n);
161  RealDistributedArray operator()(const MappedGrid & c, const Index & I1, const Index & I2,
162  const Index & I3, const int n, const real t,
163  const GridFunctionParameters::GridFunctionType & centering=GridFunctionParameters::defaultCentering );
164 ----- */
165 
166  virtual RealDistributedArray t(const MappedGrid & c, const Index & I1, const Index & I2,
167  const Index & I3, const Index & N, const real t=0.,
169  virtual RealDistributedArray x(const MappedGrid & c, const Index & I1, const Index & I2,
170  const Index & I3, const Index & N, const real t=0.,
172  virtual RealDistributedArray y(const MappedGrid & c, const Index & I1, const Index & I2,
173  const Index & I3, const Index & N, const real t=0.,
175  virtual RealDistributedArray z(const MappedGrid & c, const Index & I1, const Index & I2,
176  const Index & I3, const Index & N, const real t=0.,
178  virtual RealDistributedArray xx(const MappedGrid & c, const Index & I1, const Index & I2,
179  const Index & I3, const Index & N, const real t=0.,
181  virtual RealDistributedArray yy(const MappedGrid & c, const Index & I1, const Index & I2,
182  const Index & I3, const Index & N, const real t=0.,
184  virtual RealDistributedArray zz(const MappedGrid & c, const Index & I1, const Index & I2,
185  const Index & I3, const Index & N, const real t=0.,
187  virtual RealDistributedArray xy(const MappedGrid & c, const Index & I1, const Index & I2,
188  const Index & I3, const Index & N, const real t=0.,
190  virtual RealDistributedArray xz(const MappedGrid & c, const Index & I1, const Index & I2,
191  const Index & I3, const Index & N, const real t=0.,
193  virtual RealDistributedArray yz(const MappedGrid & c, const Index & I1, const Index & I2,
194  const Index & I3, const Index & N, const real t=0.,
196  virtual RealDistributedArray laplacian(const MappedGrid & c, const Index & I1, const Index & I2,
197  const Index & I3, const Index & N, const real t=0.,
199  virtual RealDistributedArray xxx(const MappedGrid & c, const Index & I1, const Index & I2,
200  const Index & I3, const Index & N, const real t=0.,
202  virtual RealDistributedArray xxxx(const MappedGrid & c, const Index & I1, const Index & I2,
203  const Index & I3, const Index & N, const real t=0.,
205  virtual RealDistributedArray gd(const int & ntd, const int & nxd, const int & nyd, const int & nzd,
206  const MappedGrid & c, const Index & I1, const Index & I2,
207  const Index & I3, const Index & N, const real t=0.,
210 
211  // obtain a general derivative using serial arrays
212  virtual realSerialArray& gd( realSerialArray & result, // put result here
213  const realSerialArray & x, // coordinates to use if isRectangular==true
214  const int numberOfDimensions,
215  const bool isRectangular,
216  const int & ntd, const int & nxd, const int & nyd, const int & nzd,
217  const Index & I1, const Index & I2,
218  const Index & I3, const Index & N,
219  const real t=0., int option =0 );
220 
223  realCompositeGridFunction operator()(CompositeGrid & cg, const Index & N, const real t,
225  realCompositeGridFunction t(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
227  realCompositeGridFunction x(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
229  realCompositeGridFunction y(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
231  realCompositeGridFunction z(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
233  realCompositeGridFunction xx(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
235  realCompositeGridFunction xy(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
237  realCompositeGridFunction xz(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
239  realCompositeGridFunction yy(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
241  realCompositeGridFunction yz(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
243  realCompositeGridFunction zz(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
245  realCompositeGridFunction laplacian(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
247  realCompositeGridFunction xxx(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
249  realCompositeGridFunction xxxx(CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
251 
252  realCompositeGridFunction gd(const int & ntd, const int & nxd, const int & nyd, const int & nzd,
253  CompositeGrid & cg, const Index & N=nullIndex, const real t=0.,
256 };
257 
258 
259 #undef TIME
260 
261 #endif