00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef AMROC_TWOCOMP_EULER_EVALUATOR_H
00010 #define AMROC_TWOCOMP_EULER_EVALUATOR_H
00011
00019 #include <iostream>
00020 #include <cstdio>
00021 #include <cfloat>
00022
00023 #include "Evaluator.h"
00024
00031 template <class VectorType>
00032 class TwoCompEulerEvaluator : public Evaluator<VectorType> {
00033 typedef Evaluator<VectorType> base;
00034 typedef typename VectorType::InternalDataType DataType;
00035
00036 public:
00037 typedef typename base::vector_block_type vector_block_type;
00038 typedef typename base::data_block_type data_block_type;
00039
00040 TwoCompEulerEvaluator() : evaluator_base_type() {
00041 std::sprintf(title,"3D-Euler equations - 2 Components");
00042 }
00043
00044 virtual void SetUp(VisualGridBase *gr) {
00045 evaluator_base_type::SetUp(gr);
00046 const int base=evaluator_base_type::NKeys();
00047 std::sprintf(&(tkeys[ base *LEN_TKEYS]), "Pressure ");
00048 std::sprintf(&(tkeys[(base+1)*LEN_TKEYS]), "Gamma ");
00049 std::sprintf(&(tkeys[(base+2)*LEN_TKEYS]), "Schl.-Plot Pressure ");
00050 std::sprintf(&(tkeys[(base+3)*LEN_TKEYS]), "Schl.-Plot Gamma ");
00051 base::fkeys[base ] = base::Grid->FKeys();
00052 base::fkeys[base+1] = base::Grid->FKeys();
00053 base::fkeys[base+2] = base::Grid->FKeys();
00054 base::fkeys[base+3] = base::Grid->FKeys();
00055 base::ikeys[base ] = 112;
00056 base::ikeys[base+1] = 103;
00057 base::ikeys[base+2] = 80;
00058 base::ikeys[base+3] = 71;
00059 }
00060
00061 virtual int NKeys() const { return evaluator_base_type::NKeys()+4; }
00062
00063 virtual void SetScalCells(int key,float v[],int& offset,
00064 vector_block_type& DB, float* dx, bool* CompRead) {
00065 int idx=0;
00066 const int base=evaluator_base_type::NKeys();
00067 BeginFastIndex3(dat, DB.bbox(), DB.data(), VectorType);
00068 if (key == base+1) {
00069 if (!CompRead[4] || !CompRead[0] || !CompRead[5])
00070 return;
00071
00072 float rho, u1, u2, u3, E, g, pinf;
00073 for_3 (i,j,k,DB.bbox(),DB.bbox().stepsize())
00074 rho = FastIndex3(dat,i,j,k)(0);
00075 u1 = FastIndex3(dat,i,j,k)(1);
00076 u2 = FastIndex3(dat,i,j,k)(2);
00077 u3 = FastIndex3(dat,i,j,k)(3);
00078 E = FastIndex3(dat,i,j,k)(4);
00079 g = FastIndex3(dat,i,j,k)(5);
00080 pinf = FastIndex3(dat,i,j,k)(6);
00081 v[idx+offset]=(E-0.5*rho*(u1*u1+u2*u2+u3*u3)-pinf)/g;
00082 mvals[2*base] = Min(mvals[2*base], v[idx+offset]) ;
00083 mvals[2*base+1] = Max(mvals[2*base+1], v[idx+offset]) ;
00084 idx++;
00085 end_for
00086 }
00087 else if (key == base+2) {
00088 if (!CompRead[5])
00089 return;
00090
00091 float g;
00092 for_3 (i,j,k,DB.bbox(),DB.bbox().stepsize())
00093 g = FastIndex3(dat,i,j,k)(5);
00094 v[idx+offset]=1.0/g+1.0;
00095 mvals[2*(base+1)] = Min(mvals[2*(base+1)], v[idx+offset]) ;
00096 mvals[2*(base+1)+1] = Max(mvals[2*(base+1)+1], v[idx+offset]) ;
00097 idx++;
00098 end_for
00099 }
00100 else
00101 evaluator_base_type::SetScalCells(key,v,offset,DB,dx,CompRead);
00102
00103 EndFastIndex3(dat);
00104 offset+=idx;
00105 }
00106
00107
00108
00109 virtual void SetScalNodes(int key,float v[],int& offset,
00110 vector_block_type& DB, const BBox& bbox,
00111 float* dx, bool* CompRead) {
00112 int idx=0;
00113 const int base=evaluator_base_type::NKeys();
00114 BeginFastIndex3(dat, DB.bbox(), DB.data(), VectorType);
00115 const Coords& step = bbox.stepsize();
00116 if (key == base+1) {
00117 if (!CompRead[4] || !CompRead[0] || !CompRead[5])
00118 return;
00119
00120 float rho, u1, u2, u3, E, c, g, pinf;
00121 for_3 (i, j, k, bbox, step)
00122 BBox AddOver(3,i-step(0),j-step(1),k-step(2),
00123 i,j,k,step(0),step(1),step(2));
00124 AddOver *= DB.bbox();
00125
00126 c=0;
00127 v[idx+offset] = 0.0;
00128 for_3 (l, m, n, AddOver, step)
00129 rho = FastIndex3(dat,l,m,n)(0);
00130 u1 = FastIndex3(dat,l,m,n)(1);
00131 u2 = FastIndex3(dat,l,m,n)(2);
00132 u3 = FastIndex3(dat,l,m,n)(3);
00133 E = FastIndex3(dat,l,m,n)(4);
00134 g = FastIndex3(dat,l,m,n)(5);
00135 pinf = FastIndex3(dat,l,m,n)(6);
00136 if (rho<FLT_MAX && u1<FLT_MAX && u2<FLT_MAX && u3<FLT_MAX &&
00137 E<FLT_MAX && g<FLT_MAX && pinf<FLT_MAX) {
00138 v[idx+offset] += (E-0.5*rho*(u1*u1+u2*u2+u3*u3)-pinf)/g;
00139 c += 1.0;
00140 }
00141 end_for
00142 if (c>0) v[idx+offset] /= c;
00143 else v[idx+offset] = FLT_MAX;
00144
00145 mvals[2*base] = Min(mvals[2*base], v[idx+offset]) ;
00146 mvals[2*base+1] = Max(mvals[2*base+1], v[idx+offset]) ;
00147 idx++;
00148 end_for
00149 }
00150 else if (key == base+3) {
00151 if (!CompRead[4] || !CompRead[0] || !CompRead[5])
00152 return;
00153
00154 float rho, u1, u2, u3, E, c, g, pinf;
00155 for_3 (i, j, k, bbox, step)
00156 BBox AddOver(3,i-step(0),j-step(1),k-step(2),
00157 i,j,k,step(0),step(1),step(2));
00158 AddOver *= DB.bbox();
00159
00160 data_block_type DBHelp(AddOver);
00161 DBhelp = FLT_MAX;
00162 BeginFastIndex3(help, DBHelp.bbox(), DBHelp.data(), DataType);
00163 for_3 (l, m, n, AddOver, step)
00164 rho = FastIndex3(dat,l,m,n)(0);
00165 u1 = FastIndex3(dat,l,m,n)(1);
00166 u2 = FastIndex3(dat,l,m,n)(2);
00167 u3 = FastIndex3(dat,l,m,n)(3);
00168 E = FastIndex3(dat,l,m,n)(4);
00169 g = FastIndex3(dat,l,m,n)(5);
00170 pinf = FastIndex3(dat,l,m,n)(6);
00171 if (rho<FLT_MAX && u1<FLT_MAX && u2<FLT_MAX && u3<FLT_MAX &&
00172 E<FLT_MAX && g<FLT_MAX && pinf<FLT_MAX)
00173 FastIndex3(help,l,m,n) = (E-0.5*rho*(u1*u1+u2*u2+u3*u3)-pinf)/g;
00174 end_for
00175 EndFastIndex3(help);
00176 v[idx+offset] = SetScalGradNodes(DBHelp,dx);
00177
00178 mvals[2*(base+2)] = Min(mvals[2*(base+2)], v[idx+offset]) ;
00179 mvals[2*(base+2)+1] = Max(mvals[2*(base+2)+1], v[idx+offset]) ;
00180 idx++;
00181 end_for
00182 }
00183 else if (key == base+2) {
00184 if (!CompRead[5])
00185 return;
00186
00187 float g, c;
00188 for_3 (i, j, k, bbox, step)
00189 BBox AddOver(3,i-step(0),j-step(1),k-step(2),
00190 i,j,k,step(0),step(1),step(2));
00191 AddOver *= DB.bbox();
00192
00193 c=0;
00194 v[idx+offset] = 0.0;
00195 for_3 (l, m, n, AddOver, step)
00196 g = FastIndex3(dat,l,m,n)(5);
00197 if (g<FLT_MAX) {
00198 v[idx+offset] += 1.0/g+1.0;
00199 c += 1.0;
00200 }
00201 end_for
00202 if (c>0) v[idx+offset] /= c;
00203 else v[idx+offset] = FLT_MAX;
00204
00205 mvals[2*(base+1)] = Min(mvals[2*(base+1)], v[idx+offset]) ;
00206 mvals[2*(base+1)+1] = Max(mvals[2*(base+1)+1], v[idx+offset]) ;
00207 idx++;
00208 end_for
00209 }
00210 else if (key == base+4) {
00211 if (!CompRead[5])
00212 return;
00213
00214 float g, c;
00215 for_3 (i, j, k, bbox, step)
00216 BBox AddOver(3,i-step(0),j-step(1),k-step(2),
00217 i,j,k,step(0),step(1),step(2));
00218 AddOver *= DB.bbox();
00219
00220 data_block_type DBHelp(AddOver);
00221 DBhelp = FLT_MAX;
00222 BeginFastIndex3(help, DBHelp.bbox(), DBHelp.data(), DataType);
00223 for_3 (l, m, n, AddOver, step)
00224 g = FastIndex3(dat,l,m,n)(5);
00225 if (g<FLT_MAX)
00226 FastIndex3(help,l,m,n) = 1.0/g+1.0;
00227 end_for
00228 EndFastIndex3(help);
00229 v[idx+offset] = SetScalGradNodes(DBHelp,dx);
00230
00231 mvals[2*(base+3)] = Min(mvals[2*(base+3)], v[idx+offset]) ;
00232 mvals[2*(base+3)+1] = Max(mvals[2*(base+3)+1], v[idx+offset]) ;
00233 idx++;
00234 end_for
00235 }
00236 else
00237 evaluator_base_type::SetScalNodes(key,v,offset,DB,bbox,dx,CompRead);
00238
00239 EndFastIndex3(dat);
00240 offset+=idx;
00241 }
00242
00243 };
00244
00245 #endif