# [Gmsh] outward normal of surface triangles

Ashish Garg ashish.garg.iisc at gmail.com
Thu May 3 10:28:38 CEST 2012

```Hello Ashish,

See you know all tetrahedra at the boundary surfaces. It means  u know all
the vertex of the tetrahedra ( out of four vertex three r makin boundary
faces right ) .

try this

v0 = face[i].vertex[0];
v1 = face[i].vertex[1];
v2 = face[i].vertex[2];

r01 = vertex[v1] - vertex[v0];
r12 = vertex[v2] - vertex[v1];

face[i].normal = (r01 X r12);

// Check orientation of normal
fourth_vertex        =  face[i].vertex[3]
check_normal_orientation = face[i].normal * ( fourth_vertex-
vertex[v0]);

if ( check_normal_orientation > 0.0 )
face[i].normal *=  -1.0 ;

this will resolve your problem for sure.

regards

Ashish  Garg
TIFR-CAM, Bangalore

On Thu, May 3, 2012 at 1:22 PM, Mark Starnes <mark.starnes at fttech.co.uk>wrote:

> Hi Ashish,
>
> Does it help if you change the sign of every line entry number
> in the Plane Surface definition that is a problem?
>
> Best regards,
>
> Mark.
>
> On Thu, May 03, 2012 at 06:23:34AM +0000, Negi, Ashish wrote:
> > Hi Ashish,
> >
> >
> >
> >
> >
> >
> > Let me explain my problem again. I have attached 3 pictures below.
> First, shows
> > a Tetrahedral mesh of square duct. So, all surface elements are Triangle.
> > Second, shows normal vectors computed using cross product if Triangle
> vertices
> > are saved in clockwise sense (in the picture). Third, shows normal vector
> > computed if Triangle vertices are saved in anti-clockwise sense. So,
> second
> > picture gives me outward normal which I need.
> >
> >
> >
> > I found that all Triangles do not give me outward normals if I assume
> clockwise
> > sense (in following picture). So, I wanted to know if GMSH has some
> other way
> > to provide me outward normal for each surface Triangle.
> >
> > [cid]   [cid]
> >
> >
> >
> > Thanks,
> >
> > Ashish
> >
> >
> >
> > From: Ashish Garg [mailto:ashish.garg.iisc at gmail.com]
> > Sent: Wednesday, May 02, 2012 1:09 PM
> > To: Negi, Ashish
> > Cc: gmsh at geuz.org
> > Subject: Re: [Gmsh] outward normal of surface triangles
> >
> >
> >
> > Hi Ashish
> >
> > give the condition that the cross product should be greater than zero. I
> guess
> > it will resolve the problem.
> >
> > Ashish Garg
> >
> > On Wed, May 2, 2012 at 12:38 PM, Negi, Ashish <ashish.negi at honeywell.com
> >
> > wrote:
> >
> > Hello Everyone,
> >
> >
> >
> > I?ve been using GMSH library to open Nastran BDF file and extract mesh
> data for
> > my software. I generally load a mesh consisting of only Tetrahedra.
> Hence,
> > surface of model have only Triangle elements.
> >
> >
> >
> > I want to find outward normal at each Triangle. I get coordinates of each
> > Triangle and then take cross product to get normal to the element. But,
> I?m not
> > sure if it will always be outward. Can someone suggest a solution to this
> > problem?
> >
> >
> >
> > Thanks,
> >
> > Ashish
> >
> >
> >
> >
> >
> >
> > _______________________________________________
> > gmsh mailing list
> > gmsh at geuz.org
> > http://www.geuz.org/mailman/listinfo/gmsh
> >
> >
> >
>
>
>
>
> > _______________________________________________
> > gmsh mailing list
> > gmsh at geuz.org
> > http://www.geuz.org/mailman/listinfo/gmsh
>
>
> --
> Dr. Mark Starnes
> Principal Physicist
> FT Technologies
> Church Lane
> Teddington
> TW11 8PA
>
> web:  www.fttech.co.uk
> DDI:  0208 614 2730
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.geuz.org/pipermail/gmsh/attachments/20120503/f06b4c7a/attachment.htm>
```