OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 2012 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 
51 namespace oofem {
52 
54 
55 
57 {
58 }
59 
60 
62 {
63 }
64 
65 
68 {
69  const char *__proc = "initializeFrom"; // Required by IR_GIVE_FIELD macro
70  IRResultType result; // Required by IR_GIVE_FIELD macro
71 
72 
74  this->threshold = 0.;
76 
78 }
79 
80 
81 void
82 CrackExportModule :: doOutput(TimeStep *tStep, bool forcedOutput)
83 {
84  if ( !testTimeStepOutput(tStep) ) {
85  return;
86  }
87 
88  double crackLength_projection;
89  double crackLength_sqrt;
90  double crackWidth;
91  double crackAngle;
92  double elementLength;
93 
94  double damage;
95  FloatArray crackVector;
96  FloatMatrix princDir;
97  FloatMatrix rotMatrix;
98  FloatArray strainVector, princStrain;
99 
100  double weight, totWeight;
101 
102  Domain *d = emodel->giveDomain(1);
103 
104  std::vector< FloatArray > pointsVector;
105 
106  for ( auto &elem : d->giveElements() ) {
107 
108  int csNumber = elem->giveCrossSection()->giveNumber();
109  if ( this->crossSections.containsSorted( csNumber ) ) {
110 
111  totWeight = 0.;
112  crackWidth = 0.;
113  crackLength_projection = 0.;
114  crackLength_sqrt = 0.;
115  crackAngle = 0.;
116 
117  for ( int i = 0; i < elem->giveNumberOfIntegrationRules(); i++ ) {
118  IntegrationRule *iRule = elem->giveIntegrationRule(i);
119 
120  for ( auto &gp: *iRule ) {
121 
122  FloatArray tmp;
123  elem->giveIPValue(tmp, gp, IST_DamageScalar, tStep);
124  damage = tmp.at(1);
125  elem->giveIPValue(strainVector, gp, IST_StrainTensor, tStep);
126 
127  if ( damage > 0. ) {
128 
129  weight = elem->computeVolumeAround(gp);
130  totWeight += weight;
131 
132  elem->giveIPValue(tmp, gp, IST_CharacteristicLength, tStep);
133  elementLength = tmp.at(1);
134  elem->giveIPValue(crackVector, gp, IST_CrackVector, tStep);
135  crackVector.times(1./damage);
136 
137  princDir.resize(2,2);
138 
139  princDir.at(1,1) = crackVector.at(2);
140  princDir.at(2,1) = -crackVector.at(1);
141 
142  princDir.at(1,2) = crackVector.at(1);
143  princDir.at(2,2) = crackVector.at(2);
144 
145  // modify shear strain in order to allow transformation with the stress transformation matrix
146  strainVector = {strainVector(0), strainVector(1), strainVector(6)*0.5};
147 
149  princStrain.beProductOf(rotMatrix, strainVector);
150 
151  crackWidth += elementLength * princStrain.at(1) * damage * weight;
152  crackLength_projection += elem->giveCharacteristicSize(gp, crackVector, ECSM_Projection) * weight;
153  crackLength_sqrt += elem->giveCharacteristicSize(gp, crackVector, ECSM_SquareRootOfArea) * weight;
154 
155  if ( crackVector.at(1) != 0. ) {
156  double contrib = atan( crackVector.at(2) / crackVector.at(1) ) * 180./3.1415926;
157  if ( contrib < 0. ) {
158  contrib += 180.;
159  } else if ( contrib > 180. ) {
160  contrib -= 180.;
161  }
162  crackAngle += contrib * weight;
163  } else {
164  crackAngle += 90. * weight;
165  }
166 
167 #if 0
168  double length1 = elem->giveCharacteristicSize(gp, crackVector, ECSM_SquareRootOfArea);
169  double length2 = elem->giveCharacteristicSize(gp, crackVector, ECSM_ProjectionCentered);
170  double length3 = elem->giveCharacteristicSize(gp, crackVector, ECSM_Oliver1);
171  double length4 = elem->giveCharacteristicSize(gp, crackVector, ECSM_Oliver1modified);
172  double length5 = elem->giveCharacteristicSize(gp, crackVector, ECSM_Projection);
173 #endif
174 
175  } else {
176  crackWidth += 0.;
177  crackLength_projection += 0.;
178  crackLength_sqrt += 0.;
179  crackAngle += 0.;
180  }
181  }
182 
183  if ( totWeight > 0. ) {
184  crackWidth /= totWeight;
185  crackLength_projection /= totWeight;
186  crackLength_sqrt /= totWeight;
187  crackAngle /= totWeight;
188  }
189 
190  if ( crackWidth >= threshold ) {
191 
192  pointsVector.emplace_back({
193  elem->giveNumber(),
194  crackWidth,
195  crackAngle,
196  crackLength_projection,
197  crackLength_sqrt
198  });
199  }
200  }
201  }
202  }
203  // print to output
204  std :: stringstream strCracks;
205  strCracks << ".dat";
206  std :: string nameCracks = this->giveOutputBaseFileName(tStep) + strCracks.str();
207  writeToOutputFile(nameCracks, pointsVector);
208 }
209 
210 
211 void CrackExportModule :: writeToOutputFile(const std :: string &iName, const std :: vector< FloatArray > &iPoints)
212 {
213  std :: ofstream file;
214  file.open( iName.data() );
215 
216  // Set some output options
217  file << std :: scientific;
218 
219  file << "#elem\twidth\tangle\tlength_project\tlength_sqrt\n";
220 
221  for ( auto posVec: iPoints ) {
222  for ( auto &val : posVec ) {
223  file << val << "\t";
224  }
225  file << "\n";
226  }
227 
228  file.close();
229 }
230 
231 
232 void
234 {
236 }
237 
238 
239 void
241 {}
242 
243 }
bool testTimeStepOutput(TimeStep *tStep)
Tests if given time step output is required.
Definition: exportmodule.C:148
static void givePlaneStressVectorTranformationMtrx(FloatMatrix &answer, const FloatMatrix &base, bool transpose=false)
Computes 2d stress vector transformation matrix from standard vector transformation matrix...
Class and object Domain.
Definition: domain.h:115
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
virtual ~CrackExportModule()
Destructor.
static void writeToOutputFile(const std::string &iName, const std::vector< FloatArray > &iPoints)
virtual void initialize()
Definition: exportmodule.C:86
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Represents export output module - a base class for all output modules.
Definition: exportmodule.h:71
#define _IFT_CrackExportModule_cs
Abstract base class representing integration rule.
CrossSection * giveCrossSection(int n)
Service for accessing particular domain cross section model.
Definition: domain.C:339
EngngModel * emodel
Problem pointer.
Definition: exportmodule.h:77
void beProductOf(const FloatMatrix &aMatrix, const FloatArray &anArray)
Receiver becomes the result of the product of aMatrix and anArray.
Definition: floatarray.C:676
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
#define _IFT_CrackExportModule_threshold
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Definition: exportmodule.C:58
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
virtual void doOutput(TimeStep *tStep, bool forcedOutput)
Writes the output.
virtual void terminate()
Terminates the receiver.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
Abstract base class representing the "problem" under consideration.
Definition: engngm.h:181
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
This one-purpose export module serves for estimation of the total water loss.
the oofem namespace is to define a context or scope in which all oofem names are defined.
Domain * giveDomain(int n)
Service for accessing particular problem domain.
Definition: engngm.C:1720
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
int giveNumber() const
Definition: femcmpnn.h:107
bool containsSorted(int value) const
Checks if sorted receiver contains a given value.
Definition: intarray.h:238
std::string giveOutputBaseFileName(TimeStep *tStep)
Gives the appropriate name (minus specific file extension).
Definition: exportmodule.C:125
Class representing solution step.
Definition: timestep.h:80
REGISTER_ExportModule(ErrorCheckingExportModule)

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:28 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011