00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef AMROC_PROBLEM_H
00019 #define AMROC_PROBLEM_H
00020
00021 #define DIM 2
00022 #define NPATCHES 1
00023
00024 #include <cfloat>
00025 #include <sstream>
00026
00027 #include "WENOProblem.h"
00028
00029 #define OWN_GFMAMRSOLVER
00030 #define OWN_FLAGGING
00031
00032 #include "WENOStdGFMProblem.h"
00033
00034 #define f_initialize_configuration FORTRAN_NAME_(i_c,I_C)
00035 #define f_initialize_geometry FORTRAN_NAME_(i_g,I_G)
00036 extern "C" {
00037 void f_initialize_configuration (const DOUBLE*,const INTEGER&);
00038 void f_initialize_geometry (const INTEGER&,const DOUBLE*);
00039 }
00040
00041 #ifndef MIN
00042 # define MIN(a,b) (((a)<(b))?(a):(b))
00043 #endif
00044 #ifndef MAX
00045 # define MAX(a,b) (((a)>(b))?(a):(b))
00046 #endif
00047
00048 class FlaggingSpecific :
00049 public AMRFlagging<VectorType,FixupType,FlagType,DIM> {
00050 typedef AMRFlagging<VectorType,FixupType,FlagType,DIM> base;
00051
00052 public:
00053 FlaggingSpecific(base::solver_type& solver) : base(solver) {
00054 base::AddCriterion(new ByValue<VectorType,FlagType,DIM>());
00055 base::AddCriterion(new ScaledGradient<VectorType,FlagType,DIM>());
00056 base::AddCriterion(new LimiterType<VectorType,FlagType,DIM>());
00057 base::AddCriterion(
00058 new AbsoluteError<VectorType,FixupType,FlagType,DIM>(solver));
00059 base::AddCriterion(
00060 new RelativeError<VectorType,FixupType,FlagType,DIM>(solver));
00061 # ifdef f_flgout
00062 base::AddCriterion(new F77ByValue<VectorType,FlagType,DIM>(f_flgout));
00063 base::AddCriterion(
00064 new F77ScaledGradient<VectorType,FlagType,DIM>(f_flgout));
00065 base::AddCriterion(
00066 new F77LimiterType<VectorType,FlagType,DIM>(f_flgout));
00067 base::AddCriterion(
00068 new F77AbsoluteError<VectorType,FixupType,FlagType,DIM>(solver,
00069 f_flgout));
00070 base::AddCriterion(
00071 new F77RelativeError<VectorType,FixupType,FlagType,DIM>(solver,
00072 f_flgout));
00073 # endif
00074 }
00075
00076 virtual void register_at(ControlDevice& Ctrl,const std::string& prefix) {
00077 std::string variable;
00078 int d,p;
00079
00080
00081
00082 base::register_at(Ctrl,prefix);
00083
00084 for (p=0; p<NPATCHES; p++) {
00085 std::ostringstream patch;
00086 patch << p+1;
00087 for (d=0; d<DIM; d++) {
00088 std::ostringstream dimension;
00089 dimension << d+1;
00090 variable="GCellsMin" + patch.str() + "(" + dimension.str() + ")";
00091 RegisterAt(base::LocCtrl,variable.c_str(),_GCellsMin[p*DIM+d]);
00092 variable="GCellsMax" + patch.str() + "(" + dimension.str() + ")";
00093 RegisterAt(base::LocCtrl,variable.c_str(),_GCellsMax[p*DIM+d]);
00094 }
00095 }
00096 }
00097
00098 virtual void register_at(ControlDevice& Ctrl) {
00099 register_at(Ctrl,"");
00100 }
00101
00102 virtual void SetFlags(const int Time,const int Level,double t,double dt) {
00103 int p;
00104
00105
00106 base::SetFlags(Time,Level,t,dt);
00107
00108 for (p=0; p<NPATCHES; p++) {
00109 Coords lbound(DIM,&(_GCellsMin[p*DIM])),step(DIM,1),
00110 ubound(DIM,&(_GCellsMax[p*DIM]));
00111
00112 BBox boundingBox(lbound*StepSize(base::GH(),0),
00113 ubound*StepSize(base::GH(),0),
00114 step*StepSize(base::GH(),0));
00115 boundingBox.refine(
00116 StepSize(base::GH(),0)/StepSize(base::GH(),Level));
00117
00118
00119 forall (base::Flags(),Time,Level,c)
00120 base::Flags()(Time,Level,c).equals(BadPoint,boundingBox);
00121 end_forall
00122 }
00123 }
00124
00125 ~FlaggingSpecific() {
00126 DeleteAllCriterions();
00127 }
00128
00129 protected:
00130 int _GCellsMin[NPATCHES*DIM],_GCellsMax[NPATCHES*DIM];
00131 };
00132
00133 class SolverSpecific :
00134 public AMRGFMSolver<VectorType,FixupType,FlagType,DIM> {
00135 typedef VectorType::InternalDataType DataType;
00136 typedef AMRGFMSolver<VectorType,FixupType,FlagType,DIM> base;
00137 typedef F77GFMFileOutput<VectorType,FixupType,FlagType,DIM> output_type;
00138
00139 public:
00140 SolverSpecific(IntegratorSpecific& integ,
00141 base::initial_condition_type& init,
00142 base::boundary_conditions_type& bc) : base(integ, init, bc) {
00143 SetLevelTransfer(new F77LevelTransfer<VectorType,DIM>(f_prolong,
00144 f_restrict));
00145 # ifdef f_flgout
00146 SetFileOutput(
00147 new F77GFMFileOutput<VectorType,FixupType,FlagType,DIM>(*this,
00148 f_flgout));
00149 # else
00150 SetFileOutput(
00151 new GFMFileOutput<VectorType,FixupType,FlagType,DIM>(*this));
00152 # endif
00153 SetFixup(new FixupSpecific());
00154 SetFlagging(new FlaggingSpecific(*this));
00155 AddGFM(new GhostFluidMethod<VectorType,DIM>(
00156 new F77GFMBoundary<VectorType,DIM>(f_ibndrfl,f_itrans),
00157 new F77GFMLevelSet<DataType,DIM>(f_lset)));
00158 }
00159
00160 virtual void register_at(ControlDevice& Ctrl,const std::string& prefix) {
00161 ControlDevice device;
00162
00163
00164
00165 base::register_at(Ctrl,prefix);
00166
00167
00168
00169 device=Ctrl.getSubDevice(prefix+"Geometry");
00170
00171 RegisterAt(device,"TipRadius",_tipRadius);
00172 }
00173
00174 virtual void register_at(ControlDevice& Ctrl) {
00175
00176
00177 register_at(Ctrl,"");
00178 }
00179
00180 virtual void SetupData() {
00181 DOUBLE h=FLT_MAX;
00182 INTEGER refinement=1;
00183 int i;
00184
00185 for (i=0; i<MaxLev; i++)
00186 refinement *= _RefineFactor[i];
00187
00188 for (i=0; i<DIM; i++)
00189 h=MIN(h,(geom[2*i+1]-geom[2*i])/
00190 static_cast<DOUBLE>(refinement*shape[i]));
00191 # define NOPTIONS 2
00192 INTEGER n=NOPTIONS;
00193 DOUBLE options[NOPTIONS]={
00194 static_cast<DOUBLE>(_boundaryLayer),
00195 _tipRadius
00196
00197 };
00198 # undef NOPTIONS
00199
00200
00201 base::SetupData();
00202 f_initialize_configuration (options,n);
00203 f_initialize_geometry (DIM,geom);
00204 }
00205
00206 ~SolverSpecific() {
00207 DeleteGFM(_GFM[0]);
00208 delete _Flagging;
00209 delete _Fixup;
00210 delete _FileOutput;
00211 }
00212 protected:
00213 DOUBLE _tipRadius;
00214 INTEGER _boundaryLayer;