OOFEM 3.0
Loading...
Searching...
No Matches
enrichmentfunction.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 "enrichmentfunction.h"
36#include "gausspoint.h"
37#include "mathfem.h"
38#include "feinterpol.h"
39#include "classfactory.h"
40#include "dynamicinputrecord.h"
41
42namespace oofem {
50
51void EnrichmentFunction :: giveInputRecord(DynamicInputRecord &input)
52{
53 FEMComponent :: giveInputRecord(input);
54}
55
56void DiscontinuousFunction :: evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
57{
58 oEnrFunc = sgn(iLevelSet);
59}
60
61void HeavisideFunction :: evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
62{
63 oEnrFuncDeriv.resize(2);
64 oEnrFuncDeriv.zero();
65}
66
67void HeavisideFunction :: evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
68{
69 if ( iLevelSet > 0.0 ) {
70 oEnrFunc = 1.0;
71 } else {
72 oEnrFunc = 0.0;
73 }
74}
75
76void DiscontinuousFunction :: evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
77{
78 oEnrFuncDeriv.resize(2);
79 oEnrFuncDeriv.zero();
80}
81
82void RampFunction :: evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
83{
84 oEnrFunc = fabs(iLevelSet);
85}
86
87void RampFunction :: evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
88{
89 oEnrFuncDeriv.resize(2);
90 oEnrFuncDeriv.zero();
91 oEnrFuncDeriv.at(1) = iGradLevelSet.at(1) * sgn(iLevelSet);
92 oEnrFuncDeriv.at(2) = iGradLevelSet.at(2) * sgn(iLevelSet);
93}
94
95void LinElBranchFunction :: evaluateEnrFuncAt(std :: vector< double > &oEnrFunc, const double &iR, const double &iTheta) const
96{
97 oEnrFunc.push_back( sqrt(iR) * sin(0.5 * iTheta) );
98 oEnrFunc.push_back( sqrt(iR) * sin(0.5 * iTheta) * sin(iTheta) );
99 oEnrFunc.push_back( sqrt(iR) * cos(0.5 * iTheta) );
100 oEnrFunc.push_back( sqrt(iR) * cos(0.5 * iTheta) * sin(iTheta) );
101}
102
103void LinElBranchFunction :: evaluateEnrFuncDerivAt(std :: vector< FloatArray > &oEnrFuncDeriv, const double &iR, const double &iTheta) const
104{
105 // Evaluate the enrichment function derivatives using the chain rule:
106 // dPdx = dPdr*drdx + dPdt*dtdx
107 // dPdy = dPdr*drdy + dPdt*dtdy
108
109 const double drdx = cos(iTheta);
110 const double drdy = sin(iTheta);
111 const double dtdx = -( 1.0 / iR ) * sin(iTheta);
112 const double dtdy = ( 1.0 / iR ) * cos(iTheta);
113
114 FloatArray dP;
115
116 /*
117 * double dtdy = 0.0;
118 * double eps = 1.0e-12;
119 * if( fabs(cos(iTheta)) < eps )
120 * {
121 * dtdy = 0.0;
122 * }
123 * else
124 * {
125 * dtdy = 1.0/(iR*iR);
126 * }
127 */
128 // Psi 1
129 const double dP1dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * sin(0.5 * iTheta);
130 const double dP1dt = 0.5 * sqrt(iR) * cos(0.5 * iTheta);
131 oEnrFuncDeriv.push_back(Vec2( dP1dr *drdx + dP1dt *dtdx, dP1dr *drdy + dP1dt *dtdy ));
132
133 // Psi 2
134 const double dP2dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * sin(0.5 * iTheta) * sin(iTheta);
135 const double dP2dt = 0.5 * sqrt(iR) * cos(0.5 * iTheta) * sin(iTheta) + sqrt(iR) * sin(0.5 * iTheta) * cos(iTheta);
136 oEnrFuncDeriv.push_back(Vec2( dP2dr *drdx + dP2dt *dtdx, dP2dr *drdy + dP2dt *dtdy ));
137
138 // Psi 3
139 const double dP3dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * cos(0.5 * iTheta);
140 const double dP3dt = -0.5 * sqrt(iR) * sin(0.5 * iTheta);
141 oEnrFuncDeriv.push_back(Vec2( dP3dr *drdx + dP3dt *dtdx, dP3dr *drdy + dP3dt *dtdy ));
142
143 // Psi 4
144 const double dP4dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * cos(0.5 * iTheta) * sin(iTheta);
145 const double dP4dt = -0.5 * sqrt(iR) * sin(0.5 * iTheta) * sin(iTheta) + sqrt(iR) * cos(0.5 * iTheta) * cos(iTheta);
146 oEnrFuncDeriv.push_back(Vec2( dP4dr *drdx + dP4dt *dtdx, dP4dr *drdy + dP4dt *dtdy ));
147}
148
149void LinElBranchFunction :: giveJump(std :: vector< double > &oJumps) const
150{
151 OOFEM_ERROR("The radius is needed to compute the jump for branch functions.")
152}
153
154void LinElBranchFunction :: giveJump(std :: vector< double > &oJumps, const double &iRadius) const
155{
159
160 oJumps.clear();
161 oJumps.push_back( 2.0 * sqrt(iRadius) );
162 oJumps.push_back(0.0);
163 oJumps.push_back(0.0);
164 oJumps.push_back(0.0);
165}
166
167void CohesiveBranchFunction :: evaluateEnrFuncAt(std :: vector< double > &oEnrFunc, const double &iR, const double &iTheta) const
168{
169 oEnrFunc.push_back( pow(iR,mExponent) * sin(0.5 * iTheta) );
170}
171
172void CohesiveBranchFunction :: evaluateEnrFuncDerivAt(std :: vector< FloatArray > &oEnrFuncDeriv, const double &iR, const double &iTheta) const
173{
174 // Evaluate the enrichment function derivatives using the chain rule:
175 // dPdx = dPdr*drdx + dPdt*dtdx
176 // dPdy = dPdr*drdy + dPdt*dtdy
177
178 const double drdx = cos(iTheta);
179 const double drdy = sin(iTheta);
180 const double dtdx = -( 1.0 / iR ) * sin(iTheta);
181 const double dtdy = ( 1.0 / iR ) * cos(iTheta);
182
183 FloatArray dP;
184
185 // Psi 1
186 const double dP1dr = mExponent*pow(iR, mExponent-1.0) * sin(0.5 * iTheta);
187 const double dP1dt = 0.5 * pow(iR,mExponent) * cos(0.5 * iTheta);
188 oEnrFuncDeriv.push_back(Vec2( dP1dr *drdx + dP1dt *dtdx, dP1dr *drdy + dP1dt *dtdy ));
189}
190
191void CohesiveBranchFunction :: giveJump(std :: vector< double > &oJumps) const
192{
193 OOFEM_ERROR("The radius is needed to compute the jump for branch functions.")
194}
195
196void CohesiveBranchFunction :: giveJump(std :: vector< double > &oJumps, const double &iRadius) const
197{
201
202 oJumps.clear();
203 oJumps.push_back( 2.0 * pow(iRadius,mExponent) );
204}
205
206} // end namespace oofem
#define REGISTER_EnrichmentFunction(class)
void resize(Index s)
Definition floatarray.C:94
double & at(Index i)
Definition floatarray.h:202
void zero()
Zeroes all coefficients of receiver.
Definition floatarray.C:683
#define OOFEM_ERROR(...)
Definition error.h:79
static FloatArray Vec2(const double &a, const double &b)
Definition floatarray.h:606
double sgn(double i)
Returns the signum of given value (if value is < 0 returns -1, otherwise returns 1).
Definition mathfem.h:104

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