CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

How to get access to normalVectors of specified faces in patch

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 27, 2012, 20:59
Default How to get access to normalVectors of specified faces in patch
  #1
New Member
 
Tilo
Join Date: Mar 2011
Posts: 1
Rep Power: 0
tilo is on a distinguished road
Hi at all,

my aim is to calculate the averaged normal vector of specified regions of my surface.

Therefore I tried the following:

/************************************************** ************************************************** *****/

const fileName inputSTL = "plate3x3x0.6x0.6.stl"; // a plate is only a simple example, afterwards there will be curved surfaces

triSurface surface(inputSTL);

Field<point> pointsSTLlocal(surface.localPoints());//triSurface.localPoints(): return pointField of points in patch

Foam::List<Foam::labelledTri> faceList(surface.localFaces());//triSurface.localFaces(): return patch faces addressing into local point list

// Field<point> allNormalVectors(oberflaeche.faceNormals()); //triSurface.faceNormals(): return face normals for patch
/*
--> I had a try with the above line too, but I only could output every normalvektor of the whole patch, not for specified faces.
*/

forAll(faceList, i)
{
Info << "faceList[i][0]: " << faceList[i][0] << endl;
Info << "faceList[i][1]: " << faceList[i][1] << endl;
Info << "faceList[i][2]: " << faceList[i][2] << endl;

triFace triangle(faceList[i][0], faceList[i][1], faceList[i][2]);
Info << "triangle: " << triangle << endl;

Info << "pointsSTLlocal[faceList[i][0]]: " << pointsSTLlocal[faceList[i][0]] << endl;
Info << "pointsSTLlocal[faceList[i][1]]: " << pointsSTLlocal[faceList[i][1]] << endl;
Info << "pointsSTLlocal[faceList[i][2]]: " << pointsSTLlocal[faceList[i][2]] << endl;

label number = 3;
List<point> liste(number);
forAll(liste, iterator)
{
liste[iterator] = pointsSTLlocal[faceList[i][iterator]];
}

Field<point> trianglePoints(liste);

Info << "Field<point> trianglePoints.size(): " << trianglePoints.size() << endl;

/* --> another try, but doesn't work too:

Field<point> trianglePoints();
trianglePoints[0] = pointsSTLlocal[faceList[i][0]];
trianglePoints[1] = pointsSTLlocal[faceList[i][1]];
trianglePoints[2] = pointsSTLlocal[faceList[i][2]];
*/
forAll(trianglePoints, j)
{
Info << "trianglePoints[j]: " << trianglePoints[j] << endl;
}

Foam::vector normalVector = vector::zero;
// Info << "normalVector::zero: " << normalVector << endl;

// I think here should be the problem, maybe something with the pointField must be wrong:

normalVector = triangle.normal(trianglePoints);

Info << "normalVector: " << normalVector << endl;

/************************************************** ************************************************** *****/

After running the code I get the following error message:

/************************************************** ************************************************** *****/

tilo@ubuntu:~/OpenFOAM/tilo-2.1.0/run/testSkript$ wclean
tilo@ubuntu:~/OpenFOAM/tilo-2.1.0/run/testSkript$ wmake
Making dependency list for source file testSkript.C
SOURCE=testSkript.C ; g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -

I/opt/openfoam210/src/surfMesh/lnInclude -I/opt/openfoam210/src/meshTools/lnInclude -I/opt/openfoam210/src/triSurface/lnInclude -DFULLDEBUG -g -O0 -IlnInclude -I. -

I/opt/openfoam210/src/OpenFOAM/lnInclude -I/opt/openfoam210/src/OSspecific/POSIX/lnInclude -fPIC -c $SOURCE -o Make/linuxGccDPOpt/testSkript.o
g++ -m32 -Dlinux -DWM_DP -Wall -Wextra -Wno-unused-parameter -Wold-style-cast -O3 -DNoRepository -ftemplate-depth-100 -I/opt/openfoam210/src/surfMesh/lnInclude -

I/opt/openfoam210/src/meshTools/lnInclude -I/opt/openfoam210/src/triSurface/lnInclude -DFULLDEBUG -g -O0 -IlnInclude -I. -I/opt/openfoam210/src/OpenFOAM/lnInclude -

I/opt/openfoam210/src/OSspecific/POSIX/lnInclude -fPIC -Xlinker --add-needed -Xlinker --no-as-needed Make/linuxGccDPOpt/testSkript.o -

L/opt/openfoam210/platforms/linuxGccDPOpt/lib \
-lsurfMesh -ltriSurface -lmeshTools -lOpenFOAM -ldl -lm -o /home/tilo/OpenFOAM/tilo-2.1.0/platforms/linuxGccDPOpt/bin/testDelle
tilo@ubuntu:~/OpenFOAM/tilo-2.1.0/run/testSkript$ testDelle
faceList[i][0]: 0
faceList[i][1]: 1
faceList[i][2]: 2
triangle: (0 1 2)
pointsSTLlocal[faceList[i][0]]: (0 0 0)
pointsSTLlocal[faceList[i][1]]: (0.6 0 0)
pointsSTLlocal[faceList[i][2]]: (0.6 0.6 0)
Field<point> trianglePoints.size(): 3
trianglePoints[j]: (0 0 0)
trianglePoints[j]: (0.6 0 0)
trianglePoints[j]: (0.6 0.6 0)
normalVector: (0 0 0.18)

1faceList[i][0]: 0
faceList[i][1]: 3
faceList[i][2]: 2
triangle: (0 3 2)
pointsSTLlocal[faceList[i][0]]: (0 0 0)
pointsSTLlocal[faceList[i][1]]: (0 0.6 0)
pointsSTLlocal[faceList[i][2]]: (0.6 0.6 0)
Field<point> trianglePoints.size(): 3
trianglePoints[j]: (0 0 0)
trianglePoints[j]: (0 0.6 0)
trianglePoints[j]: (0.6 0.6 0)


--> FOAM FATAL ERROR:
index 3 out of range 0 ... 2

From function UList<T>::checkIndex(const label)
in file /opt/openfoam210/src/OpenFOAM/lnInclude/UListI.H at line 109.

FOAM aborting

#0 Foam::error:rintStack(Foam::Ostream&) in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#1 Foam::error::abort() in "/opt/openfoam210/platforms/linuxGccDPOpt/lib/libOpenFOAM.so"
#2 Foam::Ostream& Foam:perator<< <Foam::error>(Foam::Ostream&, Foam::errorManip<Foam::error>) at /opt/openfoam210/src/OpenFOAM/lnInclude/errorManip.H:85
#3
at /opt/openfoam210/src/OpenFOAM/lnInclude/UListI.H:113
#4
at /opt/openfoam210/src/OpenFOAM/lnInclude/UListI.H:200
#5
at /opt/openfoam210/src/OpenFOAM/lnInclude/triFaceI.H:187
#6
at testSkript.C:105
#7 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#8
in "/home/tilo/OpenFOAM/tilo-2.1.0/platforms/linuxGccDPOpt/bin/testDelle"
Abgebrochen
tilo@ubuntu:~/OpenFOAM/tilo-2.1.0/run/testSkript$

/************************************************** ************************************************** *****/

As seen in the error message, the program starts in the right way (I hope so), but then an index-error appears. I thought that the "List<point> liste(number);" has
the wrong size, but I think it couldn't be, because it is build new in every iteration.

Maybe somebody can help me, or tell me how to get access to normal vectors of specified faces. Thanks in advance.
tilo is offline   Reply With Quote

Reply

Tags
access, face, normal vector, trisurface


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
[snappyHexMesh] snappyHexMesh won't work - zeros everywhere! sc298 OpenFOAM Meshing & Mesh Conversion 2 March 27, 2011 22:11
[snappyHexMesh] external flow with snappyHexMesh chelvistero OpenFOAM Meshing & Mesh Conversion 11 January 15, 2010 20:43
[Gmsh] Import gmsh msh to Foam adorean OpenFOAM Meshing & Mesh Conversion 24 April 27, 2005 09:19
Multicomponent fluid Andrea CFX 2 October 11, 2004 06:12


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