FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Application
00025     stressComponents
00026 
00027 Description
00028     Calculates and writes the scalar fields of the six components of the stress
00029     tensor sigma for each time.
00030 
00031 Usage
00032 
00033     - stressComponents [OPTIONS]
00034 
00035     @param -noZero \n
00036     Ignore timestep 0.
00037 
00038     @param -constant \n
00039     Include the constant directory.
00040 
00041     @param -time <time>\n
00042     Apply only to specific time.
00043 
00044     @param -latestTime \n
00045     Only apply to latest time step.
00046 
00047     @param -case <dir>\n
00048     Case directory.
00049 
00050     @param -parallel \n
00051     Run in parallel.
00052 
00053     @param -help \n
00054     Display help message.
00055 
00056     @param -doc \n
00057     Display Doxygen API documentation page for this application.
00058 
00059     @param -srcDoc \n
00060     Display Doxygen source documentation page for this application.
00061 
00062 \*---------------------------------------------------------------------------*/
00063 
00064 #include <finiteVolume/fvCFD.H>
00065 #include <incompressibleTransportModels/singlePhaseTransportModel.H>
00066 #include <finiteVolume/zeroGradientFvPatchFields.H>
00067 
00068 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00069 
00070 int main(int argc, char *argv[])
00071 {
00072     timeSelector::addOptions();
00073 
00074 #   include <OpenFOAM/setRootCase.H>
00075 #   include <OpenFOAM/createTime.H>
00076 
00077     instantList timeDirs = timeSelector::select0(runTime, args);
00078 
00079 #   include <OpenFOAM/createMesh.H>
00080 
00081     forAll(timeDirs, timeI)
00082     {
00083         runTime.setTime(timeDirs[timeI], timeI);
00084 
00085         Info<< "Time = " << runTime.timeName() << endl;
00086 
00087         IOobject Uheader
00088         (
00089             "U",
00090             runTime.timeName(),
00091             mesh,
00092             IOobject::MUST_READ
00093         );
00094 
00095         // Check U exists
00096         if (Uheader.headerOk())
00097         {
00098             mesh.readUpdate();
00099 
00100             Info<< "    Reading U" << endl;
00101             volVectorField U(Uheader, mesh);
00102 
00103 #           include <finiteVolume/createPhi.H>
00104 
00105             singlePhaseTransportModel laminarTransport(U, phi);
00106 
00107             volSymmTensorField sigma
00108             (
00109                 IOobject
00110                 (
00111                     "sigma",
00112                     runTime.timeName(),
00113                     mesh,
00114                     IOobject::NO_READ,
00115                     IOobject::AUTO_WRITE
00116                 ),
00117                 laminarTransport.nu()*2*dev(symm(fvc::grad(U)))
00118             );
00119 
00120 
00121             volScalarField sigmaxx
00122             (
00123                 IOobject
00124                 (
00125                     "sigmaxx",
00126                     runTime.timeName(),
00127                     mesh,
00128                     IOobject::NO_READ
00129                 ),
00130                 sigma.component(symmTensor::XX)
00131             );
00132             sigmaxx.write();
00133 
00134             volScalarField sigmayy
00135             (
00136                 IOobject
00137                 (
00138                     "sigmayy",
00139                     runTime.timeName(),
00140                     mesh,
00141                     IOobject::NO_READ
00142                 ),
00143                 sigma.component(symmTensor::YY)
00144             );
00145             sigmayy.write();
00146 
00147             volScalarField sigmazz
00148             (
00149                 IOobject
00150                 (
00151                     "sigmazz",
00152                     runTime.timeName(),
00153                     mesh,
00154                     IOobject::NO_READ
00155                 ),
00156                 sigma.component(symmTensor::ZZ)
00157             );
00158             sigmazz.write();
00159 
00160             volScalarField sigmaxy
00161             (
00162                 IOobject
00163                 (
00164                     "sigmaxy",
00165                     runTime.timeName(),
00166                     mesh,
00167                     IOobject::NO_READ
00168                 ),
00169                 sigma.component(symmTensor::XY)
00170             );
00171             sigmaxy.write();
00172 
00173             volScalarField sigmaxz
00174             (
00175                 IOobject
00176                 (
00177                     "sigmaxz",
00178                     runTime.timeName(),
00179                     mesh,
00180                     IOobject::NO_READ
00181                 ),
00182                 sigma.component(symmTensor::XZ)
00183             );
00184             sigmaxz.write();
00185 
00186             volScalarField sigmayz
00187             (
00188                 IOobject
00189                 (
00190                     "sigmayz",
00191                     runTime.timeName(),
00192                     mesh,
00193                     IOobject::NO_READ
00194                 ),
00195                 sigma.component(symmTensor::YZ)
00196             );
00197             sigmayz.write();
00198 
00199             volVectorField Ub
00200             (
00201                 IOobject
00202                 (
00203                     "Ub",
00204                     runTime.timeName(),
00205                     mesh,
00206                     IOobject::NO_READ
00207                 ),
00208                 U,
00209                 zeroGradientFvPatchVectorField::typeName
00210             );
00211             Ub.correctBoundaryConditions();
00212             Ub.write();
00213 
00214             volScalarField sigmaUn
00215             (
00216                 IOobject
00217                 (
00218                     "sigmaUn",
00219                     runTime.timeName(),
00220                     mesh,
00221                     IOobject::NO_READ
00222                 ),
00223                 0.0*sigma.component(symmTensor::YZ)
00224             );
00225 
00226             forAll(sigmaUn.boundaryField(), patchI)
00227             {
00228                 sigmaUn.boundaryField()[patchI] =
00229                 (
00230                     mesh.boundary()[patchI].nf()
00231                   & sigma.boundaryField()[patchI]
00232                 )().component(vector::X);
00233             }
00234 
00235             sigmaUn.write();
00236         }
00237         else
00238         {
00239             Info<< "    No U" << endl;
00240         }
00241 
00242         Info<< endl;
00243     }
00244 
00245     Info<< "End" << endl;
00246 
00247     return 0;
00248 }
00249 
00250 
00251 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines