OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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#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#include "datastream.h"
43#include <stdexcept>
44
45namespace oofem {
46Material :: Material(int n, Domain *d) : FEMComponent(n, d), propertyDictionary(), castingTime(-1.) { }
47
48
49
50double
51Material :: give(int aProperty, GaussPoint *gp) const
52// Returns the value of the property aProperty (e.g. the Young's modulus
53// 'E') of the receiver.
54// tStep allows time dependent behavior to be taken into account
55{
56 double value = 0.0;
57
58 if ( propertyDictionary.includes(aProperty) ) {
59 value = propertyDictionary.at(aProperty);
60 } else {
61 OOFEM_ERROR( "property #%d on element %d and GP %d not defined", aProperty, gp->giveElement()->giveNumber(), gp->giveNumber() );
62 }
63
64 return value;
65}
66
67double
68Material :: giveCharacteristicValue(MatResponseMode type, GaussPoint* gp, TimeStep *tStep) const
69{
70 OOFEM_ERROR( "Characteristic value %s(%d) on element %d and GP %d not defined", __MatResponseModeToString(type), type, gp->giveElement()->giveNumber(), gp->giveNumber() );
71}
72
73bool
74Material :: hasProperty(int aProperty, GaussPoint *gp) const
75// Returns true if the aProperty is defined on a material
76{
77 return propertyDictionary.includes(aProperty);
78}
79
80
81void
82Material :: modifyProperty(int aProperty, double value, GaussPoint *gp)
83{
84 if ( propertyDictionary.includes(aProperty) ) {
85 propertyDictionary.at(aProperty) = value;
86 } else {
87 OOFEM_ERROR( "property #%d on element %d and GP %d not defined", aProperty, gp->giveElement()->giveNumber(), gp->giveNumber() );
88 }
89}
90
91
92void
93Material :: initializeFrom(InputRecord &ir)
94{
95 double value;
96
97# ifdef VERBOSE
98 // VERBOSE_PRINT1 ("Instanciating material ",this->giveNumber())
99# endif
100
102 propertyDictionary.add('d', value);
103
104 this->castingTime = -1.e10;
106
107 this->preCastingTimeMat = 0;
109}
110
111
112void
113Material :: giveInputRecord(DynamicInputRecord &input)
114{
115 FEMComponent :: giveInputRecord(input);
118}
119
120
121bool
122Material :: hasMaterialModeCapability(MaterialMode mode) const
123//
124// returns whether receiver supports given mode
125//
126{
127 return false;
128}
129
130bool
131Material :: hasCastingTimeSupport() const
132{
133 return this->castingTime <= 0.;
134}
135
136
137int
138Material :: giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
139{
140 if ( type == IST_MaterialNumber ) {
141 answer.resize(1);
142 answer.at(1) = this->giveNumber();
143 return 1;
144 } else if ( type == IST_Density ) {
145 answer.resize(1);
146 answer.at(1) = this->propertyDictionary.at('d');
147 return 1;
148 }
149
150 answer.clear();
151 return 0;
152}
153
154
155void
156Material :: printYourself()
157// Prints the receiver on screen.
158{
159 printf("Material with properties : \n");
160 propertyDictionary.printYourself();
161}
162
163
164//
165// store & restore context - material info in gp not saved now!
166//
167
168void
169Material :: saveIPContext(DataStream &stream, ContextMode mode, GaussPoint *gp)
170{
171 if ( gp == nullptr ) {
173 }
174
175 MaterialStatus *status = this->giveStatus(gp);
176 if ( status ) {
177 status->saveContext(stream, mode);
178 }
179}
180
181void
182Material :: restoreIPContext(DataStream &stream, ContextMode mode, GaussPoint *gp)
183{
184 if ( gp == nullptr ) {
186 }
187
188 MaterialStatus *status = this->giveStatus(gp);
189 if ( status ) {
190 status->restoreContext(stream, mode);
191 }
192}
193
194
195int Material :: checkConsistency()
196{
197 if ( !this->hasCastingTimeSupport() ) {
198 OOFEM_WARNING("Material %3d does not support casting time (casting time = %lf)", this->giveNumber(), this->castingTime);
199 }
200
201 return FEMComponent :: checkConsistency();
202}
203
204
206Material :: giveStatus(GaussPoint *gp) const
207/*
208 * returns material status in gp corresponding to specific material class
209 */
210{
211 if (gp->hasMaterialStatus()) {
212 return static_cast< MaterialStatus * >( gp->giveMaterialStatus() );
213 } else {
214 MaterialStatus *status = static_cast<MaterialStatus*>(gp->setMaterialStatus (this->CreateStatus(gp)));
215 return status;
216 }
217}
218
219
220void
221Material :: initTempStatus(GaussPoint *gp) const
222//
223// Initialize MatStatus (respective it's temporary variables at the begining
224// of integrating incremental constitutive relations) to correct values
225//
226{
227 MaterialStatus *status = this->giveStatus(gp);
228 if ( status ) {
229 status->initTempStatus();
230 }
231}
232
233
234int
235Material :: initMaterial(Element *element)
236{
237 return 0;
238}
239
240
241void Material :: saveContext(DataStream &stream, ContextMode mode)
242{
243 FEMComponent :: saveContext(stream, mode);
244
245 if ( ( mode & CM_Definition ) ) {
246 propertyDictionary.saveContext(stream);
247
248 if ( !stream.write(castingTime) ) {
250 }
251 }
252}
253
254
255void Material :: restoreContext(DataStream &stream, ContextMode mode)
256{
257 FEMComponent :: restoreContext(stream, mode);
258
259 if ( mode & CM_Definition ) {
260 propertyDictionary.restoreContext(stream);
261
262 if ( !stream.read(castingTime) ) {
264 }
265 }
266}
267
268} // 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.
void setField(int item, InputFieldType id)
int giveNumber() const
Definition femcmpnn.h:104
FEMComponent(int n, Domain *d)
Definition femcmpnn.h:88
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
int giveNumber()
Returns number of receiver.
Definition gausspoint.h:183
Element * giveElement()
Returns corresponding element to receiver.
Definition gausspoint.h:187
virtual void restoreContext(DataStream &stream, ContextMode mode)
virtual void saveContext(DataStream &stream, ContextMode mode)
virtual void initTempStatus()
Definition matstatus.h:99
virtual std::unique_ptr< MaterialStatus > CreateStatus(GaussPoint *gp) const
Definition material.h:332
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Definition material.C:206
double castingTime
Definition material.h:115
int preCastingTimeMat
Material existing before casting time - optional parameter, zero by default.
Definition material.h:118
Dictionary propertyDictionary
Definition material.h:107
virtual bool hasCastingTimeSupport() const
Definition material.C:131
#define THROW_CIOERR(e)
#define CM_Definition
Definition contextmode.h:47
#define OOFEM_WARNING(...)
Definition error.h:80
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define _IFT_Material_density
Definition material.h:52
#define _IFT_Material_castingtime
Definition material.h:53
#define _IFT_Material_preCastingTimeMat
Definition material.h:54
long ContextMode
Definition contextmode.h:43
@ CIO_IOERR
General IO error.
@ CIO_BADOBJ
Bad object passed.

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