OOFEM 3.0
Loading...
Searching...
No Matches
dynamicrelaxationsolver.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
36#include "timestep.h"
37#include "classfactory.h"
38#include "exportmodulemanager.h"
39#include "engngm.h"
40#include "domain.h"
41#include "dofmanager.h"
42#include "element.h"
44#include "mathfem.h"
45#include "assemblercallback.h"
46
47namespace oofem {
48
49#define ERROR_NORM_SMALL_NUM 1.e-6
50#define MAX_REL_ERROR_BOUND 1.e20
51
53
54DynamicRelaxationSolver :: DynamicRelaxationSolver(Domain *d, EngngModel *m) : NRSolver(d, m)
55{
56}
57
58
59void
60DynamicRelaxationSolver :: initializeFrom(InputRecord &ir)
61{
62 NRSolver :: initializeFrom(ir);
63}
64
65
67DynamicRelaxationSolver :: solve(SparseMtrx &k, FloatArray &R, FloatArray *R0,
69 const FloatArray &internalForcesEBENorm, double &l, referenceLoadInputModeType rlm,
70 int &nite, TimeStep *tStep)
71
72{
73 // residual, iteration increment of solution, total external force
74 FloatArray rhs, ddX, RT, X_0, X_n, X_n1, M;
75
76 double RRT;
77 int neq = X.giveSize();
79 bool converged, errorOutOfRangeFlag;
80 ParallelContext *parallel_context = engngModel->giveParallelContext( this->domain->giveNumber() );
81 if ( engngModel->giveProblemScale() == macroScale ) {
82 OOFEM_LOG_INFO("DRSolver: Iteration");
83 if ( rtolf.at(1) > 0.0 ) {
84 OOFEM_LOG_INFO(" ForceError");
85 }
86 if ( rtold.at(1) > 0.0 ) {
87 OOFEM_LOG_INFO(" DisplError");
88 }
89 OOFEM_LOG_INFO("\n----------------------------------------------------------------------------\n");
90 }
91
92 // compute total load R = R+R0
93 l = 1.0;
94 RT = R;
95 if ( R0 ) {
96 RT.add(* R0);
97 }
98
99 RRT = parallel_context->localNorm(RT);
100 RRT *= RRT;
101
102 ddX.resize(neq);
103 ddX.zero();
104
105 X_0 = X;
106 X_n = X_0;
107 X_n1 = X_0;
108
109 // Compute the mass "matrix" (lumped, only storing the diagonal)
110 M.resize(neq);
111 M.zero();
112 engngModel->assembleVector(M, tStep, LumpedMassVectorAssembler(), VM_Total, EModelDefaultEquationNumbering(), domain);
113
114 double Le = -1.0;
115 for ( auto &elem : domain->giveElements() ) {
116 double size = elem->computeMeanSize();
117 if ( Le < 0 || Le >= size ) {
118 Le = size;
119 }
120 }
121
122 for ( nite = 0; ; ++nite ) {
123 // Compute the residual
124 engngModel->updateComponent(tStep, InternalRhs, domain);
125 rhs.beDifferenceOf(RT, F);
126
127 converged = this->checkConvergence(RT, F, rhs, ddX, X, RRT, internalForcesEBENorm, nite, errorOutOfRangeFlag);
128 if ( errorOutOfRangeFlag ) {
129 status = CR_DIVERGED_TOL;
130 dX.zero();
131 X.zero();
132 OOFEM_WARNING("Divergence reached after %d iterations", nite);
133 break;
134 } else if ( converged && ( nite >= minIterations ) ) {
135 status = CR_CONVERGED;
136 break;
137 } else if ( nite >= nsmax ) {
138 OOFEM_LOG_DEBUG("Maximum number of iterations reached\n");
139 status = CR_DIVERGED_ITS;
140 break;
141 }
142
143 double density = 1.;
144 double lambda = 210e9;
145 double mu = 210e9;
146 double c = sqrt((lambda + 2*mu) / density);
147 double dt = 0.25 * Le / c;
148 double alpha = 0.1 / dt;
149 printf("dt = %e\n", dt);
150 for ( int j = 0; j < neq; ++j ) {
151 //M * x'' + C*x' * dt = rhs * dt*dt
152 X[j] = rhs[j] * dt * dt / M[j] - ( -2*X_n1[j] + X_n[j] ) - alpha * (X_n1[j] - X_n[j]) * dt;
153 }
154 X_n = X_n1;
155 X_n1 = X;
156
157 dX.beDifferenceOf(X, X_0);
158 tStep->incrementStateCounter(); // update solution state counter
159 tStep->incrementSubStepNumber();
160 }
161
162 return status;
163}
164
165} // end namespace oofem
166
#define REGISTER_SparseNonLinearSystemNM(class)
void resize(Index s)
Definition floatarray.C:94
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
Definition floatarray.C:403
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
void add(const FloatArray &src)
Definition floatarray.C:218
bool checkConvergence(FloatArray &RT, FloatArray &F, FloatArray &rhs, FloatArray &ddX, FloatArray &X, double RRT, const FloatArray &internalForcesEBENorm, int nite, bool &errorOutOfRange)
Definition nrsolver.C:594
FloatArray rtold
Relative iterative displacement change tolerance for each group.
Definition nrsolver.h:152
FloatArray rtolf
Relative unbalanced force tolerance for each group.
Definition nrsolver.h:150
Domain * domain
Pointer to domain.
Definition nummet.h:84
EngngModel * engngModel
Pointer to engineering model.
Definition nummet.h:86
double localNorm(const FloatArray &src)
void incrementSubStepNumber()
Increments receiver's substep number.
Definition timestep.h:217
void incrementStateCounter()
Updates solution state counter.
Definition timestep.h:213
#define OOFEM_WARNING(...)
Definition error.h:80
#define OOFEM_LOG_INFO(...)
Definition logger.h:143
#define OOFEM_LOG_DEBUG(...)
Definition logger.h:144
@ CR_DIVERGED_TOL
@ CR_DIVERGED_ITS
@ InternalRhs
@ macroScale
Definition problemmode.h:46

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