vtf-logo

TwoCEulerEvaluator.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2002 Ralf Deiterding
00004 // Brandenburgische Universitaet Cottbus
00005 //
00006 // Copyright (C) 2003-2007 California Institute of Technology
00007 // Ralf Deiterding, ralf@amroc.net
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         v[idx+offset] /= c;
00143 
00144         mvals[2*base]   = Min(mvals[2*base],   v[idx+offset]) ;
00145         mvals[2*base+1] = Max(mvals[2*base+1], v[idx+offset]) ;
00146         idx++;        
00147       end_for 
00148     } 
00149     else if (key == base+3) {
00150       if (!CompRead[4] || !CompRead[0] || !CompRead[5])
00151         return;
00152 
00153       float rho, u1, u2, u3, E, c, g, pinf;
00154       for_3 (i, j, k, bbox, step)
00155         BBox AddOver(3,i-step(0),j-step(1),k-step(2),
00156                      i,j,k,step(0),step(1),step(2));
00157         AddOver *= DB.bbox();
00158           
00159         data_block_type DBHelp(AddOver);
00160         DBhelp = FLT_MAX;
00161         BeginFastIndex3(help, DBHelp.bbox(), DBHelp.data(), DataType);
00162         for_3 (l, m, n, AddOver, step)
00163           rho = FastIndex3(dat,l,m,n)(0);                     
00164           u1  = FastIndex3(dat,l,m,n)(1);
00165           u2  = FastIndex3(dat,l,m,n)(2);
00166           u3  = FastIndex3(dat,l,m,n)(3);
00167           E   = FastIndex3(dat,l,m,n)(4);             
00168           g   = FastIndex3(dat,l,m,n)(5);
00169           pinf = FastIndex3(dat,l,m,n)(6);
00170           if (rho<FLT_MAX && u1<FLT_MAX && u2<FLT_MAX && u3<FLT_MAX && 
00171               E<FLT_MAX && g<FLT_MAX && pinf<FLT_MAX) 
00172             FastIndex3(help,l,m,n) = (E-0.5*rho*(u1*u1+u2*u2+u3*u3)-pinf)/g;
00173         end_for
00174         EndFastIndex3(help); 
00175         v[idx+offset] = SetScalGradNodes(DBHelp,dx);
00176         
00177         mvals[2*(base+2)]   = Min(mvals[2*(base+2)],   v[idx+offset]) ;
00178         mvals[2*(base+2)+1] = Max(mvals[2*(base+2)+1], v[idx+offset]) ;
00179         idx++;        
00180       end_for 
00181     } 
00182     else if (key == base+2) {
00183       if (!CompRead[5])
00184         return;
00185 
00186       float g, c;
00187       for_3 (i, j, k, bbox, step)
00188         BBox AddOver(3,i-step(0),j-step(1),k-step(2),
00189                      i,j,k,step(0),step(1),step(2));
00190         AddOver *= DB.bbox();
00191           
00192         c=0;
00193         v[idx+offset] = 0.0;
00194         for_3 (l, m, n, AddOver, step)
00195           g = FastIndex3(dat,l,m,n)(5);
00196           if (g<FLT_MAX) {
00197             v[idx+offset] += 1.0/g+1.0;
00198             c += 1.0;
00199           }
00200         end_for
00201         v[idx+offset] /= c;
00202 
00203         mvals[2*(base+1)]   = Min(mvals[2*(base+1)],   v[idx+offset]) ;
00204         mvals[2*(base+1)+1] = Max(mvals[2*(base+1)+1], v[idx+offset]) ;
00205         idx++;        
00206       end_for
00207     }
00208     else if (key == base+4) {
00209       if (!CompRead[5])
00210         return;
00211 
00212       float g, c;
00213       for_3 (i, j, k, bbox, step)
00214         BBox AddOver(3,i-step(0),j-step(1),k-step(2),
00215                      i,j,k,step(0),step(1),step(2));
00216         AddOver *= DB.bbox();
00217           
00218         data_block_type DBHelp(AddOver);
00219         DBhelp = FLT_MAX;
00220         BeginFastIndex3(help, DBHelp.bbox(), DBHelp.data(), DataType);
00221         for_3 (l, m, n, AddOver, step)
00222           g = FastIndex3(dat,l,m,n)(5);
00223           if (g<FLT_MAX) 
00224             FastIndex3(help,l,m,n) = 1.0/g+1.0;
00225         end_for
00226         EndFastIndex3(help); 
00227         v[idx+offset] = SetScalGradNodes(DBHelp,dx);
00228 
00229         mvals[2*(base+3)]   = Min(mvals[2*(base+3)],   v[idx+offset]) ;
00230         mvals[2*(base+3)+1] = Max(mvals[2*(base+3)+1], v[idx+offset]) ;
00231         idx++;        
00232       end_for
00233     }
00234     else
00235       evaluator_base_type::SetScalNodes(key,v,offset,DB,bbox,dx,CompRead);
00236 
00237     EndFastIndex3(dat); 
00238     offset+=idx;
00239   }
00240 
00241 };
00242 
00243 #endif

Generated on Fri Aug 24 13:00:31 2007 for AMROC's HDF Tools - by  doxygen 1.4.7