1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation, either version 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 Calculates and writes the scalar fields of the six components of the stress
29 tensor sigma for each time for linear stress analysis calculations.
31 \*---------------------------------------------------------------------------*/
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 int main(int argc, char *argv[])
39 # include "addTimeOptions.H"
40 # include "setRootCase.H"
42 # include "createTime.H"
45 instantList Times = runTime.times();
47 // set startTime and endTime depending on -time and -latestTime options
48 # include "checkTimeOptions.H"
50 runTime.setTime(Times[startTime], startTime);
52 # include "createMesh.H"
53 # include "readMechanicalProperties.H"
55 for (label i = startTime; i < endTime; i++)
57 runTime.setTime(Times[i], i);
59 Info<< "Time = " << runTime.timeName() << endl;
72 if (Uheader.headerOk())
76 Info<< " Reading U" << endl;
77 volVectorField U(Uheader, mesh);
79 volTensorField gradU = fvc::grad(U);
81 volSymmTensorField sigma =
82 rho*(2.0*mu*symm(gradU) + lambda*I*tr(gradU));
84 volScalarField sigmaEq
94 sqrt((3.0/2.0)*magSqr(dev(sigma)))
97 Info<< "Max sigmaEq = " << max(sigmaEq).value()
101 volScalarField sigmaxx
111 sigma.component(symmTensor::XX)
115 volScalarField sigmayy
125 sigma.component(symmTensor::YY)
129 volScalarField sigmazz
139 sigma.component(symmTensor::ZZ)
143 volScalarField sigmaxy
153 sigma.component(symmTensor::XY)
157 volScalarField sigmaxz
167 sigma.component(symmTensor::XZ)
171 volScalarField sigmayz
181 sigma.component(symmTensor::YZ)
187 Info<< " No U" << endl;
193 Info<< "End" << endl;
199 // ************************************************************************* //