tonyuprm |
July 21, 2011 12:06 |
Assign Boundary conditions using utility
Hi all,
Im trying to create a utility which will initialize my fields and set the boundary conditions on my fields. I am having trouble assigning the boundary conditions because even though I assign "fixedValue" it will show as "calculated" instead when written to the 0 directory. Here is my code. How can I assign the boundary condition and have it write out correctly?
Thanks,
Tony
Code:
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
engineSwirl
Description
Generates a swirling flow for engine calulations
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "wallDist.H"
#include "fixedGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
//argList::validArgs.append("boundary layer thickness");
# include "setRootCase.H"
# include "createTime.H"
# include "createMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info << "Reading field U" << endl ;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimensionedVector("U",dimensionSet(0, 1, -1, 0, 0, 0, 0),vector(15.0,0,0))
);
Info << "Reading field T" << endl ;
volScalarField T
(
IOobject
(
"T",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("T",dimensionSet(0, 0, 0, 1, 0, 0, 0),300.0)
);
Info << "Reading field p" << endl ;
volScalarField p
(
IOobject
(
"p",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("p",dimensionSet(0, 1, -2, 0, 0, 0, 0),0.0)
);
Info << "Reading field nuSgs" << endl ;
volScalarField nuSgs
(
IOobject
(
"nuSgs",
runTime.timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("nuSgs",dimensionSet(0, 2, -1, 0, 0, 0, 0),0.0)
);
label patchID = mesh.boundaryMesh().findPatchID("top");
U.boundaryField()[patchID].type() == fixedValueFvPatchVectorField::typeName;
Info<<U.boundaryField()[patchID].type()<<endl;
Info<<fixedValueFvPatchVectorField::typeName<<endl;
forAll(U.boundaryField()[patchID],i)
{
U.boundaryField()[patchID][i].x()=8;
U.boundaryField()[patchID][i].y()=0;
U.boundaryField()[patchID][i].z()=0;
p.boundaryField()[patchID][i]=0;
nuSgs.boundaryField()[patchID][i]=0;
T.boundaryField()[patchID][i]=300;
}
U.boundaryField()[patchID].type() == fixedValueFvPatchVectorField::typeName;
Info<< "Writing U" << endl;
U.write();
Info<< "Writing T" << endl;
T.write();
Info<< "Writing p" << endl;
p.write();
Info<< "Writing nuSgs" << endl;
nuSgs.write();
return 0;
}
// ************************************************************************* //
|