OOFEM  2.4 OOFEM.org - Object Oriented Finite Element Solver
material.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
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 "material.h"
36 #include "verbose.h"
37 #include "gausspoint.h"
38 #include "floatarray.h"
39 #include "mathfem.h"
40 #include "dynamicinputrecord.h"
41 #include "contextioerr.h"
42
43 namespace oofem {
44 Material :: Material(int n, Domain *d) : FEMComponent(n, d), propertyDictionary(), castingTime(-1.) { }
45
46
48 {}
49
50
51 double
52 Material :: give(int aProperty, GaussPoint *gp)
53 // Returns the value of the property aProperty (e.g. the Young's modulus
54 // 'E') of the receiver.
55 // tStep allows time dependent behavior to be taken into account
56 {
57  double value = 0.0;
58
59  if ( propertyDictionary.includes(aProperty) ) {
60  value = propertyDictionary.at(aProperty);
61  } else {
62  OOFEM_ERROR( "property #%d on element %d and GP %d not defined", aProperty, gp->giveElement()->giveNumber(), gp->giveNumber() );
63  }
64
65  return value;
66 }
67
68
69 bool
71 // Returns true if the aProperty is defined on a material
72 {
73  return propertyDictionary.includes(aProperty);
74 }
75
76
77 void
78 Material :: modifyProperty(int aProperty, double value, GaussPoint *gp)
79 {
80  if ( propertyDictionary.includes(aProperty) ) {
81  propertyDictionary.at(aProperty) = value;
82  } else {
83  OOFEM_ERROR( "property #%d on element %d and GP %d not defined", aProperty, gp->giveElement()->giveNumber(), gp->giveNumber() );
84  }
85 }
86
87
90 {
91  IRResultType result; // Required by IR_GIVE_FIELD macro
92
93  double value;
94
95 # ifdef VERBOSE
96  // VERBOSE_PRINT1 ("Instanciating material ",this->giveNumber())
97 # endif
98
101
102  this->castingTime = -1.e10;
104
105  return IRRT_OK;
106 }
107
108
109 void
111 {
115 }
116
117
118 int
120 //
121 // returns whether receiver supports given mode
122 //
123 {
124  return 0;
125 }
126
127 int
129 //
130 // returns whether receiver fully supports casting time
131 //
132 {
133  if ( this->castingTime > 0. ) {
134  return 0; // casting time is user-defined. By default the casting time is not supported.
135  } else {
136  return 1; // do not check anything - casting time has not been user-defined
137  }
138 }
139
140
141 int
143 {
144  if ( type == IST_MaterialNumber ) {
147  return 1;
148  } else if ( type == IST_Density ) {
151  return 1;
152  }
153
155  return 0;
156 }
157
158
159 void
161 // Prints the receiver on screen.
162 {
163  printf("Material with properties : \n");
165 }
166
167
168 //
169 // store & restore context - material info in gp not saved now!
170 //
171
174 //
175 // saves full material status (saves state variables, that completely describe
176 // current state) stored in gp->matstatusDict with key = this->giveNumber()
177 // storing of corresponding context if it is defined for current material in
178 // gp status dictionary should be performed here by overloading this function.
179 // (such code should invoke also corresponding function for yield conditions,
180 // submaterials and so on)
181 //
182
183 //
184 {
185  contextIOResultType iores;
186
187  if ( gp == NULL ) {
189  }
190
191  // write raw data - we save status there for this
192  MaterialStatus *status = this->giveStatus(gp);
193
194  if ( status ) {
195  if ( ( iores = status->saveContext(stream, mode, gp) ) != CIO_OK ) {
196  THROW_CIOERR(iores);
197  }
198  }
199
200  return CIO_OK;
201 }
202
205 //
206 // restores full material status (saves state variables, that completely describe
207 // current state) stored in gp->matstatusDict with key = this->giveNumber()
208 // restoring of corresponding context if it is defined for current material in
209 // gp status dictionary should be performed here by overloading this function.
210 // (such code should invoke also corresponding function for yield conditions,
211 // submaterials and so on)
212 //
213
214 //
215 {
216  contextIOResultType iores;
217  if ( gp == NULL ) {
219  }
220
221  // read raw data - context
222  MaterialStatus *status = this->giveStatus(gp);
223  if ( status ) {
224  if ( ( iores = status->restoreContext(stream, mode, gp) ) != CIO_OK ) {
225  THROW_CIOERR(iores);
226  }
227  }
228
229  return CIO_OK;
230 }
231
232
234 {
235  if ( !this->hasCastingTimeSupport() ) {
236  OOFEM_WARNING("Material %3d does not support casting time (casting time = %lf)", this->giveNumber(), this->castingTime);
237  }
238
240 }
241
242
245 /*
246  * returns material status in gp corresponding to specific material class
247  */
248 {
249  MaterialStatus *status = static_cast< MaterialStatus * >( gp->giveMaterialStatus() );
250  if ( status == NULL ) {
251  // create a new one
252  status = this->CreateStatus(gp);
253
254  // if newly created status is null
255  // dont include it. specific instance
256  // does not have status.
257  if ( status != NULL ) {
258  gp->setMaterialStatus( status, this->giveNumber() );
259  }
260  }
261
262  return status;
263 }
264
265
266 void
268 //
269 // Initialize MatStatus (respective it's temporary variables at the begining
270 // of integrating incremental constitutive relations) to correct values
271 //
272 {
273  MaterialStatus *status = this->giveStatus(gp);
274  if ( status ) {
275  status->initTempStatus();
276  }
277 }
278
279
280 int
282 {
283  return 0;
284 }
285 } // end namespace oofem
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
void setField(int item, InputFieldType id)
void printYourself()
Definition: dictionary.C:145
virtual ~Material()
Destructor.
Definition: material.C:47
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Returns material status of receiver in given integration point.
Definition: material.C:244
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
Definition: material.C:233
Class and object Domain.
Definition: domain.h:115
virtual int initMaterial(Element *element)
Optional function to call specific procedures when initializing a material.
Definition: material.C:281
virtual contextIOResultType saveIPContext(DataStream &stream, ContextMode mode, GaussPoint *gp)
Stores integration point state to output stream.
Definition: material.C:173
double & at(int aKey)
Returns the value of the pair which key is aKey.
Definition: dictionary.C:106
The purpose of DataStream abstract class is to allow to store/restore context to different streams...
Definition: datastream.h:54
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
void clear()
Definition: floatarray.h:206
bool includes(int aKey)
Checks if dictionary includes given key.
Definition: dictionary.C:126
Dictionary propertyDictionary
Property dictionary.
Definition: material.h:105
Abstract base class for all finite elements.
Definition: element.h:145
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Definition: femcmpnn.C:51
Element * giveElement()
Definition: gausspoint.h:188
virtual contextIOResultType restoreIPContext(DataStream &stream, ContextMode mode, GaussPoint *gp)
Reads integration point state to output stream.
Definition: material.C:204
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Definition: material.C:110
MaterialMode
Type representing material mode of integration point.
Definition: materialmode.h:89
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Definition: femcmpnn.C:77
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
virtual double give(int aProperty, GaussPoint *gp)
Returns the value of material property &#39;aProperty&#39;.
Definition: material.C:52
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
Definition: matstatus.h:103
virtual int checkConsistency()
Allows programmer to test some internal data, before computation begins.
Definition: femcmpnn.C:94
#define OOFEM_ERROR(...)
Definition: error.h:61
int giveNumber()
Definition: gausspoint.h:184
#define _IFT_Material_density
Definition: material.h:51
Material(int n, Domain *d)
Constructor.
Definition: material.C:44
Abstract base class representing a material status information.
Definition: matstatus.h:84
Pair * add(int aKey, double value)
Definition: dictionary.C:81
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual int hasMaterialModeCapability(MaterialMode mode)
Tests if material supports material mode.
Definition: material.C:119
#define _IFT_Material_castingtime
Definition: material.h:52
virtual void printYourself()
Prints receiver state on stdout. Useful for debugging.
Definition: material.C:160
Class representing the general Input Record.
Definition: inputrecord.h:101
virtual int hasCastingTimeSupport()
Tests if material supports casting time.
Definition: material.C:128
Class representing the a dynamic Input Record.
virtual void modifyProperty(int aProperty, double value, GaussPoint *gp)
Modify &#39;aProperty&#39;, which already exists on material.
Definition: material.C:78
long ContextMode
Definition: contextmode.h:43
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
Definition: femcmpnn.C:64
double castingTime
Casting time.
Definition: material.h:113
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual bool hasProperty(int aProperty, GaussPoint *gp)
Returns true if &#39;aProperty&#39; exists on material.
Definition: material.C:70
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
virtual void initTempStatus(GaussPoint *gp)
Initializes temporary variables stored in integration point status at the beginning of new time step...
Definition: material.C:267
int giveNumber() const
Definition: femcmpnn.h:107
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: material.C:89
Class representing integration point in finite element program.
Definition: gausspoint.h:93
#define OOFEM_WARNING(...)
Definition: error.h:62
Class representing solution step.
Definition: timestep.h:80
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
Definition: material.C:142
The top abstract class of all classes constituting the finite element mesh.
Definition: femcmpnn.h:76
void resize(int s)