Getting the cells next to a patch
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){ thanks !! |
Do patch.faceCells()
That will give you cell indices for cells next to patch faces. Enjoy, Hrv |
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 |
I suggest you read the code in wallViscosity
HTML Code:
const fvPatchList& patches = mesh.boundary(); |
:)another question
what different is betweent U.boundaryField( )[patchi].patchInternalField( ) and U[faceCelli] |
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 |
All times are GMT -4. The time now is 22:06. |