OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 2013 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"
43 #include "unknownnumberingscheme.h"
44 #include "mathfem.h"
45 
46 namespace oofem {
47 
48 #define ERROR_NORM_SMALL_NUM 1.e-6
49 #define MAX_REL_ERROR_BOUND 1.e20
50 
52 
54 {
55 }
56 
57 
60 {
61  return NRSolver :: initializeFrom(ir);
62 }
63 
64 
67  FloatArray &X, FloatArray &dX, FloatArray &F,
68  const FloatArray &internalForcesEBENorm, double &l, referenceLoadInputModeType rlm,
69  int &nite, TimeStep *tStep)
70 
71 {
72  // residual, iteration increment of solution, total external force
73  FloatArray rhs, ddX, RT, X_0, X_n, X_n1, M;
74 
75  double RRT;
76  int neq = X.giveSize();
77  NM_Status status = NM_None;
78  bool converged, errorOutOfRangeFlag;
79  ParallelContext *parallel_context = engngModel->giveParallelContext( this->domain->giveNumber() );
81  OOFEM_LOG_INFO("DRSolver: Iteration");
82  if ( rtolf.at(1) > 0.0 ) {
83  OOFEM_LOG_INFO(" ForceError");
84  }
85  if ( rtold.at(1) > 0.0 ) {
86  OOFEM_LOG_INFO(" DisplError");
87  }
88  OOFEM_LOG_INFO("\n----------------------------------------------------------------------------\n");
89  }
90 
91  // compute total load R = R+R0
92  l = 1.0;
93  RT = R;
94  if ( R0 ) {
95  RT.add(* R0);
96  }
97 
98  RRT = parallel_context->localNorm(RT);
99  RRT *= RRT;
100 
101  ddX.resize(neq);
102  ddX.zero();
103 
104  X_0 = X;
105  X_n = X_0;
106  X_n1 = X_0;
107 
108  // Compute the mass "matrix" (lumped, only storing the diagonal)
109  M.resize(neq);
110  M.zero();
112 
113  double Le = -1.0;
114  for ( auto &elem : domain->giveElements() ) {
115  double size = elem->computeMeanSize();
116  if ( Le < 0 || Le >= size ) {
117  Le = size;
118  }
119  }
120 
121  for ( nite = 0; ; ++nite ) {
122  // Compute the residual
124  rhs.beDifferenceOf(RT, F);
125 
126  converged = this->checkConvergence(RT, F, rhs, ddX, X, RRT, internalForcesEBENorm, nite, errorOutOfRangeFlag);
127  if ( errorOutOfRangeFlag ) {
128  status = NM_NoSuccess;
129  dX.zero();
130  X.zero();
131  OOFEM_WARNING("Divergence reached after %d iterations", nite);
132  break;
133  } else if ( converged && ( nite >= minIterations ) ) {
134  status |= NM_Success;
135  break;
136  } else if ( nite >= nsmax ) {
137  OOFEM_LOG_DEBUG("Maximum number of iterations reached\n");
138  break;
139  }
140 
141  double density = 1.;
142  double lambda = 210e9;
143  double mu = 210e9;
144  double c = sqrt((lambda + 2*mu) / density);
145  double dt = 0.25 * Le / c;
146  double alpha = 0.1 / dt;
147  printf("dt = %e\n", dt);
148  for ( int j = 0; j < neq; ++j ) {
149  //M * x'' + C*x' * dt = rhs * dt*dt
150  X[j] = rhs[j] * dt * dt / M[j] - ( -2*X_n1[j] + X_n[j] ) - alpha * (X_n1[j] - X_n[j]) * dt;
151  }
152  X_n = X_n1;
153  X_n1 = X;
154 
155  dX.beDifferenceOf(X, X_0);
156  tStep->incrementStateCounter(); // update solution state counter
157  tStep->incrementSubStepNumber();
158  }
159 
160  return status;
161 }
162 
163 } // end namespace oofem
164 
The representation of EngngModel default unknown numbering.
virtual NM_Status solve(SparseMtrx &k, FloatArray &R, FloatArray *R0, FloatArray &X, FloatArray &dX, FloatArray &F, const FloatArray &internalForcesEBENorm, double &l, referenceLoadInputModeType rlm, int &nite, TimeStep *)
Solves the given sparse linear system of equations .
#define NM_Success
Numerical method exited with success.
Definition: nmstatus.h:47
Class and object Domain.
Definition: domain.h:115
virtual IRResultType initializeFrom(InputRecord *ir)
problemScale giveProblemScale()
Returns scale in multiscale simulation.
Definition: engngm.h:418
Solves static equilibrium by means of explicit dynamic iterations.
Base class for all matrices stored in sparse format.
Definition: sparsemtrx.h:60
This class implements Newton-Raphson Method, derived from abstract NumericalMethod class for solving ...
Definition: nrsolver.h:95
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
REGISTER_SparseNonLinearSystemNM(CylindricalALM)
Definition: calmls.C:58
virtual IRResultType initializeFrom(InputRecord *ir)
Definition: nrsolver.C:103
FloatArray rtold
Relative iterative displacement change tolerance for each group.
Definition: nrsolver.h:150
void incrementStateCounter()
Updates solution state counter.
Definition: timestep.h:190
int giveNumber()
Returns domain number.
Definition: domain.h:266
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
Definition: nmstatus.h:44
#define OOFEM_LOG_DEBUG(...)
Definition: logger.h:128
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
Sets receiver to be a - b.
Definition: floatarray.C:341
void incrementSubStepNumber()
Increments receiver&#39;s substep number.
Definition: timestep.h:194
#define NM_NoSuccess
Numerical method failed to solve problem.
Definition: nmstatus.h:48
Domain * domain
Pointer to domain.
Definition: nummet.h:84
#define OOFEM_LOG_INFO(...)
Definition: logger.h:127
virtual void updateComponent(TimeStep *tStep, NumericalCmpn cmpn, Domain *d)
Updates components mapped to numerical method if necessary during solution process.
Definition: engngm.C:1485
FloatArray rtolf
Relative unbalanced force tolerance for each group.
Definition: nrsolver.h:148
virtual ParallelContext * giveParallelContext(int n)
Returns the parallel context corresponding to given domain (n) and unknown type Default implementatio...
Definition: engngm.C:1745
referenceLoadInputModeType
The following parameter allows to specify how the reference load vector is obtained from given totalL...
#define NM_None
Definition: nmstatus.h:46
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Implementation for assembling lumped mass matrix (diagonal components) in vector form.
Class representing the general Input Record.
Definition: inputrecord.h:101
This class provides an communication context for distributed memory parallelism.
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
EngngModel * engngModel
Pointer to engineering model.
Definition: nummet.h:86
double localNorm(const FloatArray &src)
Norm for a locally distributed array.
#define OOFEM_WARNING(...)
Definition: error.h:62
void assembleVector(FloatArray &answer, TimeStep *tStep, const VectorAssembler &va, ValueModeType mode, const UnknownNumberingScheme &s, Domain *domain, FloatArray *eNorms=NULL)
Assembles characteristic vector of required type from dofManagers, element, and active boundary condi...
Definition: engngm.C:986
Class representing solution step.
Definition: timestep.h:80
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
bool checkConvergence(FloatArray &RT, FloatArray &F, FloatArray &rhs, FloatArray &ddX, FloatArray &X, double RRT, const FloatArray &internalForcesEBENorm, int nite, bool &errorOutOfRange)
Determines whether or not the solution has reached convergence.
Definition: nrsolver.C:580
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

This page is part of the OOFEM documentation. Copyright (c) 2011 Borek Patzak
Project e-mail: info@oofem.org
Generated at Tue Jan 2 2018 20:07:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011