FemProcess
The GeMA Fem Process Plugin
Loading...
Searching...
No Matches
gmpFemSolver.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
24#ifndef _GEMA_PLUGIN_FEM_SOLVER_H_
25#define _GEMA_PLUGIN_FEM_SOLVER_H_
26
27#include <gmElementMesh.h>
28#include <gmElement.h>
29
30#include "gmpFemMatrixSet.h"
31#include "gmpFemVectorSet.h"
32#include "gmpFemProcessConfig.h"
33#include "gmpFemSolverOptions.h"
34#include "gmpFemAssembler.h"
35#include "gmpFemPhysics.h"
36
37class GmNumSolver;
39class GmLogCategory;
40class GmSolverMatrix;
42class GmCellBoundary;
43class GmMatrixDof;
44
45class GmpFemAssembler;
48
49
51class GMP_FEM_PROCESS_API_EXPORT GmpFemSolver : public QObject, public GmGroupDumpItem
52{
53 friend class XfemSolver;
54 Q_OBJECT
55
56public:
57
58 GmpFemSolver(GmElementMesh* mesh, GmSimulationData* simulation, const QVector<GmpFemPhysics*>& physics,
59 GmNumSolver* solver, const GmpFemSolverOptions& options, const GmLogCategory& logger);
60 virtual ~GmpFemSolver(void);
61
62 virtual bool init();
63 bool run();
64
65 bool calcLinearResidual(double* rnorm, double* maxNodeDiff, double* avgNodeDiff);
66
75 void setMatrixCombinerObject(const GmpFemAssemblerMatrixCombiner* combiner) { _matCombiner = combiner; }
76
85 void setVectorCombinerObject(const GmpFemAssemblerVectorCombiner* combiner) { _vecCombiner = combiner; }
86
87 bool update(int mode, QString& err);
88
89 virtual bool addStateItemsToGroup(GmStateDump* state, int groupId);
90 virtual bool stateAboutToBeSaved (GmStateDump* state);
91 virtual bool stateSaved (GmStateDump* state);
92 virtual bool stateAboutToBeLoaded(GmStateDump* state);
93 virtual bool stateLoaded (GmStateDump* state);
94
95 virtual bool fillStateControlMapData (QVariantMap* map);
96 virtual bool stateControlMapDataLoaded(QVariantMap* map);
97
102 virtual bool stateLoadedCalcDerivedResultsNonLinear() { return false; }
103
104private:
106
107protected slots :
108 virtual void meshChanged();
109
110protected:
111
123
124 bool initSolver(GmpFemAssembler::FixedDofMode assemblerMode, bool assemblerReverseMapping, bool enableFastUpdate);
125
126 virtual bool initElementSets(GmNumSolver* solver);
127 virtual bool initResultAttributes(int fatherItemId);
128 virtual void intLinearSolverPrintOptions();
129 virtual bool cleanup();
130
131 GmpFemPhysics::FemResultType prepareMatrices(bool skipFixedBcs = false);
132 GmpFemPhysics::FemResultType saveElementData(int iter);
133 bool solveLinearSystem(bool xFilled);
134
135 double timeConvert(double val);
136
137 GmpFemPhysics::FemResultType traverseElements();
138 GmpFemPhysics::FemResultType traverseBoundaryElements();
139 GmpFemPhysics::FemResultType traverseExternalLoads();
140 GmpFemPhysics::FemResultType traverseContactBoundaries();
141 GmpFemPhysics::FemResultType traverseElementsForSaving(FILE* f, int iter);
142
143 GmpFemPhysics::FemResultType fillElementData (const GmElement* e, int physIndex);
144 GmpFemPhysics::FemResultType fillElementBoundaryData(const GmElement* e, int physIndex, const GmBoundaryCondition* bc,
145 int bcIndex, int bcListIndex, int border, const GmCellBoundary* b);
146 GmpFemPhysics::FemResultType fillElementDataForLoads(const GmElement* e, int physIndex, int loadIndex);
147 GmpFemPhysics::FemResultType fillContactData(GmMatrixDof& localDofMap, const GmContactBoundaryCondition* cbc, int physIndex, int index1, int index2);
148
149 bool addFixedForces();
150 virtual bool applyFixedBoundaryConditions(int* numFixed);
151
152 bool collectFixedBcs(QVector<bool>& fixedRows, QVector<double>& fixedValues, QVector<int>& dofIndex);
153 virtual void collectGlobalContactPairs(const GmContactBoundaryCondition* cbc, QVector<QPair<int, int> >& contactPairs);
154
155 void printElementData(const GmElement* e, int ndof, const int* dofMapping, const GmpFemPhysics* p,
156 const GmBoundaryCondition* bc = NULL, const GmContactBoundaryCondition* cbc = NULL,
157 int loadId1 = -1, int id2 = -1);
158 void printGlobalData ();
159
167
168 bool _enabledWarn[NumDisabledWarnings];
169
171
173
177
182
183 unsigned _preCount;
184 unsigned _runCount;
185
186 QVariantMap _controlMap;
187
189 int _ntasks;
190 int _nworkers;
192
193 int _iterAttr = -1;
194 int _iterErrAttr = -1;
195
196 int _femItem = -1;
197 int _prepareItem = -1;
198 int _physicsItem = -1;
199 int _fixedBcItem = -1;
200 int _fixedForcesItem = -1;
201 int _assemblerItem = -1;
202 int _physicsBeforeLoopItem = -1;
203 int _physicsfillElemDataItem = -1;
204 int _physicsfillElemDataBcItem = -1;
205 int _physicsfillElemDataExtLoadsItem = -1;
206 int _physicsfillContactDataItem = -1;
207 int _physicsAfterLoopItem = -1;
208 int _assemblerBeginItem = -1;
209 int _assemblerAddItem = -1;
210 int _assemblerEndItem = -1;
211 int _assemblerT1Item = -1;
212 int _assemblerT2Item = -1;
213 int _assemblerT3Item = -1;
214 int _assemblerT4Item = -1;
215};
216
217#endif
virtual bool stateAboutToBeSaved(GmStateDump *state)
virtual bool stateSaved(GmStateDump *state)
virtual bool addStateItemsToGroup(GmStateDump *state, int groupId)=0
virtual bool stateLoaded(GmStateDump *state)
virtual bool stateAboutToBeLoaded(GmStateDump *state)
A class responsible for assembling the global stiffness matrix, handling multiple physics with possib...
Definition gmpFemAssembler.h:63
FixedDofMode
Definition gmpFemAssembler.h:67
Basic interface for defining the rules used to combine information from multiple matrices into a sing...
Definition gmpFemAssemblerCombiner.h:34
Basic interface for defining the rules used to combine information from multiple vectors into a singl...
Definition gmpFemAssemblerCombiner.h:103
A convenience class that builds a GmMatrixSet with the types given by GmpFemMatrixTypes and also asso...
Definition gmpFemMatrixSet.h:59
Base interface class for FEM Physics type plugins.
Definition gmpFemPhysics.h:45
FemResultType
Result type for local matrix calculation methods.
Definition gmpFemPhysics.h:50
Basic class for the FEM solving process.
Definition gmpFemSolver.h:52
const GmLogCategory & _logger
Logger for eventual messages.
Definition gmpFemSolver.h:165
void setVectorCombinerObject(const GmpFemAssemblerVectorCombiner *combiner)
Sets the combiner objects that will be used by the assembler to merge elemental data from multiple ve...
Definition gmpFemSolver.h:85
void setMatrixCombinerObject(const GmpFemAssemblerMatrixCombiner *combiner)
Sets the combiner object that will be used by the assembler to merge elemental data from multiple mat...
Definition gmpFemSolver.h:75
bool _parallelAssembler
Can we do the assembling steps in parallel?
Definition gmpFemSolver.h:188
QVector< GmpFemPhysics * > _physicsList
List of physics that will cooperate to generate the system response.
Definition gmpFemSolver.h:163
GmElementMesh * _mesh
Mesh with the nodes and cells data.
Definition gmpFemSolver.h:161
GmpFemSolverOptions _solverOptions
The set of solver options.
Definition gmpFemSolver.h:170
QVariantMap _controlMap
Variant map used for storing dump control data for the solver.
Definition gmpFemSolver.h:186
DisabledWarnings
Enums describing the set of warnings that can be disabled by simulation options.
Definition gmpFemSolver.h:114
@ NumDisabledWarnings
The number of entries above.
Definition gmpFemSolver.h:121
@ PrescribedForceForFixedDof
Prescribed force over a fixed BC Dof warning at addFixedForces()
Definition gmpFemSolver.h:116
@ FixedBcForInvalidDof
Fixed BC specified over an invalid Dof warning at collectFixedBcs()
Definition gmpFemSolver.h:117
@ ConflictingFixedBcValue
Different fixed BC values specified for a single Dof at collectFixedBcs()
Definition gmpFemSolver.h:118
@ PrescribedForceForInvalidDof
Prescribed force over an invalid Dof warning at addFixedForces()
Definition gmpFemSolver.h:115
const GmpFemAssemblerVectorCombiner * _vecCombiner
The combiner object used with the assembler to merge data from multiple elemental vectors.
Definition gmpFemSolver.h:176
unsigned _preCount
Number of times that prepareMatrices() was called.
Definition gmpFemSolver.h:183
virtual bool stateLoadedCalcDerivedResultsNonLinear()
Returns the value of the "nonLinearSolver" parameter that will be passed to the calcDerivedResults() ...
Definition gmpFemSolver.h:102
int _solverId
A unique index for this solver object used by the result attribute auto prefix feature.
Definition gmpFemSolver.h:160
UnitConverter * _timeConv
Unit converter from the currentTimeUnit to the physics unit. Used only by derived solvers.
Definition gmpFemSolver.h:172
const GmpFemAssemblerMatrixCombiner * _matCombiner
The combiner object used with the assembler to merge data from multiple elemental matrices.
Definition gmpFemSolver.h:175
GmVector _x
State vector.
Definition gmpFemSolver.h:180
GmVector _r
Residual vector.
Definition gmpFemSolver.h:181
GmpFemVectorSet _vecSet
Set of global/element vectors filled by physics.
Definition gmpFemSolver.h:178
unsigned _runCount
Number of times that run() was called.
Definition gmpFemSolver.h:184
GmSimulationData * _simulation
Simulation Data.
Definition gmpFemSolver.h:162
GmpFemAssembler * _assembler
Assembler used for adding element contributions to vectors and matrices.
Definition gmpFemSolver.h:174
QMutex _printMutex
Mutex for serializing calls to printElementData when traversing elements in parallel.
Definition gmpFemSolver.h:166
GmNumSolverPrinter * _solver
Wrapper over the numeric solver that will be used to solve the set of linear equations.
Definition gmpFemSolver.h:164
GmpFemMatrixSet _matSet
Set of global/element matrices filled by physics.
Definition gmpFemSolver.h:179
Definition gmpFemSolverOptions.h:39
A convenience class that builds a GmVectorSet with the types given by GmpFemVectorTypes and also asso...
Definition gmpFemVectorSet.h:50
arma::vec GmVector
Declaration of the GmpFemAssembler class.
Declaration of the GmpFemMatrixSet class.
Declaration of the GmpFemPhysics interface class.
Declaration of useful configuration definitions for the plugin library.
Declaration of the GmpFemSolverOptions class.
Declaration of the GmpFemVectorSet class.
Q_DISABLE_COPY(Class)