14 #ifndef _SIM_SOLVER_TS_H_
15 #define _SIM_SOLVER_TS_H_
50 virtual bool read(
const char* file)
76 int geoBlk = 0, nBlock = 0;
83 while (this->
tp.
time.
t <
aStart-1.0e-12 && this->advanceStep())
84 if (!this->
S1.solveStep(this->tp))
96 int tranStep = this->
tp.
step;
97 int lastRef = 1, refElms = 0;
100 if (
maxPred < 0) this->
S1.enableStaggering(
false);
101 for (
int iPred = 0; iPred < abs(
maxPred) && lastRef > 0; iPred++)
109 this->
S1.saveState();
114 if (!this->
S1.solveStep(this->tp))
124 IFEM::cout <<
"\n >>> Paused for mesh refinement at time="
125 << this->
tp.
time.
t << std::endl;
134 else if (refElms == 0 && !this->
tp.
finished() && !this->
S1.stopped())
135 IFEM::cout <<
" No refinement, resume from current state"<< std::endl;
137 if (lastRef == 0 &&
maxPred > 0)
142 if (!this->
saveState(geoBlk,nBlock,refElms > 0))
161 this->
S1.restoreState();
166 this->
S1.enableStaggering(
true);
168 if (!this->
S1.solveStep(this->tp))
170 else if (!this->
saveState(geoBlk,nBlock,j < 1))
175 return this->
dumpMesh(infile) ? 0 : 2;
186 data[this->
S1.getName()+
"::basis"] = std::to_string(
lastRLev);
193 virtual bool parse(
const tinyxml2::XMLElement* elem)
195 if (strcasecmp(elem->Value(),
"adaptive"))
202 const char* value =
nullptr;
203 const tinyxml2::XMLElement* child = elem->FirstChildElement();
204 for (; child; child = child->NextSiblingElement())
217 else if (this->
S1.getRefined())
222 this->
S1.parsePreref(child);
227 else if (!strcasecmp(child->Value(),
"prerefine"))
235 <<
"\n\tPre-refinement tolerance: "<<
refTol <<
"\n";
237 <<
"\n\tNumber of steps between each refinement: "<<
nForward
238 <<
"\n\tMax. number of trial cycles at refinement: "<<
maxPred
239 <<
"\n\tMax. number of refinements of an element: "<<
maxRef
240 <<
"\n\tRelative refinement threshold: "<<
minFrac;
251 bool dumpMesh(
char* infile,
bool done =
true)
const
256 return done ? this->
S1.dumpMesh(strcat(strtok(infile,
"."),
".lr")) :
true;
262 static int gridNo = 1;
263 sprintf(fileName,
"%s_m%d.lr",strtok(infile,
"."),++gridNo);
264 return this->
S1.dumpMesh(fileName);
SIM solver class template.
static const double T1[2]
1-point rule coordinates.
Definition: TriangleQuadrature.C:19
std::map< std::string, std::string > SerializeData
Convenience type.
Definition: HDF5Restart.h:34
static utl::LogStream cout
Combined standard out for parallel processes.
Definition: IFEM.h:62
T1 & S1
The actual solver.
Definition: SIMSolver.h:109
void printHeading(const char *heading)
Writes an application-specific heading, if provided.
Definition: SIMSolver.h:69
Template class for time-slab adaptive simulator drivers.
Definition: SIMSolverTS.h:31
int maxPred
Maximum number of prediction cycles.
Definition: SIMSolverTS.h:270
virtual int solveProblem(char *infile, const char *heading)
Solves the problem up to the final time.
Definition: SIMSolverTS.h:62
virtual ~SIMSolverTS()
Empty destructor.
Definition: SIMSolverTS.h:47
double refTol
Pre-refinement threshold.
Definition: SIMSolverTS.h:273
int maxRef
Number of refinements to allow for a single element.
Definition: SIMSolverTS.h:271
virtual bool read(const char *file)
Reads solver data from the specified input file.
Definition: SIMSolverTS.h:50
bool dumpMesh(char *infile, bool done=true) const
Dumps the refined LR-mesh to file.
Definition: SIMSolverTS.h:251
virtual bool serialize(HDF5Restart::SerializeData &data)
Serialize internal state for restarting purposes.
Definition: SIMSolverTS.h:180
int preRef
Number of pre-refinement cycles.
Definition: SIMSolverTS.h:272
virtual bool parse(const tinyxml2::XMLElement *elem)
Parses a data section from an XML element.
Definition: SIMSolverTS.h:193
size_t nForward
Number of steps to advance on new mesh.
Definition: SIMSolverTS.h:268
size_t nPredict
Number of steps to use for prediction.
Definition: SIMSolverTS.h:269
double aStart
Time from where to check for mesh adaptation.
Definition: SIMSolverTS.h:276
char dumpGrid
Option for mesh output: 0=none, 1=last, 2=all.
Definition: SIMSolverTS.h:277
double beta
Percentage of elements to refine.
Definition: SIMSolverTS.h:275
SIMSolverTS(T1 &s1)
The constructor forwards to the parent class constructor.
Definition: SIMSolverTS.h:34
int lastRLev
Restart time level for last mesh refinement.
Definition: SIMSolverTS.h:278
double minFrac
Element-level refinement threshold.
Definition: SIMSolverTS.h:274
Template class for transient simulator drivers.
Definition: SIMSolver.h:123
bool advanceStep()
Advances the time step one step forward.
Definition: SIMSolver.h:144
TimeStep tp
Time stepping information.
Definition: SIMSolver.h:304
virtual bool serialize(HDF5Restart::SerializeData &data)
Serialize internal state for restarting purposes.
Definition: SIMSolver.h:196
bool saveState(int &geoBlk, int &nBlock, bool newMesh=false, char *infile=nullptr, bool saveRes=true)
Saves geometry and results to VTF and HDF5 for current time step.
Definition: SIMSolver.h:229
virtual bool parse(char *keyw, std::istream &is)
Parses a data section from an input stream.
Definition: SIMSolver.h:210
virtual bool read(const char *fileName)
Reads model data from the specified input file *fileName.
Definition: SIMadmin.C:68
int step
Time step counter.
Definition: TimeStep.h:72
bool reset(int istep=0)
Resets the time step to the specified step.
Definition: TimeStep.C:203
bool finished() const
Returns true if the end of the simulation has been reached.
Definition: TimeStep.C:331
TimeDomain time
Time domain data.
Definition: TimeStep.h:74
const char * getValue(const tinyxml2::XMLNode *xml, const char *tag)
Returns the value (if any) of the specified XML-node.
Definition: Utilities.C:319
int getAttribute(const tinyxml2::XMLElement *xml, const char *att, bool &val)
Extracts a boolean attribute value from the specified XML-element.
Definition: Utilities.C:188
double t
Current time (or pseudo time, load parameter)
Definition: TimeDomain.h:24