OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
isointerfacedamage02.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 <algorithm>
36 
37 #include "isointerfacedamage02.h"
38 #include "gausspoint.h"
39 #include "floatmatrix.h"
40 #include "floatarray.h"
41 #include "mathfem.h"
42 #include "datastream.h"
43 #include "contextioerr.h"
44 #include "classfactory.h"
45 #include "dynamicinputrecord.h"
46 
47 namespace oofem {
48 REGISTER_Material(IsoInterfaceDamageMaterial_2);
49 
51 {
52  maxOmega = 0.999999;
53 }
54 
55 
57 
58 
59 void
61 {
63  FloatMatrix de;
64  double f, equivStrain, tempKappa = 0.0, omega = 0.0;
65 
66  // compute equivalent strain
67  equivStrain = macbra( jump.at(1) );
68 
69  // compute value of loading function if strainLevel crit apply
70  f = equivStrain - status->giveKappa();
71 
72  if ( f <= 0.0 ) {
73  // damage do not grow
74  tempKappa = status->giveKappa();
75  omega = status->giveDamage();
76  } else {
77  // damage grows
78  tempKappa = equivStrain;
79  // evaluate damage parameter
80  this->computeDamageParam(omega, tempKappa, jump, gp);
81  }
82 
83  this->give3dStiffnessMatrix_Eng(de, ElasticStiffness, gp, tStep);
84  // damage in tension only
85  if ( equivStrain >= 0.0 ) {
86  de.times(1.0 - omega);
87  }
88 
89  answer.beProductOf(de, jump);
90 
91  // update gp
92  status->letTempJumpBe(jump);
93  status->letTempTractionBe(answer);
94  status->setTempKappa(tempKappa);
95  status->setTempDamage(omega);
96 }
97 
98 
99 void
101 {
102  double om, un;
104 
105  // assemble eleastic stiffness
106  answer.resize(3, 3);
107  answer.zero();
108  answer.at(1, 1) = kn;
109  answer.at(2, 2) = ks;
110  answer.at(3, 3) = ks;
111 
112  if ( rMode == ElasticStiffness ) {
113  return;
114  }
115 
116  if ( rMode == SecantStiffness ) {
117  // Secant stiffness
118  om = status->giveTempDamage();
119  un = status->giveTempJump().at(1);
120  om = min(om, maxOmega);
121  // damage in tension only
122  if ( un >= 0 ) {
123  answer.times(1.0 - om);
124  }
125 
126  return;
127  } else {
128  // Tangent Stiffness
129  FloatArray se;
130  const FloatArray &e = status->giveTempJump();
131  se.beProductOf(answer, e);
132 
133  om = status->giveTempDamage();
134  un = status->giveTempJump().at(1);
135  om = min(om, maxOmega);
136  // damage in tension only
137  if ( un >= 0 ) {
138  answer.times(1.0 - om);
139  return;
140 #if 0
141  // Unreachable code - commented out to supress compiler warnings
142  double dom = -( -e0 / un / un * exp( -( ft / gf ) * ( un - e0 ) ) + e0 / un * exp( -( ft / gf ) * ( un - e0 ) ) * ( -( ft / gf ) ) );
143  if ( ( om > 0. ) && ( status->giveTempKappa() > status->giveKappa() ) ) {
144  answer.at(1, 1) -= se.at(1) * dom;
145  answer.at(2, 1) -= se.at(2) * dom;
146  }
147 #endif
148  }
149  }
150 }
151 
152 
153 int
155 {
157  if ( type == IST_DamageTensor ) {
158  answer.resize(6);
159  answer.zero();
160  answer.at(1) = answer.at(2) = answer.at(3) = status->giveDamage();
161  return 1;
162  } else if ( type == IST_DamageTensorTemp ) {
163  answer.resize(6);
164  answer.zero();
165  answer.at(1) = answer.at(2) = answer.at(3) = status->giveTempDamage();
166  return 1;
167  } else if ( type == IST_PrincipalDamageTensor ) {
168  answer.resize(3);
169  answer.at(1) = answer.at(2) = answer.at(3) = status->giveDamage();
170  return 1;
171  } else if ( type == IST_PrincipalDamageTempTensor ) {
172  answer.resize(3);
173  answer.at(1) = answer.at(2) = answer.at(3) = status->giveTempDamage();
174  return 1;
175  } else if ( type == IST_MaxEquivalentStrainLevel ) {
176  answer.resize(1);
177  answer.at(1) = status->giveKappa();
178  return 1;
179  } else {
180  return StructuralInterfaceMaterial :: giveIPValue(answer, gp, type, tStep);
181  }
182 }
183 
184 
187 {
188  IRResultType result; // Required by IR_GIVE_FIELD macro
189  std :: ifstream is;
190  int nbrOfLinesToRead;
191 
195 
196  this->e0 = ft / kn;
197 
198  //Set limit on the maximum isotropic damage parameter if needed
200  maxOmega = min(maxOmega, 0.999999);
201  maxOmega = max(maxOmega, 0.0);
202 
203  // Parse the table file
205 
206  is.open(tablename.c_str(), std :: ifstream :: in);
207  if ( !is.is_open() ) {
208  OOFEM_ERROR("Can't open table file %s.", tablename.c_str() );
209  }
210 
211  // Read first line
212  if ( is >> nbrOfLinesToRead ) {
213  printf("NumberofLinestoRead: %d\n", nbrOfLinesToRead);
214  } else {
215  OOFEM_ERROR("Error reading table file, first line should be "
216  "an integer stating how many strain damage pairs that exist in the file.");
217  }
218 
219  damages.resize(nbrOfLinesToRead + 1);
220  strains.resize(nbrOfLinesToRead + 1);
221 
222  // Insert a (0,0) pair
223  strains(0) = damages(0) = 0.0;
224 
225  for ( int i = 0; i < nbrOfLinesToRead; i++ ) {
226  if ( !( is >> strains(i + 1) >> damages(i + 1) ) ) {
227  OOFEM_ERROR("Error reading table file at line %d, expected a "
228  "strain damage pair.", i + 2);
229  }
230 
231  if ( ( damages(i + 1) < damages(i) ) || ( strains(i + 1) < strains(i) ) ) {
232  OOFEM_ERROR("Error reading table file at line %d, strain "
233  "and damage must be given in an increasing order and be positive.", i + 2);
234  }
235  }
236 
237  // We add e0 to the strains since strains should be given as the increase in
238  // strain relative to e0.
239  strains.add(e0);
240 
242 }
243 
244 
245 void
247 {
249 
255 }
256 
257 
258 void
260 {
261  kappa = macbra( strain.at(1) );
262 }
263 
264 void
265 IsoInterfaceDamageMaterial_2 :: computeDamageParam(double &omega, double kappa, const FloatArray &strain, GaussPoint *gp)
266 {
267  if ( kappa > this->e0 ) {
268  // Linear interpolation between table values.
269 
270  // If out of bounds damage is set to the last given damage value in the table
271  if ( kappa >= strains.at( strains.giveSize() ) ) {
272  omega = damages.at( damages.giveSize() );
273  } else {
274  // std::lower_bound uses binary search to find index with value bounding kappa from above
275  int index = (int)(std :: lower_bound(strains.givePointer(), strains.givePointer() + strains.giveSize(), kappa) - strains.givePointer());
276 
277 #if 0
278  printf("e0 %lf\n", e0);
279  printf( "sizeof %d\n", sizeof( strains.givePointer() ) );
280  printf("pointer: %d\n", index);
281  printf("value: %lf\n", * index);
282  printf( "Index found: %d\n", index - strains.givePointer() );
283  printf( "First index: %d\n", strains.givePointer() );
284  printf( "Last index: %d\n", strains.givePointer() + strains.giveSize() );
285 #endif
286 
287  // Pointer arithmetic to find the values used in interpolation
288  double x0 = strains(index - 1);
289  double x1 = strains(index );
290  double y0 = damages(index - 1);
291  double y1 = damages(index );
292 
293  // Interpolation formula
294  omega = y0 + ( y1 - y0 ) * ( kappa - x0 ) / ( x1 - x0 );
295  }
296  } else {
297  omega = 0.0;
298  }
299 }
300 
301 
303 {
304  kappa = tempKappa = 0.0;
305  damage = tempDamage = 0.0;
306 }
307 
308 
310 { }
311 
312 
313 void
315 {
317  fprintf(file, "status { ");
318  if ( this->damage > 0.0 ) {
319  fprintf(file, "kappa %f, damage %f ", this->kappa, this->damage);
320  }
321 
322  fprintf(file, "}\n");
323 }
324 
325 
326 void
328 {
330  this->tempKappa = this->kappa;
331  this->tempDamage = this->damage;
332 }
333 
334 void
336 {
338  this->kappa = this->tempKappa;
339  this->damage = this->tempDamage;
340 }
341 
342 
345 {
346  contextIOResultType iores;
347 
348  // save parent class status
349  if ( ( iores = StructuralInterfaceMaterialStatus :: saveContext(stream, mode, obj) ) != CIO_OK ) {
350  THROW_CIOERR(iores);
351  }
352 
353  // write a raw data
354  if ( !stream.write(kappa) ) {
356  }
357 
358  if ( !stream.write(damage) ) {
360  }
361 
362  return CIO_OK;
363 }
364 
367 {
368  contextIOResultType iores;
369 
370  // read parent class status
371  if ( ( iores = StructuralInterfaceMaterialStatus :: restoreContext(stream, mode, obj) ) != CIO_OK ) {
372  THROW_CIOERR(iores);
373  }
374 
375  // read raw data
376  if ( !stream.read(kappa) ) {
378  }
379 
380  if ( !stream.read(damage) ) {
382  }
383 
384  return CIO_OK;
385 }
386 } // end namespace oofem
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
InternalStateType
Type representing the physical meaning of element or constitutive model internal variable.
void setField(int item, InputFieldType id)
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
virtual MaterialStatus * giveStatus(GaussPoint *gp) const
Returns material status of receiver in given integration point.
Definition: material.C:244
double maxOmega
Maximum limit on omega. The purpose is elimination of a too compliant material which may cause conver...
double kappa
Scalar measure of the largest equivalent displacement ever reached in material.
Class and object Domain.
Definition: domain.h:115
#define _IFT_IsoInterfaceDamageMaterial_2_kn
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
int max(int i, int j)
Returns bigger value form two given decimals.
Definition: mathfem.h:71
double kn
Elastic properties (normal moduli).
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
double macbra(double x)
Returns the positive part of given float.
Definition: mathfem.h:115
General IO error.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
virtual int read(int *data, int count)=0
Reads count integer values into array pointed by data.
MatResponseMode
Describes the character of characteristic material matrix.
virtual contextIOResultType restoreContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Restores the receiver state previously written in stream.
virtual ~IsoInterfaceDamageMaterial_2()
Destructor.
#define THROW_CIOERR(e)
Definition: contextioerr.h:61
virtual void updateYourself(TimeStep *tStep)
Update equilibrium history variables according to temp-variables.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
double damage
Damage level of material.
std::string tablename
Name of table file.
virtual int giveIPValue(FloatArray &answer, GaussPoint *gp, InternalStateType type, TimeStep *tStep)
Returns the integration point corresponding value in Reduced form.
virtual int write(const int *data, int count)=0
Writes count integer values from array pointed by data.
double giveTempDamage()
Returns the temp. damage level.
This class implements associated Material Status to IsoInterfaceDamageMaterial_2. ...
#define OOFEM_ERROR(...)
Definition: error.h:61
void letTempJumpBe(FloatArray v)
Assigns tempJump to given vector v.
void times(double f)
Multiplies receiver by factor f.
Definition: floatmatrix.C:1594
void setTempDamage(double newDamage)
Sets the temp damage level to given value.
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix and anArray.
Definition: floatarray.C:676
This class implements a structural interface material status information.
double giveDamage()
Returns the last equilibrated damage level.
double giveTempKappa()
Returns the temp. scalar measure of the largest strain level.
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
void setTempKappa(double newKappa)
Sets the temp scalar measure of the largest strain level to given value.
IsoInterfaceDamageMaterialStatus_2(int n, Domain *d, GaussPoint *g)
Constructor.
virtual void updateYourself(TimeStep *tStep)
Update equilibrium history variables according to temp-variables.
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
double giveKappa()
Returns the last equilibrated scalar measure of the largest strain level.
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Print receiver&#39;s output to given stream.
FloatArray damages
Damages read from the second column in the table file.
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
virtual void give3dStiffnessMatrix_Eng(FloatMatrix &answer, MatResponseMode rMode, GaussPoint *gp, TimeStep *tStep)
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual void computeEquivalentStrain(double &kappa, const FloatArray &strain, GaussPoint *gp, TimeStep *tStep)
Computes the equivalent strain measure from given strain vector (full form).
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
Definition: floatmatrix.C:1358
Class representing the general Input Record.
Definition: inputrecord.h:101
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
#define _IFT_IsoInterfaceDamageMaterial_2_maxOmega
virtual contextIOResultType saveContext(DataStream &stream, ContextMode mode, void *obj=NULL)
Stores receiver state to output stream.
Class representing the a dynamic Input Record.
const double * givePointer() const
Gives the pointer to the raw data, breaking encapsulation.
Definition: floatarray.h:469
long ContextMode
Context mode (mask), defining the type of information written/read to/from context.
Definition: contextmode.h:43
#define _IFT_IsoInterfaceDamageMaterial_2_ks
virtual void giveEngTraction_3d(FloatArray &answer, GaussPoint *gp, const FloatArray &jump, TimeStep *tStep)
virtual void printOutputAt(FILE *file, TimeStep *tStep)
Print receiver&#39;s output to given stream.
void zero()
Zeroes all coefficient of receiver.
Definition: floatmatrix.C:1326
int min(int i, int j)
Returns smaller value from two given decimals.
Definition: mathfem.h:59
IsoInterfaceDamageMaterial_2(int n, Domain *d)
Constructor.
REGISTER_Material(DummyMaterial)
void letTempTractionBe(FloatArray v)
Assigns tempTraction to given vector v.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
double tempDamage
Non-equilibrated damage level of material.
#define _IFT_IsoInterfaceDamageMaterial_2_tablename
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
Abstract base class for all "structural" interface models.
#define _IFT_IsoInterfaceDamageMaterial_2_ft
the oofem namespace is to define a context or scope in which all oofem names are defined.
double e0
Limit elastic deformation.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
const FloatArray & giveTempJump() const
Returns the const pointer to receiver&#39;s temporary jump.
virtual void initTempStatus()
Initializes the temporary internal variables, describing the current state according to previously re...
double tempKappa
Non-equilibrated scalar measure of the largest equivalent displacement.
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
FloatArray strains
Strains read from the first column in the table file.
virtual void computeDamageParam(double &omega, double kappa, const FloatArray &strain, GaussPoint *gp)
computes the value of damage parameter omega, based on given value of equivalent strain.
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:29 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011