CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

How to get area, face normal vector of a patch

Register Blogs Community New Posts Updated Threads Search

Like Tree5Likes
  • 5 Post By GCMS_A

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 27, 2015, 10:27
Default How to get area, face normal vector of a patch
  #1
New Member
 
Join Date: Apr 2015
Posts: 3
Rep Power: 11
GCMS_A is on a distinguished road
Hi everyone,

I have this code that I would like to modify to fit to my problem :
Code:
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

void velocityChannelWallFunctionFvPatchField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

//  Set up access to the mesh
    const fvMesh& mesh = patch().boundaryMesh().mesh();

//  Set up access to the internal velocity field.
    const volVectorField& UCell = db().objectRegistry::lookupObject<volVectorField>("U");

//  Interpolate velocity on the cell faces.
    surfaceVectorField UFace = fvc::interpolate(UCell);


//  Get face areas (individual and global sum) (note that "gSum" is used as
//  opposed to "sum" because "gSum" is parallel-aware --- it gathers sums from
//  each processor to which this patch belongs and makes the global sum)
    const scalarField area = patch().magSf();
    scalar areaTotal = gSum(area);
//  Get perpendicular distance from cell center to boundary.  In other words,
//  the height of the y_1/2 grid level.
    const scalarField y12 = 1.0/patch().deltaCoeffs();

//  Get face normal vectors
    vectorField normal = patch().nf();
I have modified it like this :

Code:
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

void velocityChannelWallFunctionFvPatchField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

//  Set up access to the mesh
    const fvMesh& mesh = patch().boundaryMesh().mesh();

//  --------

    label patchIndexUp = mesh.boundaryMesh().findPatchID("topWall");
    Info << "patchIndexUp =" << patchIndexUp << endl; 

    label patchIndexDown = mesh.boundaryMesh().findPatchID("bottomWall");
    Info << "patchIndexDown =" << patchIndexDown << endl; 

//  --------



//  Set up access to the internal velocity field.
    const volVectorField& UCell = db().objectRegistry::lookupObject<volVectorField>("U");

//  Interpolate velocity on the cell faces.
    surfaceVectorField UFace = fvc::interpolate(UCell);


//  Get face areas (individual and global sum) (note that "gSum" is used as
//  opposed to "sum" because "gSum" is parallel-aware --- it gathers sums from
//  each processor to which this patch belongs and makes the global sum)
    const scalarField area = patch().magSf();
    scalar areaTotal = gSum(area);
//  Get perpendicular distance from cell center to boundary.  In other words,
//  the height of the y_1/2 grid level.
    const scalarField y12 = 1.0/patch().deltaCoeffs();

//  Get face normal vectors
    vectorField normal = patch().nf();
but I don't know how can I get the area, face normal vectors ... of the patchIndexUp & the patchIndexDown.

If anybody know how to do this, I would be very happy to have explanations.

Thank you

Anass
GCMS_A is offline   Reply With Quote

Old   May 28, 2015, 03:52
Default following ...
  #2
New Member
 
Join Date: Apr 2015
Posts: 3
Rep Power: 11
GCMS_A is on a distinguished road
Hi everyone,
I finaly found how to get the face area for the two patches (patchIndexUp & Down).

My code became as follow :

Code:
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

void velocityChannelWallFunctionFvPatchField::updateCoeffs()
{
    if (this->updated())
    {
        return;
    }

//  Set up access to the mesh
    const fvMesh& mesh = patch().boundaryMesh().mesh();

//  --------

    label patchIndexUp = mesh.boundaryMesh().findPatchID("topWall");
    Info << "patchIndexUp =" << patchIndexUp << endl; 

    label patchIndexDown = mesh.boundaryMesh().findPatchID("bottomWall");
    Info << "patchIndexDown =" << patchIndexDown << endl; 

//  --------



//  Set up access to the internal velocity field.
    const volVectorField& UCell = db().objectRegistry::lookupObject<volVectorField>("U");

//  Interpolate velocity on the cell faces.
    surfaceVectorField UFace = fvc::interpolate(UCell);


//  Get face areas (individual and global sum) (note that "gSum" is used as
//  opposed to "sum" because "gSum" is parallel-aware --- it gathers sums from
//  each processor to which this patch belongs and makes the global sum)
//  const scalarField area = patch().magSf();
//  scalar areaTotal = gSum(area);


//  --------
    const surfaceScalarField& magSf = mesh.magSf();
    scalar areaUpTotal = gSum(magSf.boundaryField()[patchIndexUp]);
    scalar areaDownTotal = gSum(magSf.boundaryField()[patchIndexDown]);
//  --------

//  Get perpendicular distance from cell center to boundary.  In other words,
//  the height of the y_1/2 grid level.
    //const scalarField y12 = 1.0/patch().deltaCoeffs();


//  --------
    const scalarField yUp = mesh.boundary()[patchIndexUp].deltaCoeffs();
    const scalarField yDown = mesh.boundary()[patchIndexDown].deltaCoeffs();
//  --------

//  Get face normal vectors
    //vectorField normal = patch().nf();

//  --------
    vectorField normalUp = mesh.Sf().boundaryField()[patchIndexUp];
    vectorField normalDown = mesh.Sf().boundaryField()[patchIndexDown];
My question now is : For this part of code :

Code:
//  Set up access to the internal velocity field.
    const volVectorField& UCell = db().objectRegistry::lookupObject<volVectorField>("U");

//  Interpolate velocity on the cell faces.
    surfaceVectorField UFace = fvc::interpolate(UCell);
Is someone could explain to me the meaning of these lines of code ? and how can I change them if I want to find the values ​​of Ucell and UFace for the patchIndexUp and patchIndexDown ?


Thank you

Anass
GCMS_A is offline   Reply With Quote

Old   September 16, 2018, 11:20
Default
  #3
Member
 
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10
pvpnrao is on a distinguished road
GCMS_A

Thank you very much for posting the fix for calculating the areas of other boundaries within a boundary condition.

You saved me a lot of time today. I understand your query in in the second post is three years old. I am sure you must have figured it.

Let me know if you still need this information.
pvpnrao is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cyclic Boundary Condition Luiz Eduardo Bittencourt Sampaio (Sampaio) OpenFOAM Running, Solving & CFD 36 July 2, 2012 12:23
[blockMesh] error message with modeling a cube with a hold at the center hsingtzu OpenFOAM Meshing & Mesh Conversion 2 March 14, 2012 09:56
[Gmsh] Import problem ARC OpenFOAM Meshing & Mesh Conversion 0 February 27, 2010 10:56
CFX Solver Memory Error mike CFX 1 March 19, 2008 07:22
NACA0012 geometry/design software needed Franny Main CFD Forum 13 July 7, 2007 15:57


All times are GMT -4. The time now is 01:51.