Overture  Version 25
xDC.h
Go to the documentation of this file.
1 #ifndef X_D_C_H
2 #define X_D_C_H
3 
4 #include "MappedGridOperators.h"
5 
6 //-----------------------------------------------------------------------------
7 // Define the routines that return the coefficients of the finite difference
8 // operators.
9 //-----------------------------------------------------------------------------
10 #define U(I1,I2,I3,N) u(I1,I2,I3,N)
11 #define UR2(I1,I2,I3,N) ur(I1,I2,I3,N)
12 #define US2(I1,I2,I3,N) us(I1,I2,I3,N)
13 #define UT2(I1,I2,I3,N) ut(I1,I2,I3,N)
14 #include "cgux2a.h" // define 2nd order difference approximations
15 
16 //-----------------------------------------------------------------------------
17 // Define fourth order difference approximations:
18 // The include file cgux4a.h defines fourth order difference approximations
19 //
20 // Notes : see above
21 //----------------------------------------------------------------------------
22 #define UR4(I1,I2,I3,N) ur(I1,I2,I3,N)
23 #define US4(I1,I2,I3,N) us(I1,I2,I3,N)
24 #define UT4(I1,I2,I3,N) ut(I1,I2,I3,N)
25 #include "cgux4a.h" // define 4th order difference approximations
26 
27 
28 // MERGE0 : use for A++ operations when the first index is a scalar
29 // a(i0,I1,I2,I3)=
30 // you must define the following in your code
31 // int dum;
32 // Range aR0,aR1,aR2,aR3;
33 #define MERGE0(a,i0,I1,I2,I3) \
34  for( \
35  aR0=Range(a.getBase(0),a.getBound(0)), \
36  aR1=Range(a.getBase(1),a.getBound(1)), \
37  aR2=Range(a.getBase(2),a.getBound(2)), \
38  aR3=Range(a.getBase(3),a.getBound(3)), \
39  a.reshape(Range(0,aR0.length()*aR1.length()-1),aR2,aR3), \
40  dum=0; dum<1; dum++, \
41  a.reshape(aR0,aR1,aR2,aR3) ) \
42  a(Index(i0-aR0.getBase()+aR0.length()*(I1.getBase()-aR1.getBase()), \
43  I1.length(),aR0.length()),I2,I3)
44 
45 
46 #define M123(m1,m2,m3) (m1+halfWidth1+width*(m2+halfWidth2+width*(m3+halfWidth3)))
47 #define M123N(m1,m2,m3,n) (M123(m1,m2,m3)+stencilSize*(n))
48 
49 // Use this for indexing into coefficient matrices representing systems of equations
50 #define CE(c,e) (stencilSize*((c)+numberOfComponentsForCoefficients*(e)))
51 #define M123CE(m1,m2,m3,c,e) (M123(m1,m2,m3)+CE(c,e))
52 
53 // M123 with a fixed offset
54 #define MCE(m1,m2,m3) (M123(m1,m2,m3)+CE(c0,e0))
55 // define COEFF(I1,I2,I3,m1,m2,m3) coeff(I1,I2,I3,MN(m1,m2,m3))
56 // define EQUATIONNUMBER(I1,I2,I3,m1,m2,m3) equationNumber0(I1,I2,I3,MN(m1,m2,m3))
57 
58 // Use this for A++ index operations:
59 #undef UX_MERGED
60 #define UX_MERGED(m1,m2,m3,c,e,I1,I2,I3) MERGE0(derivative,M123CE(m1,m2,m3,c,e),I1,I2,I3)
61 #undef EQUATIONNUMBER
62 #define EQUATIONNUMBER(m1,m2,m3,n,I1,I2,I3) MERGE0(equationNumber0,M123N(m1,m2,m3,n),I1,I2,I3)
63 // Scalar indexing:
64 #define COEFFS(m1,m2,m3,n,I1,I2,I3) coeff0(M123N(m1,m2,m3,n),I1,I2,I3)
65 #define EQUATIONNUMBERS(m1,m2,m3,n,I1,I2,I3) equationNumber0(M123N(m1,m2,m3,n),I1,I2,I3)
66 
67 
68 #define ForStencil(m1,m2,m3) \
69  for( m3=-halfWidth3; m3<=halfWidth3; m3++) \
70  for( m2=-halfWidth2; m2<=halfWidth2; m2++) \
71  for( m1=-halfWidth1; m1<=halfWidth1; m1++)
72 
73 #define ForStencilN(n,m1,m2,m3) \
74  for( n=0; n<numberOfComponents; n++) \
75  for( m3=-halfWidth3; m3<=halfWidth3; m3++) \
76  for( m2=-halfWidth2; m2<=halfWidth2; m2++) \
77  for( m1=-halfWidth1; m1<=halfWidth1; m1++)
78 
79 
80 
81 // Define second order difference approximations:
82 #undef U
83 #undef UR2
84 #undef US2
85 #undef UT2
86 #undef URR2
87 #undef URS2
88 #undef URT2
89 #undef USS2
90 #undef UST2
91 #undef UTT2
92 #define U(I1,I2,I3,N) (delta(m1) *delta(m2) *delta(m3))
93 #define UR2(I1,I2,I3,N) (Dr(m1) *delta(m2) *delta(m3))
94 #define US2(I1,I2,I3,N) (delta(m1) *Ds(m2) *delta(m3))
95 #define UT2(I1,I2,I3,N) (delta(m1) *delta(m2) *Dt(m3))
96 #define URR2(I1,I2,I3,N) (Drr(m1) *delta(m2) *delta(m3))
97 #define URS2(I1,I2,I3,N) (Dr(m1) *Ds(m2) *delta(m3))
98 #define URT2(I1,I2,I3,N) (Dr(m1) *delta(m2) *Dt(m3))
99 #define USS2(I1,I2,I3,N) (delta(m1) *Dss(m2) *delta(m3))
100 #define UST2(I1,I2,I3,N) (delta(m1) *Ds(m2) *Dt(m3))
101 #define UTT2(I1,I2,I3,N) (delta(m1) *delta(m2) *Dtt(m3))
102 // Here are the defines for 4th order operators used in cgux4a.h
103 #undef UR4
104 #undef US4
105 #undef UT4
106 #undef URR4
107 #undef URS4
108 #undef URT4
109 #undef USS4
110 #undef UST4
111 #undef UTT4
112 #define UR4(I1,I2,I3,N) (Dr4(m1) *delta(m2) *delta(m3))
113 #define US4(I1,I2,I3,N) (delta(m1) *Ds4(m2) *delta(m3))
114 #define UT4(I1,I2,I3,N) (delta(m1) *delta(m2) *Dt4(m3))
115 #define URR4(I1,I2,I3,N) (Drr4(m1) *delta(m2) *delta(m3))
116 #define URS4(I1,I2,I3,N) (Dr4(m1) *Ds4(m2) *delta(m3))
117 #define URT4(I1,I2,I3,N) (Dr4(m1) *delta(m2) *Dt4(m3))
118 #define USS4(I1,I2,I3,N) (delta(m1) *Dss4(m2) *delta(m3))
119 #define UST4(I1,I2,I3,N) (delta(m1) *Ds4(m2) *Dt4(m3))
120 #define UTT4(I1,I2,I3,N) (delta(m1) *delta(m2) *Dtt4(m3))
121 
122 #endif