question about mesh.sf[faceI]mesh.sf[faceI]
Hi FOAMers,
I need to loop over all faces of a cell and collect fluxes. I have a 2D case so i set the boundaries with face normal in y-direction to empty. I use the following code: PHP Code:
PHP Code:
Why are all vector components negative (it stays like that for the whole grid)? Why are there no vectors with a y-Component? Is this because of the pseudo 2D grid? I get the same output with a zeroGradient boundary condition for the third dimension. I don't want to sum over the boundaries which are set to empty. I guess I could also use this as a condition but I still would like to know why mesh.Sf() behaves so wired. I have looked for some time now but could not find an answer... Thanks for any help and suggestions!!! Cheers friederike |
Hi Friederike,
I know it is an old thread, but actually i am stuck on the same issues, so I am interested to know if you have already found the answers to your questions Thank you |
Hi Friederike,
Are you still stuck with this problem? I found at least two problems with the above code: First of all, The index of Quote:
Secondly, you cannot get the surface area vector for boundary faces as Sf() only contains area vectors for internal faces. As for why all the vector components stay negative, it is because of the mesh (all the surface normal directions are positive). For example, face 0 seems to be negative for cell 1 in x direction, but because of the owner and neighbor rule, it's always pointing from cell 0 (owner) to cell 1 (neighbor) such that it's still (-1, 0, 0). As for why y-component is always 0, the reason is that you will not be able to get the surface vector based on Sf() even if you correct the index as suggested above. You have to access the boundary faces through the fvBoundaryMesh variable boundary_. I hope it can help you. |
Hi,
For the first question. I think the negative value of vector components is due to the presence of the "-" character in the code just near the mesh.Sf()[faceI] Best regards |
Hi stater,
You are right. As I mentioned above, all the surface normal directions are positive. After putting am "-" sign in front, all becomes negative. In addition to this, what I was trying to say above is that some surfaces "seem" to have negative direction, but because of the owner-neighbour convention, they are still positive. |
How to get area vector for boundary faces.
As mentioned in the first question in this thread, If a particular face is an internal face then only mesh.Sf() works. |
Quote:
Code:
const fvBoundaryMesh& boundary = mesh.boundary(); Code:
const volVectorField::GeometricBoundaryField& boundaryField = mesh().Sf().boundaryField(); |
Hi Sergie,
Thanks for your reply. I tried the following code forAll( cellIfaces, i ) // loop over all faces in the cellIndex { if(mesh.isInternalFace(cellIfaces[i])) // If face is internalFace { vector faceNormal = mesh.Sf()[cellIfaces[i]] / mesh.magSf()[cellIfaces[i]]; } else // If face is boundaryFace { label patchID = mesh.boundaryMesh().whichPatch(cellIfaces[i]); label faceID = mesh.boundaryMesh()[patchID].whichFace(cellIfaces[i]); vector faceNormal = mesh.Sf().boundaryField()[patchID][faceID] / mesh.magSf().boundaryField()[patchID][faceID]; } } This compiles successfully, but during case run, it shows an error because one of the patches was defined as empty patch type. I am getting the following error: --> FOAM FATAL ERROR: attempt to access element from zero sized list Can you please suggest some way resolve or get around with this type of error. |
All times are GMT -4. The time now is 19:30. |