OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
ncprincipalstrain.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 "ncprincipalstrain.h"
36 
37 #include "error.h"
38 #include "xfem/enrichmentitem.h"
39 #include "domain.h"
40 #include "element.h"
41 #include "gausspoint.h"
42 
43 #include "Materials/structuralms.h"
45 
47 #include "xfem/xfemmanager.h"
53 #include "dynamicdatareader.h"
54 #include "dynamicinputrecord.h"
55 #include "geometry.h"
56 #include "classfactory.h"
57 #include "spatiallocalizer.h"
58 #include "crosssection.h"
59 
60 #include <memory>
61 
62 namespace oofem {
64 
66 NucleationCriterion(ipDomain),
67 mStrainThreshold(0.0),
68 mInitialCrackLength(0.0),
69 mIncrementLength(1.0),
70 mPropStrainThreshold(0.0),
71 mCutOneEl(false),
72 mCrossSectionInd(1)
73 {
74 
75 }
76 
78 
79 }
80 
81 std::vector<std::unique_ptr<EnrichmentItem>> NCPrincipalStrain::nucleateEnrichmentItems() {
82 
83 
86 
87  std::vector<std::unique_ptr<EnrichmentItem>> eiList;
88 
89  // Center coordinates of newly inserted cracks
90  std::vector<FloatArray> center_coord_inserted_cracks;
91 
92  // Loop over all elements and all bulk GP.
93  for(auto &el : mpDomain->giveElements() ) {
94 
95  int numIR = el->giveNumberOfIntegrationRules();
96 
97  int csNum = el->giveCrossSection()->giveNumber();
98 
99  if(csNum == mCrossSectionInd) {
100 
101  for(int irInd = 0; irInd < numIR; irInd++) {
102  IntegrationRule *ir = el->giveIntegrationRule(irInd);
103 
104 
105  int numGP = ir->giveNumberOfIntegrationPoints();
106 
107  for(int gpInd = 0; gpInd < numGP; gpInd++) {
108  GaussPoint *gp = ir->getIntegrationPoint(gpInd);
109 
110 
112 
113  if(ms != NULL) {
114 
115  const FloatArray &strain = ms->giveTempStrainVector();
116 
117  FloatArray principalVals;
118  FloatMatrix principalDirs;
119  StructuralMaterial::computePrincipalValDir(principalVals, principalDirs, strain, principal_strain);
120 
121  if(principalVals[0] > mStrainThreshold) {
122 
123  FloatArray crackNormal;
124  crackNormal.beColumnOf(principalDirs, 1);
125  // printf("crackNormal: "); crackNormal.printYourself();
126 
127  FloatArray crackTangent = {-crackNormal(1), crackNormal(0)};
128  crackTangent.normalize();
129  // printf("crackTangent: "); crackTangent.printYourself();
130 
131 
132  // Create geometry
133  FloatArray pc = {gp->giveGlobalCoordinates()(0), gp->giveGlobalCoordinates()(1)};
134  // printf("Global coord: "); pc.printYourself();
135 
136 
137  FloatArray ps = pc;
138  ps.add(-0.5*mInitialCrackLength, crackTangent);
139 
140  FloatArray pe = pc;
141  pe.add(0.5*mInitialCrackLength, crackTangent);
142 
143  if(mCutOneEl) {
144  // If desired, ensure that the crack cuts exactly one element.
145  Line line(ps, pe);
146  std::vector<FloatArray> intersecPoints;
147  // line.computeIntersectionPoints(el.get(), intersecPoints);
148 
149 
150  if(intersecPoints.size() == 2) {
151  ps = std::move(intersecPoints[0]);
152  pe = std::move(intersecPoints[1]);
153  }
154  else {
155  OOFEM_ERROR("intersecPoints.size() != 2")
156  }
157  }
158 
159  FloatArray points = {ps(0), ps(1), pc(0), pc(1), pe(0), pe(1)};
160 
161 
162  // Check if nucleation is allowed, by checking for already existing cracks close to the GP.
163  // Idea: Nucleation is not allowed if we are within an enriched element. In this way, branching is not
164  // completely prohibited, but we avoid initiating multiple similar cracks.
165  bool insertionAllowed = true;
166 
167  Element *el_s = octree->giveElementContainingPoint(ps);
168  if(el_s) {
169  if( xMan->isElementEnriched(el_s) ) {
170  insertionAllowed = false;
171  }
172  }
173 
174  Element *el_c = octree->giveElementContainingPoint(pc);
175  if(el_c) {
176  if( xMan->isElementEnriched(el_c) ) {
177  insertionAllowed = false;
178  }
179  }
180 
181  Element *el_e = octree->giveElementContainingPoint(pe);
182  if(el_e) {
183  if( xMan->isElementEnriched(el_e) ) {
184  insertionAllowed = false;
185  }
186  }
187 
188  for(const auto &x: center_coord_inserted_cracks) {
189  if( x.distance(pc) < 2.0*mInitialCrackLength) {
190  insertionAllowed = false;
191  break;
192  printf("Preventing insertion.\n");
193  }
194  }
195 
196  if(insertionAllowed) {
197  int n = xMan->giveNumberOfEnrichmentItems() + 1;
198  std::unique_ptr<Crack> crack(new Crack(n, xMan, mpDomain));
199 
200 
201  // Geometry
202  std::unique_ptr<BasicGeometry> geom = std::unique_ptr<BasicGeometry>(new PolygonLine());
203  geom->insertVertexBack(ps);
204  geom->insertVertexBack(pc);
205  geom->insertVertexBack(pe);
206  crack->setGeometry(std::move(geom));
207 
208  // Enrichment function
210  crack->setEnrichmentFunction(ef);
211 
212  // Enrichment fronts
213 // EnrichmentFront *efStart = new EnrFrontLinearBranchFuncOneEl();
215  crack->setEnrichmentFrontStart(efStart);
216 
217 // EnrichmentFront *efEnd = new EnrFrontLinearBranchFuncOneEl();
219  crack->setEnrichmentFrontEnd(efEnd);
220 
221 
222 
223 
225  // Propagation law
226 
227  // Options
229  pl->setRadius(0.1*mIncrementLength);
232 
233  crack->setPropagationLaw(pl);
234 
235  crack->updateDofIdPool();
236 
237  center_coord_inserted_cracks.push_back(pc);
238  eiList.push_back( std::unique_ptr<EnrichmentItem>(std::move(crack)) );
239 
240  printf("NCPrincipalStrain: Nucleating a crack. principalVals[0]: %e\n", principalVals[0] );
241 
242  // We only introduce one crack per element in a single time step.
243  break;
244  }
245  }
246  }
247 
248  }
249  }
250  } // If correct csNum
251  }
252 
253 
254  return std::move( eiList );
255 }
256 
257 
259 
260  IRResultType result; // Required by IR_GIVE_FIELD macro
261 
263  printf("mStrainThreshold: %e\n", mStrainThreshold);
264 
266  printf("mInitialCrackLength: %e\n", mInitialCrackLength);
267 
269  printf("mIncrementLength: %e\n", mIncrementLength);
270 
272  printf("mPropStrainThreshold: %e\n", mPropStrainThreshold);
273 
275 }
276 
278 {
280 
281  ir->setRecordKeywordField( this->giveInputRecordName(), 1 );
282 
287 
289 
290  // Enrichment function
291  DynamicInputRecord *efRec = new DynamicInputRecord();
294 }
295 
296 } /* namespace oofem */
The base class for all spatial localizers.
void setField(int item, InputFieldType id)
Class and object Domain.
Definition: domain.h:115
Class representing the implementation of a dynamic data reader for in-code use.
For computing principal strains from engineering strains.
virtual const char * giveInputRecordName() const
#define _IFT_NCPrincipalStrain_StrainThreshold
int mCrossSectionInd
Index of the cross section that the nucleation criterion applies to.
This class implements a structural material status information.
Definition: structuralms.h:65
bool mCutOneEl
If the initiated crack should cut exactly one element.
virtual void appendInputRecords(DynamicDataReader &oDR)
Abstract base class for all finite elements.
Definition: element.h:145
virtual IRResultType initializeFrom(InputRecord *ir)
#define _IFT_NCPrincipalStrain_IncrementLength
static void computePrincipalValDir(FloatArray &answer, FloatMatrix &dir, const FloatArray &s, stressStrainPrincMode mode)
Computes principal values and directions of stress or strain vector.
XfemManager * giveXfemManager()
Definition: domain.C:375
Abstract class representing global shape function Base class declares abstract interface common to al...
Abstract base class representing integration rule.
void beColumnOf(const FloatMatrix &mat, int col)
Reciever will be set to a given column in a matrix.
Definition: floatarray.C:1114
int giveNumberOfEnrichmentItems() const
Definition: xfemmanager.h:185
Crack.
Definition: crack.h:54
#define OOFEM_ERROR(...)
Definition: error.h:61
REGISTER_NucleationCriterion(NCPrincipalStrain)
Class EnrichmentFront: describes the edge or tip of an XFEM enrichment.
SpatialLocalizer * giveSpatialLocalizer()
Returns receiver&#39;s associated spatial localizer.
Definition: domain.C:1184
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
const FloatArray & giveTempStrainVector() const
Returns the const pointer to receiver&#39;s temporary strain vector.
Definition: structuralms.h:115
virtual IRResultType initializeFrom(InputRecord *ir)
virtual Element * giveElementContainingPoint(const FloatArray &coords, const IntArray *regionList=NULL)=0
Returns the element, containing given point and belonging to one of the region in region list...
const FloatArray & giveGlobalCoordinates()
Definition: gausspoint.h:160
#define _IFT_NCPrincipalStrain_PropStrainThreshold
void setIncrementLength(double iIncrementLength)
Class representing vector of real numbers.
Definition: floatarray.h:82
virtual std::vector< std::unique_ptr< EnrichmentItem > > nucleateEnrichmentItems()
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
This class manages the xfem part.
Definition: xfemmanager.h:109
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
GaussPoint * getIntegrationPoint(int n)
Access particular integration point of receiver.
IntegrationPointStatus * giveMaterialStatus()
Returns reference to associated material status (NULL if not defined).
Definition: gausspoint.h:205
Class representing the general Input Record.
Definition: inputrecord.h:101
bool isElementEnriched(const Element *elem)
Definition: xfemmanager.C:104
Class representing Heaviside EnrichmentFunction.
int giveNumberOfIntegrationPoints() const
Returns number of integration points of receiver.
Class representing the a dynamic Input Record.
void setRecordKeywordField(std::string keyword, int number)
void setStrainThreshold(double iStrainThreshold)
#define _IFT_NCPrincipalStrain_InitialCrackLength
void setRadius(double iRadius)
std::vector< std::unique_ptr< Element > > & giveElements()
Definition: domain.h:279
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
EnrichmentFunction * mpEnrichmentFunc
double normalize()
Normalizes receiver.
Definition: floatarray.C:828
Class representing integration point in finite element program.
Definition: gausspoint.h:93
void insertInputRecord(InputRecordType type, InputRecord *record)
Main purpose of this class it the possibility to add new input records in code.
void add(const FloatArray &src)
Adds array src to receiver.
Definition: floatarray.C:156

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