14 #ifndef _SIM_SOLVER_ADAP_H_
15 #define _SIM_SOLVER_ADAP_H_
26 template<
class T1,
bool SolutionTransfer = false>
36 bool adaptMesh(
int iStep, std::streamsize outPrec = 0)
38 if constexpr (SolutionTransfer) {
61 if constexpr (SolutionTransfer) {
69 if (
model.solveStep(dummy))
81 return model.savePoints(0.0,iStep);
95 template<
class T1,
class AdapSim>
102 this->
S1.setSol(&
aSim.getSolution());
103 this->
S1.opt.saveNorms =
true;
115 if (!
aSim.initAdaptor())
121 &
aSim.getProjections(),
124 for (
int iStep = 1;
aSim.adaptMesh(iStep); iStep++)
125 if (!
aSim.solveStep(infile,iStep))
127 else if (!
aSim.writeGlv(infile,iStep))
140 virtual bool parse(
char* kyw, std::istream& is) {
return aSim.parse(kyw,is); }
142 virtual bool parse(
const tinyxml2::XMLElement* elem) {
return aSim.parse(elem); }
175 if (!this->
S1.initAdapPrm())
178 int geoBlk = 0, nBlock = 0;
179 for (
int iStep = 1; this->
S1.adaptMesh(iStep); iStep++) {
180 IFEM::cout <<
"\nAdaptive step "<< iStep << std::endl;
181 if (!this->
S1.solveStep(infile,iStep))
183 else if (!this->
S1.projectNorms(iStep))
185 else if (!this->
saveState(geoBlk,nBlock,iStep,infile))
193 bool parse(
const tinyxml2::XMLElement* elem)
override
195 return this->
S1.parse(elem);
200 bool saveState(
int& geoBlk,
int& nBlock,
int iStep,
char* infile)
202 if (!this->
S1.saveModel(iStep == 1 ? infile :
nullptr,geoBlk,nBlock))
208 if (!this->
S1.saveElmNorms(iStep,nBlock))
211 if (!this->
S1.saveProjections(iStep,nBlock))
214 if (!this->
S1.saveStep(tp,nBlock))
Adaptive solution driver for linear static FEM simulators.
std::vector< Vector > Vectors
An array of real-valued vectors with algebraic operations.
Definition: MatVec.h:37
SIM solver class template.
Class for encapsulation of general time stepping parameters.
static const double T1[2]
1-point rule coordinates.
Definition: TriangleQuadrature.C:19
Adaptive simulator driver using the ISolver interface.
Definition: SIMSolverAdap.h:28
virtual void prepareSolutionTransfer()
Hook for preparation steps before solution transfer.
Definition: SIMSolverAdap.h:53
virtual void prepareAdapt()
Hook for preparation steps before mesh adaptation.
Definition: SIMSolverAdap.h:50
bool assembleAndSolveSystem() override
Assembles and solves the linearized FE equation system.
Definition: SIMSolverAdap.h:56
Vectors transfered
Transfered solutions.
Definition: SIMSolverAdap.h:85
bool savePoints(int iStep) const override
Saves point results to output file for a given refinement step.
Definition: SIMSolverAdap.h:79
T1 & model
Reference to the actual sim.
Definition: SIMSolverAdap.h:84
AdaptiveISolver(T1 &sim, bool sa)
The constructor forwards to the parent class constructor.
Definition: SIMSolverAdap.h:31
bool adaptMesh(int iStep, std::streamsize outPrec=0)
Refines the current mesh based on the element norms.
Definition: SIMSolverAdap.h:36
Adaptive solution driver for linear static FEM simulators.
Definition: AdaptiveSIM.h:28
Vectors solution
All solutions (including Galerkin projections)
Definition: AdaptiveSIM.h:112
bool adaptMesh(int iStep, std::streamsize outPrec=0)
Refines the current mesh based on the element norms.
Definition: AdaptiveSIM.C:197
bool dumpTimeLevel(const TimeStep *tp=nullptr, bool geoUpd=false, bool doLog=false)
Dumps all registered fields using the registered writers.
Definition: DataExporter.C:95
static utl::LogStream cout
Combined standard out for parallel processes.
Definition: IFEM.h:62
Template class for stationary adaptive simulator drivers.
Definition: SIMSolverAdap.h:97
virtual int solveProblem(char *infile, const char *=nullptr)
Solves the problem on a sequence of adaptively refined meshes.
Definition: SIMSolverAdap.h:113
SIMSolverAdapImpl(T1 &s1)
The constructor forwards to the parent class constructor.
Definition: SIMSolverAdap.h:100
virtual bool parse(const tinyxml2::XMLElement *elem)
Parses a data section from an XML element.
Definition: SIMSolverAdap.h:142
AdapSim aSim
Adaptive simulation driver.
Definition: SIMSolverAdap.h:144
void setExporterName(const std::string &name)
Set name of data exporter registration to use.
Definition: SIMSolverAdap.h:136
virtual ~SIMSolverAdapImpl()
Empty destructor.
Definition: SIMSolverAdap.h:107
std::string exporterName
Name for data exporter registration to use.
Definition: SIMSolverAdap.h:145
virtual bool read(const char *file)
Reads solver data from the specified input file.
Definition: SIMSolverAdap.h:110
virtual bool parse(char *kyw, std::istream &is)
Parses a data section from an input stream.
Definition: SIMSolverAdap.h:140
Template class for adaptive simulator drivers which handle adaptation internally.
Definition: SIMSolverAdap.h:161
virtual ~SIMSolverAdapInternal()
Empty destructor.
Definition: SIMSolverAdap.h:167
int solveProblem(char *infile, const char *=nullptr) override
Solves the problem on a sequence of adaptively refined meshes.
Definition: SIMSolverAdap.h:173
bool parse(const tinyxml2::XMLElement *elem) override
Parse an element from an XML input file.
Definition: SIMSolverAdap.h:193
bool read(const char *file) override
Reads solver data from the specified input file.
Definition: SIMSolverAdap.h:170
SIMSolverAdapInternal(T1 &s1)
The constructor forwards to the parent class constructor.
Definition: SIMSolverAdap.h:164
bool saveState(int &geoBlk, int &nBlock, int iStep, char *infile)
Saves geometry and results to VTF and HDF5 for current time step.
Definition: SIMSolverAdap.h:200
Template class for stationary simulator drivers.
Definition: SIMSolver.h:32
DataExporter * exporter
Administrator for result output to HDF5 file.
Definition: SIMSolver.h:111
T1 & S1
The actual solver.
Definition: SIMSolver.h:109
virtual bool read(const char *fileName)
Reads model data from the specified input file *fileName.
Definition: SIMadmin.C:68
Class for encapsulation of general time stepping parameters.
Definition: TimeStep.h:31
int step
Time step counter.
Definition: TimeStep.h:72