OOFEM 3.0
Loading...
Searching...
No Matches
mpmsemodels.h
Go to the documentation of this file.
1/*
2 *
3 * ##### ##### ###### ###### ### ###
4 * ## ## ## ## ## ## ## ### ##
5 * ## ## ## ## #### #### ## # ##
6 * ## ## ## ## ## ## ## ##
7 * ## ## ## ## ## ## ## ##
8 * ##### ##### ## ###### ## ##
9 *
10 *
11 * OOFEM : Object Oriented Finite Element Code
12 *
13 * Copyright (C) 1993 - 2025 Borek Patzak
14 *
15 *
16 *
17 * Czech Technical University, Faculty of Civil Engineering,
18 * Department of Structural Mechanics, 166 29 Prague, Czech Republic
19 *
20 * This library is free software; you can redistribute it and/or
21 * modify it under the terms of the GNU Lesser General Public
22 * License as published by the Free Software Foundation; either
23 * version 2.1 of the License, or (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
28 * Lesser General Public License for more details.
29 *
30 * You should have received a copy of the GNU Lesser General Public
31 * License along with this library; if not, write to the Free Software
32 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
33 */
34
35#ifndef mpmsemodels_h
36#define mpmsemodels_h
37
38#include "engngm.h"
39#include "sparselinsystemnm.h"
41#include "sparsemtrx.h"
42#include "primaryfield.h"
43#include "function.h"
46#include "integral.h"
47#include "nrsolver.h"
48#include "connectivitytable.h"
49
50#define _IFT_StationaryMPMSProblem_Name "mpmsymbolicstationaryproblem"
51
52
53namespace oofem {
54
56 {
57 protected:
58
62 std :: unique_ptr< PrimaryField > unknownsField;
63
64 std :: unique_ptr< SparseMtrx > effectiveMatrix;
68
70 std::unique_ptr<SparseNonLinearSystemNM> nMethod;
71
72 bool keepTangent = false;
73
74 // list of integrals contributing to lhs and rhs
77
78 public:
79 StationaryMPMSProblem(int i, EngngModel * _master) : EngngModel(i, _master), nMethod(nullptr) { ndomains = 1;}
80
81 void initializeFrom(InputRecord &ir) override {
83 IR_GIVE_FIELD(ir, lhsIntegrals, "lhsterms");
84 IR_GIVE_FIELD(ir, rhsIntegrals, "rhsterms");
85 if ( !unknownsField ) {
86 //unknownsField = std::make_unique<DofDistributedPrimaryField>(this, 1, FT_Unknown, 0);
87 unknownsField = std::make_unique<PrimaryField>(this, 1, FT_Unknown, 0);
88 }
89 }
90
91 void postInitialize() override {
93 for (const auto& i: integralList) {
94 i->initialize();
95 }
97 }
98
99 void solveYourselfAt(TimeStep *tStep) override {
100 unknownsField->advanceSolution(tStep);
101
104
105 OOFEM_LOG_INFO("MPM Symbolic solver\n");
106 OOFEM_LOG_INFO("Number of equations %d\n", this->giveNumberOfDomainEquations( 1, EModelDefaultEquationNumbering()) );
107
108 if ( tStep->giveNumber() == 1 ) {
109 // allocate space for solution vector
110 FloatArray *solutionVector = unknownsField->giveSolutionVector(tStep);
111 solutionVector->resize(neq);
112 solutionVector->zero();
113
114 effectiveMatrix = classFactory.createSparseMtrx(sparseMtrxType);
115 if ( !effectiveMatrix ) {
116 OOFEM_ERROR("LHS sparse matrix creation failed");
117 }
118
119 effectiveMatrix->buildInternalStructure( this, 1, EModelDefaultEquationNumbering() );
120 if ( this->keepTangent ) {
121 this->effectiveMatrix->zero();
122 // loop over lhs integrals
123 for (auto i: lhsIntegrals) {
124 Integral* integral = this->integralList[i-1].get();
126 }
127 }
128 }
129 // assemble rhs
131 // loop over rhs integrals
132 for (auto i: rhsIntegrals) {
133 Integral* integral = this->integralList[i-1].get();
134 integral->assemble_rhs (rhs, EModelDefaultEquationNumbering(), tStep);
135 }
137
138 residualVector.resize(neq);
139
140 // set-up numerical method
142 FloatArray incrementOfSolution;
143 double loadLevel;
144 int currentIterations;
145 this->nMethod->solve(*this->effectiveMatrix,
146 rhs,
147 NULL,
148 *unknownsField->giveSolutionVector(tStep),
149 incrementOfSolution,
151 this->eNorm,
152 loadLevel, // Only relevant for incrementalBCLoadVector
153 SparseNonLinearSystemNM :: rlm_total,
154 currentIterations,
155 tStep);
156 }
157
158 void updateComponent(TimeStep *tStep, NumericalCmpn cmpn, Domain *d) override
159 {
160 if ( cmpn == InternalRhs ) {
161 this->residualVector.zero();
162 int maxdofids = d->giveMaxDofID();
163 eNorm.resize(maxdofids);
164 eNorm.zero();
165 for (auto i: lhsIntegrals) {
166 Integral* integral = this->integralList[i-1].get();
168 }
170 return;
171 } else if ( cmpn == NonLinearLhs ) {
172 if ( !this->keepTangent ) {
173 // Optimization for linear problems, we can keep the old matrix (which could save its factorization)
174 this->effectiveMatrix->zero();
175 // loop over lhs integrals
176 for (auto i: lhsIntegrals) {
177 Integral* integral = this->integralList[i-1].get();
179 }
180 }
181 return;
182 } else {
183 OOFEM_ERROR("Unknown component");
184 }
185 }
186
188 {}
189
190
192 {
193 int istep = this->giveNumberOfFirstStep();
194 StateCounterType counter = 1;
195
196 if ( currentStep ) {
197 istep = currentStep->giveNumber() + 1;
198 counter = currentStep->giveSolutionStateCounter() + 1;
199 }
200
201 previousStep = std :: move(currentStep);
202 currentStep = std::make_unique<TimeStep>(istep, this, 1, ( double ) istep, 0., counter);
203 return currentStep.get();
204 }
205
207 {
208 if ( !nMethod ) {
209 nMethod = std::make_unique<NRSolver>(this->giveDomain(1), this);
210 }
211 return nMethod.get();
212 }
213
214 double giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) override
215 // returns unknown quantity like displacement, velocity of equation eq
216 // This function translates this request to numerical method language
217 {
218 #ifdef DEBUG
219 int eq = dof->__giveEquationNumber();
220 if ( eq == 0 ) {
221 OOFEM_ERROR("invalid equation number");
222 }
223 #endif
224
225 if (mode == VM_TotalIntrinsic) mode = VM_Total;
226 return unknownsField->giveUnknownValue(dof, mode, tStep);
227 }
228 // identification
230 const char *giveClassName() const override { return "StationaryMPMSProblem"; }
231 fMode giveFormulation() override { return TL; }
232 };
233
234} // end namespace oofem
235#endif // mpmsemodels_h
void buildSharedBoundaryEntities(Domain *d)
ConnectivityTable * giveConnectivityTable()
Definition domain.C:1240
int giveMaxDofID()
Definition domain.h:641
virtual int forceEquationNumbering()
Definition engngm.C:534
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Definition engngm.C:452
EngngModel(int i, EngngModel *_master=NULL)
Definition engngm.C:99
std ::unique_ptr< TimeStep > previousStep
Previous time step.
Definition engngm.h:243
MetaStep * giveCurrentMetaStep()
Returns current meta step.
Definition engngm.C:1900
int ndomains
Number of receiver domains.
Definition engngm.h:215
Domain * giveDomain(int n)
Definition engngm.C:1936
std ::unique_ptr< TimeStep > currentStep
Current time step.
Definition engngm.h:241
@ InternalForcesExchangeTag
Definition engngm.h:321
virtual void postInitialize()
Definition engngm.C:2072
virtual void initializeFrom(InputRecord &ir)
Definition engngm.C:292
virtual int giveNumberOfFirstStep(bool force=false)
Definition engngm.h:763
int updateSharedDofManagers(FloatArray &answer, const UnknownNumberingScheme &s, int ExchangeTag)
Definition engngm.C:2162
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
Class representing weak form integral.
Definition integral.h:49
void assemble_lhs(SparseMtrx &dest, const UnknownNumberingScheme &s, TimeStep *tStep) const
Definition integral.h:76
void assemble_rhs(FloatArray &dest, const UnknownNumberingScheme &s, TimeStep *tstep, FloatArray *eNorms=NULL) const
Definition integral.h:98
fMode giveFormulation() override
void updateSolution(FloatArray &solutionVector, TimeStep *tStep, Domain *d) override
StationaryMPMSProblem(int i, EngngModel *_master)
Definition mpmsemodels.h:79
void postInitialize() override
Definition mpmsemodels.h:91
void updateComponent(TimeStep *tStep, NumericalCmpn cmpn, Domain *d) override
TimeStep * giveNextStep() override
Returns next time step (next to current step) of receiver.
NumericalMethod * giveNumericalMethod(MetaStep *mStep) override
Returns reference to receiver's numerical method.
const char * giveClassName() const override
Returns class name of the receiver.
std ::unique_ptr< PrimaryField > unknownsField
This field stores solution vector. For fixed size of problem, the PrimaryField is used,...
Definition mpmsemodels.h:62
SparseMtrxType sparseMtrxType
Definition mpmsemodels.h:59
std::unique_ptr< SparseNonLinearSystemNM > nMethod
Numerical method used to solve the problem.
Definition mpmsemodels.h:70
void initializeFrom(InputRecord &ir) override
Definition mpmsemodels.h:81
double giveUnknownComponent(ValueModeType mode, TimeStep *tStep, Domain *d, Dof *dof) override
const char * giveInputRecordName() const
LinSystSolverType solverType
Definition mpmsemodels.h:60
void solveYourselfAt(TimeStep *tStep) override
Definition mpmsemodels.h:99
std ::unique_ptr< SparseMtrx > effectiveMatrix
Definition mpmsemodels.h:64
int giveNumber()
Returns receiver's number.
Definition timestep.h:144
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define OOFEM_LOG_INFO(...)
Definition logger.h:143
#define _IFT_StationaryMPMSProblem_Name
Definition mpmsemodels.h:50
fMode
Definition fmode.h:42
@ TL
Total Lagrange.
Definition fmode.h:44
long StateCounterType
StateCounterType type used to indicate solution state.
@ SMT_Skyline
Symmetric skyline.
ClassFactory & classFactory
@ NonLinearLhs
@ InternalRhs

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011