initial commit for version 1.5.x patch release
[OpenFOAM-1.5.x.git] / applications / utilities / postProcessing / stressField / stressComponents / stressComponents.C
blobc3b912074a689b3e9dd9e6bee8f7b01ae8923e10
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
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     stressComponents
28 Description
29     Calculates and writes the scalar fields of the six components of the stress
30     tensor sigma for each time.
32 \*---------------------------------------------------------------------------*/
34 #include "fvCFD.H"
35 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
36 #include "zeroGradientFvPatchFields.H"
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 int main(int argc, char *argv[])
44 #   include "addTimeOptions.H"
45 #   include "setRootCase.H"
47 #   include "createTime.H"
49     // Get times list
50     instantList Times = runTime.times();
52     // set startTime and endTime depending on -time and -latestTime options
53 #   include "checkTimeOptions.H"
55     runTime.setTime(Times[startTime], startTime);
57 #   include "createMesh.H"
59     for (label i=startTime; i<endTime; i++)
60     {
61         runTime.setTime(Times[i], i);
63         Info<< "Time = " << runTime.timeName() << endl;
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 #           include "createPhi.H"
83             singlePhaseTransportModel laminarTransport(U, phi);
85             volSymmTensorField sigma
86             (
87                 IOobject
88                 (
89                     "sigma",
90                     runTime.timeName(),
91                     mesh,
92                     IOobject::NO_READ,
93                     IOobject::AUTO_WRITE
94                 ),
95                 laminarTransport.nu()*2*dev(symm(fvc::grad(U)))
96             );
99             volScalarField sigmaxx
100             (
101                 IOobject
102                 (
103                     "sigmaxx",
104                     runTime.timeName(),
105                     mesh,
106                     IOobject::NO_READ
107                 ),
108                 sigma.component(tensor::XX)
109             );
110             sigmaxx.write();
112             volScalarField sigmayy
113             (
114                 IOobject
115                 (
116                     "sigmayy",
117                     runTime.timeName(),
118                     mesh,
119                     IOobject::NO_READ
120                 ),
121                 sigma.component(tensor::YY)
122             );
123             sigmayy.write();
125             volScalarField sigmazz
126             (
127                 IOobject
128                 (
129                     "sigmazz",
130                     runTime.timeName(),
131                     mesh,
132                     IOobject::NO_READ
133                 ),
134                 sigma.component(tensor::ZZ)
135             );
136             sigmazz.write();
138             volScalarField sigmaxy
139             (
140                 IOobject
141                 (
142                     "sigmaxy",
143                     runTime.timeName(),
144                     mesh,
145                     IOobject::NO_READ
146                 ),
147                 sigma.component(tensor::XY)
148             );
149             sigmaxy.write();
151             volScalarField sigmaxz
152             (
153                 IOobject
154                 (
155                     "sigmaxz",
156                     runTime.timeName(),
157                     mesh,
158                     IOobject::NO_READ
159                 ),
160                 sigma.component(tensor::XZ)
161             );
162             sigmaxz.write();
164             volScalarField sigmayz
165             (
166                 IOobject
167                 (
168                     "sigmayz",
169                     runTime.timeName(),
170                     mesh,
171                     IOobject::NO_READ
172                 ),
173                 sigma.component(tensor::YZ)
174             );
175             sigmayz.write();
177             volVectorField Ub
178             (
179                 IOobject
180                 (
181                     "Ub",
182                     runTime.timeName(),
183                     mesh,
184                     IOobject::NO_READ
185                 ),
186                 U,
187                 zeroGradientFvPatchVectorField::typeName
188             );
189             Ub.correctBoundaryConditions();
190             Ub.write();
192             volScalarField sigmaUn
193             (
194                 IOobject
195                 (
196                     "sigmaUn",
197                     runTime.timeName(),
198                     mesh,
199                     IOobject::NO_READ
200                 ),
201                 0.0*sigma.component(tensor::YZ)
202             );
204             forAll(sigmaUn.boundaryField(), patchI)
205             {
206                 sigmaUn.boundaryField()[patchI] =
207                 (
208                     mesh.boundary()[patchI].nf()
209                   & sigma.boundaryField()[patchI]
210                 )().component(vector::X);
211             }
213             sigmaUn.write();
214         }
215         else
216         {
217             Info<< "    No U" << endl;
218         }
220         Info<< endl;
221     }
223     Info<< "End" << endl;
225     return(0);
229 // ************************************************************************* //