|
[Sponsors] |
How to get area, face normal vector of a patch |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 27, 2015, 11:27 |
How to get area, face normal vector of a patch
|
#1 |
New Member
Join Date: Apr 2015
Posts: 3
Rep Power: 11 |
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(); 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(); If anybody know how to do this, I would be very happy to have explanations. Thank you Anass |
|
May 28, 2015, 04:52 |
following ...
|
#2 |
New Member
Join Date: Apr 2015
Posts: 3
Rep Power: 11 |
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]; 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); Thank you Anass |
|
September 16, 2018, 12:20 |
|
#3 |
Member
Pavan
Join Date: Jan 2016
Posts: 53
Rep Power: 10 |
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. |
|
|
|
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 13:23 |
[blockMesh] error message with modeling a cube with a hold at the center | hsingtzu | OpenFOAM Meshing & Mesh Conversion | 2 | March 14, 2012 10:56 |
[Gmsh] Import problem | ARC | OpenFOAM Meshing & Mesh Conversion | 0 | February 27, 2010 11:56 |
CFX Solver Memory Error | mike | CFX | 1 | March 19, 2008 08:22 |
NACA0012 geometry/design software needed | Franny | Main CFD Forum | 13 | July 7, 2007 16:57 |