FemProcess
The GeMA Fem Process Plugin
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
GmpFemTransientSolver Class Reference

Basic class for solving a transient FEM problem. More...

#include <gmpFemTransientSolver.h>

Inheritance diagram for GmpFemTransientSolver:
Inheritance graph
[legend]
Collaboration diagram for GmpFemTransientSolver:
Collaboration graph
[legend]

Public Member Functions

 GmpFemTransientSolver (GmElementMesh *mesh, GmSimulationData *simulation, const QList< GmpFemPhysics * > &physics, GmNumSolver *solver, bool nonlinear, const GmpFemSolverOptions &options, const GmLogCategory &logger)
 Constructor. Expects to receive as parameters the mesh we are acting upon, the list of physics objects that will cooperate to create the global stiffness matrix and the solver used to solve the resulting linear system. More...
 
virtual ~GmpFemTransientSolver ()
 Destructor.
 
virtual bool init ()
 Prepares the solver for assembling matrices by creating the assembler object and allocating the needed memory. This operations only needs to be done once if the solver is used in a loop.
 
bool runStep (double dt, bool updateDof=false)
 Execute the process. Should be used by linear processes only. More...
 
bool runLinearStep (double dt, int iter, bool updateDof=false)
 Execute the process. Should be used by non linear processes only. More...
 
bool calcLinearResidual (double dt, double *rnorm, double *maxNodeDiff, double *avgNodeDiff)
 When solving a non linear system by repeated iterations, this function aims to calculate the residual of the actual solution. More...
 
bool nonlinear () const
 Returns true if the solver is non linear.
 
virtual bool addStateItemsToGroup (GmStateDump *state, int groupId)
 Adds to 'state' the data items that should be saved for this FEM process. Should probably be overriden by derived classes to add their own requirements. More...
 
- Public Member Functions inherited from GmpFemSolver
 GmpFemSolver (GmElementMesh *mesh, GmSimulationData *simulation, const QList< GmpFemPhysics * > &physics, GmNumSolver *solver, const GmpFemSolverOptions &options, const GmLogCategory &logger)
 Constructor. Expects to receive as parameters the mesh we are acting upon, the list of physics objects that will cooperate to create the global stiffness matrix and the solver used to solve the resulting linear system. More...
 
virtual ~GmpFemSolver (void)
 Destructor.
 
bool run ()
 Execute the process. Returns true on success.
 
bool calcLinearResidual (double *rnorm, double *maxNodeDiff, double *avgNodeDiff)
 When solving a non linear system by repeated iterations, this function aims to calculate the residual of the actual solution. More...
 
void setMatrixCombinerObject (const GmpFemAssemblerMatrixCombiner *combiner)
 Sets the combiner object that will be used by the assembler to merge elemental data from multiple matrices (eg. C and K) into an equivalent matrix. More...
 
void setVectorCombinerObject (const GmpFemAssemblerVectorCombiner *combiner)
 Sets the combiner objects that will be used by the assembler to merge elemental data from multiple vectors (eg. Fe and Fi) into an equivalent vector. More...
 
bool update (int mode, QString &err)
 Informs the solver of an external change in model dofs, elements or BCs that must be forwarded to the assembler. See the documentation of GmpFemAssembler::update() for more details.
 
virtual bool stateAboutToBeSaved (GmStateDump *state)
 
virtual bool stateSaved (GmStateDump *state)
 
virtual bool stateAboutToBeLoaded (GmStateDump *state)
 
virtual bool stateLoaded (GmStateDump *state)
 Informs physics objects that a load operation was completed giving them an opportunity to adjust its state in case the loaded data is not exactly what the internal state needs to be. It will also call derivedResults() so that previous results can be recovered. In that call, the nonLinearSolver parameter is obtained from the stateLoadedCalcDerivedResultsNonLinear() virtual function.
 
virtual bool fillStateControlMapData (QVariantMap *map)
 Method called for filling the state dump control regustered in addStateItemsToGroup()
 
virtual bool stateControlMapDataLoaded (QVariantMap *map)
 Method called when the state dump control registered in addStateItemsToGroup() has been loaded.
 
virtual bool stateLoadedCalcDerivedResultsNonLinear ()
 Returns the value of the "nonLinearSolver" parameter that will be passed to the calcDerivedResults() call from the standard implementation of stateLoaded()
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
virtual void * qt_metacast (const char *)
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 

Protected Member Functions

virtual bool initElementSets (GmNumSolver *solver)
 Reimplements GmpFemSolver::initElementSets() to include the C matrix in the set of calculated matrices by physics objects.
 
virtual bool cleanup ()
 Dealocates memory and sets allocated resources to NULL. As a convenience, returns false.
 
bool step (double dt, int iter, bool updateDof, bool updateBcs)
 
bool istep (double dt, int iter, bool updateDof, bool updateBcs)
 Worker function for both runStep() and runLinearStep()
 
bool estep (double dt, bool updateDof, bool updateBcs)
 
bool prepareLinearSystem (double dt)
 Fills the matrix K and the vector Fe with the linear system resulting from applying an implicit schema to the transient temperature equation. More...
 
bool prepareExplicitLinearSystem (double dt)
 
bool GuyanReductionSolve ()
 
- Protected Member Functions inherited from GmpFemSolver
bool initSolver (GmpFemAssembler::FixedDofMode assemblerMode, bool assemblerReverseMapping, bool enableFastUpdate)
 Basic implementation of the init function receiving as parameters the configuration options that are sent to the assembler. More...
 
virtual bool initResultAttributes (QString prefix)
 Helpper function used to register the set of result attributes managed by the fem solver. To avoid name clashes, all of them should prepend the given prefix (usually "fem") to the attribute name. More...
 
GmpFemPhysics::FemResultType prepareMatrices (bool skipFixedBcs=false)
 Auxilliary function used to fill the K, and f matrices / vectors along with any other matrices/vectors stored in _matSet and _vecSet. More...
 
GmpFemPhysics::FemResultType saveElementData (int iter)
 Auxilliary function used to save to the configured file data from the set of element matrices and vectors. In this process, physics are called again to fill element matrices and vectors (according to the active matrices and vectors in _vecSet and _matSet) but the results are NOT added to the global matrices.
 
bool solveLinearSystem (bool xFilled)
 Solves the linear system K.x = f taking K and f from the single equivalent matrix/vector or from matrix K / vector f, depending on the assembler configuration. Results are saved in _x. Prints the used matrices / result as configured in _printOptions. More...
 
double timeConvert (double val)
 Auxiliary function created for being used by derived classes that converts a time value given in the current simulation time unit and returns that value converted to the physics expected unit.
 
GmpFemPhysics::FemResultType traverseElements ()
 Fills the stiffness matrix _K and the force vector _f by traversing elements asking physics for the local element matrix / force vector. More...
 
GmpFemPhysics::FemResultType traverseBoundaryElements ()
 Simillar to traverseElements(), this function steps through each element that belongs to an edge or face boundary condition, asking physics for additional contributions to the stiffness matrix _K and the force vector _f.
 
GmpFemPhysics::FemResultType traverseExternalLoads ()
 Simillar to traverseElements(), this function steps through each element associated to an external load force, asking physics for additional contributions to the force vector _f.
 
GmpFemPhysics::FemResultType traverseContactBoundaries ()
 Simillar to traverseElements(), this function steps through each possible contact from the given contact boundary conditions and asks the physics for additional contributions to the solver matrices and vectors. This is different from the other element based loops since the returned matrices are not restricted to a single element, but can combine nodes from several ones.
 
GmpFemPhysics::FemResultType traverseElementsForSaving (FILE *f, int iter)
 Similar to traverseElements() but instead of adding the elements to the assembler, saves the element data to the given file. More...
 
GmpFemPhysics::FemResultType fillElementData (const GmElement *e, int physIndex)
 Helper function used by traverseElements() to get data for a single element calling phys->fillElementData()
 
GmpFemPhysics::FemResultType fillElementBoundaryData (const GmElement *e, int physIndex, const GmBoundaryCondition *bc, int bcIndex, int bcListIndex, int border, const GmCellBoundary *b)
 Helper function used by traverseBoundaryElements() to get data for a single element calling phys->fillElementDataForBc()
 
GmpFemPhysics::FemResultType fillContactData (GmMatrixDof &localDofMap, const GmContactBoundaryCondition *cbc, int physIndex, int index1, int index2)
 Helper function used by traverseContactBoundaries() to get data for a single contact pair calling phys->fillContactData()
 
bool addFixedForces ()
 Adds fixed nodal forces, as seen by each physics, to the global vector _f.
 
virtual bool applyFixedBoundaryConditions (int *numFixed)
 Apply Dirichlet (fixed) boundary conditions to the global equation system. More...
 
bool collectFixedBcs (QVector< bool > &fixedRows, QVector< double > &fixedValues, QList< int > &dofIndex)
 Fills the set of vectors received as parameters with the complete set of fixed boundary conditions, as seen by the full set of physics in use, checking for possible conflicts in conditions. More...
 
virtual void collectGlobalContactPairs (const GmContactBoundaryCondition *cbc, QList< QPair< int, int > > &contactPairs)
 Global search rule used to define contact surfaces. Should be implemented to allow global contact conditions, filling contactPairs with the indices in cbc of the in-contact surfaces.
 
void printElementData (const GmElement *e, int ndof, const int *dofMapping, const GmpFemPhysics *p, const GmBoundaryCondition *bc=NULL, const GmContactBoundaryCondition *cbc=NULL, int loadId1=-1, int id2=-1)
 Print element dof mapping, local matrices and vectors depending on the current solver print options. More...
 
void printGlobalData (bool linear)
 Print global matrices and vectors, either after assembling or before solving the linear system.
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Private Attributes

bool _implicit
 Is this a implicit or explicit scheme ?
 
bool _nonlinear
 Is this a non linear problem ?
 
GmVector _oldx
 Previous state of the x vector used for non linear problems;.
 

Additional Inherited Members

- Public Types inherited from GmpFemSolver
enum  PrintOptions {
  PRINT_ELEMENT_MATRICES = 0x001, PRINT_ELEMENT_VECTORS = 0x002, PRINT_ELEMENT_DOF_MAPPING = 0x004, PRINT_EQ_MATRIX = 0x008,
  PRINT_EQ_VECTOR = 0x010, PRINT_GLOBAL_MATRICES = 0x020, PRINT_GLOBAL_VECTORS = 0x040, PRINT_LINEAR_MATRIX = 0x080,
  PRINT_LINEAR_VECTOR = 0x100, PRINT_LINEAR_RESULT = 0x200
}
 Flag options used to compose the printOptions constructor parameter. More...
 
- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Protected Types inherited from GmpFemSolver
enum  DisabledWarnings {
  PrescribedForceForInvalidDof, PrescribedForceForFixedDof, FixedBcForInvalidDof, ConflictingFixedBcValue,
  NumDisabledWarnings
}
 Enums describing the set of warnings that can be disabled by simulation options. More...
 
- Protected Slots inherited from GmpFemSolver
virtual void meshChanged ()
 Slot called when the underlying mesh has been changed. More...
 
- Protected Attributes inherited from GmpFemSolver
int _solverId
 A unique index for this solver object used by the result attribute auto prefix feature.
 
GmElementMesh_mesh
 Mesh with the nodes and cells data.
 
GmSimulationData_simulation
 Simulation Data.
 
QList< GmpFemPhysics * > _physicsList
 List of physics that will cooperate to generate the system response.
 
GmNumSolver_solver
 Numeric solver that will be used to solve the set of linear equations.
 
const GmLogCategory_logger
 Logger for eventual messages.
 
QMutex _printMutex
 Mutex for serializing calls to printElementData when traversing elements in parallel.
 
bool _enabledWarn [NumDisabledWarnings]
 Vector storing which warnings are enabled.
 
GmpFemSolverOptions _solverOptions
 The set of solver options.
 
UnitConverter_timeConv
 Unit converter from the currentTimeUnit to the physics unit. Used only by derived solvers.
 
GmpFemAssembler_assembler
 Assembler used for adding element contributions to vectors and matrices.
 
const GmpFemAssemblerMatrixCombiner_matCombiner
 The combiner object used with the assembler to merge data from multiple elemental matrices.
 
const GmpFemAssemblerVectorCombiner_vecCombiner
 The combiner object used with the assembler to merge data from multiple elemental vectors.
 
GmpFemVectorSet _vecSet
 Set of global/element vectors filled by physics.
 
GmpFemMatrixSet _matSet
 Set of global/element matrices filled by physics.
 
GmVector _x
 State vector.
 
GmVector _r
 Residual vector.
 
unsigned _preCount
 Number of times that prepareMatrices() was called.
 
unsigned _runCount
 Number of times that run() was called.
 
QVariantMap _controlMap
 Variant map used for storing dump control data for the solver.
 
int _iterResAttr
 The registered id for the "fem.iter" result attribute.
 
int _iterResErrAttr
 The registered id for the "fem.iterErr" result attribute.
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Basic class for solving a transient FEM problem.

Constructor & Destructor Documentation

◆ GmpFemTransientSolver()

GmpFemTransientSolver::GmpFemTransientSolver ( GmElementMesh mesh,
GmSimulationData simulation,
const QList< GmpFemPhysics * > &  physics,
GmNumSolver solver,
bool  nonlinear,
const GmpFemSolverOptions options,
const GmLogCategory logger 
)

Constructor. Expects to receive as parameters the mesh we are acting upon, the list of physics objects that will cooperate to create the global stiffness matrix and the solver used to solve the resulting linear system.

The nonlinear parameter should be set to true if the problem is non linear and will be solved by multiple calls to runLinearStep().

The options parameter contains the set of parameters sent to the solver.

Member Function Documentation

◆ addStateItemsToGroup()

bool GmpFemTransientSolver::addStateItemsToGroup ( GmStateDump state,
int  groupId 
)
virtual

Adds to 'state' the data items that should be saved for this FEM process. Should probably be overriden by derived classes to add their own requirements.

Auxiliar variant map dump item that notifies us for loading and saving data to the map

< Our "father" solver object

Reimplemented from GmpFemSolver.

◆ calcLinearResidual()

bool GmpFemTransientSolver::calcLinearResidual ( double  dt,
double *  rnorm,
double *  maxNodeDiff,
double *  avgNodeDiff 
)

When solving a non linear system by repeated iterations, this function aims to calculate the residual of the actual solution.

Consider a model K(x).x = f and an initial state x0, the model can be iterated so that we have K1 = K(x0), x1 = inv(K1).f, K2 = K(x1), ... More generally, we have Ki = K(xi-1), xi = inv(Ki).f.

With that model, our residual vector ri will be equal to K(xi).xi - f and the returned values: rnorm: The level two norm of the vector ri, ||ri|| maxNodeDiff: The maximum value of each entry in ri (makes sense only if all dof are comparable). Calculated only if maxNodeDiff != NULL. avgNodeDiff: The average value of each entry in ri (makes sense only if all dof are comparable) Calculated only if avgNodeDiff != NULL.

IMPORTANT: Keep in mind that this function expects to find in _x the result of the last call to runLinearStep() and will by itself fill a new version of _K and _f, calculated based on this new value of _x.

The function returns false on errors (while evaluating K(x)).

◆ prepareExplicitLinearSystem()

bool GmpFemTransientSolver::prepareExplicitLinearSystem ( double  dt)
protected

An auxiliar class used by the assembler for to construct two Global Matrix C and K. (Explicit Methods)

Constructor. Automatically register the combiner on the solver

Enable localMatricesToGlobalVectorContribution() storing returned values in the equivalent global vector

An auxiliar combiner class used for multiplying local vector values by dt.

Destructor. Automatically removes the combiner from the solver

The dt * f_n+1 term

◆ prepareLinearSystem()

bool GmpFemTransientSolver::prepareLinearSystem ( double  dt)
protected

Fills the matrix K and the vector Fe with the linear system resulting from applying an implicit schema to the transient temperature equation.

Implicit schema: (C + dt*K) * x_n+1 = C * x_n + dt * f_n+1 |-—K-—| |-x-| |------—Fe-----—|

If the solver is non linear, uses _oldx instead of _x for the x_n vector

An auxiliar class for combining data from matrices C and K into an equivalent matrix that will be used by the assembler

Constructor. Automatically registers the combiner on the solver

Destructor. Automatically removes the combiner from the solver

The C + dt * K term

Enable localMatricesToGlobalVectorContribution() storing returned values in the equivalent global vector

The C * x_n term

An auxiliar combiner class used for multiplying local vector values by dt.

Constructor. Automatically registers the combiner on the solver

Destructor. Automatically removes the combiner from the solver

The dt * f_n+1 term

◆ runLinearStep()

bool GmpFemTransientSolver::runLinearStep ( double  dt,
int  iter,
bool  updateDof = false 
)

Execute the process. Should be used by non linear processes only.

Important: This function does not update the current simulation time since this should be done only after the last step iteration.

Parameters
dtThe interval that we are going forward in time, in the unit specified by the current time unit. Will be converted to the unit expected by physics.
iterThe number of the nonlinear iteration (1 for the first one)
updateDofIf true means that we need to reload the _x vector from the state vars. This might be needed in rare occasions if the values where changed externally.
Returns
Returns true on success, false on errors.

◆ runStep()

bool GmpFemTransientSolver::runStep ( double  dt,
bool  updateDof = false 
)

Execute the process. Should be used by linear processes only.

Important: This function does not update the current simulation time so that its behaviour is compatible with runLinearStep()

Parameters
dtThe interval that we are going forward in time, in the unit specified by the current time unit. Will be converted to the unit expected by physics.
updateDofIf true means that we need to reload the _x vector from the state vars. This might be needed in rare occasions if the values where changed externally.
Returns
Returns true on success, false on errors.

The documentation for this class was generated from the following files: