OOFEM 3.0
Loading...
Searching...
No Matches
crackexportmodule.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 program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (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
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
33 */
34
35#include "crackexportmodule.h"
36#include "gausspoint.h"
37#include "material.h"
38#include "element.h"
39#include "integrationrule.h"
40#include "timestep.h"
41#include "engngm.h"
42#include "classfactory.h"
44#include "crosssection.h"
45#include "floatarray.h"
46
47#include <fstream>
48#include <sstream>
49#include <boost/concept_check.hpp>
50
51namespace oofem {
52
54
55
56CrackExportModule :: CrackExportModule(int n, EngngModel *e) : ExportModule(n, e)
57{
58}
59
60
61CrackExportModule :: ~CrackExportModule()
62{
63}
64
65
66void
67CrackExportModule :: initializeFrom(InputRecord &ir)
68{
69 ExportModule :: initializeFrom(ir);
70
72 this->threshold = 0.;
74}
75
76
77void
78CrackExportModule :: doOutput(TimeStep *tStep, bool forcedOutput)
79{
80 if ( !testTimeStepOutput(tStep) ) {
81 return;
82 }
83
84 double crackLength_projection;
85 double crackLength_sqrt;
86 double crackWidth;
87 double crackAngle;
88 double elementLength;
89
90 double damage;
91 FloatArray crackVector;
92 FloatMatrix princDir;
93 FloatMatrix rotMatrix;
94 FloatArray strainVector, princStrain;
95
96 double weight, totWeight;
97
98 Domain *d = emodel->giveDomain(1);
99
100 std::vector< FloatArray > pointsVector;
101
102 for ( auto &elem : d->giveElements() ) {
103
104 int csNumber = elem->giveCrossSection()->giveNumber();
105 if ( this->crossSections.containsSorted( csNumber ) ) {
106
107 totWeight = 0.;
108 crackWidth = 0.;
109 crackLength_projection = 0.;
110 crackLength_sqrt = 0.;
111 crackAngle = 0.;
112
113 for ( int i = 0; i < elem->giveNumberOfIntegrationRules(); i++ ) {
114 IntegrationRule *iRule = elem->giveIntegrationRule(i);
115
116 for ( auto &gp: *iRule ) {
117
118 FloatArray tmp;
119 elem->giveIPValue(tmp, gp, IST_DamageScalar, tStep);
120 damage = tmp.at(1);
121 elem->giveIPValue(strainVector, gp, IST_StrainTensor, tStep);
122
123 if ( damage > 0. ) {
124
125 weight = elem->computeVolumeAround(gp);
126 totWeight += weight;
127
128 elem->giveIPValue(tmp, gp, IST_CharacteristicLength, tStep);
129 elementLength = tmp.at(1);
130 elem->giveIPValue(crackVector, gp, IST_CrackVector, tStep);
131 crackVector.times(1./damage);
132
133 princDir.resize(2,2);
134
135 princDir.at(1,1) = crackVector.at(2);
136 princDir.at(2,1) = -crackVector.at(1);
137
138 princDir.at(1,2) = crackVector.at(1);
139 princDir.at(2,2) = crackVector.at(2);
140
141 // modify shear strain in order to allow transformation with the stress transformation matrix
142 strainVector = {strainVector(0), strainVector(1), strainVector(6)*0.5};
143
144 StructuralMaterial :: givePlaneStressVectorTranformationMtrx(rotMatrix, princDir, false);
145 princStrain.beProductOf(rotMatrix, strainVector);
146
147 crackWidth += elementLength * princStrain.at(1) * damage * weight;
148 crackLength_projection += elem->giveCharacteristicSize(gp, crackVector, ECSM_Projection) * weight;
149 crackLength_sqrt += elem->giveCharacteristicSize(gp, crackVector, ECSM_SquareRootOfArea) * weight;
150
151 if ( crackVector.at(1) != 0. ) {
152 double contrib = atan( crackVector.at(2) / crackVector.at(1) ) * 180./3.1415926;
153 if ( contrib < 0. ) {
154 contrib += 180.;
155 } else if ( contrib > 180. ) {
156 contrib -= 180.;
157 }
158 crackAngle += contrib * weight;
159 } else {
160 crackAngle += 90. * weight;
161 }
162
163#if 0
164 double length1 = elem->giveCharacteristicSize(gp, crackVector, ECSM_SquareRootOfArea);
165 double length2 = elem->giveCharacteristicSize(gp, crackVector, ECSM_ProjectionCentered);
166 double length3 = elem->giveCharacteristicSize(gp, crackVector, ECSM_Oliver1);
167 double length4 = elem->giveCharacteristicSize(gp, crackVector, ECSM_Oliver1modified);
168 double length5 = elem->giveCharacteristicSize(gp, crackVector, ECSM_Projection);
169#endif
170
171 } else {
172 crackWidth += 0.;
173 crackLength_projection += 0.;
174 crackLength_sqrt += 0.;
175 crackAngle += 0.;
176 }
177 }
178
179 if ( totWeight > 0. ) {
180 crackWidth /= totWeight;
181 crackLength_projection /= totWeight;
182 crackLength_sqrt /= totWeight;
183 crackAngle /= totWeight;
184 }
185
186 if ( crackWidth >= threshold ) {
187
188 pointsVector.emplace_back({
189 elem->giveNumber(),
190 crackWidth,
191 crackAngle,
192 crackLength_projection,
193 crackLength_sqrt
194 });
195 }
196 }
197 }
198 }
199 // print to output
200 std :: stringstream strCracks;
201 strCracks << ".dat";
202 std :: string nameCracks = this->giveOutputBaseFileName(tStep) + strCracks.str();
203 writeToOutputFile(nameCracks, pointsVector);
204}
205
206
207void CrackExportModule :: writeToOutputFile(const std :: string &iName, const std :: vector< FloatArray > &iPoints)
208{
209 std :: ofstream file;
210 file.open( iName.data() );
211
212 // Set some output options
213 file << std :: scientific;
214
215 file << "#elem\twidth\tangle\tlength_project\tlength_sqrt\n";
216
217 for ( auto posVec: iPoints ) {
218 for ( auto &val : posVec ) {
219 file << val << "\t";
220 }
221 file << "\n";
222 }
223
224 file.close();
225}
226
227
228void
229CrackExportModule :: initialize()
230{
231 ExportModule :: initialize();
232}
233
234
235void
236CrackExportModule :: terminate()
237{}
238
239}
#define REGISTER_ExportModule(class)
static void writeToOutputFile(const std ::string &iName, const std ::vector< FloatArray > &iPoints)
std ::vector< std ::unique_ptr< Element > > & giveElements()
Definition domain.h:294
std::string giveOutputBaseFileName(TimeStep *tStep)
EngngModel * emodel
Problem pointer.
bool testTimeStepOutput(TimeStep *tStep)
double & at(Index i)
Definition floatarray.h:202
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Definition floatarray.C:689
void times(double s)
Definition floatarray.C:834
void resize(Index rows, Index cols)
Definition floatmatrix.C:79
double at(std::size_t i, std::size_t j) const
#define _IFT_CrackExportModule_cs
#define _IFT_CrackExportModule_threshold
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Definition inputrecord.h:75
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
@ ECSM_SquareRootOfArea
@ ECSM_ProjectionCentered

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