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

potentialFoam.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     potentialFoam
00026 
00027 Description
00028     Simple potential flow solver which can be used to generate starting fields
00029     for full Navier-Stokes codes.
00030 
00031 Usage
00032     - potentialFoam [OPTION]
00033 
00034     @param -writep \n
00035     Also write the pressure field
00036 
00037     @param -case <dir> \n
00038     Specify the case directory
00039 
00040     @param -parallel \n
00041     Run the case in parallel
00042 
00043     @param -help \n
00044     Display short usage message
00045 
00046     @param -doc \n
00047     Display Doxygen documentation page
00048 
00049     @param -srcDoc \n
00050     Display source code
00051 
00052 \*---------------------------------------------------------------------------*/
00053 
00054 #include <finiteVolume/fvCFD.H>
00055 
00056 
00057 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00058 
00059 int main(int argc, char *argv[])
00060 {
00061 
00062     argList::validOptions.insert("writep", "");
00063 
00064 #   include <OpenFOAM/setRootCase.H>
00065 
00066 #   include <OpenFOAM/createTime.H>
00067 #   include <OpenFOAM/createMesh.H>
00068 #   include "createFields.H"
00069 #   include <finiteVolume/readSIMPLEControls.H>
00070 
00071 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00072 
00073     Info<< nl << "Calculating potential flow" << endl;
00074 
00075     adjustPhi(phi, U, p);
00076 
00077     for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
00078     {
00079         fvScalarMatrix pEqn
00080         (
00081             fvm::laplacian
00082             (
00083                 dimensionedScalar
00084                 (
00085                     "1",
00086                     dimTime/p.dimensions()*dimensionSet(0, 2, -2, 0, 0),
00087                     1
00088                 ),
00089                 p
00090             )
00091          ==
00092             fvc::div(phi)
00093         );
00094 
00095         pEqn.setReference(pRefCell, pRefValue);
00096         pEqn.solve();
00097 
00098         if (nonOrth == nNonOrthCorr)
00099         {
00100             phi -= pEqn.flux();
00101         }
00102     }
00103 
00104     Info<< "continuity error = "
00105         << mag(fvc::div(phi))().weightedAverage(mesh.V()).value()
00106         << endl;
00107 
00108     U = fvc::reconstruct(phi);
00109     U.correctBoundaryConditions();
00110 
00111     Info<< "Interpolated U error = "
00112         << (sqrt(sum(sqr((fvc::interpolate(U) & mesh.Sf()) - phi)))
00113           /sum(mesh.magSf())).value()
00114         << endl;
00115 
00116     // Force the write
00117     U.write();
00118     phi.write();
00119 
00120     if (args.optionFound("writep"))
00121     {
00122         p.write();
00123     }
00124 
00125     Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
00126         << "  ClockTime = " << runTime.elapsedClockTime() << " s"
00127         << nl << endl;
00128 
00129     Info<< "End\n" << endl;
00130 
00131     return 0;
00132 }
00133 
00134 
00135 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines