OOFEM 3.0
Loading...
Searching...
No Matches
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 - 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
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
47namespace oofem {
49
50IntMatIsoDamageTable :: IntMatIsoDamageTable(int n, Domain *d) : IntMatIsoDamage(n, d) {}
51
52
53void
54IntMatIsoDamageTable :: initializeFrom(InputRecord &ir)
55{
56 StructuralInterfaceMaterial :: initializeFrom(ir);
57
58 std :: ifstream is;
59 int nbrOfLinesToRead;
60
64
65 this->e0 = ft / kn;
66
67 //Set limit on the maximum isotropic damage parameter if needed
69 maxOmega = min(maxOmega, 0.999999);
70 maxOmega = max(maxOmega, 0.0);
71
72 // Parse the table file
74
75 is.open(tablename.c_str(), std :: ifstream :: in);
76 if ( !is.is_open() ) {
77 OOFEM_ERROR(" Can't open table file %s.", tablename.c_str());
78 }
79
80 // Read first line
81 if ( is >> nbrOfLinesToRead ) {
82 printf("NumberofLinestoRead: %d\n", nbrOfLinesToRead);
83 } else {
84 OOFEM_ERROR("IntMatIsoDamageTable :: initializeFrom: Error reading table file, first line should be "
85 "an integer stating how many strain damage pairs that exist in the file.");
86 }
87
88 tableDamages.resize(nbrOfLinesToRead + 1);
89 tableJumps.resize(nbrOfLinesToRead + 1);
90
91 // Insert a (0,0) pair
92 tableJumps(0) = tableDamages(0) = 0.0;
93
94 for ( int i = 0; i < nbrOfLinesToRead; i++ ) {
95 if ( !( is >> tableJumps(i + 1) >> tableDamages(i + 1) ) ) {
96 OOFEM_ERROR("Error reading table file at line %d, expected a "
97 "strain damage pair.", i + 2);
98 }
99
100 if ( ( tableDamages(i + 1) < tableDamages(i) ) || ( tableJumps(i + 1) < tableJumps(i) ) ) {
101 OOFEM_ERROR("Error reading table file at line %d, strain "
102 "and damage must be given in an increasing order and be positive.", i + 2);
103 }
104 }
105
106 // We add e0 to the tableJumps since these should be given as the increase in
107 // strain relative to e0.
108 tableJumps.add(e0);
109}
110
111
112void
113IntMatIsoDamageTable :: giveInputRecord(DynamicInputRecord &input)
114{
115 StructuralInterfaceMaterial :: giveInputRecord(input);
116
122}
123
124
125double
126IntMatIsoDamageTable :: computeDamageParam(double kappa) const
127{
128 if ( kappa > this->e0 ) {
129 // Linear interpolation between able values.
130
131 // If out of bounds damage is set to the last given damage value in the table
132 if ( kappa >= tableJumps.at( tableJumps.giveSize() ) ) {
133 return tableDamages.at( tableDamages.giveSize() );
134 } else {
135 // std::lower_bound uses binary search to find index with value bounding kappa from above
136 int index = (int)(std :: lower_bound(tableJumps.givePointer(), tableJumps.givePointer() + tableJumps.giveSize(), kappa) - tableJumps.givePointer());
137
138#if 0
139 printf("e0 %lf\n", e0);
140 printf( "sizeof %d\n", sizeof( tableJumps.givePointer() ) );
141 printf("pointer: %d\n", index);
142 printf("value: %lf\n", * index);
143 printf( "Index found: %d\n", index - tableJumps.givePointer() );
144 printf( "First index: %d\n", tableJumps.givePointer() );
145 printf( "Last index: %d\n", tableJumps.givePointer() + tableJumps.giveSize() );
146#endif
147
148 // Pointer arithmetic to find the values used in interpolation
149 double x0 = tableJumps(index - 1);
150 double x1 = tableJumps(index );
151 double y0 = tableDamages(index - 1);
152 double y1 = tableDamages(index );
153
154 // Interpolation formula
155 return y0 + ( y1 - y0 ) * ( kappa - x0 ) / ( x1 - x0 );
156 }
157 } else {
158 return 0.0;
159 }
160}
161
162} // end namespace oofem
#define REGISTER_Material(class)
void setField(int item, InputFieldType id)
FloatArray tableDamages
Damages read from the second column in the table file.
std::string tablename
Name of table file.
FloatArray tableJumps
Jumps read from the first column in the table file.
double maxOmega
Maximum limit on omega. The purpose is elimination of a too compliant material which may cause conver...
IntMatIsoDamage(int n, Domain *d)
double kn
Elastic properties (normal moduli).
double e0
Limit elastic deformation.
double ks
Shear moduli.
double ft
Tension strength.
#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_IntMatIsoDamageTable_ks
#define _IFT_IntMatIsoDamageTable_tablename
#define _IFT_IntMatIsoDamageTable_maxOmega
#define _IFT_IntMatIsoDamageTable_ft
#define _IFT_IntMatIsoDamageTable_kn
FloatArrayF< N > min(const FloatArrayF< N > &a, const FloatArrayF< N > &b)
FloatArrayF< N > max(const FloatArrayF< N > &a, const FloatArrayF< N > &b)

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