This repository has been archived on 2023-11-20. You can view files and clone it, but cannot push or open issues or pull requests.
foam-extend4.1-coherent-io/tutorials/solidMechanics/elasticSolidFoam/plateHole/analyticalPlateHole/analyticalPlateHole.C

141 lines
3.9 KiB
C
Raw Normal View History

2012-09-11 15:42:55 +00:00
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Generate analytical solution for a infinite plaste with a circular
hole.
Stress field sigma is generated.
Based on solution outlined in Timoshenko, Theory of Elasticity.
2012-09-11 15:42:55 +00:00
Author
plateHoleSolution function by Z. Tukovic
utility assembled by P. Cardiff
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "volFields.H"
#include "fvc.H"
#include "fixedValueFvPatchFields.H"
#include "coordinateSystem.H"
symmTensor plateHoleSolution(const vector& C);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
runTime++;
2012-09-11 15:42:55 +00:00
Info << "Writing analytical solution for an infinite plate with a circular hole,\nwhere"
<< "\n\tradius = 0.5"
<< "\n\tdistant traction = (10,000 0 0 )"
<< nl << endl;
volSymmTensorField sigma
2012-09-11 15:42:55 +00:00
(
IOobject
(
"sigmaAnalyticalCylin",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionedSymmTensor("zero", dimForce/dimArea, symmTensor::zero)
);
const volVectorField& C = mesh.C();
forAll(sigma.internalField(), celli)
2012-09-11 15:42:55 +00:00
{
vector curR = vector(C[celli].x(), C[celli].y(), 0);
2012-09-11 15:42:55 +00:00
sigma.internalField()[celli] = plateHoleSolution(curR);
2012-09-11 15:42:55 +00:00
}
forAll(sigma.boundaryField(), patchi)
2012-09-11 15:42:55 +00:00
{
forAll(sigma.boundaryField()[patchi], facei)
{
vector curR = vector(C.boundaryField()[patchi][facei].x(), C.boundaryField()[patchi][facei].y(), 0);
2012-09-11 15:42:55 +00:00
sigma.boundaryField()[patchi][facei] = plateHoleSolution(curR);
}
2012-09-11 15:42:55 +00:00
}
Info << "Writing analytical sigma tensor" << endl;
sigma.write();
2012-09-11 15:42:55 +00:00
Info << nl << "End" << endl;
return 0;
2012-09-11 15:42:55 +00:00
}
// ************************************************************************* //
symmTensor plateHoleSolution(const vector& C)
{
tensor sigma = tensor::zero;
scalar T = 10000;
scalar a = 0.5;
scalar r = ::sqrt(sqr(C.x()) + sqr(C.y()));
scalar theta = Foam::atan2(C.y(), C.x());
coordinateSystem cs("polarCS", C, vector(0, 0, 1), C/mag(C));
sigma.xx() =
T*(1 - sqr(a)/sqr(r))/2
2012-09-11 15:42:55 +00:00
+ T*(1 + 3*pow(a,4)/pow(r,4) - 4*sqr(a)/sqr(r))*::cos(2*theta)/2;
sigma.xy() =
- T*(1 - 3*pow(a,4)/pow(r,4) + 2*sqr(a)/sqr(r))*::sin(2*theta)/2;
sigma.yx() = sigma.xy();
sigma.yy() =
T*(1 + sqr(a)/sqr(r))/2
2012-09-11 15:42:55 +00:00
- T*(1 + 3*pow(a,4)/pow(r,4))*::cos(2*theta)/2;
// Transformation to global coordinate system
sigma = ((cs.R()&sigma)&cs.R().T());
symmTensor S = symmTensor::zero;
S.xx() = sigma.xx();
S.xy() = sigma.xy();
S.yy() = sigma.yy();
2012-09-11 15:42:55 +00:00
return S;
}