|
[Sponsors] |
July 21, 2011, 13:06 |
Assign Boundary conditions using utility
|
#1 |
Member
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 16 |
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; } // ************************************************************************* // |
|
July 21, 2011, 14:42 |
|
#2 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
The utility engineSwirl initializes a swirling field, but it may not do exactly what you need. Try change the reading of the U field to use AUTO_WRITE instead of NO_WRITE.
Also, are your fields uniformly zero, or is zero specified for every cell? |
|
July 21, 2011, 17:38 |
|
#3 |
Member
Tony
Join Date: Jun 2010
Posts: 54
Rep Power: 16 |
Hi Marco and thanks for your reply. I tried changing it to AUTO_WRITE but still no luck. The utility will write the correct value I try to assign to the fields but instead of setting the boundary condition it will write "type calculated;" instead of the one I have on my blockMeshDict file.
Thanks, Tony |
|
July 21, 2011, 18:37 |
|
#4 |
Senior Member
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 740
Rep Power: 28 |
If you only need the field to be written as an initial condition, then it may be more useful to install swak4Foam and use the included funkySetFields utility. Read more about swak4Foam on the wiki:
http://openfoamwiki.net/index.php/Contrib/swak4Foam From your code it looks like funkySetFields will do exactly what you want: you can set the boundary "top" to be fixedValue, and the value will be written exactly as you want it. Good luck! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
mesh file for flow over a circular cylinder | Ardalan | Main CFD Forum | 7 | December 15, 2020 14:06 |
Impinging Jet Boundary Conditions | Anindya | Main CFD Forum | 25 | February 27, 2016 13:58 |
Boundary conditions for 2D Navie-Stockes simulation | L1011 | OpenFOAM | 5 | December 13, 2012 09:17 |
how to assign radiation boundary conditions? | Jinfeng | CFX | 0 | January 10, 2009 18:18 |
A problem about setting boundary conditions | lyang | Main CFD Forum | 0 | September 19, 1999 19:29 |