OOFEM  2.4
OOFEM.org - Object Oriented Finite Element Solver
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 - 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 "enrichmentfunction.h"
36 #include "gausspoint.h"
37 #include "mathfem.h"
38 #include "feinterpol.h"
39 #include "classfactory.h"
40 #include "dynamicinputrecord.h"
41 
42 namespace oofem {
46 
47 IRResultType EnrichmentFunction :: initializeFrom(InputRecord *ir)
48 {
49  return IRRT_OK;
50 }
51 
53 {
55 }
56 
57 void DiscontinuousFunction :: evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
58 {
59  oEnrFunc = sgn(iLevelSet);
60 }
61 
62 void HeavisideFunction :: evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
63 {
64  oEnrFuncDeriv.resize(2);
65  oEnrFuncDeriv.zero();
66 }
67 
68 void HeavisideFunction :: evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
69 {
70  if ( iLevelSet > 0.0 ) {
71  oEnrFunc = 1.0;
72  } else {
73  oEnrFunc = 0.0;
74  }
75 }
76 
77 void DiscontinuousFunction :: evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
78 {
79  oEnrFuncDeriv.resize(2);
80  oEnrFuncDeriv.zero();
81 }
82 
83 void RampFunction :: evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
84 {
85  oEnrFunc = fabs(iLevelSet);
86 }
87 
88 void RampFunction :: evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
89 {
90  oEnrFuncDeriv.resize(2);
91  oEnrFuncDeriv.zero();
92  oEnrFuncDeriv.at(1) = iGradLevelSet.at(1) * sgn(iLevelSet);
93  oEnrFuncDeriv.at(2) = iGradLevelSet.at(2) * sgn(iLevelSet);
94 }
95 
96 void LinElBranchFunction :: evaluateEnrFuncAt(std :: vector< double > &oEnrFunc, const double &iR, const double &iTheta) const
97 {
98  oEnrFunc.push_back( sqrt(iR) * sin(0.5 * iTheta) );
99  oEnrFunc.push_back( sqrt(iR) * sin(0.5 * iTheta) * sin(iTheta) );
100  oEnrFunc.push_back( sqrt(iR) * cos(0.5 * iTheta) );
101  oEnrFunc.push_back( sqrt(iR) * cos(0.5 * iTheta) * sin(iTheta) );
102 }
103 
104 void LinElBranchFunction :: evaluateEnrFuncDerivAt(std :: vector< FloatArray > &oEnrFuncDeriv, const double &iR, const double &iTheta) const
105 {
106  // Evaluate the enrichment function derivatives using the chain rule:
107  // dPdx = dPdr*drdx + dPdt*dtdx
108  // dPdy = dPdr*drdy + dPdt*dtdy
109 
110  const double drdx = cos(iTheta);
111  const double drdy = sin(iTheta);
112  const double dtdx = -( 1.0 / iR ) * sin(iTheta);
113  const double dtdy = ( 1.0 / iR ) * cos(iTheta);
114 
115  FloatArray dP;
116 
117  /*
118  * double dtdy = 0.0;
119  * double eps = 1.0e-12;
120  * if( fabs(cos(iTheta)) < eps )
121  * {
122  * dtdy = 0.0;
123  * }
124  * else
125  * {
126  * dtdy = 1.0/(iR*iR);
127  * }
128  */
129  // Psi 1
130  const double dP1dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * sin(0.5 * iTheta);
131  const double dP1dt = 0.5 * sqrt(iR) * cos(0.5 * iTheta);
132  oEnrFuncDeriv.push_back({ dP1dr *drdx + dP1dt *dtdx, dP1dr *drdy + dP1dt *dtdy });
133 
134  // Psi 2
135  const double dP2dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * sin(0.5 * iTheta) * sin(iTheta);
136  const double dP2dt = 0.5 * sqrt(iR) * cos(0.5 * iTheta) * sin(iTheta) + sqrt(iR) * sin(0.5 * iTheta) * cos(iTheta);
137  oEnrFuncDeriv.push_back({ dP2dr *drdx + dP2dt *dtdx, dP2dr *drdy + dP2dt *dtdy });
138 
139  // Psi 3
140  const double dP3dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * cos(0.5 * iTheta);
141  const double dP3dt = -0.5 * sqrt(iR) * sin(0.5 * iTheta);
142  oEnrFuncDeriv.push_back({ dP3dr *drdx + dP3dt *dtdx, dP3dr *drdy + dP3dt *dtdy });
143 
144  // Psi 4
145  const double dP4dr = ( 1.0 / ( 2.0 * sqrt(iR) ) ) * cos(0.5 * iTheta) * sin(iTheta);
146  const double dP4dt = -0.5 * sqrt(iR) * sin(0.5 * iTheta) * sin(iTheta) + sqrt(iR) * cos(0.5 * iTheta) * cos(iTheta);
147  oEnrFuncDeriv.push_back({ dP4dr *drdx + dP4dt *dtdx, dP4dr *drdy + dP4dt *dtdy });
148 }
149 
150 void LinElBranchFunction :: giveJump(std :: vector< double > &oJumps) const
151 {
152  OOFEM_ERROR("The radius is needed to compute the jump for branch functions.")
153 }
154 
155 void LinElBranchFunction :: giveJump(std :: vector< double > &oJumps, const double &iRadius) const
156 {
161  oJumps.clear();
162  oJumps.push_back( 2.0 * sqrt(iRadius) );
163  oJumps.push_back(0.0);
164  oJumps.push_back(0.0);
165  oJumps.push_back(0.0);
166 }
167 
168 void CohesiveBranchFunction :: evaluateEnrFuncAt(std :: vector< double > &oEnrFunc, const double &iR, const double &iTheta) const
169 {
170  oEnrFunc.push_back( pow(iR,mExponent) * sin(0.5 * iTheta) );
171 }
172 
173 void CohesiveBranchFunction :: evaluateEnrFuncDerivAt(std :: vector< FloatArray > &oEnrFuncDeriv, const double &iR, const double &iTheta) const
174 {
175  // Evaluate the enrichment function derivatives using the chain rule:
176  // dPdx = dPdr*drdx + dPdt*dtdx
177  // dPdy = dPdr*drdy + dPdt*dtdy
178 
179  const double drdx = cos(iTheta);
180  const double drdy = sin(iTheta);
181  const double dtdx = -( 1.0 / iR ) * sin(iTheta);
182  const double dtdy = ( 1.0 / iR ) * cos(iTheta);
183 
184  FloatArray dP;
185 
186  // Psi 1
187  const double dP1dr = mExponent*pow(iR, mExponent-1.0) * sin(0.5 * iTheta);
188  const double dP1dt = 0.5 * pow(iR,mExponent) * cos(0.5 * iTheta);
189  oEnrFuncDeriv.push_back({ dP1dr *drdx + dP1dt *dtdx, dP1dr *drdy + dP1dt *dtdy });
190 }
191 
192 void CohesiveBranchFunction :: giveJump(std :: vector< double > &oJumps) const
193 {
194  OOFEM_ERROR("The radius is needed to compute the jump for branch functions.")
195 }
196 
197 void CohesiveBranchFunction :: giveJump(std :: vector< double > &oJumps, const double &iRadius) const
198 {
203  oJumps.clear();
204  oJumps.push_back( 2.0 * pow(iRadius,mExponent) );
205 }
206 
207 } // end namespace oofem
virtual void evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
virtual void giveJump(std::vector< double > &oJumps) const
Class representing bimaterial interface.
double & at(int i)
Coefficient access function.
Definition: floatarray.h:131
double sgn(double i)
Returns the signum of given value (if value is < 0 returns -1, otherwise returns 1) ...
Definition: mathfem.h:91
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Definition: femcmpnn.C:77
Abstract class representing global shape function Base class declares abstract interface common to al...
virtual void evaluateEnrFuncAt(std::vector< double > &oEnrFunc, const double &iR, const double &iTheta) const
virtual void evaluateEnrFuncDerivAt(std::vector< FloatArray > &oEnrFuncDeriv, const double &iR, const double &iTheta) const
REGISTER_EnrichmentFunction(DiscontinuousFunction)
#define OOFEM_ERROR(...)
Definition: error.h:61
Class representing Sign EnrichmentFunction.
virtual void giveInputRecord(DynamicInputRecord &input)
Setups the input record string of receiver.
Class representing vector of real numbers.
Definition: floatarray.h:82
IRResultType
Type defining the return values of InputRecord reading operations.
Definition: irresulttype.h:47
virtual void evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
virtual void evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
Class representing the general Input Record.
Definition: inputrecord.h:101
virtual void evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
Class representing Heaviside EnrichmentFunction.
void zero()
Zeroes all coefficients of receiver.
Definition: floatarray.C:658
Class representing the a dynamic Input Record.
virtual void evaluateEnrFuncAt(std::vector< double > &oEnrFunc, const double &iR, const double &iTheta) const
virtual void giveJump(std::vector< double > &oJumps) const
virtual void evaluateEnrFuncAt(double &oEnrFunc, const FloatArray &iPos, const double &iLevelSet) const
virtual void evaluateEnrFuncDerivAt(std::vector< FloatArray > &oEnrFuncDeriv, const double &iR, const double &iTheta) const
the oofem namespace is to define a context or scope in which all oofem names are defined.
virtual void evaluateEnrFuncDerivAt(FloatArray &oEnrFuncDeriv, const FloatArray &iPos, const double &iLevelSet, const FloatArray &iGradLevelSet) const
void resize(int s)
Resizes receiver towards requested size.
Definition: floatarray.C:631

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