|
[Sponsors] |
March 12, 2015, 07:59 |
question about mesh.sf[faceI]mesh.sf[faceI]
|
#1 |
New Member
Join Date: Nov 2010
Posts: 10
Rep Power: 15 |
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 |
|
July 23, 2016, 14:47 |
|
#2 |
New Member
H. Omar
Join Date: Mar 2013
Posts: 23
Rep Power: 13 |
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 |
|
July 25, 2016, 09:38 |
|
#3 | |
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12 |
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. |
||
July 27, 2016, 13:00 |
|
#4 |
New Member
H. Omar
Join Date: Mar 2013
Posts: 23
Rep Power: 13 |
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 |
|
July 27, 2016, 14:40 |
|
#5 |
Member
Jerry
Join Date: Oct 2013
Location: Salt Lake City, UT, USA
Posts: 52
Rep Power: 12 |
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. |
|
May 14, 2017, 01:05 |
|
#6 |
Member
Ashish Kumar
Join Date: Jun 2015
Posts: 33
Rep Power: 10 |
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. |
|
May 14, 2017, 11:23 |
|
#7 |
Senior Member
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21 |
Code:
const fvBoundaryMesh& boundary = mesh.boundary(); forAll(boundary, i) { const fvPatch& patch = boundary[i]; const vectorField& patchSf = patch.Sf(); } Code:
const volVectorField::GeometricBoundaryField& boundaryField = mesh().Sf().boundaryField(); forAll(boundaryField, i) { const fvPatchVectorField& patchField = boundaryField[i]; const vectorField& patchSf = patchField.internalField(); } |
|
May 15, 2017, 00:17 |
|
#8 |
Member
Ashish Kumar
Join Date: Jun 2015
Posts: 33
Rep Power: 10 |
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. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
small question about the functionalities of topological changes in OpenFoam | ngj | OpenFOAM Running, Solving & CFD | 2 | February 28, 2013 10:02 |
Question Re Engineering Data Source | imnull | ANSYS | 0 | March 5, 2012 13:51 |
internal field question - PitzDaily Case | atareen64 | OpenFOAM Running, Solving & CFD | 2 | January 26, 2011 15:26 |
question on bounday layer modeling | Wen Long | Main CFD Forum | 2 | November 12, 2005 17:29 |
Poisson Solver question | Suresh | Main CFD Forum | 3 | August 12, 2005 04:37 |