CFD Online Logo CFD Online URL
Home > Forums > OpenFOAM Post-Processing

isoSurface normal

Register Blogs Members List Search Today's Posts Mark Forums Read

LinkBack Thread Tools Display Modes
Old   October 8, 2015, 10:56
Default isoSurface normal
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 303
Rep Power: 9
Andrea_85 is on a distinguished road
Hi All,

i am facing some problems using sampleIsoSurface to extract the iso surface of alpha1 (interFoam) during the run. The case is 2D and i am simulating a simple drop relaxation. I correctly defined the surface which is triangulated and i extracted the centre and the normal of each triangle. There are two problems: first the normals are not pointing in the same direction (all inward, all outward with respect to the iso surface) but they seem to have random direction. Second i do not understand why, even if the case is 2D (x-y plane), there are some normals with non-zero z component.
Does sampleIsoSurface work for 2D?

If i do 3D, the problem on the random normal direction remains...

Any clue?

Andrea_85 is offline   Reply With Quote

Old   October 8, 2015, 17:46
Senior Member
Join Date: Aug 2014
Posts: 198
Rep Power: 4
ssss is on a distinguished road
Try filling a bug report in the MANTIS OpenFOAM platform, maybe there is a bug in the code
ssss is offline   Reply With Quote

Old   October 9, 2015, 09:53
Senior Member
Andrea Ferrari
Join Date: Dec 2010
Posts: 303
Rep Power: 9
Andrea_85 is on a distinguished road
I am not sure it is really a bug or (more likely) i am simply doing something wrong. So here are the steps i used to create the surface.

1) i created a dictionary name "alpha05Dict" and put it in /constant

version 2.0;
format ascii;
class dictionary;
location "constant";
object sampleDict;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

isoField alpha1;
isoValue 0.5;
interpolate true;
//zone ABC; // Optional: zone only
//exposedPatchName fixedWalls; // Optional: zone only
//regularise false; // Optional: do not simplify
Then in createField.H i read the dictionary with

 IOdictionary alpha05Dict
I created the surface by calling the appropiate function and then used the method update()

 sampledIsoSurface alpha05("alpha05",mesh,alpha05Dict);
tmp<vectorField>  alpha05point = alpha05.points();    //points on the surface
faceList surfaceFace = alpha05.faces();      //faces on the surface
Then to calculate normals and centers i loop over the faces

  pointField pp(alpha05point );

 vectorField areavec(surfaceFace.size(),vector(0,0,0));
 vectorField centre(surfaceFace.size(),vector(0,0,0));
 vectorField areavec1(surfaceFace.size(),vector(0,0,0));
 vectorField centre1(surfaceFace.size(),vector(0,0,0));

      const face& ll = surfaceFace[facei];  //list of  point label of facei
      const pointField& pll = ll.points(alpha05point);

        areavec[facei] = 0.5*(pp[ll[0]] ^ pp[ll[1]]) + 0.5*(pp[ll[1]] ^ pp[ll[2]]) + 0.5*(pp[ll[2]] ^  pp[ll[0]]);
        centre[facei] = (1.0/3.0) * (pp[ll[0]] + pp[ll[1]] + pp[ll[2]]);

          areavec1[facei] = ll.normal(pll);
          centre1[facei] = ll.centre(pll);

I calculated centers and vector area using standard formula for a triangle (centre, areavec) and using the in-bluid functions of the class face (centre1, areavec1). The should return the same values...
Then i pun some "Info" to print the calculated centers and normals.

Points3((0.028 0.0290354 0.0001) (0.028 0.0290354 3.53975e-06) (0.0280251 0.0290251 9.74915e-05)) //points on a particular face

areavec1(0 0 0)

areavec(-4.97389e-10 -1.20984e-09 0)

Centre1 (0 0 0)

Centre (0.0280084 0.029032 6.70104e-05)
This is just an example, but what i got is something like this for every face. .normal() and .centre() always return zero and i don't know why.
If i plot the vector area obtained with the explicit formula i have the problem mentioned in my previous post: the direction of the vectors seems more or less random (sometime inward, sometime outward) and there are vectors with non-zero z component (case is 2D). I noticed that in isoSurface.H is reported
"- does not do 2D correctly, creates non-flat iso surface.",
which probably explains why i get strange orientation with 2D. Despite this if I sum up the face area vector magnitude i get the total interfacial area with an error less than 0.002% for a fine mesh, so the triangulated isosurface seems to well represent the 0.5 contourn of the VOF function.
I simulated the same case 3D but i still have problem with the orientation of the vectors.

Any help will be really appreaciated.
Andrea_85 is offline   Reply With Quote


Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Wedge patch '*' is not planar LilumDaru OpenFOAM Meshing & Mesh Conversion 4 May 21, 2016 07:50
determining displacement for added points CFDnewbie147 OpenFOAM Native Meshers: snappyHexMesh and Others 1 October 22, 2013 09:53
my stl surface is seen as just a line rcastilla OpenFOAM Meshing & Mesh Conversion 2 January 6, 2010 02:30
NACA0012 geometry/design software needed Franny Main CFD Forum 13 July 7, 2007 15:57

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