OOFEM 3.0
Loading...
Searching...
No Matches
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 - 2025 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
41namespace oofem {
43
44SymmetryBarrier :: 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
50SymmetryBarrier :: ~SymmetryBarrier()
51// Destructor.
52{ }
53
54void
55SymmetryBarrier :: applyConstraint(const double cl, const FloatArray &c1, const FloatArray &c2, double &weight,
56 bool &shieldFlag, const 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(cl, 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(cl, 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(cl, c1, mc2);
120 }
121}
122
123void
124SymmetryBarrier :: initializeFrom(InputRecord &ir)
125{
127
130
131 lcs.resize(3, 3);
132 int size = normals.giveSize();
133 if ( !( ( size == 0 ) || ( size == 6 ) ) ) {
134 OOFEM_WARNING("lcs in node %d is not properly defined, will be ignored", this->giveNumber() );
135 }
136
137 if ( size == 6 ) {
138 double n1 = 0.0, n2 = 0.0;
139 // compute transformation matrix
140 for ( int j = 1; j <= 3; j++ ) {
141 lcs.at(1, j) = normals.at(j);
142 n1 += normals.at(j) * normals.at(j);
143 lcs.at(2, j) = normals.at(j + 3);
144 n2 += normals.at(j + 3) * normals.at(j + 3);
145 }
146
147 n1 = sqrt(n1);
148 n2 = sqrt(n2);
149 if ( ( n1 <= 1.e-6 ) || ( n2 <= 1.e-6 ) ) {
150 OOFEM_ERROR("lcs input error");
151 }
152
153 for ( int j = 1; j <= 3; j++ ) { // normalize e1' e2'
154 lcs.at(1, j) /= n1;
155 lcs.at(2, j) /= n2;
156 }
157
158 // vector e3' computed from vector product of e1', e2'
159 lcs.at(3, 1) = lcs.at(1, 2) * lcs.at(2, 3) - lcs.at(1, 3) * lcs.at(2, 2);
160 lcs.at(3, 2) = lcs.at(1, 3) * lcs.at(2, 1) - lcs.at(1, 1) * lcs.at(2, 3);
161 lcs.at(3, 3) = lcs.at(1, 1) * lcs.at(2, 2) - lcs.at(1, 2) * lcs.at(2, 1);
162 }
163
165 if ( mask.giveSize() != 3 ) {
166 throw ValueInputException(ir, _IFT_SymmetryBarrier_activemask, "size must be 3");
167 }
168}
169} // end namespace oofem
#define REGISTER_NonlocalBarrier(class)
int giveNumber() const
Definition femcmpnn.h:104
double & at(Index i)
Definition floatarray.h:202
Index giveSize() const
Returns the size of receiver.
Definition floatarray.h:261
virtual double computeWeightFunction(const double cl, const double distance) const
#define OOFEM_WARNING(...)
Definition error.h:80
#define OOFEM_ERROR(...)
Definition error.h:79
#define IR_GIVE_FIELD(__ir, __value, __id)
Definition inputrecord.h:67
#define _IFT_SymmetryBarrier_activemask
#define _IFT_SymmetryBarrier_normals
#define _IFT_SymmetryBarrier_origin

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011