OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
prescribedgradientbcweak.h
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 #ifndef PRESCRIBEDGRADIENTBCWEAK_H_
36 #define PRESCRIBEDGRADIENTBCWEAK_H_
37 
39 #include "activebc.h"
40 #include "geometry.h"
41 #include "dofiditem.h"
42 
43 #include <unordered_map>
44 #include <memory>
45 #include "node.h"
46 
47 #define _IFT_PrescribedGradientBCWeak_Name "prescribedgradientbcweak"
48 #define _IFT_PrescribedGradientBCWeak_TractionInterpOrder "tractioninterporder"
49 #define _IFT_PrescribedGradientBCWeak_NumTractionNodesAtIntersections "numnodesatintersections"
50 #define _IFT_PrescribedGradientBCWeak_NumTractionNodeSpacing "tractionnodespacing"
51 #define _IFT_PrescribedGradientBCWeak_DuplicateCornerNodes "duplicatecornernodes"
52 #define _IFT_PrescribedGradientBCWeak_TangDistPadding "tangdistpadding"
53 #define _IFT_PrescribedGradientBCWeak_TracDofScaling "tracdofscaling"
54 #define _IFT_PrescribedGradientBCWeak_PeriodicityNormal "periodicitynormal"
55 #define _IFT_PrescribedGradientBCWeak_MirrorFunction "mirrorfunction"
56 
57 namespace oofem {
58 class IntegrationRule;
59 class Node;
60 class GaussPoint;
61 
63 {
64 public:
66  virtual ~TracSegArray() {}
67 
68  void printYourself() {
69  printf("\nTracSegArray segments:\n");
70  for(auto &l: mInteriorSegments) {
71  printf("\n");
72  l.giveVertex(1).printYourself();
73  l.giveVertex(2).printYourself();
74  }
75  }
76 
77  double giveLength() {
78  double l = 0.0;
79  for(Line &line : mInteriorSegments) {
80  l += line.giveLength();
81  }
82 
83  return l;
84  }
85 
87 
89 
90  std :: vector< Line >mInteriorSegments;
91 
92  // Interior segments used for Gaussian quadrature
93  std :: vector< Line > mInteriorSegmentsFine;
94 
95  std :: vector< FloatArray > mInteriorSegmentsPointsFine;
96 
97 
98 
99  std :: unique_ptr< Node > mFirstNode;
100 
101  std :: unique_ptr< IntegrationRule > mIntRule;
102 };
103 
112 {
113 public:
114  PrescribedGradientBCWeak(int n, Domain *d);
115  virtual ~PrescribedGradientBCWeak();
116 
117  void clear();
118 
119  virtual double domainSize() {return PrescribedGradientHomogenization::domainSize(this->giveDomain(), this->giveSetNumber());}
120 
121  virtual int giveNumberOfInternalDofManagers();
122  virtual DofManager *giveInternalDofManager(int i);
123 
124  virtual bcType giveType() const { return UnknownBT; }
125 
126  virtual IRResultType initializeFrom(InputRecord *ir);
127  virtual void giveInputRecord(DynamicInputRecord &input);
128 
129  virtual void postInitialize();
130 
131  virtual void computeField(FloatArray &sigma, TimeStep *tStep);
132  virtual void computeTangent(FloatMatrix &E, TimeStep *tStep);
133 
134  virtual void assembleVector(FloatArray &answer, TimeStep *tStep,
135  CharType type, ValueModeType mode,
136  const UnknownNumberingScheme &s, FloatArray *eNorm = NULL);
137 
138  void computeExtForceElContrib(FloatArray &oContrib, TracSegArray &iEl, int iDim, TimeStep *tStep);
139  void computeIntForceGPContrib(FloatArray &oContrib_disp, IntArray &oDisp_loc_array, FloatArray &oContrib_trac, IntArray &oTrac_loc_array,TracSegArray &iEl, GaussPoint &iGP, int iDim, TimeStep *tStep, const FloatArray &iBndCoord, const double &iScaleFac, ValueModeType mode, CharType type, const UnknownNumberingScheme &s);
140 
141 
142  virtual void assemble(SparseMtrx &answer, TimeStep *tStep,
143  CharType type, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s, double scale = 1.0);
144 
145  virtual void assembleExtraDisplock(SparseMtrx &answer, TimeStep *tStep,
146  CharType type, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s);
147 
148  virtual void assembleGPContrib(SparseMtrx &answer, TimeStep *tStep,
149  CharType type, const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s, TracSegArray &iEl, GaussPoint &iGP, double k);
150 
151  virtual void giveLocationArrays(std :: vector< IntArray > &rows, std :: vector< IntArray > &cols, CharType type,
152  const UnknownNumberingScheme &r_s, const UnknownNumberingScheme &c_s);
153 
154  virtual void giveTractionLocationArray(IntArray &rows,
155  const UnknownNumberingScheme &s);
156 
157  virtual void giveDisplacementLocationArray(IntArray &rows,
158  const UnknownNumberingScheme &s);
159 
160  void compute_x_times_N_1(FloatMatrix &o_x_times_N);
161  void compute_x_times_N_2(FloatMatrix &o_x_times_N);
162 
163 
164 // virtual void giveTractionLocationArrays(int iTracElInd, IntArray &rows, CharType type,
165 // const UnknownNumberingScheme &s);
166 //
167 // virtual void giveDisplacementLocationArrays(int iTracElInd, IntArray &rows, CharType type,
168 // const UnknownNumberingScheme &s);
169 
170  virtual const char *giveClassName() const { return "PrescribedGradientBCWeak"; }
171  virtual const char *giveInputRecordName() const { return _IFT_PrescribedGradientBCWeak_Name; }
172 
173  // Routines for postprocessing
174  size_t giveNumberOfTractionElements() const { return mpTracElNew.size(); }
175  void giveTractionElCoord(size_t iElInd, FloatArray &oStartCoord, FloatArray &oEndCoord) const { oStartCoord = mpTracElNew [ iElInd ]->mInteriorSegments[0].giveVertex(1); oEndCoord = mpTracElNew [ iElInd ]->mInteriorSegments.back().giveVertex(2); }
176  void giveTractionElNormal(size_t iElInd, FloatArray &oNormal, FloatArray &oTangent) const;
177  void giveTractionElArcPos(size_t iElInd, double &oXiStart, double &oXiEnd) const;
178  void giveBoundaries(IntArray &oBoundaries);
179 
180  void giveTraction(size_t iElInd, FloatArray &oStartTraction, FloatArray &oEndTraction, ValueModeType mode, TimeStep *tStep);
181 
182  // TODO: Consider moving this function to Domain.
183  void computeDomainBoundingBox(Domain &iDomain, FloatArray &oLC, FloatArray &oUC);
184 
185 
186  const IntArray &giveTracDofIDs() const {return mTractionDofIDs;}
187  const IntArray &giveDispLockDofIDs() const {return mDispLockDofIDs;}
188  const IntArray &giveRegularDispDofIDs() const {return mRegularDispDofIDs;}
189 
190 
191  // Functions mainly for testing
192  void setPeriodicityNormal(const FloatArray &iPeriodicityNormal) {mPeriodicityNormal = iPeriodicityNormal; };
193  void setDomainSize(double iDomainSize) {mDomainSize = std::move(iDomainSize);};
194  void setLowerCorner(FloatArray iLC) {mLC = std::move(iLC);};
195  void setUpperCorner(FloatArray iUC) {mUC = std::move(iUC);};
196 
197  void setMirrorFunction(int iMirrorFunction) {mMirrorFunction = iMirrorFunction;};
198 
199 protected:
200 
201  const IntArray mTractionDofIDs;
204 
205 
206  // Options
207 
210 
219 
225 
233 
234 
240 
245 
247 
250 
253 
254 
259 
264 
265 
267  std :: vector< TracSegArray * > mpTracElNew;
268 
269 
274 
275  double mDomainSize;
276 
282 
283 public:
284  void recomputeTractionMesh();
285 
286  void giveMirroredPointOnGammaMinus(FloatArray &oPosMinus, const FloatArray &iPosPlus) const;
287  void giveMirroredPointOnGammaPlus(FloatArray &oPosPlus, const FloatArray &iPosMinus) const;
288 
289 protected:
290  void createTractionMesh(bool iEnforceCornerPeriodicity, int iNumSides);
291 
292  void splitSegments(std :: vector< TracSegArray * > &ioElArray);
293 
294  bool damageExceedsTolerance(Element *el);
295 
296  void assembleTangentGPContributionNew(FloatMatrix &oTangent, TracSegArray &iEl, GaussPoint &iGP, const double &iScaleFactor, const FloatArray &iBndCoord);
297 
298  bool pointIsOnGammaPlus(const FloatArray &iPos) const;
299 
300  virtual void giveBoundaryCoordVector(FloatArray &oX, const FloatArray &iPos) const = 0;
301  virtual void checkIfCorner(bool &oIsCorner, bool &oDuplicatable, const FloatArray &iPos, const double &iNodeDistTol) const = 0;
302  virtual bool boundaryPointIsOnActiveBoundary(const FloatArray &iPos) const = 0;
303 
304  int giveSideIndex(const FloatArray &iPos) const;
305 
306 
307  void findHoleCoord(std::vector<FloatArray> &oHoleCoordUnsorted, std::vector<FloatArray> &oAllCoordUnsorted);
308  void findCrackBndIntersecCoord(std::vector<FloatArray> &oHoleCoordUnsorted);
309  void findPeriodicityCoord(std::vector<FloatArray> &oHoleCoordUnsorted);
310 
311  void removeClosePoints(std::vector<FloatArray> &ioCoords, const double &iAbsTol);
312  void removeSegOverHoles(TracSegArray &ioTSeg, const double &iAbsTol);
313 };
314 
316 {
317 public:
318  ArcPosSortFunction(const FloatArray &iStartPos) : mStartPos(iStartPos) {}
320 
321  bool operator()(const FloatArray &iVec1, const FloatArray &iVec2) const
322  {
323  return mStartPos.distance_square(iVec1) < mStartPos.distance_square(iVec2);
324  }
325 
326 private:
328 };
329 
330 template< class T >
332 {
333 public:
334  ArcPosSortFunction3(const FloatArray &iLC, const FloatArray &iUC, const double &iTol, int iSideInd) :
335  mLC(iLC),
336  mUC(iUC),
337  mTol(iTol),
338  mSideInd(iSideInd)
339  {}
340 
342 
343  bool operator()(const std :: pair< FloatArray, T > &iVec1, const std :: pair< FloatArray, int > &iVec2) const
344  {
345  return calcArcPos(iVec1.first) < calcArcPos(iVec2.first);
346  }
347 
348  double calcArcPos(const FloatArray &iPos) const
349  {
350  double Lx = mUC [ 0 ] - mLC [ 0 ];
351  double Ly = mUC [ 1 ] - mLC [ 1 ];
352 
353  if ( mSideInd == 0 ) {
354  const FloatArray &x = { mUC [ 0 ], mLC [ 1 ] };
355  double dist = Lx + iPos.distance(x);
356  return dist;
357  }
358 
359  if ( mSideInd == 1 ) {
360  double dist = Lx + Ly + iPos.distance(mUC);
361  return dist;
362  }
363 
364  if ( mSideInd == 2 ) {
365  const FloatArray &x = { mLC [ 0 ], mUC [ 1 ] };
366  double dist = Lx + Ly + Lx + iPos.distance(x);
367  return dist;
368  }
369 
370  if ( mSideInd == 3 ) {
371  double dist = iPos.distance(mLC);
372  return dist;
373  }
374 
375  OOFEM_ERROR("Could not compute distance.")
376  return 0.0;
377  }
378 
379 private:
382  const double mTol;
383 
384  // 0->x=L, 1->y=L, 2->x=0, 3->y=0
385  const int mSideInd;
386 };
387 
388 
390 {
391 public:
392  ArcPosSortFunction4(const FloatArray &iLC, const FloatArray &iUC, const double &iRelTol) :
393  mLC(iLC),
394  mUC(iUC),
395  mRelTol(iRelTol)
396  {}
397 
399 
400  bool operator()(const FloatArray &iVec1, const FloatArray &iVec2) const
401  {
402  return calcArcPos(iVec1) < calcArcPos(iVec2);
403  }
404 
405  double calcArcPos(const FloatArray &iPos) const
406  {
407  double Lx = mUC [ 0 ] - mLC [ 0 ];
408  double Ly = mUC [ 1 ] - mLC [ 1 ];
409 
410 
411  int sideInd = -1;
412 
413  if( iPos[0] > Lx - Lx*mRelTol ) {
414  sideInd = 0;
415  }
416 
417  if( iPos[1] > Ly - Ly*mRelTol ) {
418  sideInd = 1;
419  }
420 
421  if( iPos[0] < Lx*mRelTol ) {
422  sideInd = 2;
423  }
424 
425  if( iPos[1] < Ly*mRelTol ) {
426  sideInd = 3;
427  }
428 
429  if ( sideInd == 0 ) {
430  const FloatArray &x = { mUC [ 0 ], mLC [ 1 ] };
431  double dist = Lx + iPos.distance(x);
432  return dist;
433  }
434 
435  if ( sideInd == 1 ) {
436  double dist = Lx + Ly + iPos.distance(mUC);
437  return dist;
438  }
439 
440  if ( sideInd == 2 ) {
441  const FloatArray &x = { mLC [ 0 ], mUC [ 1 ] };
442  double dist = Lx + Ly + Lx + iPos.distance(x);
443  return dist;
444  }
445 
446  if ( sideInd == 3 ) {
447  double dist = iPos.distance(mLC);
448  return dist;
449  }
450 
451  OOFEM_ERROR("Could not compute distance.")
452  return 0.0;
453  }
454 
455 private:
458  const double mRelTol;
459 
460 };
461 
462 } /* namespace oofem */
463 
464 #endif /* PRESCRIBEDGRADIENTBCWEAK_H_ */
bool mMeshIsPeriodic
true -> the traction lives only on gammaPlus, so that we get strong periodicity as a special case...
std::vector< Line > mInteriorSegments
bool operator()(const FloatArray &iVec1, const FloatArray &iVec2) const
Class and object Domain.
Definition: domain.h:115
void giveTractionElCoord(size_t iElInd, FloatArray &oStartCoord, FloatArray &oEndCoord) const
Base class for all matrices stored in sparse format.
Definition: sparsemtrx.h:60
FloatArray mUC
Upper corner of domain (assuming a rectangular RVE)
Class for homogenization of applied gradients.
std::unique_ptr< IntegrationRule > mIntRule
ArcPosSortFunction(const FloatArray &iStartPos)
Unknown.
Definition: bctype.h:41
bool operator()(const FloatArray &iVec1, const FloatArray &iVec2) const
ValueModeType
Type representing the mode of UnknownType or CharType, or similar types.
Definition: valuemodetype.h:78
int mTractionNodeSpacing
Use every (mTractionNodeSpacing) displacement nodes when constructing the traction element mesh...
Abstract base class for all finite elements.
Definition: element.h:145
Node * mpDisplacementLock
Lock displacements in one node if periodic.
Base class for dof managers.
Definition: dofmanager.h:113
ArcPosSortFunction3(const FloatArray &iLC, const FloatArray &iUC, const double &iTol, int iSideInd)
#define _IFT_PrescribedGradientBCWeak_Name
int mTractionInterpOrder
Order of interpolation for traction (0->piecewise constant, 1->piecewise linear)
Class implementing an array of integers.
Definition: intarray.h:61
ArcPosSortFunction4(const FloatArray &iLC, const FloatArray &iUC, const double &iRelTol)
int mMirrorFunction
Mirror function (i.e.
double distance(const FloatArray &x) const
Computes the distance between position represented by receiver and position given as parameter...
Definition: floatarray.C:489
void giveTractionLocationArray(IntArray &rows, CharType type, const UnknownNumberingScheme &s)
bcType
Type representing the type of bc.
Definition: bctype.h:40
const IntArray & giveTracDofIDs() const
#define E(p)
Definition: mdm.C:368
#define OOFEM_ERROR(...)
Definition: error.h:61
const IntArray & giveDispLockDofIDs() const
double calcArcPos(const FloatArray &iPos) const
double mTangDistPadding
Parameter for creation of traction mesh.
Abstract base class allowing to control the way, how equations are assigned to individual DOFs...
bool operator()(const std::pair< FloatArray, T > &iVec1, const std::pair< FloatArray, int > &iVec2) const
FloatArray mPeriodicityNormal
Periodicity direction.
Abstract base class for all active boundary conditions.
Definition: activebc.h:63
double calcArcPos(const FloatArray &iPos) const
std::vector< Line > mInteriorSegmentsFine
int mNumTractionNodesAtIntersections
If traction nodes should be inserted where cracks intersect the RVE boundary.
Imposes a prescribed gradient weakly on the boundary with an independent traction discretization...
virtual const char * giveClassName() const
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
CharType
Definition: chartype.h:87
Class representing the general Input Record.
Definition: inputrecord.h:101
std::unique_ptr< Node > mFirstNode
FloatArray mLC
Lower corner of domain (assuming a rectangular RVE)
void setMirrorFunction(int iMirrorFunction)
Class representing the a dynamic Input Record.
virtual const char * giveInputRecordName() const
const IntArray & giveRegularDispDofIDs() const
the oofem namespace is to define a context or scope in which all oofem names are defined.
Class implementing node in finite element mesh.
Definition: node.h:87
std::vector< TracSegArray * > mpTracElNew
Elements for the independent traction discretization.
Class representing integration point in finite element program.
Definition: gausspoint.h:93
Class representing solution step.
Definition: timestep.h:80
void setPeriodicityNormal(const FloatArray &iPeriodicityNormal)
bool mDuplicateCornerNodes
0 -> Do not duplicate corner traction nodes 1 -> Duplicate corner traction nodes
std::vector< FloatArray > mInteriorSegmentsPointsFine

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