|
[Sponsors] |
How to change fvPatchField type of volume Field |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
August 4, 2014, 10:52 |
How to change fvPatchField type of volume Field
|
#1 |
Member
Lianhua Zhu
Join Date: Aug 2011
Location: Wuhan, China
Posts: 35
Rep Power: 15 |
Hi, all!
How can I change the patchField type of a specific patch? I need to do this because for the calculated temporary field, all of the patch is set to "calculated" automatically, except those "empty" type. For example: Code:
volScalarField p ( IOobject ( "p", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Info << "=================Field p ====================" << endl; Info << p << endl; volScalarField a = 2*p; Info << "=================Field a ====================" << endl; Info << a << endl; The output would be: Code:
=================Field p ==================== dimensions [0 2 -2 0 0 0 0]; internalField uniform 0; boundaryField { movingWall { type fixedValue; value uniform 7; } fixedWalls { type fixedValue; value uniform 1; } frontAndBack { type empty; } } =================Field a ==================== dimensions [0 2 -2 0 0 0 0]; internalField uniform 0; boundaryField { movingWall { type calculated; value uniform 14; } fixedWalls { type calculated; value uniform 2; } frontAndBack { type empty; } } After reading the souce code of GeometricField class, I have tried to construct the a object with the patchFields of p to circumvent this problem, but failed to compile it. The code is: Code:
volScalarField a ( IOobject ( "a", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE ), mesh, p.dimensions(), scalar(0), p.boundaryField() ); Code:
Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( const Foam::IOobject&, const typename GeoMesh::Mesh&, const Foam::dimensionSet&, const Foam::Field<Type>&, const Foam::PtrList<PatchField<Type> >& ) Code:
No matching function for call to Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricField ( Foam::IOobject, Foam::fvMesh&, Foam::dimensionSet&, Foam::scalar, Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::GeometricBoundaryField& ) So: Problem 2. How to use this Constructing function properly? Sorry for the long post... Any information would be great! Bests, Lianhua |
|
August 5, 2014, 09:08 |
|
#2 |
Member
Lianhua Zhu
Join Date: Aug 2011
Location: Wuhan, China
Posts: 35
Rep Power: 15 |
I found the answer for the Problem 1.
suppose patchi is the patch I want to change to PatchField type, and name is the PatchField type name. I can simply do this: Code:
a.boundaryField().set(patchi, fvPatchField<scalar>::New(name, mesh.boundary()[patchi], a)); Code:
a.boundaryField()[0][0] = 1; //first boundary face of the 0th patch a.boundaryField()[0][1] = 2; //first boundary face of the 0th patch a.boundaryField()[0][2] = 3; ... Code:
a.boundaryField()[0] == 4; Lianhua. |
|
August 23, 2018, 12:40 |
|
#3 | |
Senior Member
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 11 |
Quote:
|
||
October 2, 2018, 05:44 |
|
#4 |
New Member
Y H Tang
Join Date: Nov 2014
Posts: 2
Rep Power: 0 |
Hi Lianhua,
Thanks for your self-reply. It enlightened me to look more into run time change of boundary conditions, so that now it all be done on-the-fly IN PARALLEL without the annoying reconstruction-change-decompose every time The setting of boundary patch type you explained is very useful. However, for some reason your method of assigning the value at each boundary mesh surface is not working for me, which leads to solution singularity. I assume the problem is that the face value is only enforced at the moment of the assignment, while the original b.c. is still applied when the partial differential equations later being solved. So I did some research myself, and I found that to change the boundary value, a good way is to use refCast, e.g. Code:
label patchID = mesh.boundaryMesh().findPatchID("ports"); fixedValueFvPatchVectorField& UPatch = refCast<fixedValueFvPatchVectorField>(U.boundaryField()[patchID]); vectorField& UField = UPatch; UField = -10.0*mesh.Sf().boundaryField()[patchID]/mesh.magSf().boundaryField()[patchID]; Now I'm posting this reply and hope that someday, and that day may never come, someone will find it useful. Not sure this is the best way to do, but it definitely works for my case. GLTA Below are ref. threads where I learned all these: A general openfoam development question about boundary condition Neumann boundary conditions |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Why Menter's SST model low-Re issue has not been seriously investigated? | vkrastev | OpenFOAM | 58 | January 8, 2018 16:20 |
interFoam/kOmegaSST tank filling with printStackError/Mules | simpomann | OpenFOAM Running, Solving & CFD | 3 | February 17, 2014 18:06 |
singularity? | mihaipruna | OpenFOAM Running, Solving & CFD | 5 | April 24, 2012 18:18 |
[blockMesh] BlockMesh FOAM warning | gaottino | OpenFOAM Meshing & Mesh Conversion | 7 | July 19, 2010 15:11 |
[blockMesh] Axisymmetrical mesh | Rasmus Gjesing (Gjesing) | OpenFOAM Meshing & Mesh Conversion | 10 | April 2, 2007 15:00 |