12 #beginMacro getGridCoordinates(xv)
28 #beginMacro getWidestBoxDirectionsMacro(dir1,dir2)
29 if( numberOfDimensions==2 )
33 dir1 = xWidth > yWidth ? 0 : 1;
39 if( xWidth < min(yWidth,zWidth) )
43 else if( yWidth < min(xWidth,zWidth) )
71 #beginMacro addBodyForceMacro(TYPE,I1,I2,I3)
76 #Elif #TYPE eq "boundary"
79 OV_ABORT(
"addBodyForceMacro: UNKNOWN argument =TYPE");
84 if( regionType==
"box" )
88 const real *boxBounds = bodyForce.dbase.get<real[6] >(
"boxBounds");
90 #define xab(side,axis) boxBounds[(side)+2*(axis)]
91 const real & xa =
xab(0,0), &xb =
xab(1,0);
92 const real & ya =
xab(0,1), &yb =
xab(1,1);
93 const real & za =
xab(0,2), &zb =
xab(1,2);
95 const aString &
profileType = bodyForce.dbase.get<aString>(
"profileType");
101 if( profileType==
"uniform" )
107 getGridCoordinates(
xv);
110 if(
xv[0]>=xa &&
xv[0]<=xb &&
xv[1]>=ya &&
xv[1]<=yb &&
xv[2]>=za &&
xv[2]<=zb )
117 else if( profileType==
"parabolic" )
127 const real & parabolicProfileDepth = bodyForce.dbase.get<real>(
"parabolicProfileDepth");
128 const real xWidth=xb-xa, yWidth=yb-ya, zWidth=zb-za;
132 getWidestBoxDirectionsMacro(dir1,dir2);
137 getGridCoordinates(
xv);
143 if( numberOfDimensions==3 )
144 dist=min( dist,
xv[2]-
xab(0,2),
xab(1,2)-
xv[2] );
145 #Elif #TYPE eq "boundary"
147 dist = min(
xv[dir1]-
xab(0,dir1),
xab(1,dir1)-
xv[dir1] );
148 if( numberOfDimensions==3 )
149 dist=min( dist,
xv[dir2]-
xab(0,dir2),
xab(1,dir2)-
xv[dir2] );
151 OV_ABORT(
"addBodyForceMacro: UNKNOWN argument =TYPE");
158 dist /= parabolicProfileDepth;
162 profileFactor = dist*(2.-dist);
175 else if( profileType==
"tanh" )
182 const real & b = bodyForce.dbase.get<real>(
"tanhProfileExponent");
183 const real xWidth=xb-xa, yWidth=yb-ya, zWidth=zb-za;
187 getWidestBoxDirectionsMacro(dir1,dir2);
192 getGridCoordinates(
xv);
199 profileFactor = .5*( tanh( b*(
xv[0]-
xab(0,0)) ) - tanh( b*(
xv[0]-
xab(1,0)) ) );
200 profileFactor *= .5*( tanh( b*(
xv[1]-
xab(0,1)) ) - tanh( b*(
xv[1]-
xab(1,1)) ) );
201 if( numberOfDimensions==3 )
202 profileFactor *= .5*( tanh( b*(
xv[2]-
xab(0,2)) ) - tanh( b*(
xv[2]-
xab(1,2)) ) );
203 #Elif #TYPE eq "boundary"
205 profileFactor = .5*( tanh( b*(
xv[dir1]-
xab(0,dir1)) ) - tanh( b*(
xv[dir1]-
xab(1,dir1)) ) );
206 if( numberOfDimensions==3 )
207 profileFactor *= .5*( tanh( b*(
xv[dir2]-
xab(0,dir2)) ) - tanh( b*(
xv[dir2]-
xab(1,dir2)) ) );
209 OV_ABORT(
"addBodyForceMacro: UNKNOWN argument =TYPE");
219 printF(
"addBodyForceMacro: ERROR: unknown profileType=%s\n",(
const char*)profileType);
225 else if( regionType==
"ellipse" )
230 const real *ellipse = bodyForce.dbase.get<real[6] >(
"ellipse");
232 const real ae = ellipse[0];
233 const real be = ellipse[1];
234 const real ce = ellipse[2];
235 const real
xe = ellipse[3];
236 const real
ye = ellipse[4];
237 const real
ze = ellipse[5];
243 getGridCoordinates(xv);
246 if( numberOfDimensions==2 )
248 real xa = (
xv[0]-
xe)/ae;
249 real ya = (
xv[1]-
ye)/be;
254 real xa = (
xv[0]-
xe)/ae;
255 real ya = (
xv[1]-
ye)/be;
256 real za = (
xv[2]-
ze)/ce;
257 rad = xa*xa+ya*ya+za*za;
275 else if( regionType==
"maskFromGridFunction" )
279 if( !parameters.dbase.has_key(
"bodyForceMaskGridFunction") )
281 printF(
"ERROR: regionType==`maskFromGridFunction' but the grid function does not exist!\n");
287 realCompositeGridFunction *maskPointer =
288 parameters.dbase.get<realCompositeGridFunction*>(
"bodyForceMaskGridFunction");
289 assert( maskPointer!=NULL );
290 realCompositeGridFunction & bodyForceMask = *maskPointer;
292 realArray & bfMask = bodyForceMask[
grid];
293 OV_GET_SERIAL_ARRAY(real,bfMask,bfMaskLocal);
297 bool ok = ParallelUtility::getLocalArrayBounds(bfMask,bfMaskLocal,
I1,I2,
I3,1);
305 if( bfMaskLocal(
i1,
i2,
i3)<=0. )
317 printF(
"computeBodyForcing:ERROR: unexpected regionType=%s\n",(
const char*)regionType);
326 #beginMacro saveBodyForceRegionInfoMacro(bodyForce,regionPar)
329 const aString & regionType = regionPar.dbase.get<aString>(
"regionType");
332 if( !bodyForce.dbase.has_key(
"regionType") )
333 bodyForce.dbase.put<aString>(
"regionType");
334 bodyForce.dbase.get<aString>(
"regionType")=regionType;
336 if( !bodyForce.dbase.has_key(
"linesToPlot") )
337 bodyForce.dbase.put<
int[3]>(
"linesToPlot");
339 int *
lines = regionPar.dbase.get<
int[3] >(
"linesToPlot");
340 for(
int i=0;
i<3;
i++ )
341 linesToPlot[
i]=lines[
i];
343 if( regionType==
"box" )
345 bodyForce.dbase.put<real[6] >(
"boxBounds");
346 real *boxBounds = bodyForce.dbase.get<real[6]>(
"boxBounds");
347 const real *bpar = regionPar.dbase.get<real[6]>(
"boxBounds");
348 for(
int i=0;
i<6;
i++ )
349 boxBounds[
i]=bpar[
i];
351 else if( regionType==
"ellipse" )
353 bodyForce.dbase.put<real[6] >(
"ellipse");
354 real *ellipse = bodyForce.dbase.get<real[6]>(
"ellipse");
355 const real *epar = regionPar.dbase.get<real[6]>(
"ellipse");
356 for(
int i=0;
i<6;
i++ )
359 else if( regionType==
"maskFromGridFunction" )
365 printF(
"defineVariableBoundaryValues:ERROR: unexpected regionType=%s\n",(
const char*)regionType);
370 const aString &
profileType = regionPar.dbase.get<aString>(
"profileType");
371 bodyForce.dbase.put<aString>(
"profileType");
372 bodyForce.dbase.get<aString>(
"profileType")=profileType;
373 if( profileType==
"parabolic" )
375 bodyForce.dbase.put<real>(
"parabolicProfileDepth");
376 bodyForce.dbase.get<real>(
"parabolicProfileDepth")=regionPar.dbase.get<real>(
"parabolicProfileDepth");
378 else if( profileType==
"tanh" )
380 bodyForce.dbase.put<real>(
"tanhProfileExponent");
381 bodyForce.dbase.get<real>(
"tanhProfileExponent")=regionPar.dbase.get<real>(
"tanhProfileExponent");