1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM 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 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Calculates and writes the scalar fields of the six components of the stress
30 tensor sigma for each time for linear stress analysis calculations.
32 \*---------------------------------------------------------------------------*/
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 int main(int argc, char *argv[])
41 # include "addTimeOptions.H"
42 # include "setRootCase.H"
44 # include "createTime.H"
47 instantList Times = runTime.times();
49 // set startTime and endTime depending on -time and -latestTime options
50 # include "checkTimeOptions.H"
52 runTime.setTime(Times[startTime], startTime);
54 # include "createMesh.H"
55 # include "readMechanicalProperties.H"
57 for (label i=startTime; i<endTime; i++)
59 runTime.setTime(Times[i], i);
61 Info<< "Time = " << runTime.timeName() << endl;
74 if (Uheader.headerOk())
78 Info<< " Reading U" << endl;
79 volVectorField U(Uheader, mesh);
81 volTensorField gradU = fvc::grad(U);
83 volSymmTensorField sigma =
84 rho*(2.0*mu*symm(gradU) + lambda*I*tr(gradU));
86 volScalarField sigmaEq
96 sqrt((3.0/2.0)*magSqr(dev(sigma)))
99 Info<< "Max sigmaEq = " << max(sigmaEq).value()
103 volScalarField sigmaxx
113 sigma.component(symmTensor::XX)
117 volScalarField sigmayy
127 sigma.component(symmTensor::YY)
131 volScalarField sigmazz
141 sigma.component(symmTensor::ZZ)
145 volScalarField sigmaxy
155 sigma.component(symmTensor::XY)
159 volScalarField sigmaxz
169 sigma.component(symmTensor::XZ)
173 volScalarField sigmayz
183 sigma.component(symmTensor::YZ)
189 Info<< " No U" << endl;
195 Info<< "End" << endl;
201 // ************************************************************************* //