OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

stressComponents.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Application
00026     stressComponents
00027 
00028 Description
00029     Calculates and writes the scalar fields of the six components of the stress
00030     tensor sigma for each time.
00031 
00032 \*---------------------------------------------------------------------------*/
00033 
00034 #include "fvCFD.H"
00035 #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H"
00036 #include "zeroGradientFvPatchFields.H"
00037 
00038 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00039 
00040 int main(int argc, char *argv[])
00041 {
00042     timeSelector::addOptions();
00043 
00044 #   include "setRootCase.H"
00045 #   include "createTime.H"
00046 
00047     instantList timeDirs = timeSelector::select0(runTime, args);
00048 
00049 #   include "createMesh.H"
00050 
00051     forAll(timeDirs, timeI)
00052     {
00053         runTime.setTime(timeDirs[timeI], timeI);
00054 
00055         Info<< "Time = " << runTime.timeName() << endl;
00056 
00057         IOobject Uheader
00058         (
00059             "U",
00060             runTime.timeName(),
00061             mesh,
00062             IOobject::MUST_READ
00063         );
00064 
00065         // Check U exists
00066         if (Uheader.headerOk())
00067         {
00068             mesh.readUpdate();
00069 
00070             Info<< "    Reading U" << endl;
00071             volVectorField U(Uheader, mesh);
00072 
00073 #           include "createPhi.H"
00074 
00075             singlePhaseTransportModel laminarTransport(U, phi);
00076 
00077             volSymmTensorField sigma
00078             (
00079                 IOobject
00080                 (
00081                     "sigma",
00082                     runTime.timeName(),
00083                     mesh,
00084                     IOobject::NO_READ,
00085                     IOobject::AUTO_WRITE
00086                 ),
00087                 laminarTransport.nu()*2*dev(symm(fvc::grad(U)))
00088             );
00089 
00090 
00091             volScalarField sigmaxx
00092             (
00093                 IOobject
00094                 (
00095                     "sigmaxx",
00096                     runTime.timeName(),
00097                     mesh,
00098                     IOobject::NO_READ
00099                 ),
00100                 sigma.component(tensor::XX)
00101             );
00102             sigmaxx.write();
00103 
00104             volScalarField sigmayy
00105             (
00106                 IOobject
00107                 (
00108                     "sigmayy",
00109                     runTime.timeName(),
00110                     mesh,
00111                     IOobject::NO_READ
00112                 ),
00113                 sigma.component(tensor::YY)
00114             );
00115             sigmayy.write();
00116 
00117             volScalarField sigmazz
00118             (
00119                 IOobject
00120                 (
00121                     "sigmazz",
00122                     runTime.timeName(),
00123                     mesh,
00124                     IOobject::NO_READ
00125                 ),
00126                 sigma.component(tensor::ZZ)
00127             );
00128             sigmazz.write();
00129 
00130             volScalarField sigmaxy
00131             (
00132                 IOobject
00133                 (
00134                     "sigmaxy",
00135                     runTime.timeName(),
00136                     mesh,
00137                     IOobject::NO_READ
00138                 ),
00139                 sigma.component(tensor::XY)
00140             );
00141             sigmaxy.write();
00142 
00143             volScalarField sigmaxz
00144             (
00145                 IOobject
00146                 (
00147                     "sigmaxz",
00148                     runTime.timeName(),
00149                     mesh,
00150                     IOobject::NO_READ
00151                 ),
00152                 sigma.component(tensor::XZ)
00153             );
00154             sigmaxz.write();
00155 
00156             volScalarField sigmayz
00157             (
00158                 IOobject
00159                 (
00160                     "sigmayz",
00161                     runTime.timeName(),
00162                     mesh,
00163                     IOobject::NO_READ
00164                 ),
00165                 sigma.component(tensor::YZ)
00166             );
00167             sigmayz.write();
00168 
00169             volVectorField Ub
00170             (
00171                 IOobject
00172                 (
00173                     "Ub",
00174                     runTime.timeName(),
00175                     mesh,
00176                     IOobject::NO_READ
00177                 ),
00178                 U,
00179                 zeroGradientFvPatchVectorField::typeName
00180             );
00181             Ub.correctBoundaryConditions();
00182             Ub.write();
00183 
00184             volScalarField sigmaUn
00185             (
00186                 IOobject
00187                 (
00188                     "sigmaUn",
00189                     runTime.timeName(),
00190                     mesh,
00191                     IOobject::NO_READ
00192                 ),
00193                 0.0*sigma.component(tensor::YZ)
00194             );
00195 
00196             forAll(sigmaUn.boundaryField(), patchI)
00197             {
00198                 sigmaUn.boundaryField()[patchI] =
00199                 (
00200                     mesh.boundary()[patchI].nf()
00201                   & sigma.boundaryField()[patchI]
00202                 )().component(vector::X);
00203             }
00204 
00205             sigmaUn.write();
00206         }
00207         else
00208         {
00209             Info<< "    No U" << endl;
00210         }
00211 
00212         Info<< endl;
00213     }
00214 
00215     Info<< "End" << endl;
00216 
00217     return 0;
00218 }
00219 
00220 
00221 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd