FemProcess
The GeMA Fem Process Plugin
Loading...
Searching...
No Matches
gmpFemNonLinearSolver.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
26#ifndef _GEMA_PLUGIN_FEM_NONLINEARSOLVER_H_
27#define _GEMA_PLUGIN_FEM_NONLINEARSOLVER_H_
28
29#include "gmpFemSolver.h"
30#include "gmpFemSolverOptions.h"
31
33class GmRunProgress;
34
36class GMP_FEM_PROCESS_API_EXPORT GmpFemNonLinearSolver : public GmpFemSolver
37{
38 friend class XfemSolver;
39public:
40 //constructor
42 const GmpFemSolverOptions&, const GmLogCategory&);
43
44 //destructor
45 virtual ~GmpFemNonLinearSolver();
46
48 {
49 bool _equilibrium = false;
50 bool _iter4new = false;
51 double _dt;
52 double _newdt = 0.0;
53 double _time;
54 double _tolmax = 0.0;
55 double _erMax = 0.0;
56 double _erMax1 = 1e6;
57 double _erMax2 = 1e6;
58 unsigned _iter = 0;
59 GmVector _erL;
60 solverState(unsigned ng, double dt, const double t)
61 :_erL(ng, arma::fill::zeros), _time(t), _dt(dt)
62 {}
63 };
64
65 void enableFastUpdate(bool mode) { _fastUpdate = mode; }
66
67 // initializing Fem NL Solver
68 virtual bool init();
69
70 virtual bool initResultAttributes(int fatherItemId);
71 bool initReport(GmRunProgressStats* ps);
72
73
74 //virtual bool step(double dt, double* newt);
75 virtual bool runStep(double dt, double* newt, bool* conv, double* err, int* niter, bool eval=false);
76 // Geostatic procedure
77 virtual bool geostatic(QString svId = "u", QString gaId = "Em");
78 // virtual check time step
79 virtual bool checkTimeStep(double dt);
80 // Initialize progress stats
81 void initializeProgress(solverState& sS, GmRunProgress& ps);
82
83protected:
84 virtual bool addStateItemsToGroup (GmStateDump* state, int groupId);
85 virtual bool fillStateControlMapData (QVariantMap* map);
86 virtual bool stateControlMapDataLoaded(QVariantMap* map);
88
90 virtual bool fillStateControlMapDataStaticSolver(QVariantMap* map);
92 virtual bool stateControlMapDataLoadedStaticSolver(QVariantMap* map);
94 virtual bool fillStateControlMapDataTransientSolver(QVariantMap* map);
96 virtual bool stateControlMapDataLoadedTransientSolver(QVariantMap* map);
97
98//private:
99 // general
100 virtual bool initElementSets(GmNumSolver*);
101 virtual void setElementSets(bool, bool, bool, bool, bool);
102
103 virtual bool prepareNonLinearSolverStep(solverState& sS, GmRunProgress& ps);
104
105 virtual bool assembleInitialSystem(const double&);
106 virtual bool solveInitialSystem(solverState& sS, GmRunProgress& ps);
107
108 virtual bool assembleIterationSystem(const double&);
109
110 virtual bool solveNewtonRaphson(GmRunProgress& ps, double& dt, const double& t, double* newt);
111
112 virtual bool applyTimeDiscretization() { return true; }
113
114 virtual bool applyFixedBoundaryConditions(int*);
115 virtual bool intialFixedBoundaryConditions(int*);
116 virtual bool applyNonzeroFixedBCsbyModification(int*);
117 virtual bool isTransient() const;
118 virtual bool isNonlinear() const;
119
121 virtual bool convergence() const;
122 virtual bool convergenceN (GmVector& erL, GmRunProgress* rp = NULL) const;
123 virtual bool convergenceDC(GmVector& er) const;
124 virtual void update();
125 virtual void restore();
126 //Corrector
127 //virtual bool corrector(GmVector& er, GmVector) const;
128
129 //Iterative Error
130 virtual bool loadError(GmVector& er)const;
131 virtual bool dispError(GmVector& er) const;
132 virtual bool velocityError(GmVector& er)const;
133 virtual bool fluxError(GmVector& er) const;
134 virtual bool fluxMagnitude(GmVector& qa) const;
135
137 virtual bool convergenceStep(unsigned& attempt, unsigned& incT, double, double);
139 virtual bool maxErr(GmVector, double& ermax, double &tolmax);
141 virtual bool maxVal(GmVector& array, const GmVector&) const;
143 virtual bool phygroupName(int & kgroup, QString var) const;
145 virtual bool divergingIncrement(unsigned iter, double tolmax, double ermax, double& ermax_1, double& ermax_2);
147 virtual bool adaptativeTimeAbqs(bool conv, unsigned iter, double dt, double& newdt, double errmax, unsigned inc, bool iter4);
149 virtual bool adaptativeTime(bool conv, int iter, double dt, double& newdt, double err, double tol);
151 virtual void saveInternalForceAttributes(GmVector& dv);
152
153 virtual void setLoad();
154 virtual void setTime();
155 virtual void setState();
157 virtual void setTransientSystem(double);
158
160 virtual bool getLinearSystem(double dt);
161 virtual bool getSystemRHSVector(double dt);
162 virtual bool getSystemResidualVector(double dt);
163 virtual bool solveLinearSystem();
164 bool applyDirichletBoundaryConditions();
165
167 virtual GmpFemPhysics::FemResultType updateResidualForceAndStiffnessMatrix(double l);
169 virtual GmpFemPhysics::FemResultType fillStiffnessMatrixBroyden();
170
171
173 virtual double evalLocalError(GmVector, GmVector);
174
176 virtual double evalTimeIncrementSize(unsigned, double, double, GmVector&);
177
178 // Solvers
179
180 //virtual bool staticSolver(double step, double* newt, bool* conv, double* err, int* niter, bool eval);
181 virtual bool transientSolver(double dt, double* newt, bool* conv, double* err, int* niter, bool eval);
182 virtual bool transientLocalSolver(double dt, double* newt, bool* conv, double* err, int* niter, bool eval);
183 virtual bool iterativeSolver(double dt, double* newt, bool* conv, double* err, int* niter, bool eval);
184
185 // To check
186 virtual bool stepStandardDc(double dt, double* newt, bool* conv, double* err, int* niter, bool eval);
187 //virtual bool stepTransientNonlinearAut(double dt, double* newt);
188
189 // atributtes
190 double _dl;
191 double _dl0;
192 double _ddl;
193 double _Lold;
194 double _tin;
195 // double _ts;
196 double _dt;
197 double _oldIter;
198 double _hlast;
199
200 // controls time incrementation
201 unsigned _attempt = 0;
202 unsigned _ninc = 0;
203 unsigned _incT = 0;
204 bool _iter4old = false;
205
206
207
208 GmVector _v;
209 GmVector _dx;
210 GmVector _dv;
211 GmVector _xold;
212 GmVector _vold;
213 GmVector _dxt;
214 GmVector _ddx;
215 GmVector _ddxt;
216 GmVector _ddxr;
217 GmVector _FeGs;
218 GmVector _r0;
219 // controls fluxe
222
223
224 QVector<int> _fixedDof;
225
226 bool _fastUpdate;
228
229
231 {
232 bool _geostatic = false; // Is this a geostatic step?
233 int _femItem = -1;
234 int _femNlItem = -1;
235 int _solverItem = -1;
236
237 int _incAttr = -1;
238 int _attemptAttr = -1;
239 int _convAttr = -1;
240 int _nlIterAttr = -1;
241 int _simTimeAttr = -1;
242 int _simStepAttr = -1;
243 int _solverCallsAttr = -1;
244
245 int _nlErrorAttr = -1;
246
247 int _solverFemExecTimeAttr = -1;
248 int _solverFemNumIterAttr = -1;
249 int _prepareExecTimeAttr = -1;
250 };
251
253
254};
255
256#endif
Basic class for solving Non linear FEM problems.
Definition gmpFemNonLinearSolver.h:37
bool _hasUnanamedDofs
Set to true if there are dofs that belong to the 'unnamed' group.
Definition gmpFemNonLinearSolver.h:227
GmVector _qtamax
The time-averaged value of the largest flux corresponding to the field αduring this step,...
Definition gmpFemNonLinearSolver.h:221
GmVector _qta
An overall time-averaged value of the typical flux for field α so far during this step including the ...
Definition gmpFemNonLinearSolver.h:220
TrackItemState _td
The "track data" object, controlling time & simulation progress tracking.
Definition gmpFemNonLinearSolver.h:252
FemResultType
Result type for local matrix calculation methods.
Definition gmpFemPhysics.h:50
Basic class for the FEM solving process.
Definition gmpFemSolver.h:52
virtual bool applyFixedBoundaryConditions(int *numFixed)
Apply Dirichlet (fixed) boundary conditions to the global equation system.
Definition gmpFemSolver.cpp:1791
virtual bool initResultAttributes(int fatherItemId)
Helper function used to register the set of result attributes managed by the fem solver.
Definition gmpFemSolver.cpp:487
virtual bool stateControlMapDataLoaded(QVariantMap *map)
Method called when the state dump control registered in addStateItemsToGroup() has been loaded.
Definition gmpFemSolver.cpp:2204
bool solveLinearSystem(bool xFilled)
Solves the linear system K.x = f taking K and f from the single equivalent matrix/vector or from matr...
Definition gmpFemSolver.cpp:872
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...
Definition gmpFemSolver.cpp:356
virtual bool stateLoadedCalcDerivedResultsNonLinear()
Returns the value of the "nonLinearSolver" parameter that will be passed to the calcDerivedResults() ...
Definition gmpFemSolver.h:102
virtual bool fillStateControlMapData(QVariantMap *map)
Method called for filling the state dump control registered in addStateItemsToGroup()
Definition gmpFemSolver.cpp:2183
virtual bool initElementSets(GmNumSolver *solver)
Helper function used to initialize the matrix / vector sets with the definition of the needed types a...
Definition gmpFemSolver.cpp:460
virtual bool init()
Prepares the solver for assembling matrices by creating the assembler object and allocating the neede...
Definition gmpFemSolver.cpp:138
virtual bool addStateItemsToGroup(GmStateDump *state, int groupId)
Adds to 'state' the data items that should be saved for this FEM process. Should probably be overridd...
Definition gmpFemSolver.cpp:2104
Definition gmpFemSolverOptions.h:39
arma::vec GmVector
Declaration of the GmpFemSolver class.
Declaration of the GmpFemSolverOptions class.
Definition gmpFemNonLinearSolver.h:231
Definition gmpFemNonLinearSolver.h:48
double _dt
Simulation time increment.
Definition gmpFemNonLinearSolver.h:51
double _time
Total simulation time.
Definition gmpFemNonLinearSolver.h:53