1 #ifndef INMOST_MODEL_INCLUDED
2 #define INMOST_MODEL_INCLUDED
4 #include "inmost_common.h"
5 #include "inmost_autodiff.h"
6 #include "inmost_residual.h"
7 #include "inmost_operator.h"
9 #if defined(USE_AUTODIFF) && defined(USE_MESH) && defined(USE_SOLVER)
15 class AbstractOperator;
105 virtual bool SetTime(
double t) {
return true; }
140 virtual bool SetTime(
double t) {
return true; }
175 virtual bool SetTime(
double t) {
return true; }
189 std::vector< std::pair<std::string, AbstractSubModel *> > SubModels;
190 std::vector< std::pair<std::string, AbstractEntry *> > Entries;
191 std::vector< std::pair<std::string, Mesh *> > Meshes;
192 std::map< AbstractSubModel*, std::vector< std::pair<std::string, AbstractCouplingTerm*> > > CouplingTerms;
194 std::vector< std::pair<std::string, AbstractScalarFunction*> > ScalarFunctions;
195 std::vector< std::pair<std::string, AbstractMatrixFunction*> > MatrixFunctions;
196 std::vector< std::pair<std::string, AbstractOperator *> > Operators;
197 std::map< std::string, bool> activeEntries, activeSubModels;
208 void ActivateSubModel(std::string name) { activeSubModels[name] =
true; }
209 void DeactivateSubModel(std::string name) { activeSubModels[name] =
false; }
210 void ToggleEntryState();
211 void ActivateEntry(std::string name) { activeEntries[name] =
true; }
212 void DeactivateEntry(std::string name) { activeEntries[name] =
false; }
363 void ReportErrors(
const Residual & R)
const;
364 void PrepareOutput();
A class to manage residual fill-in of the coupling between models.
virtual bool SetTime(double t)
Provide current time.
virtual bool RestoreTimeStep()
Roll back to previous step.
virtual bool Initialize(Model &P)=0
Initialize coupling and dependent unknowns.
virtual bool SetTimeStep(double dt)
Provide time step.
virtual bool FillResidual(Residual &R) const =0
Fill part of the residual related to my unknowns.
virtual bool PrepareIterations()
This functions might be not necessary:
virtual bool SetupCoupling(Model &P)
Setup coupling with unknowns of otheer models.
virtual double AdjustTimeStep(double dt) const
Calculate time step for this model. Can simply return dt.
virtual double UpdateMultiplier(const Sparse::Vector &sol) const
Calculate multiplier for update for this model. Can simply return 1.
virtual bool UpdateTimeStep()
Update time step.
This class is used to organize unknowns in abstract way, it should be registered with and managed by ...
This can be used to abstract implementation of particular matrix functions, that depend on mesh data ...
virtual bool SetupCoupling(Model &P)
Setup coupling with unknowns of otheer models.
virtual bool RestoreTimeStep()
Roll back to previous step.
virtual bool PrepareIterations()
This functions might be not necessary:
virtual double AdjustTimeStep(double dt) const
Calculate time step for this model. Can simply return dt.
virtual bool UpdateTimeStep()
Update time step.
virtual bool Initialize(Model &P)=0
Initialize coupling and dependent unknowns.
virtual vMatrix Evaluate(const Storage &e) const =0
The main function provided by operator.
virtual double UpdateMultiplier(const Sparse::Vector &sol) const
Calculate multiplier for update for this function. Can simply return 1.
virtual bool SetTime(double t)
Provide current time.
virtual bool SetTimeStep(double dt)
Provide time step.
This class is responsible to unite access to various point-wise implementations of discrete operators...
This can be used to abstract implementation of particular scalar functions, that depend on mesh data ...
virtual double UpdateMultiplier(const Sparse::Vector &sol) const
Calculate multiplier for update for this function. Can simply return 1.
virtual bool SetTimeStep(double dt)
Provide time step.
virtual bool SetupCoupling(Model &P)
Setup coupling with unknowns of otheer models.
virtual bool UpdateTimeStep()
Update time step.
virtual double AdjustTimeStep(double dt) const
Calculate time step for this model. Can simply return dt.
virtual bool PrepareIterations()
This functions might be not necessary:
virtual variable Evaluate(const Storage &e) const =0
The main function provided by operator.
virtual bool Initialize(Model &P)=0
Initialize coupling and dependent unknowns.
virtual bool SetTime(double t)
Provide current time.
virtual bool RestoreTimeStep()
Roll back to previous step.
A class to manage a submodel within a model.
virtual double AdjustTimeStep(double dt) const
Calculate time step for this model. Can simply return dt.
virtual bool PrepareIterations()
Initialize data needed for FillResidual.
virtual bool FillResidual(Residual &R) const =0
Fill part of the residual related to my unknowns.
virtual bool SetTimeStep(double dt)=0
Provide time step.
virtual bool RestoreTimeStep()=0
Roll back to previous step.
virtual void PrepareOutput()
Prepare submodel data for output.
virtual void FinishOutput()
Remove submodel data for output.
virtual bool SetTime(double t)=0
Provide current time.
virtual bool Initialize(Model &P)=0
Initialize coupling and dependent unknowns.
virtual bool UpdateSolution(const Sparse::Vector &sol, double alpha)=0
Update solution.
virtual double UpdateMultiplier(const Sparse::Vector &sol) const
Calculate multiplier for update for this model. Can simply return 1.
virtual bool UpdateTimeStep()=0
Update time step.
virtual bool PrepareEntries(Model &P)=0
Let the submodel introduce its unknowns.
virtual bool SetupCoupling(Model &P)
Setup coupling with unknowns of other models.
The Automatizator class helps in defining primary unknowns of the model and enhances user experience ...
void SynchronizeData()
Update variables contained in all block of automatizator on ghost elements of the grid.
Class for linear algebra operations on dense matrices.
A class to organize a model.
AbstractScalarFunction * GetScalarFunction(std::string name)
Retrieve a scalar function of the model by name.
bool PrepareIterations()
Initialize data needed for FillResidual.
const AbstractCouplingTerm * GetCouplingTerm(std::string submodel, std::string name) const
Retrieve a coupling term of the model by name.
double AdjustTimeStep(double dt) const
Calculate optimal time step for submodels.
std::vector< std::string > GetScalarFunctionNames() const
Retrieve all names of scalar functions.
bool SetTime(double t)
Provide current time.
void AddFirstEntry(std::string name, AbstractEntry &entry)
Add an entry of block unknowns to a model as a first entry.
std::vector< std::string > GetOperatorsNames() const
Retrieve all names of operators.
bool UpdateTimeStep()
Move to the next time step.
void AddMatrixFunction(std::string name, AbstractMatrixFunction &func)
Add matrix coupling function to a model.
const Mesh * GetMesh(std::string) const
Retrieve a mesh by name.
void AddMesh(std::string name, Mesh &m)
Add a mesh to a model.
void AddOperator(std::string name, AbstractOperator &op)
Add an operator to a model.
std::string GetSubModelName(const AbstractSubModel *model) const
Retrieve the name by submodel address.
bool SetTimeStep(double dt)
Provide new time step.
AbstractSubModel * GetSubModel(std::string name)
Retrieve a submodel of the model by name.
AbstractEntry * GetEntry(std::string name)
Retrieve an entry that describe unknowns of the model by name.
std::vector< std::string > GetMatrixFunctionNames() const
Retrieve all names of matrix functions.
std::vector< std::string > GetMeshesNames() const
Retrieve all names of meshes.
const AbstractScalarFunction * GetScalarFunction(std::string name) const
Retrieve a scalar function of the model by name.
bool isInitialized() const
Check if the model was initialized.
AbstractMatrixFunction * GetMatrixFunction(std::string name)
Retrieve a matrix functon of the model by name.
const AbstractMatrixFunction * GetMatrixFunction(std::string name) const
Retrieve a matrix function of the model by name.
std::vector< std::string > GetEntriesNames() const
Retrieve all names of entries.
bool PrepareEntries()
Each submodel introduces its unknowns into the model so that later it can be accessed.
bool Initialize()
Initialize all entries and submodels.
void AddAfterEntry(std::string name, AbstractEntry &entry, std::string after)
Add an entry of block unknowns to a model after an entry with certain name.
bool RestoreTimeStep()
Roll back to previous time step.
Mesh * GetMesh(std::string)
Retrieve a mesh by name.
void AddScalarFunction(std::string name, AbstractScalarFunction &func)
Add scalar coupling function to a model.
Automatizator & GetAutomatizator()
Retrieve an automatizator.
void AddCouplingTerm(std::string submodel, std::string name, AbstractCouplingTerm &term)
Add coupling term to a submodel.
AbstractCouplingTerm * GetCouplingTerm(std::string submodel, std::string name)
Retrieve a coupling term of the model by name.
void SynchronizeData()
Update variables contained in all block of automatizator on ghost elements of the grid.
const AbstractOperator * GetOperator(std::string name) const
Retrieve an operator of the model by name.
bool areEntriesSet() const
Check if the entries were set.
std::vector< std::pair< std::string, std::vector< std::string > > > GetCouplingTermNames() const
Retrieve all names of coupling terms.
bool UpdateSolution(const Sparse::Vector &sol, double alpha)
Update solution.
const Automatizator & GetAutomatizator() const
Retrieve an automatizator.
std::vector< std::string > GetSubModelsNames() const
Retrieve all names of submodules.
void AddSubModel(std::string name, AbstractSubModel &submodel)
Add a submodel to a model.
void AddEntry(std::string name, AbstractEntry &entry)
Add an entry of block unknowns to a model.
bool FillResidual(Residual &R) const
Compute the residual of the model.
bool SetupCoupling()
Link to all couplings after PrepareEntries and Initialize.
const AbstractSubModel * GetSubModel(std::string name) const
Retrieve a submodel of the model by name.
double UpdateMultiplier(const Sparse::Vector &sol) const
Calculate multiplier for update.
AbstractOperator * GetOperator(std::string name)
Retrieve an operator of the model by name.
const AbstractEntry * GetEntry(std::string name) const
Retrieve an entry that describe unknowns of the model by name.
The Residual class provides a representation for array of residuals of nonlinear equations.
Distributed vector class.
Base class for Mesh, Element, and ElementSet classes.
A class that represents a variable with multiple first order variations.