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

[Other] Getting the cells next to a patch

Register Blogs Community New Posts Updated Threads Search

Like Tree15Likes
  • 1 Post By arkangel
  • 10 Post By hjasak
  • 3 Post By nygbook
  • 1 Post By nygbook

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2010, 09:05
Default Getting the cells next to a patch
  #1
Member
 
O R
Join Date: Mar 2009
Posts: 50
Rep Power: 17
arkangel is on a distinguished road
Dear Foamers,

I want to get the indexes of the cells right next to a patch. In other words, I want to access the owner index of a face that conforms a patch

something like this

Code:
foreach (patchList , patchI){
    foreach (patchList[patchI].faces(), facesI){
        mesh.C[patchList[patchI].faces[facesI].owner] =val;

   }
 }
or maybe you have a better idea of how can I do it

thanks !!
mm.abdollahzadeh likes this.

Last edited by arkangel; December 8, 2010 at 09:20.
arkangel is offline   Reply With Quote

Old   December 20, 2010, 12:43
Default
  #2
Senior Member
 
Hrvoje Jasak
Join Date: Mar 2009
Location: London, England
Posts: 1,905
Rep Power: 33
hjasak will become famous soon enough
Do patch.faceCells()

That will give you cell indices for cells next to patch faces.

Enjoy,

Hrv
__________________
Hrvoje Jasak
Providing commercial FOAM/OpenFOAM and CFD Consulting: http://wikki.co.uk
hjasak is offline   Reply With Quote

Old   January 25, 2011, 11:33
Default
  #3
Member
 
O R
Join Date: Mar 2009
Posts: 50
Rep Power: 17
arkangel is on a distinguished road
Thanks a lot Hrv!

Now I want to access the face values of a boundary patch in a specific scalarField/vectorField using these indexes.

I mean, let says that
forAll ( patch.faceCells(),cellI) gives me indexes cellI=1 2 ....

then cell[1] has a face on this patch whose b value is -1.0, where b is an scalar field
I want to recover this -1.0.

I hope I was clear enough

Regards
arkangel is offline   Reply With Quote

Old   April 13, 2011, 21:21
Default
  #4
New Member
 
NieYongguang
Join Date: Sep 2010
Posts: 27
Rep Power: 15
nygbook is on a distinguished road
I suggest you read the code in wallViscosity
HTML Code:
  const fvPatchList& patches = mesh.boundary();
    forAll(patches, patchi)
    {
        const fvPatch& currPatch = patches[patchi];
        if (isType<wallFvPatch>(currPatch))
        {
            scalarField& nutw = nutb.boundaryField()[patchi];
            forAll(currPatch, facei)
            {
                label faceCelli = currPatch.faceCells()[facei];
                // calculate yPlus
                scalar yPlus =
                    Cmu25*y[patchi][facei]
                   *::sqrt(k[faceCelli])
                   /nub_;
                if (yPlus > 11.6)
                {
                    nutw[facei] =
                        yPlus*nub_*kappa_
                       /::log(E_*yPlus)
                      - nub_;
                }
                else
                {
                    nutw[facei] = 0.0;
                }
            }
        }
    }
}
where k[faceCelli] is the turbulent kinetic in cell close to wall. However, I have another question. What is y[patchi][facei] and nutw[facei]? According to wall function theory, y[patchi][facei] and nutw[facei] should be distance between center of cell and wall and viscosity in cell close to wall. why cann't write nutw[faceCelli]
sushant, mm.abdollahzadeh and tiam like this.
nygbook is offline   Reply With Quote

Old   April 13, 2011, 21:34
Default
  #5
New Member
 
NieYongguang
Join Date: Sep 2010
Posts: 27
Rep Power: 15
nygbook is on a distinguished road
another question
what different is betweent U.boundaryField( )[patchi].patchInternalField( ) and U[faceCelli]
mm.abdollahzadeh likes this.
nygbook is offline   Reply With Quote

Old   April 23, 2012, 08:10
Default
  #6
New Member
 
Darío López
Join Date: Oct 2011
Location: Vigo, Spain
Posts: 10
Rep Power: 14
darlopez is on a distinguished road
Hi everybody.

I try to program the Simpson's rule in order to obtain the pressure force on a patch. To do it I should obtain the value of the pressure in all cells next to the patch. I have programed:



forAll(forcePatches, patchi)
{
const fvPatch& curPatch = forcePatches[patchi];
label forcePatchID = mesh.boundaryMesh().findPatchID(forcePatches[patchi]);

if (isType<wallFvPatch>(forcePatches[patchi]))
{
scalarField& pp = p.boundaryField()[patchi];

forAll(forcePatches[patchi], facei)
{
label faceCelli = curPatch.faceCells()[facei];
P[faceCelli]=pp[faceCelli]; // I save the values of pressure in vector P
}
}

// Now, Simpson's rule:
int i = 1;
for(int i = 1; i <= 374; i++) // I have 750 cells on each patch
{
A = A + 2 * P[2*i]*0.02*0.02; // where 0.02*0.02 is the area of the face of each cell
}
int j = 2;
for(int j = 2; j <= 375; j++)
{
B = B + 4 * P[2*j-1]*0.02*0.02;
}
a0 = P[1];
an = P[750];

scalar PressForce = 0.02/3*(a0 + A + B + an);

vector patchPressForce = PressForce * gSum(mesh.Sf().boundaryField()[forcePatchID])/gSum(mesh.magSf().boundaryField()[forcePatchID]);

// Multiply the resulting force by density to account for normalisation in
// incompressible solvers, and get component in direction of motion
scalar totPatchPressForce = (patchPressForce
* mediumRho.value()
) & aVector;

Info << "Area of patch " << forcePatches[patchi] << " [m^2] = "
<< gSum(mesh.magSf().boundaryField()[forcePatchID]) << endl;

Info << "Pressure force on patch " << forcePatches[patchi] << " [N] = " << totPatchPressForce << endl;

totPressureForce += totPatchPressForce;
}

Info << "Total Pressure Force along motion vector [N] = " << totPressureForce << endl;
}


But this loop does not work. Any ideas?? Where is the problem??

Thanks a lot.

Darío
darlopez 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
cellZone not taking all the cells inside rahulksoni OpenFOAM Running, Solving & CFD 6 January 25, 2019 00:11
[snappyHexMesh] SHM Layer Addition Phase dickcruz OpenFOAM Meshing & Mesh Conversion 4 November 1, 2018 07:05
[snappyHexMesh] sHM layer process keeps getting killed MBttR OpenFOAM Meshing & Mesh Conversion 4 August 15, 2016 03:21
Problem with cyclic boundaries in Openfoam 1.5 fs82 OpenFOAM 36 January 7, 2015 00:31
Cyclic Boundary Condition Luiz Eduardo Bittencourt Sampaio (Sampaio) OpenFOAM Running, Solving & CFD 36 July 2, 2012 12:23


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