OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
polylinenonlocalbarrier.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 
36 #include "domain.h"
37 #include "node.h"
38 #include "intarray.h"
39 #include "floatarray.h"
40 #include "mathfem.h"
41 #include "classfactory.h"
42 
43 namespace oofem {
45 
47  NonlocalBarrier(n, aDomain), vertexNodes()
48  // Constructor. Creates an element with number n, belonging to aDomain.
49 {
50  localXCoordIndx = 1;
51  localYCoordIndx = 2;
52 }
53 
54 
56 // Destructor.
57 { }
58 
59 
60 void
62  bool &shieldFlag, NonlocalMaterialExtensionInterface *nei)
63 {
64  if ( this->isActivated(c1, c2) ) {
65  weight = 0.0;
66  shieldFlag = true;
67  } else {
68  shieldFlag = false;
69  }
70 }
71 
72 
73 bool
75 {
76  int size = vertexNodes.giveSize();
77  int indx;
78  double xc1, xc2, xa, xb, yc1, yc2, ya, yb;
79  double a11, a12, a21, a22, b1, b2, det, t, s;
80  Node *A, *B;
81 
82  xc1 = c1.at(localXCoordIndx);
83  yc1 = c1.at(localYCoordIndx);
84  xc2 = c2.at(localXCoordIndx);
85  yc2 = c2.at(localYCoordIndx);
86 
87  for ( indx = 1; indx < size; indx++ ) {
88  A = domain->giveNode( vertexNodes.at(indx) );
89  B = domain->giveNode( vertexNodes.at(indx + 1) );
90 
95 
96  a11 = xc2 - xc1;
97  a12 = xa - xb;
98  a21 = yc2 - yc1;
99  a22 = ya - yb;
100  b1 = xa - xc1;
101  b2 = ya - yc1;
102  det = a11 * a22 - a21 * a12;
103  if ( det == 0 ) {
104  continue;
105  }
106 
107  t = ( b1 * a22 - b2 * a12 ) / det;
108  if ( t < 0. || t > 1. ) {
109  continue;
110  }
111 
112  s = ( -b1 * a21 + b2 * a11 ) / det;
113  if ( s >= 0. && s <= 1. ) {
114  return true;
115  }
116  }
117 
118  return false;
119 }
120 
121 double
123 {
124  double min = 1.e10;
125  double tempDistance;
126  //Loop over all linear sections forming the nonlocal boundary to find the minimum distance
127  for ( int i = 1; i < vertexNodes.giveSize(); i++ ) {
128  //Get the coordinates of the vertices
129  FloatArray coordsA(coords);
130  FloatArray coordsB(coords);
131  for ( int j = 1; j <= coords.giveSize(); j++ ) {
132  coordsA.at(j) = domain->giveNode( vertexNodes.at(i) )->giveCoordinate(j);
133  coordsB.at(j) = domain->giveNode( vertexNodes.at(i + 1) )->giveCoordinate(j);
134  }
135 
136  //Get the distance from the line segment described by the vertices
137  tempDistance = giveDistancePointLine(coordsA, coordsB, coords);
138  if ( min > tempDistance ) { //Check if it is smaller than the minimum value
139  min = tempDistance;
140  }
141  }
142 
143  return min;
144 }
145 
146 double
148 {
149  FloatArray lineAGP(coordsGP); //Line start A, Line End Gauss Point
150  lineAGP.subtract(coordsA);
151  FloatArray lineAB(coordsB); //Line Start A, Line End B
152  lineAB.subtract(coordsA);
153 
154  if ( lineAB.computeNorm() == 0. ) { //Check if A,B coincide
155  return lineAGP.computeNorm();
156  }
157 
158  //Since vectors AB and AP are collinear and have the same direction: AP=scaleFactor*AB
159  double scaleFactor;
160  scaleFactor = ( lineAGP.dotProduct(lineAB) ) / lineAB.computeSquaredNorm();
161  if ( scaleFactor < 0. || scaleFactor > 1. ) { //Check if P is outside line segment AB
162  FloatArray lineBGP(coordsGP); //Line start B, Line End Gauss Point
163  lineBGP.subtract(coordsB);
164  //Return minimum of A-Gauss Point and B-Gauss Point
165  if ( lineAGP.computeNorm() < lineBGP.computeNorm() ) {
166  return lineAGP.computeNorm();
167  } else {
168  return lineBGP.computeNorm();
169  }
170  } else {
171  // Find coordinates of Point P = A + AB*scaleFactor
172  lineAB.times(scaleFactor);
173  FloatArray coordsP(coordsA);
174  coordsP.add(lineAB);
175  //Calculate distance from Point P to Gauss Point
176  FloatArray linePGP(coordsP); //Line start P, Line End Gauss Point
177  linePGP.subtract(coordsGP);
178  return linePGP.computeNorm();
179  }
180 }
181 
182 
185 {
186  IRResultType result; // Required by IR_GIVE_FIELD macro
187 
189 
190  // default: polyline in xy plane
191  localXCoordIndx = 1;
192  localYCoordIndx = 2;
193 
196 
197  return IRRT_OK;
198 }
199 } // end namespace oofem
void subtract(const FloatArray &src)
Subtracts array src to receiver.
Definition: floatarray.C:258
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Class and object Domain.
Definition: domain.h:115
double giveDistancePointLine(const FloatArray &coordsA, const FloatArray &coordsB, const FloatArray &coordsGP)
This function computes the length of the normal to the line defined by 2 vertices that passes through...
Abstract base class for all nonlocal barriers.
#define _IFT_PolylineNonlocalBarrier_xcoordindx
Abstract base class for all nonlocal materials.
Domain * domain
Link to domain object, useful for communicating with other FEM components.
Definition: femcmpnn.h:82
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
int localXCoordIndx
Local x-coordinate index.
Implementation of polyline nonlocal barrier.
virtual double calculateMinimumDistanceFromBoundary(const FloatArray &coords)
Abstract method calculating the minimum distance of the Gauss Point from the nonlocal boundaries...
virtual double giveCoordinate(int i)
Definition: node.C:82
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
double dotProduct(const FloatArray &x) const
Computes the dot product (or inner product) of receiver and argument.
Definition: floatarray.C:463
double computeSquaredNorm() const
Computes the square of the norm.
Definition: floatarray.C:846
int localYCoordIndx
Local y-coordinate index.
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
#define _IFT_PolylineNonlocalBarrier_ycoordindx
double computeNorm() const
Computes the norm (or length) of the vector.
Definition: floatarray.C:840
Class representing the general Input Record.
Definition: inputrecord.h:101
virtual void applyConstraint(const FloatArray &c1, const FloatArray &c2, double &weight, bool &shieldFlag, NonlocalMaterialExtensionInterface *nei)
Abstract method modifying the integration weight between master (c1) and source (c2) point...
virtual bool isActivated(const FloatArray &c1, const FloatArray &c2)
IntArray vertexNodes
List of polyline vertices.
void times(double s)
Multiplies receiver with scalar.
Definition: floatarray.C:818
int min(int i, int j)
Returns smaller value from two given decimals.
Definition: mathfem.h:59
virtual ~PolylineNonlocalBarrier()
Virtual destructor.
#define IR_GIVE_OPTIONAL_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:78
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
Node * giveNode(int n)
Service for accessing particular domain node.
Definition: domain.h:371
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
#define IR_GIVE_FIELD(__ir, __value, __id)
Macro facilitating the use of input record reading methods.
Definition: inputrecord.h:69
#define _IFT_PolylineNonlocalBarrier_vertexnodes
REGISTER_NonlocalBarrier(PolylineNonlocalBarrier)
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