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

phaseModel.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 \*---------------------------------------------------------------------------*/
00026 
00027 #include "phaseModel.H"
00028 #include "fixedValueFvPatchFields.H"
00029 #include "surfaceInterpolate.H"
00030 
00031 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00032 
00033 Foam::phaseModel::phaseModel
00034 (
00035     const fvMesh& mesh,
00036     const dictionary& transportProperties,
00037     const word& phaseName
00038 )
00039 :
00040     dict_
00041     (
00042         transportProperties.subDict("phase" + phaseName)
00043     ),
00044     name_(phaseName),
00045     d_
00046     (
00047         dict_.lookup("d")
00048     ),
00049     nu_
00050     (
00051         dict_.lookup("nu")
00052     ),
00053     rho_
00054     (
00055         dict_.lookup("rho")
00056     ),
00057     U_
00058     (
00059         IOobject
00060         (
00061             "U" + phaseName,
00062             mesh.time().timeName(),
00063             mesh,
00064             IOobject::MUST_READ,
00065             IOobject::AUTO_WRITE
00066         ),
00067         mesh
00068     )
00069 {
00070     const word phiName = "phi" + phaseName;
00071 
00072     IOobject phiHeader
00073     (
00074         phiName,
00075         mesh.time().timeName(),
00076         mesh,
00077         IOobject::NO_READ
00078     );
00079 
00080     if (phiHeader.headerOk())
00081     {
00082         Info<< "Reading face flux field " << phiName << endl;
00083 
00084         phiPtr_.reset
00085         (
00086             new surfaceScalarField
00087             (
00088                 IOobject
00089                 (
00090                     phiName,
00091                     mesh.time().timeName(),
00092                     mesh,
00093                     IOobject::MUST_READ,
00094                     IOobject::AUTO_WRITE
00095                 ),
00096                 mesh
00097             )
00098         );
00099     }
00100     else
00101     {
00102         Info<< "Calculating face flux field " << phiName << endl;
00103 
00104         wordList phiTypes
00105         (
00106             U_.boundaryField().size(),
00107             calculatedFvPatchScalarField::typeName
00108         );
00109 
00110         for (label i=0; i<U_.boundaryField().size(); i++)
00111         {
00112             if (isType<fixedValueFvPatchVectorField>(U_.boundaryField()[i]))
00113             {
00114                 phiTypes[i] = fixedValueFvPatchScalarField::typeName;
00115             }
00116         }
00117 
00118         phiPtr_.reset
00119         (
00120             new surfaceScalarField
00121             (
00122                 IOobject
00123                 (
00124                     phiName,
00125                     mesh.time().timeName(),
00126                     mesh,
00127                     IOobject::NO_READ,
00128                     IOobject::AUTO_WRITE
00129                 ),
00130                 fvc::interpolate(U_) & mesh.Sf(),
00131                 phiTypes
00132             )
00133         );
00134     }
00135 }
00136 
00137 
00138 Foam::autoPtr<Foam::phaseModel> Foam::phaseModel::New
00139 (
00140     const fvMesh& mesh,
00141     const dictionary& transportProperties,
00142     const word& phaseName
00143 )
00144 {
00145     return autoPtr<phaseModel>
00146     (
00147         new phaseModel(mesh, transportProperties, phaseName)
00148     );
00149 }
00150 
00151 
00152 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00153 
00154 Foam::phaseModel::~phaseModel()
00155 {}
00156 
00157 
00158 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd