OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
plprincipalstrain.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 "plprincipalstrain.h"
36 #include "xfem/propagationlaw.h"
37 #include "xfem/tipinfo.h"
38 #include "classfactory.h"
39 #include "mathfem.h"
40 #include "dynamicinputrecord.h"
41 #include "spatiallocalizer.h"
42 #include "floatmatrix.h"
43 #include "gausspoint.h"
44 #include "xfem/enrichmentitem.h"
45 #include "feinterpol.h"
46 #include "xfem/xfemmanager.h"
47 
48 #include "Materials/structuralms.h"
50 
51 #include "xfem/XFEMDebugTools.h"
52 
53 namespace oofem {
55 
57 mRadius(0.0),mIncrementLength(0.0),mStrainThreshold(0.0), mUseRadialBasisFunc(false)
58 {
59 
60 }
61 
63 
64 }
65 
67 {
68  IRResultType result;
69 
73 
74  int useRadialBasisFunc = 0;
76  if ( useRadialBasisFunc == 1 ) {
77  mUseRadialBasisFunc = true;
78  }
79 
80  return IRRT_OK;
81 }
82 
84 {
85  int number = 1;
86  input.setRecordKeywordField(this->giveInputRecordName(), number);
87 
91 
92  if ( mUseRadialBasisFunc ) {
94  }
95 }
96 
97 
99 {
100  if ( !iEnrFront.propagationIsAllowed() ) {
101  return false;
102  }
103 
104  // Fetch crack tip data
105  const TipInfo &tipInfo = iEnrFront.giveTipInfo();
106 
107  SpatialLocalizer *localizer = iDomain.giveSpatialLocalizer();
108 
109 
110  const FloatArray &xT = tipInfo.mGlobalCoord;
111  const FloatArray &t = tipInfo.mTangDir;
112 // const FloatArray &n = tipInfo.mNormalDir;
113 
114  // It is meaningless to propagate a tip that is not inside any element
115  Element *el = localizer->giveElementContainingPoint(tipInfo.mGlobalCoord);
116  if ( el != NULL ) {
117 
118 
119 
120  FloatArray x(xT);
121  x.add(mRadius, t);
122 // circPoints.push_back(x);
123 
124 
125  std :: vector< double >sigTTArray, sigRTArray;
126 
127  FloatArray strainVec;
128 
129  if ( mUseRadialBasisFunc ) {
130  // Interpolate strain with radial basis functions
131 
132  // Choose a cut-off length l:
133  // take the distance between two nodes in the element containing the
134  // crack tip multiplied by a constant factor.
135  // ( This choice implies that we hope that the element has reasonable
136  // aspect ratio.)
137  const FloatArray &x1 = * ( el->giveDofManager(1)->giveCoordinates() );
138  const FloatArray &x2 = * ( el->giveDofManager(2)->giveCoordinates() );
139  const double l = 1.0 * x1.distance(x2);
140 
141  // Use the octree to get all elements that have
142  // at least one Gauss point in a certain region around the tip.
143  const double searchRadius = 3.0 * l;
144  IntArray elIndices;
145  localizer->giveAllElementsWithIpWithinBox(elIndices, x, searchRadius);
146 
147 
148  // Loop over the elements and Gauss points obtained.
149  // Evaluate the interpolation.
150  FloatArray sumQiWiVi;
151  double sumWiVi = 0.0;
152  for ( int elIndex: elIndices ) {
153  Element *gpEl = iDomain.giveElement(elIndex);
154 
155  for ( GaussPoint *gp_i: *gpEl->giveDefaultIntegrationRulePtr() ) {
157  // Compute global gp coordinates
158  FloatArray N;
159  FEInterpolation *interp = gpEl->giveInterpolation();
160  interp->evalN( N, gp_i->giveNaturalCoordinates(), FEIElementGeometryWrapper(gpEl) );
161 
162 
163  // Compute global coordinates of Gauss point
164  FloatArray globalCoord(2);
165  globalCoord.zero();
166 
167  for ( int i = 1; i <= gpEl->giveNumberOfDofManagers(); i++ ) {
168  DofManager *dMan = gpEl->giveDofManager(i);
169  globalCoord.at(1) += N.at(i) * dMan->giveCoordinate(1);
170  globalCoord.at(2) += N.at(i) * dMan->giveCoordinate(2);
171  }
172 
173 
175  // Compute weight of kernel function
176 
177  FloatArray tipToGP;
178  tipToGP.beDifferenceOf(globalCoord, xT);
179  bool inFrontOfCrack = true;
180  if ( tipToGP.dotProduct(t) < 0.0 ) {
181  inFrontOfCrack = false;
182  }
183 
184  double r = x.distance(globalCoord);
185 
186  if ( r < l && inFrontOfCrack ) {
187  double w = ( ( l - r ) / ( pow(2.0 * M_PI, 1.5) * pow(l, 3) ) ) * exp( -0.5 * pow(r, 2) / pow(l, 2) );
188 
189  // Compute gp volume
190  double V = gpEl->computeVolumeAround(gp_i);
191 
192  // Get stress
193  StructuralMaterialStatus *ms = dynamic_cast< StructuralMaterialStatus * >( gp_i->giveMaterialStatus() );
194  if ( ms == NULL ) {
195  OOFEM_ERROR("failed to fetch MaterialStatus.");
196  }
197 
198  FloatArray strainVecGP = ms->giveStrainVector();
199 
200  if ( sumQiWiVi.giveSize() != strainVecGP.giveSize() ) {
201  sumQiWiVi.resize( strainVecGP.giveSize() );
202  sumQiWiVi.zero();
203  }
204 
205  // Add to numerator
206  sumQiWiVi.add(w * V, strainVecGP);
207 
208  // Add to denominator
209  sumWiVi += w * V;
210  }
211  }
212  }
213 
214 
215  if ( fabs(sumWiVi) > 1.0e-12 ) {
216  strainVec.beScaled(1.0 / sumWiVi, sumQiWiVi);
217  } else {
218  // Take strain from closest Gauss point
219  int region = 1;
220  bool useCZGP = false;
221  GaussPoint &gp = * ( localizer->giveClosestIP(x, region, useCZGP) );
222 
223 
224  // Compute strain
226  if ( ms == NULL ) {
227  OOFEM_ERROR("failed to fetch MaterialStatus.");
228  }
229 
230  strainVec = ms->giveStrainVector();
231  }
232  } else {
233  // Take stress from closest Gauss point
234  int region = 1;
235  bool useCZGP = false;
236  GaussPoint &gp = * ( localizer->giveClosestIP(x, region, useCZGP) );
237 
238 
239  // Compute stresses
241  if ( ms == NULL ) {
242  OOFEM_ERROR("failed to fetch MaterialStatus.");
243  }
244 
245  strainVec = ms->giveStrainVector();
246  }
247 
248  // Compute principal strain
249  FloatArray principalVals;
250  FloatMatrix principalDirs;
251  StructuralMaterial::computePrincipalValDir(principalVals, principalDirs, strainVec, principal_strain);
252 
253 
254 
255  // Compare with threshold
256  printf("Max principal strain: %e\n", principalVals[0]);
257  if ( principalVals[0] > mStrainThreshold ) {
258 
259  FloatArray propNormal;
260  propNormal.beColumnOf(principalDirs, 1);
261 
262  FloatArray propTangent = {-propNormal(1), propNormal(0)};
263 
264  if( propTangent.dotProduct(t) < 0.0 ) {
265  propTangent.times(-1.0);
266  }
267 
268  // Fill up struct
269  oTipProp.mTipIndex = tipInfo.mTipIndex;
270  oTipProp.mPropagationDir = propTangent;
272 
273  return true;
274  }
275 
276  } // Tip is inside an element.
277 
278 
279  return false;
280 }
281 
282 } // end namespace oofem
283 
The base class for all spatial localizers.
void setField(int item, InputFieldType id)
virtual void evalN(FloatArray &answer, const FloatArray &lcoords, const FEICellGeometry &cellgeo)=0
Evaluates the array of interpolation functions (shape functions) at given point.
Class and object Domain.
Definition: domain.h:115
virtual IntegrationRule * giveDefaultIntegrationRulePtr()
Access method for default integration rule.
Definition: element.h:822
FloatArray mPropagationDir
Definition: tipinfo.h:44
For computing principal strains from engineering strains.
#define _IFT_PLPrincipalStrain_StrainThreshold
Threshold for crack propagation.
int mTipIndex
Definition: tipinfo.h:34
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
TipInfo gathers useful information about a crack tip, like its position and tangent direction...
Definition: tipinfo.h:24
This class implements a structural material status information.
Definition: structuralms.h:65
#define _IFT_PLPrincipalStrain_RadialBasisFunc
If radial basis functions should be used for strain interpolation.
virtual FloatArray * giveCoordinates()
Definition: dofmanager.h:382
Abstract base class for all finite elements.
Definition: element.h:145
Base class for dof managers.
Definition: dofmanager.h:113
static void computePrincipalValDir(FloatArray &answer, FloatMatrix &dir, const FloatArray &s, stressStrainPrincMode mode)
Computes principal values and directions of stress or strain vector.
Class implementing an array of integers.
Definition: intarray.h:61
virtual void giveAllElementsWithIpWithinBox(elementContainerType &elemSet, const FloatArray &coords, const double radius)=0
Returns container (set) of all domain elements having integration point within given box...
virtual int giveNumberOfDofManagers() const
Definition: element.h:656
virtual FEInterpolation * giveInterpolation() const
Definition: element.h:629
void beDifferenceOf(const FloatArray &a, const FloatArray &b)
Sets receiver to be a - b.
Definition: floatarray.C:341
void beColumnOf(const FloatMatrix &mat, int col)
Reciever will be set to a given column in a matrix.
Definition: floatarray.C:1114
virtual IRResultType initializeFrom(InputRecord *ir)
double distance(const FloatArray &x) const
Computes the distance between position represented by receiver and position given as parameter...
Definition: floatarray.C:489
Class representing a general abstraction for finite element interpolation class.
Definition: feinterpol.h:132
void beScaled(double s, const FloatArray &b)
Sets receiver to be .
Definition: floatarray.C:146
virtual double computeVolumeAround(GaussPoint *gp)
Returns volume related to given integration point.
Definition: element.h:518
Element * giveElement(int n)
Service for accessing particular domain fe element.
Definition: domain.C:160
#define M_PI
Definition: mathfem.h:52
double dotProduct(const FloatArray &x) const
Computes the dot product (or inner product) of receiver and argument.
Definition: floatarray.C:463
#define _IFT_PLPrincipalStrain_Radius
Radius away from tip used when picking sampling point.
#define OOFEM_ERROR(...)
Definition: error.h:61
#define _IFT_PLPrincipalStrain_IncLength
Increment length per time step.
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 bool propagationIsAllowed() const
Wrapper around element definition to provide FEICellGeometry interface.
Definition: feinterpol.h:95
REGISTER_PropagationLaw(PLDoNothing)
#define N(p, q)
Definition: mdm.C:367
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...
virtual const char * giveInputRecordName() const
Class representing vector of real numbers.
Definition: floatarray.h:82
Implementation of matrix containing floating point numbers.
Definition: floatmatrix.h:94
virtual void giveInputRecord(DynamicInputRecord &input)
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
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
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class representing the a dynamic Input Record.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
FloatArray mTangDir
Definition: tipinfo.h:32
void setRecordKeywordField(std::string keyword, int number)
const TipInfo & giveTipInfo() const
double mPropagationLength
Definition: tipinfo.h:45
virtual bool propagateInterface(Domain &iDomain, EnrichmentFront &iEnrFront, TipPropagation &oTipProp)
#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
FloatArray mGlobalCoord
Definition: tipinfo.h:30
virtual double giveCoordinate(int i)
Definition: dofmanager.h:380
the oofem namespace is to define a context or scope in which all oofem names are defined.
DofManager * giveDofManager(int i) const
Definition: element.C:514
virtual GaussPoint * giveClosestIP(const FloatArray &coords, int region, bool iCohesiveZoneGP=false)=0
Returns the integration point in associated domain, which is closest to given point.
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
const FloatArray & giveStrainVector() const
Returns the const pointer to receiver&#39;s strain vector.
Definition: structuralms.h:105
Class representing integration point in finite element program.
Definition: gausspoint.h:93
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:30 for OOFEM by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2011