BUGFIX: Uninitialised member variables
[foam-extend-3.2.git] / applications / utilities / postProcessing / stressField / solidStress / solidStress.C
blob3949bb1a12dd7d9f355200125d4cf0887a4172dc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Application
26     solidStress
28 Description
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 \*---------------------------------------------------------------------------*/
34 #include "fvCFD.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 int main(int argc, char *argv[])
41 #   include "addTimeOptions.H"
42 #   include "setRootCase.H"
44 #   include "createTime.H"
46     // Get times list
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++)
58     {
59         runTime.setTime(Times[i], i);
61         Info<< "Time = " << runTime.timeName() << endl;
63         mesh.readUpdate();
65         IOobject Uheader
66         (
67             "U",
68             runTime.timeName(),
69             mesh,
70             IOobject::MUST_READ
71         );
73         // Check U exists
74         if (Uheader.headerOk())
75         {
76             mesh.readUpdate();
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
87             (
88                 IOobject
89                 (
90                     "sigmaEq",
91                     runTime.timeName(),
92                     mesh,
93                     IOobject::NO_READ,
94                     IOobject::AUTO_WRITE
95                 ),
96                 sqrt((3.0/2.0)*magSqr(dev(sigma)))
97             );
99             Info<< "Max sigmaEq = " << max(sigmaEq).value()
100                 << endl;
101             sigmaEq.write();
103             volScalarField sigmaxx
104             (
105                 IOobject
106                 (
107                     "sigmaxx",
108                     runTime.timeName(),
109                     mesh,
110                     IOobject::NO_READ,
111                     IOobject::AUTO_WRITE
112                 ),
113                 sigma.component(symmTensor::XX)
114             );
115             sigmaxx.write();
117             volScalarField sigmayy
118             (
119                 IOobject
120                 (
121                     "sigmayy",
122                     runTime.timeName(),
123                     mesh,
124                     IOobject::NO_READ,
125                     IOobject::AUTO_WRITE
126                 ),
127                 sigma.component(symmTensor::YY)
128             );
129             sigmayy.write();
131             volScalarField sigmazz
132             (
133                 IOobject
134                 (
135                     "sigmazz",
136                     runTime.timeName(),
137                     mesh,
138                     IOobject::NO_READ,
139                     IOobject::AUTO_WRITE
140                 ),
141                 sigma.component(symmTensor::ZZ)
142             );
143             sigmazz.write();
145             volScalarField sigmaxy
146             (
147                 IOobject
148                 (
149                     "sigmaxy",
150                     runTime.timeName(),
151                     mesh,
152                     IOobject::NO_READ,
153                     IOobject::AUTO_WRITE
154                 ),
155                 sigma.component(symmTensor::XY)
156             );
157             sigmaxy.write();
159             volScalarField sigmaxz
160             (
161                 IOobject
162                 (
163                     "sigmaxz",
164                     runTime.timeName(),
165                     mesh,
166                     IOobject::NO_READ,
167                     IOobject::AUTO_WRITE
168                 ),
169                 sigma.component(symmTensor::XZ)
170             );
171             sigmaxz.write();
173             volScalarField sigmayz
174             (
175                 IOobject
176                 (
177                     "sigmayz",
178                     runTime.timeName(),
179                     mesh,
180                     IOobject::NO_READ,
181                     IOobject::AUTO_WRITE
182                 ),
183                 sigma.component(symmTensor::YZ)
184             );
185             sigmayz.write();
186        }
187         else
188         {
189             Info<< "    No U" << endl;
190         }
192         Info<< endl;
193     }
195     Info<< "End" << endl;
197     return(0);
201 // ************************************************************************* //