OOFEM 3.0
Loading...
Searching...
No Matches
pdelta.C
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
38#include "nummet.h"
39#include "timestep.h"
40#include "element.h"
41#include "dof.h"
42#include "sparsemtrx.h"
43#include "verbose.h"
44#include "classfactory.h"
45#include "datastream.h"
46#include "contextioerr.h"
47#include "classfactory.h"
49
50#ifdef __MPI_PARALLEL_MODE
51 #include "problemcomm.h"
52 #include "communicator.h"
53#endif
54
55#include <typeinfo>
56
57namespace oofem {
59
60Pdelta :: Pdelta(int i, EngngModel *_master) : LinearStatic(i, _master)
61{
62 ndomains = 1;
63 initFlag = 1;
66}
67
68void
69Pdelta :: initializeFrom(InputRecord &ir)
70{
71 LinearStatic :: initializeFrom(ir);
72
74 this->maxiter = 50;
77}
78
79void Pdelta :: solveYourselfAt(TimeStep *tStep)
80{
81
82 FloatArray rhs, previousDisplacementVector;
83 //
84 // first step assemble stiffness Matrix
85 //
87 if ( !stiffnessMatrix ) {
88 OOFEM_ERROR("sparse matrix creation failed");
89 }
91 if ( !initialStressMatrix ) {
92 OOFEM_ERROR("sparse matrix creation failed");
93 }
94
95 stiffnessMatrix->buildInternalStructure( this, 1, this->giveEquationNumbering() );
96 initialStressMatrix->buildInternalStructure( this, 1, this->giveEquationNumbering() );
97
98#ifdef VERBOSE
99 OOFEM_LOG_DEBUG("Assembling stiffness matrix\n");
100#endif
101
102 this->assemble( *stiffnessMatrix, tStep, TangentAssembler(TangentStiffness),
103 this->giveEquationNumbering(), this->giveDomain(1) );
104
105#ifdef VERBOSE
106 OOFEM_LOG_DEBUG("Assembling load\n");
107#endif
108
109 //
110 // allocate space for displacementVector
111 //
112 displacementVector.resize( this->giveNumberOfDomainEquations( 1, this->giveEquationNumbering() ) ); // km?? replace EModelDefaultEquationNumbering() with this->giveEquationNumbering(). Use pointer?
113 displacementVector.zero();
114
115 //
116 // assembling the load vector
117 //
119 loadVector.zero();
120 this->assembleVector( loadVector, tStep, ExternalForceAssembler(), VM_Total,
121 this->giveEquationNumbering(), this->giveDomain(1) );
122
123 //
124 // internal forces (from Dirichlet b.c's, or thermal expansion, etc.)
125 //
126 FloatArray internalForces( this->giveNumberOfDomainEquations( 1, this->giveEquationNumbering() ) );
127 internalForces.zero();
128 this->assembleVector( internalForces, tStep, InternalForceAssembler(), VM_Total,
129 this->giveEquationNumbering(), this->giveDomain(1) );
130
131 loadVector.subtract(internalForces);
132
134
135 //
136 // set-up numerical model
137 //
138 this->giveNumericalMethod( this->giveMetaStep( tStep->giveMetaStepNumber() ) );
139
140 //
141 // call numerical model to solve arose problem
142 //
143#ifdef VERBOSE
144 OOFEM_LOG_INFO("\n\nSolving ...\n");
145#endif
146 int iter = 0;
147 double error;
148 FloatArray feq(displacementVector.giveSize());
149
150 do {
151 previousDisplacementVector = displacementVector;
152 rhs = loadVector;
153 if (iter) {
154 feq.zero();
155 if (this->lumpedInitialStressMatrix) {
157 VM_Total, EModelDefaultEquationNumbering(), this->giveDomain(1) );
158 } else {
160 VM_Total, EModelDefaultEquationNumbering(), this->giveDomain(1) );
161
162 }
163 rhs.subtract(feq);
164 //this->assembleVector(rhs, tStep, EquivalentLateralLoadAssembler(), VM_Total,
165 // this->giveEquationNumbering(), this->giveDomain(1) );
166 }
168
169 if ( s != CR_CONVERGED ) {
170 OOFEM_ERROR("No success in solving system.");
171 }
172 tStep->convergedReason = s;
173 tStep->incrementStateCounter(); // update solution state counter
174 previousDisplacementVector.subtract(displacementVector);
175 error = previousDisplacementVector.computeNorm()/displacementVector.computeNorm();
176 iter++;
177 } while ((error > rtolv) && (iter <= this->maxiter));
178 OOFEM_LOG_INFO("Done in %d iteration(s) (err = %le)\n", iter-1, error);
179}
180
181
182
183
184} // end namespace oofem
#define REGISTER_EngngModel(class)
virtual int giveNumberOfDomainEquations(int di, const UnknownNumberingScheme &num)
Definition engngm.C:452
int ndomains
Number of receiver domains.
Definition engngm.h:215
Domain * giveDomain(int n)
Definition engngm.C:1936
MetaStep * giveMetaStep(int i)
Returns the i-th meta step.
Definition engngm.h:773
int updateSharedDofManagers(FloatArray &answer, const UnknownNumberingScheme &s, int ExchangeTag)
Definition engngm.C:2162
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Definition engngm.C:1106
double computeNorm() const
Definition floatarray.C:861
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
void subtract(const FloatArray &src)
Definition floatarray.C:320
SparseMtrxType sparseMtrxType
LinSystSolverType solverType
LinearStatic(int i, EngngModel *master=nullptr)
FloatArray displacementVector
virtual UnknownNumberingScheme & giveEquationNumbering()
NumericalMethod * giveNumericalMethod(MetaStep *mStep) override
Returns reference to receiver's numerical method.
FloatArray loadVector
std ::unique_ptr< SparseMtrx > stiffnessMatrix
std ::unique_ptr< SparseLinearSystemNM > nMethod
Numerical method used to solve the problem.
bool lumpedInitialStressMatrix
Definition pdelta.h:71
int maxiter
Definition pdelta.h:70
double rtolv
Definition pdelta.h:69
std ::unique_ptr< SparseMtrx > initialStressMatrix
Definition pdelta.h:68
int giveMetaStepNumber()
Returns receiver's meta step number.
Definition timestep.h:150
void incrementStateCounter()
Updates solution state counter.
Definition timestep.h:213
ConvergedReason convergedReason
Status of solution step (Converged,.
Definition timestep.h:120
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define OOFEM_LOG_INFO(...)
Definition logger.h:143
#define OOFEM_LOG_DEBUG(...)
Definition logger.h:144
FloatArrayF< N > assemble(const FloatArrayF< M > &x, int const (&c)[M])
Assemble components into zero matrix.
ClassFactory & classFactory
#define _IFT_Pdelta_rtolv
Definition pdelta.h:50
#define _IFT_Pdelta_lumpedInitialStressMatrix
Definition pdelta.h:53
#define _IFT_Pdelta_maxiter
Definition pdelta.h:52

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