OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
adaptlinearstatic.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 
35 #include "../sm/EngineeringModels/adaptlinearstatic.h"
36 #include "remeshingcrit.h"
37 #include "mesherinterface.h"
38 #include "errorestimator.h"
39 #include "domain.h"
40 #include "classfactory.h"
41 #include "contextioerr.h"
42 #include "outputmanager.h"
43 
44 namespace oofem {
45 REGISTER_EngngModel(AdaptiveLinearStatic);
46 
47 void
49 {
51  // perform error evaluation
52  // evaluate error of the reached solution
54  // this->defaultErrEstimator->estimateError (equilibratedEM, this->giveCurrentStep());
56 
57  if ( strategy == NoRemeshing_RS ) {
58  return;
59  } else {
60  // do remeshing
61  std :: unique_ptr< MesherInterface >mesher( classFactory.createMesherInterface( meshPackage, this->giveDomain(1) ) );
62  Domain *newDomain;
63 
65  mesher->createMesh(tStep, 1, this->giveDomain(1)->giveSerialNumber() + 1, & newDomain);
66 
67  if ( result == MesherInterface :: MI_OK ) { } else if ( result == MesherInterface :: MI_NEEDS_EXTERNAL_ACTION ) {
68  // terminate step
69  //this->terminate( tStep );
70  //this->terminateAnalysis();
71  //exit(1);
72  } else {
73  OOFEM_ERROR("createMesh failed");
74  }
75  }
76 }
77 
78 
79 void
81 {
82  if ( !this->giveDomain(1)->giveOutputManager()->testTimeStepOutput(tStep) ) {
83  return;
84  }
85 
86  LinearStatic :: printOutputAt(file, tStep);
87  fprintf(file, "\nRelative error estimate: %5.2f%%\n", this->defaultErrEstimator->giveValue(relativeErrorEstimateEEV, tStep) * 100.0);
88 }
89 
90 
91 int
93 {
94  /*
95  * Due to linear character of the problem,
96  * the whole analysis is restarted from beginning.
97  * The solution steps represent the adaptive steps and for each adaptive step
98  * new domain with corresponding domainSerNum is generated.
99  */
100  int result = 1;
101  /*
102  * this -> initStepIncrements();
103  *
104  * int sernum = tStepNumber + 1;
105  * printf ("\nrestoring domain %d.%d\n", 1, sernum);
106  * Domain* dNew = new Domain (1, sernum, this);
107  * FILE* domainInputFile;
108  * this->giveDomainFile (&domainInputFile, 1, sernum, contextMode_read);
109  * if (!dNew -> instanciateYourself(domainInputFile)) OOFEM_ERROR("domain Instanciation failed");
110  * fclose (domainInputFile);
111  *
112  * printf ("\ndeleting old domain\n");
113  * delete domainList->at(1);
114  * domainList->put(1, dNew);
115  *
116  * // init equation numbering
117  * this->forceEquationNumbering();
118  *
119  * // set time step
120  * this->giveCurrentStep()->setTime(tStepNumber+1);
121  *
122  * // init equation numbering
123  * // this->forceEquationNumbering();
124  * this->giveNumericalMethod(giveCurrentStep())->setDomain (dNew);
125  * this->ee->setDomain (dNew);
126  */
127  return result;
128 }
129 
130 
132 {
133  contextIOResultType iores;
134  if ( ( iores = LinearStatic :: restoreContext(stream, mode) ) != CIO_OK ) {
135  THROW_CIOERR(iores);
136  }
137 
138  return CIO_OK;
139 }
140 
143 // input from inputString
144 {
145  IRResultType result; // Required by IR_GIVE_FIELD macro
146 
147  int meshPackageId = 0;
149 
150  if ( meshPackageId == 1 ) {
151  meshPackage = MPT_TARGE2;
152  } else if ( meshPackageId == 2 ) {
153  meshPackage = MPT_FREEM;
154  } else {
155  meshPackage = MPT_T3D;
156  }
157 
159 }
160 
161 
162 void
164 {
166  // associate ee to possibly newly restored mesh
167  this->defaultErrEstimator->setDomain( this->giveDomain(1) );
168 }
169 } // end namespace oofem
void setDomain(Domain *d)
Sets Domain; should also re-initialize attributes if necessary.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
Definition: linearstatic.C:94
Class and object Domain.
Definition: domain.h:115
virtual void updateYourself(TimeStep *tStep)
Updates internal state after finishing time step.
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
MeshPackageType meshPackage
Meshing package used for refinements.
ErrorEstimator * defaultErrEstimator
Error estimator. Useful for adaptivity, or simply printing errors output.
Definition: engngm.h:273
virtual RemeshingStrategy giveRemeshingStrategy(TimeStep *tStep)=0
Determines, if the remeshing is needed, and if needed, the type of strategy used. ...
REGISTER_EngngModel(ProblemSequence)
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description in input reader.
virtual void updateDomainLinks()
Updates domain links after the domains of receiver have changed.
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual int estimateError(EE_ErrorMode mode, TimeStep *tStep)=0
Estimates the error on associated domain at given time step.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
virtual RemeshingCriteria * giveRemeshingCrit()=0
Returns reference to associated remeshing criteria.
virtual void updateDomainLinks()
Updates domain links after the domains of receiver have changed.
Definition: linearstatic.C:300
MesherInterface * createMesherInterface(MeshPackageType name, Domain *d)
Definition: classfactory.C:441
virtual void updateYourself(TimeStep *tStep)
Updates internal state after finishing time step.
RemeshingStrategy
Type representing the remeshing strategy.
Definition: remeshingcrit.h:50
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode)
Restores the state of model from output stream.
Definition: linearstatic.C:283
Class representing the general Input Record.
Definition: inputrecord.h:101
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Prints output of receiver to output domain stream, for given time step.
virtual double giveValue(EE_ValueType type, TimeStep *tStep)=0
Returns the characteristic value of given type.
#define _IFT_AdaptiveLinearStatic_meshpackage
ClassFactory & classFactory
Definition: classfactory.C:59
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Prints output of receiver to output domain stream, for given time step.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
virtual int initializeAdaptive(int tStepNumber)
Initializes the newly generated discretization state according to previous solution.
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
Class representing solution step.
Definition: timestep.h:80

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:27 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011