OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
intmatisodamagetable.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 "intmatisodamagetable.h"
36 #include "gausspoint.h"
37 #include "floatmatrix.h"
38 #include "floatarray.h"
39 #include "mathfem.h"
40 #include "datastream.h"
41 #include "contextioerr.h"
42 #include "classfactory.h"
43 #include "dynamicinputrecord.h"
44 
45 #include <algorithm>
46 
47 namespace oofem {
48 REGISTER_Material(IntMatIsoDamageTable);
49 
51 
52 
53 
55 
56 
57 
58 
61 {
62  IRResultType result; // Required by IR_GIVE_FIELD macro
63  std :: ifstream is;
64  int nbrOfLinesToRead;
65 
69 
70  this->e0 = ft / kn;
71 
72  //Set limit on the maximum isotropic damage parameter if needed
74  maxOmega = min(maxOmega, 0.999999);
75  maxOmega = max(maxOmega, 0.0);
76 
77  // Parse the table file
79 
80  is.open(tablename.c_str(), std :: ifstream :: in);
81  if ( !is.is_open() ) {
82  OOFEM_ERROR(" Can't open table file %s.", tablename.c_str());
83  }
84 
85  // Read first line
86  if ( is >> nbrOfLinesToRead ) {
87  printf("NumberofLinestoRead: %d\n", nbrOfLinesToRead);
88  } else {
89  OOFEM_ERROR("IntMatIsoDamageTable :: initializeFrom: Error reading table file, first line should be "
90  "an integer stating how many strain damage pairs that exist in the file.");
91  }
92 
93  tableDamages.resize(nbrOfLinesToRead + 1);
94  tableJumps.resize(nbrOfLinesToRead + 1);
95 
96  // Insert a (0,0) pair
97  tableJumps(0) = tableDamages(0) = 0.0;
98 
99  for ( int i = 0; i < nbrOfLinesToRead; i++ ) {
100  if ( !( is >> tableJumps(i + 1) >> tableDamages(i + 1) ) ) {
101  OOFEM_ERROR("Error reading table file at line %d, expected a "
102  "strain damage pair.", i + 2);
103  }
104 
105  if ( ( tableDamages(i + 1) < tableDamages(i) ) || ( tableJumps(i + 1) < tableJumps(i) ) ) {
106  OOFEM_ERROR("Error reading table file at line %d, strain "
107  "and damage must be given in an increasing order and be positive.", i + 2);
108  }
109  }
110 
111  // We add e0 to the tableJumps since these should be given as the increase in
112  // strain relative to e0.
113  tableJumps.add(e0);
114 
116 }
117 
118 
119 void
121 {
123 
129 }
130 
131 
132 
133 void
134 IntMatIsoDamageTable :: computeDamageParam(double &omega, double kappa)
135 {
136  if ( kappa > this->e0 ) {
137  // Linear interpolation between able values.
138 
139  // If out of bounds damage is set to the last given damage value in the table
140  if ( kappa >= tableJumps.at( tableJumps.giveSize() ) ) {
141  omega = tableDamages.at( tableDamages.giveSize() );
142  } else {
143  // std::lower_bound uses binary search to find index with value bounding kappa from above
144  int index = (int)(std :: lower_bound(tableJumps.givePointer(), tableJumps.givePointer() + tableJumps.giveSize(), kappa) - tableJumps.givePointer());
145 
146 #if 0
147  printf("e0 %lf\n", e0);
148  printf( "sizeof %d\n", sizeof( tableJumps.givePointer() ) );
149  printf("pointer: %d\n", index);
150  printf("value: %lf\n", * index);
151  printf( "Index found: %d\n", index - tableJumps.givePointer() );
152  printf( "First index: %d\n", tableJumps.givePointer() );
153  printf( "Last index: %d\n", tableJumps.givePointer() + tableJumps.giveSize() );
154 #endif
155 
156  // Pointer arithmetic to find the values used in interpolation
157  double x0 = tableJumps(index - 1);
158  double x1 = tableJumps(index );
159  double y0 = tableDamages(index - 1);
160  double y1 = tableDamages(index );
161 
162  // Interpolation formula
163  omega = y0 + ( y1 - y0 ) * ( kappa - x0 ) / ( x1 - x0 );
164  }
165  } else {
166  omega = 0.0;
167  }
168 }
169 
170 
171 
172 
173 } // end namespace oofem
FloatArray tableJumps
Jumps read from the first column in the table file.
void setField(int item, InputFieldType id)
std::string tablename
Additional parameters Name of table file.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Class and object Domain.
Definition: domain.h:115
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
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
double kn
Elastic properties (normal moduli).
IntMatIsoDamageTable(int n, Domain *d)
Constructor.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
#define _IFT_IntMatIsoDamageTable_ft
#define _IFT_IntMatIsoDamageTable_kn
double e0
Limit elastic deformation.
#define OOFEM_ERROR(...)
Definition: error.h:61
virtual ~IntMatIsoDamageTable()
Destructor.
double ks
Shear moduli.
#define _IFT_IntMatIsoDamageTable_ks
Simple isotropic damage based model for interface elements.
FloatArray tableDamages
Damages read from the second column in the table file.
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
Class representing the general Input Record.
Definition: inputrecord.h:101
#define _IFT_IntMatIsoDamageTable_maxOmega
Class representing the a dynamic Input Record.
const double * givePointer() const
Gives the pointer to the raw data, breaking encapsulation.
Definition: floatarray.h:469
#define _IFT_IntMatIsoDamageTable_tablename
double ft
Tension strength.
int min(int i, int j)
Returns smaller value from two given decimals.
Definition: mathfem.h:59
REGISTER_Material(DummyMaterial)
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
double maxOmega
Maximum limit on omega. The purpose is elimination of a too compliant material which may cause conver...
virtual void computeDamageParam(double &omega, double kappa)
Computes the value of damage parameter omega, based on given value of equivalent strain.
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156
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