OOFEM 3.0
Loading...
Searching...
No Matches
timestep.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
35/*
36 * The original idea for this class comes from
37 * Dubois-Pelerin, Y.: "Object-Oriented Finite Elements: Programming concepts and Implementation",
38 * PhD Thesis, EPFL, Lausanne, 1992.
39 */
40
41#include "timestep.h"
42#include "engngm.h"
43#include "datastream.h"
44#include "contextioerr.h"
45#include "error.h"
46#include "convergedreason.h"
47
48namespace oofem {
49TimeStep :: TimeStep(int n, EngngModel *e, int mn, double tt, double dt, StateCounterType counter, TimeDiscretizationType td) :
50 eModel(e), targetTime(tt), intrinsicTime(tt), deltaT(dt), solutionStateCounter(counter),
52{
53 // Target time and intrinsic time is the same in the constructor.
54 this->solutionTime = 0.0;
55}
56
57TimeStep :: TimeStep(EngngModel *e)
58{
59 eModel = e;
60 deltaT = 0.0;
61 targetTime = 0.0;
62 intrinsicTime = 0.0;
64 number = -1;
65 version = 0;
66 mStepNumber = 0;
67 subStepNumber = 0;
71 solutionTime = 0.0;
73}
74
92
93TimeStep :: TimeStep(const TimeStep &previous, double dt)
94{
95 eModel = previous.eModel;
96 targetTime = previous.targetTime + dt;
97 intrinsicTime = previous.intrinsicTime + dt;
98 deltaT = dt;
100 number = previous.number + 1;
101 version = 0;
102 mStepNumber = previous.mStepNumber ? previous.mStepNumber : 1;
103 subStepNumber = 0;
107 solutionTime = 0.0;
109}
110
111
112TimeStep &
113TimeStep :: operator = ( const TimeStep & src )
114{
115 eModel = src.eModel;
118 deltaT = src.deltaT;
120 number = src.number;
121 version = src.version;
127
128 return * this;
129}
130
131
132TimeStep *TimeStep :: givePreviousStep()
133{
134 if ( isTheCurrentTimeStep() ) {
135 return eModel->givePreviousStep();
136 } else {
137 OOFEM_ERROR("Could not return previous step of noncurrent step");
138 }
139}
140
141
142bool TimeStep :: isNotTheLastStep()
143{
144 return ( number != eModel->giveNumberOfSteps() );
145}
146
147
148bool TimeStep :: isTheFirstStep()
149{
150 return ( number == eModel->giveNumberOfFirstStep() );
151}
152
153
154bool TimeStep :: isIcApply()
155{
156 // Returns True if the receiver is the time step,
157 // when Initial conditions apply
158 // else returns False.
159
160 return ( number == eModel->giveNumberOfTimeStepWhenIcApply() );
161}
162
163
164bool TimeStep :: isTheCurrentTimeStep()
165{
166 return this == eModel->giveCurrentStep();
167}
168
169void TimeStep :: setTimeStepReductionFactor(double tsrf)
170{
171 this->eModel->giveCurrentMetaStep()->setTimeStepReductionFactor(tsrf);
172}
173
174
175
176void
177TimeStep :: saveContext(DataStream &stream)
178{
179 if ( !stream.write(number) ) {
181 }
182
183 if ( !stream.write(mStepNumber) ) {
185 }
186
187 if ( !stream.write(this->targetTime) ) {
189 }
190
191 if ( !stream.write(this->intrinsicTime) ) {
193 }
194
195 if ( !stream.write(this->deltaT) ) {
197 }
198
199 if ( !stream.write(this->solutionStateCounter) ) {
201 }
202
203 int tDiscretization = ( int ) timeDiscretization;
204 if ( !stream.write(tDiscretization) ) {
206 }
207}
208
209
210void
211TimeStep :: restoreContext(DataStream &stream)
212{
213 if ( !stream.read(number) ) {
215 }
216
217 if ( !stream.read(mStepNumber) ) {
219 }
220
221 if ( !stream.read(this->targetTime) ) {
223 }
224
225 if ( !stream.read(this->intrinsicTime) ) {
227 }
228
229 if ( !stream.read(this->deltaT) ) {
231 }
232
233 if ( !stream.read(this->solutionStateCounter) ) {
235 }
236
237 int tDiscretization = 0;
238 if ( !stream.read(tDiscretization) ) {
240 }
241 timeDiscretization = ( TimeDiscretizationType ) tDiscretization;
242}
243} // end namespace oofem
virtual int read(int *data, std::size_t count)=0
Reads count integer values into array pointed by data.
virtual int write(const int *data, std::size_t count)=0
Writes count integer values from array pointed by data.
double intrinsicTime
Current intrinsic time, which may represents imposing time of boundary condition or time entering con...
Definition timestep.h:89
int numberOfAttempts
Number of attempts (reduction ot time incerement, etc) needed to reach convergence.
Definition timestep.h:118
double deltaT
Current intrinsic time increment.
Definition timestep.h:91
int mStepNumber
Corresponding meta step number.
Definition timestep.h:107
double targetTime
Current target time, which represents time at the end of a time step.
Definition timestep.h:87
ConvergedReason convergedReason
Status of solution step (Converged,.
Definition timestep.h:120
int numberOfIterations
Number of itarations needed to achieve convergence.
Definition timestep.h:116
StateCounterType solutionStateCounter
Solution state counter.
Definition timestep.h:93
int number
Receiver's number.
Definition timestep.h:95
EngngModel * eModel
Engineering model reference.
Definition timestep.h:85
bool isTheCurrentTimeStep()
Definition timestep.C:164
double solutionTime
time step solution time in seconds
Definition timestep.h:122
TimeDiscretizationType timeDiscretization
Time discretization.
Definition timestep.h:109
TimeStep(int n, EngngModel *e, int mn, double tt, double dt, StateCounterType counter, TimeDiscretizationType td=TD_Unspecified)
Definition timestep.C:49
#define THROW_CIOERR(e)
#define OOFEM_ERROR(...)
Definition error.h:79
long StateCounterType
StateCounterType type used to indicate solution state.
TimeDiscretizationType
Time discretization used by transient solvers.
@ TD_Unspecified
Unspecified.
@ CIO_IOERR
General IO error.

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