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

Boundary condition: check all cell values normal to the face of patch

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By JeremyChvlr

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 31, 2021, 06:14
Default Boundary condition: check all cell values normal to the face of patch
  #1
Senior Member
 
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15
agustinvo is on a distinguished road
Hi,


for a certain simulation I need to define a fixed value for a patch in function of all the cells which are on the normal direction to the patch. I need to recognize these cells, and compute a value in function of these cells.


As the mesh is just a prism, I was thinking to filter in function of a cell coordinate (with the same coordinate value the face has), but I was wondering if there is another "easier way" for this, like considering the patch normal vector, etc.


Thanks in advance for your tips and advices!
agustinvo is offline   Reply With Quote

Old   April 27, 2021, 09:36
Default
  #2
New Member
 
Jérémy Chevalier
Join Date: Feb 2021
Posts: 10
Rep Power: 5
JeremyChvlr is on a distinguished road
Hi,
I would like to have something like that too, have you found the solution?


Jérémy
JeremyChvlr is offline   Reply With Quote

Old   April 30, 2021, 20:01
Default
  #3
Senior Member
 
Agustín Villa
Join Date: Apr 2013
Location: Alcorcón
Posts: 314
Rep Power: 15
agustinvo is on a distinguished road
Hi
Unfortunately I haven't found any other way to compute this.
agustinvo is offline   Reply With Quote

Old   May 1, 2021, 07:00
Default
  #4
New Member
 
Jérémy Chevalier
Join Date: Feb 2021
Posts: 10
Rep Power: 5
JeremyChvlr is on a distinguished road
Hi, I think I found the good way to do that, maybe we don't wan't to do the same thing but I share it with you. It is very inspired by another topic on this forum but I can't find it anymore sorry


Code:
#include "wallDist.H"
#include "wallFvPatch.H"






 const fvPatchList& patches = mesh.boundary();
volScalarField y = wallDist(mesh).y();
scalar tol = 0.0000001 //Fixe it has you need
const surfaceVectorField& Cf = mesh.Cf();
const volVectorField& C = mesh.C();
dynamicList<scalar> listOfCells

forAll(patches,patchi)
{
  const fvPatch& currPatch = patches[patchi];
  label nFaces = mesh.boundaryMesh()[patchi].size();
  if(isType<wallFvPatch>(currPatch))
  {
    for(int facei = 0; facei<nFaces; facei++)
        {
        scalar distance;
        distance = Foam::sqrt(sqr(C[cellI].x()-Cf.boundaryField()[patchi][facei].x()) +  sqr(C[cellI].y()-Cf.boundaryField()[patchi][facei].y())+ sqr(C[cellI].z()-   Cf.boundaryField()[patchi][facei].z()));
         scalar yTemp = y[cellI];
         scalar diff = mag(distance - yTemp);
                    if( diff <= tol)

                    {
                     listOfCells.append(cellI)

                      //Here you can add cellI on a list, and you have all cells normal to facei in

                    }
         }
   }
}
In my case I search walls but you can adapt it I think to do what you want.

Note that I use foamExtend 4.1 and some function can be different.
Sorry for my bad english


Jérémy
wht likes this.
JeremyChvlr 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
[mesh manipulation] Importing Multiple Meshes thomasnwalshiii OpenFOAM Meshing & Mesh Conversion 18 December 19, 2015 19:57
[Netgen] Import netgen mesh to OpenFOAM hsieh OpenFOAM Meshing & Mesh Conversion 32 September 13, 2011 06:50
[blockMesh] BlockMeshmergePatchPairs hjasak OpenFOAM Meshing & Mesh Conversion 11 August 15, 2008 08:36
[blockMesh] Axisymmetrical mesh Rasmus Gjesing (Gjesing) OpenFOAM Meshing & Mesh Conversion 10 April 2, 2007 15:00
[Commercial meshers] Trimmed cell and embedded refinement mesh conversion issues michele OpenFOAM Meshing & Mesh Conversion 2 July 15, 2005 05:15


All times are GMT -4. The time now is 17:56.