OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
symmetrybarrier.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 "symmetrybarrier.h"
36 #include "intarray.h"
37 #include "floatarray.h"
38 #include "mathfem.h"
39 #include "classfactory.h"
40 
41 namespace oofem {
43 
44 SymmetryBarrier :: SymmetryBarrier(int n, Domain *aDomain) :
45  NonlocalBarrier(n, aDomain), origin(), normals(), mask(), lcs(3, 3)
46  // Constructor. Creates an element with number n, belonging to aDomain.
47 { }
48 
49 
51 // Destructor.
52 { }
53 
54 void
55 SymmetryBarrier :: applyConstraint(const FloatArray &c1, const FloatArray &c2, double &weight,
56  bool &shieldFlag, NonlocalMaterialExtensionInterface *nei)
57 {
58  // compute node coordinates in barrrier lcs
59  FloatArray mc2(3), help(3);
60  int i, ii, jj, kk, mi, dim = c1.giveSize();
61  double d;
62 
63  shieldFlag = false;
64 
65 
66  for ( i = 1; i <= dim; i++ ) {
67  help.at(i) = c2.at(i) - origin.at(i);
68  }
69 
70  // first compute mirrors to active planes
71  // loop over active planes, mirror source point and compute weights
72  for ( mi = 1; mi <= 3; mi++ ) {
73  if ( mask.at(mi) ) {
74  // plane active
75  // mirror source
76  for ( d = 0.0, i = 1; i <= dim; i++ ) {
77  d += help.at(i) * lcs.at(mi, i);
78  }
79 
80  for ( i = 1; i <= dim; i++ ) {
81  mc2.at(i) = c2.at(i) - 2.0 *d *lcs.at(mi, i);
82  }
83 
84  // compute weight of mirrored source
85  weight += nei->computeWeightFunction(c1, mc2);
86  }
87  }
88 
89  // compute mirrors to lines common to two active planes
90  for ( mi = 0; mi < 3; mi++ ) {
91  ii = mi + 1;
92  jj = ( mi + 1 ) % 3 + 1;
93  kk = ( mi + 2 ) % 3 + 1;
94 
95  if ( mask.at(ii) && mask.at(jj) ) {
96  // compute mirror point
97  for ( d = 0.0, i = 1; i <= dim; i++ ) {
98  d += help.at(i) * lcs.at(kk, i);
99  }
100 
101  d = sqrt(d);
102  for ( i = 1; i <= dim; i++ ) {
103  mc2.at(i) = c2.at(i) - 2.0 * ( c2.at(i) - ( origin.at(i) + d * lcs.at(kk, i) ) );
104  }
105 
106  // compute weight of mirrored source
107  weight += nei->computeWeightFunction(c1, mc2);
108  }
109  }
110 
111  // finally compute mirror to origin if all three planes are active
112  if ( mask.at(1) && mask.at(2) && mask.at(3) ) {
113  // mirror source
114  for ( i = 1; i <= dim; i++ ) {
115  mc2.at(i) = c2.at(i) - 2.0 * ( c2.at(i) - origin.at(i) );
116  }
117 
118  // compute weight of mirrored source
119  weight += nei->computeWeightFunction(c1, mc2);
120  }
121 }
122 
125 {
126  IRResultType result; // Required by IR_GIVE_FIELD macro
127 
129 
132 
133  lcs.resize(3, 3);
134  int size = normals.giveSize();
135  if ( !( ( size == 0 ) || ( size == 6 ) ) ) {
136  OOFEM_WARNING("lcs in node %d is not properly defined, will be ignored", this->giveNumber() );
137  }
138 
139  if ( size == 6 ) {
140  double n1 = 0.0, n2 = 0.0;
141  // compute transformation matrix
142  for ( int j = 1; j <= 3; j++ ) {
143  lcs.at(1, j) = normals.at(j);
144  n1 += normals.at(j) * normals.at(j);
145  lcs.at(2, j) = normals.at(j + 3);
146  n2 += normals.at(j + 3) * normals.at(j + 3);
147  }
148 
149  n1 = sqrt(n1);
150  n2 = sqrt(n2);
151  if ( ( n1 <= 1.e-6 ) || ( n2 <= 1.e-6 ) ) {
152  OOFEM_ERROR("lcs input error");
153  }
154 
155  for ( int j = 1; j <= 3; j++ ) { // normalize e1' e2'
156  lcs.at(1, j) /= n1;
157  lcs.at(2, j) /= n2;
158  }
159 
160  // vector e3' computed from vector product of e1', e2'
161  lcs.at(3, 1) = lcs.at(1, 2) * lcs.at(2, 3) - lcs.at(1, 3) * lcs.at(2, 2);
162  lcs.at(3, 2) = lcs.at(1, 3) * lcs.at(2, 1) - lcs.at(1, 1) * lcs.at(2, 3);
163  lcs.at(3, 3) = lcs.at(1, 1) * lcs.at(2, 2) - lcs.at(1, 2) * lcs.at(2, 1);
164  }
165 
167  if ( mask.giveSize() != 3 ) {
168  OOFEM_WARNING("activemask size should be 3");
169  return IRRT_BAD_FORMAT;
170  }
171 
172  return IRRT_OK;
173 }
174 } // end namespace oofem
virtual IRResultType initializeFrom(InputRecord *ir)
Initializes receiver according to object description stored in input record.
Class and object Domain.
Definition: domain.h:115
Abstract base class for all nonlocal barriers.
Abstract base class for all nonlocal materials.
#define _IFT_SymmetryBarrier_normals
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
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...
int & at(int i)
Coefficient access function.
Definition: intarray.h:103
#define OOFEM_ERROR(...)
Definition: error.h:61
Implementation of symmetry nonlocal barrier.
double at(int i, int j) const
Coefficient access function.
Definition: floatmatrix.h:176
#define _IFT_SymmetryBarrier_origin
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
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
int giveSize() const
Definition: intarray.h:203
int giveSize() const
Returns the size of receiver.
Definition: floatarray.h:218
the oofem namespace is to define a context or scope in which all oofem names are defined.
#define _IFT_SymmetryBarrier_activemask
#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
REGISTER_NonlocalBarrier(PolylineNonlocalBarrier)
virtual ~SymmetryBarrier()
Destructor.
#define OOFEM_WARNING(...)
Definition: error.h:62
virtual double computeWeightFunction(double distance)
Evaluates the basic nonlocal weight function for a given distance between interacting points...

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