00001 #ifdef CH_LANG_CC
00002
00003
00004
00005
00006
00007
00008
00009 #endif
00010
00011 #ifndef _EBPATCHADVECT_H_
00012 #define _EBPATCHADVECT_H_
00013
00014 #include "EBPatchGodunov.H"
00015 #include "EBPatchGodunovFactory.H"
00016 #include "NamespaceHeader.H"
00017
00018 #define TOL 1.e-12
00019
00020
00021
00022
00023
00024
00025 class EBPatchAdvect : public EBPatchGodunov
00026 {
00027 public:
00028
00029
00030 EBPatchAdvect();
00031
00032
00033 ~EBPatchAdvect();
00034
00035
00036
00037
00038
00039 virtual int numPrimitives() const
00040 {
00041 return 1;
00042 }
00043
00044
00045
00046
00047
00048 virtual int numFluxes() const
00049 {
00050 return 1;
00051 }
00052
00053
00054
00055
00056
00057 virtual int numConserved() const
00058 {
00059 return 1;
00060 }
00061
00062
00063
00064
00065 virtual int numSlopes() const
00066 {
00067 return 1;
00068 }
00069
00070
00071
00072
00073 void
00074 normalPred(EBCellFAB& a_primLo,
00075 EBCellFAB& a_primHi,
00076 const EBCellFAB& a_primState,
00077 const EBCellFAB& a_slopePrim,
00078 const Real& a_scale,
00079 const int& a_dir,
00080 const Box& a_box);
00081
00082
00083
00084
00085 void
00086 transversePred(EBCellFAB& a_primLo,
00087 EBCellFAB& a_primHi,
00088 const EBCellFAB& a_primState,
00089 const EBCellFAB& a_slopePrim,
00090 const Real& a_scale,
00091 const int& a_dir,
00092 const Box& a_box);
00093
00094
00095
00096
00097 void
00098 interpolateFluxToCentroids(BaseIFFAB<Real> a_centroidFlux[SpaceDim],
00099 const EBFluxFAB& a_fluxInterpolant,
00100 const IntVectSet& a_irregIVS);
00101
00102
00103
00104
00105 void
00106 extrapToCoveredFaces(BaseIVFAB<Real>& a_extendedPrim,
00107 const EBFaceFAB& a_primFace,
00108 const EBCellFAB& a_primState,
00109 const Vector<VolIndex>& a_coveredFaces,
00110 const int& a_faceDir,
00111 const Side::LoHiSide& a_sd,
00112 const Box& a_box);
00113
00114
00115
00116
00117 void
00118 pointExtrapToCovered2D(Vector<Real>& a_extrapVal,
00119 const EBFaceFAB& a_primFace,
00120 const EBCellFAB& a_primState,
00121 const int& a_faceDir,
00122 const VolIndex& a_vof,
00123 const RealVect& a_normal,
00124 const Side::LoHiSide& a_sd,
00125 const int& a_numPrim);
00126
00127
00128
00129
00130 void
00131 pointExtrapToCovered3D(Vector<Real>& a_extrapVal,
00132 const EBFaceFAB& a_primFace,
00133 const EBCellFAB& a_primState,
00134 const int& a_faceDir,
00135 const VolIndex& a_vof,
00136 const RealVect& a_normal,
00137 const Side::LoHiSide& a_sd,
00138 const int& a_numPrim);
00139
00140
00141
00142
00143
00144 virtual void
00145 updatePrim(EBCellFAB& a_primMinu,
00146 EBCellFAB& a_primPlus,
00147 const EBFaceFAB& a_flux,
00148 const BaseIVFAB<Real>& a_coveredFluxMinu,
00149 const BaseIVFAB<Real>& a_coveredFluxPlus,
00150 const Vector<VolIndex>& a_coveredFaceMinu,
00151 const Vector<VolIndex>& a_coveredFacePlus,
00152 const int& a_dir,
00153 const Box& a_box,
00154 const Real& a_scale);
00155
00156 void
00157 upwindSlope(EBCellFAB& a_slopeUpWi,
00158 const EBCellFAB& a_primState,
00159 const int& a_dir,
00160 const Box& a_box);
00161
00162 void
00163 pointGetSlopesUpwind(Real& a_dql,
00164 Real& a_dqr,
00165 Real& a_dqc,
00166 bool& a_hasFacesLeft,
00167 bool& a_hasFacesRigh,
00168 const VolIndex& a_vof,
00169 const EBCellFAB& a_primState,
00170 const int& a_dir,
00171 const int& a_ivar,
00172 const bool& a_verbose);
00173
00174
00175 virtual void
00176 floorPrimitives(EBCellFAB& a_primState,
00177 const Box& a_box)
00178 {
00179 if (m_isMaxMinSet)
00180 {
00181 CH_assert(numPrimitives()==1);
00182
00183 IntVectSet ivsIrreg(a_box);
00184 for (VoFIterator vofit(ivsIrreg, m_ebisBox.getEBGraph());vofit.ok(); ++vofit)
00185 {
00186 const VolIndex& vof = vofit();
00187 a_primState(vof, 0) = Min(a_primState(vof, 0), m_maxVal);
00188 a_primState(vof, 0) = Max(a_primState(vof, 0), m_minVal);
00189 }
00190 }
00191 }
00192
00193
00194 virtual void
00195 floorPrimitives(BaseIVFAB<Real>& a_primState,
00196 const IntVectSet& a_set)
00197 {
00198 if (m_isMaxMinSet)
00199 {
00200 CH_assert(numPrimitives()==1);
00201 for (VoFIterator vofit(a_set, m_ebisBox.getEBGraph());vofit.ok(); ++vofit)
00202 {
00203 const VolIndex& vof = vofit();
00204 a_primState(vof, 0) = Min(a_primState(vof, 0), m_maxVal);
00205 a_primState(vof, 0) = Max(a_primState(vof, 0), m_minVal);
00206 }
00207 }
00208 }
00209
00210
00211 virtual void
00212 floorConserved(EBCellFAB& a_consState,
00213 const Box& a_box)
00214 {
00215 if (m_isMaxMinSet)
00216 {
00217 MayDay::Error("EBPatchAdvect::floorConserved::EBCellFAB:: unexpected case");
00218 }
00219 }
00220
00221
00222 virtual void
00223 floorConserved(BaseIVFAB<Real>& a_consState,
00224 const IntVectSet& a_set)
00225 {
00226 if (m_isMaxMinSet)
00227 {
00228 MayDay::Error("EBPatchAdvect::floorConserved::BaseIVFAB:: unexpected case");
00229 }
00230 }
00231
00232
00233 virtual void getCoveredValuesPrim(Vector<Real>& a_covValues)
00234 {;}
00235
00236
00237 virtual void getCoveredValuesCons(Vector<Real>& a_covValues)
00238 {;}
00239
00240
00241 virtual void setCoveredConsVals(EBCellFAB& a_consState)
00242 {;}
00243
00244
00245
00246
00247
00248 virtual void
00249 consToPrim(EBCellFAB& a_primState,
00250 const EBCellFAB& a_conState,
00251 const Box& a_box,
00252 int a_logflag,
00253 bool a_verbose=false);
00254
00255
00256
00257
00258
00259 virtual void
00260 consToPrim(BaseIVFAB<Real>& a_primState,
00261 const BaseIVFAB<Real>& a_conState,
00262 const IntVectSet& a_ivs);
00263
00264
00265
00266
00267
00268 virtual void
00269 consToPrim(BaseIVFAB<Real>& a_primState,
00270 const EBCellFAB& a_conState,
00271 const IntVectSet& a_ivs);
00272
00273
00274
00275
00276
00277 virtual void
00278 primToCons(EBCellFAB& a_primState,
00279 const EBCellFAB& a_conState,
00280 const Box& a_box);
00281
00282
00283
00284
00285
00286 virtual void
00287 primToCons(BaseIVFAB<Real>& a_primState,
00288 const BaseIVFAB<Real>& a_conState,
00289 const IntVectSet& a_ivs);
00290
00291
00292
00293
00294
00295 virtual void
00296 riemann(EBFaceFAB& a_primState,
00297 const EBCellFAB& a_primLeft,
00298 const EBCellFAB& a_primRight,
00299 const int& a_dir,
00300 const Box& a_box);
00301
00302
00303
00304
00305
00306 virtual void
00307 riemann(BaseIVFAB<Real>& a_coveredFlux,
00308 const BaseIVFAB<Real>& a_extendedState,
00309 const EBCellFAB& a_primState,
00310 const Vector<VolIndex>& a_region,
00311 const int& a_dir,
00312 const Side::LoHiSide& a_sd,
00313 const Box& a_box);
00314
00315
00316
00317
00318
00319
00320
00321 virtual void
00322 computeEBIrregFlux(BaseIVFAB<Real>& a_ebIrregFlux,
00323 const EBCellFAB& a_primState,
00324 const EBCellFAB a_slopePrim[SpaceDim],
00325 const IntVectSet& a_irregIVS,
00326 const EBCellFAB& a_source);
00327
00328
00329
00330
00331 void
00332 extrapolatePrim(EBFluxFAB& a_flux,
00333 EBCellFAB& a_primState,
00334 EBCellFAB a_slopePrim[SpaceDim],
00335 EBCellFAB a_slopeNLim[SpaceDim],
00336 Vector<BaseIVFAB<Real> * >& a_coveredFluxMinu,
00337 Vector<BaseIVFAB<Real> * >& a_coveredFluxPlus,
00338 const Vector<IntVectSet >& a_coveredSetsMinu,
00339 const Vector<IntVectSet >& a_coveredSetsPlus,
00340 const Vector<Vector<VolIndex> >& a_coveredFaceMinu,
00341 const Vector<Vector<VolIndex> >& a_coveredFacePlus,
00342 const EBCellFAB& a_flattening,
00343 const EBCellFAB& a_consState,
00344 const EBCellFAB& a_source,
00345 const Box& a_box,
00346 const DataIndex& a_dit,
00347 bool a_verbose);
00348
00349
00350
00351
00352 void
00353 extrapolateBCG(EBFluxFAB& a_flux,
00354
00355 EBCellFAB a_slopePrim[SpaceDim],
00356 EBCellFAB a_slopeNLim[SpaceDim],
00357 const EBCellFAB& a_flattening,
00358 const EBCellFAB& a_consState,
00359 const EBCellFAB& a_source,
00360 const Box& a_box,
00361 const DataIndex& a_dit,
00362 bool a_verbose);
00363
00364 void
00365 extrapolateBCG(EBCellFAB a_primMinu[SpaceDim],
00366 EBCellFAB a_primPlus[SpaceDim],
00367
00368 EBCellFAB a_slopesPrim[SpaceDim],
00369 EBCellFAB a_slopesSeco[SpaceDim],
00370 const EBCellFAB& a_flattening,
00371 const EBCellFAB& a_consState,
00372 const EBCellFAB& a_source,
00373 const Box& a_box,
00374 const DataIndex& a_dit,
00375 bool a_verbose);
00376
00377
00378 virtual void
00379 advectiveDerivative(EBCellFAB & a_udotDelRho,
00380 const EBFluxFAB & a_faceRho,
00381 const EBFluxFAB & a_faceVel,
00382 const Vector<BaseIVFAB<Real>*> & a_coveredRhoMinu,
00383 const Vector<BaseIVFAB<Real>*> & a_coveredRhoPlus,
00384 const Vector<BaseIVFAB<Real>*> & a_coveredVelMinu,
00385 const Vector<BaseIVFAB<Real>*> & a_coveredVelPlus,
00386 const Vector<Vector<VolIndex> >& a_coveredFaceMinu,
00387 const Vector<Vector<VolIndex> >& a_coveredFacePlus,
00388 const Box & a_box);
00389
00390
00391 void
00392 advectiveDerivative(EBCellFAB & a_udotDelRho,
00393 const EBFluxFAB & a_faceRho,
00394 const EBFluxFAB & a_faceVel,
00395 const Box & a_box);
00396
00397
00398
00399
00400
00401
00402 virtual bool usesFlattening() const;
00403
00404
00405
00406
00407
00408 virtual bool usesArtificialViscosity() const;
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 virtual void
00427 slope(EBCellFAB& a_slopePrim,
00428 EBCellFAB& a_slopeNLim,
00429 const EBCellFAB& a_primState,
00430 const EBCellFAB& a_flattening,
00431 const int& a_dir,
00432 const Box& a_box,
00433 bool a_doAgg = false);
00434
00435 virtual void
00436 doSecondOrderSlopes(EBCellFAB& a_delta2W,
00437 EBCellFAB& a_deltaWL,
00438 EBCellFAB& a_deltaWR,
00439 EBCellFAB& a_deltaWC,
00440 const EBCellFAB& a_primState,
00441 const int& a_dir,
00442 const Box& a_box);
00443
00444
00445
00446
00447
00448
00449 virtual bool usesFourthOrderSlopes() const;
00450
00451
00452 void
00453 averageVelToCC(EBCellFAB& a_normalVel,
00454 const EBFluxFAB& a_advectionVel,
00455 const Vector<BaseIVFAB<Real> * >& a_coveredVeloLo,
00456 const Vector<BaseIVFAB<Real> * >& a_coveredVeloHi,
00457 const Vector<Vector<VolIndex> >& a_coveredFaceLo,
00458 const Vector<Vector<VolIndex> >& a_coveredFaceHi,
00459 const Box& a_box) const;
00460
00461 virtual void setVelocities(const EBCellFAB& a_normalVel,
00462 const EBFluxFAB& a_advectionVel);
00463
00464 virtual void
00465 setValidBox(const Box& a_validBox,
00466 const EBISBox& a_ebisBox,
00467 const IntVectSet& a_coarseFineIVS,
00468 const Real& a_time,
00469 const Real& a_dt);
00470
00471 virtual void setTimeAndDt(const Real& a_time, const Real& a_dt)
00472 {
00473 m_time = a_time;
00474 m_dt = a_dt;
00475 }
00476
00477
00478 virtual Vector<string> stateNames();
00479
00480 virtual Vector<string> primNames();
00481
00482
00483 void useLimiting(bool a_limiting);
00484
00485
00486
00487
00488 Real
00489 getMaxWaveSpeed(const EBCellFAB& a_consState,
00490 const Box& a_box)
00491 {
00492 MayDay::Error("should not be called ");
00493 return -1.0;
00494 }
00495
00496 void
00497 getFlux(EBFaceFAB& a_flux,
00498 const EBFaceFAB& a_prim,
00499 const int& a_dir,
00500 const Box& a_box)
00501 {
00502 MayDay::Error("should not be called ");
00503 }
00504
00505
00506
00507
00508
00509 Interval velocityInterval() const
00510 {
00511 MayDay::Error("should not be called");
00512 Interval retval;
00513 return retval;
00514 }
00515
00516
00517
00518
00519
00520
00521
00522
00523 virtual int densityIndex() const
00524 {
00525 return 0;
00526 }
00527
00528
00529
00530
00531
00532
00533
00534
00535 int pressureIndex() const
00536 {
00537 return -1;
00538 }
00539
00540
00541 int bulkModulusIndex() const
00542 {
00543 MayDay::Error("should not be called");
00544 return -1;
00545 }
00546
00547
00548 Real artificialViscosityCoefficient() const
00549 {
00550 MayDay::Error("should not be called");
00551 return -1.0;
00552 }
00553
00554 void setMaxMin(const Real& a_maxVal,
00555 const Real& a_minVal)
00556 {
00557 m_isMaxMinSet = true;
00558 m_maxVal = a_maxVal;
00559 m_minVal = a_minVal;
00560 }
00561 EBCellFAB& getPrimState()
00562 {
00563 return m_primState;
00564 }
00565
00566
00567
00568 protected:
00569
00570 const EBFluxFAB* m_advectionVelPtr;
00571 const EBCellFAB* m_normalVelPtr;
00572
00573 bool m_isVelSet;
00574 bool m_isMaxMinSet;
00575 Real m_maxVal;
00576 Real m_minVal;
00577 private:
00578
00579 void operator=(const EBPatchAdvect& a_input)
00580 {
00581 MayDay::Error("invalid operator");
00582 }
00583 EBPatchAdvect(const EBPatchAdvect& a_input)
00584 {
00585 MayDay::Error("invalid operator");
00586 }
00587
00588 };
00589
00590
00591
00592
00593
00594 class EBPatchAdvectFactory: public EBPatchGodunovFactory
00595 {
00596 public:
00597
00598
00599
00600 virtual ~EBPatchAdvectFactory();
00601
00602
00603
00604
00605 EBPatchGodunov* create() const;
00606
00607
00608
00609
00610 EBPatchAdvectFactory(RefCountedPtr<EBPhysIBCFactory>& a_bc,
00611 const bool& a_useLimiting,
00612 const Real& a_maxVal =-1.e99,
00613 const Real& a_minVal = 1.e99,
00614 const bool& a_setMaxMin = false);
00615
00616 protected:
00617 RefCountedPtr<EBPhysIBCFactory> m_bcFactoryPtr;
00618 bool m_useLimiting;
00619 bool m_setMaxMin;
00620 Real m_maxVal;
00621 Real m_minVal;
00622
00623 private:
00624
00625
00626 EBPatchAdvectFactory()
00627 {
00628 MayDay::Error("invalid operator");
00629 }
00630 void operator=(const EBPatchAdvectFactory& a_input)
00631 {
00632 MayDay::Error("invalid operator");
00633 }
00634 EBPatchAdvectFactory(const EBPatchAdvectFactory& a_input)
00635 {
00636 MayDay::Error("invalid operator");
00637 }
00638 };
00639
00640 #include "NamespaceFooter.H"
00641 #endif