# How to get access to normalVectors of specified faces in patch

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

 April 27, 2012, 19:59 How to get access to normalVectors of specified faces in patch #1 New Member   Tilo Join Date: Mar 2011 Posts: 1 Rep Power: 0 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 pointsSTLlocal(surface.localPoints());//triSurface.localPoints(): return pointField of points in patch Foam::List faceList(surface.localFaces());//triSurface.localFaces(): return patch faces addressing into local point list // Field 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 liste(number); forAll(liste, iterator) { liste[iterator] = pointsSTLlocal[faceList[i][iterator]]; } Field trianglePoints(liste); Info << "Field trianglePoints.size(): " << trianglePoints.size() << endl; /* --> another try, but doesn't work too: Field 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 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 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::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::Ostream&, Foam::errorManip) 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 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.

 Tags access, face, normal vector, trisurface

 Thread Tools Display Modes Linear Mode

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

 Similar Threads Thread Thread Starter Forum Replies Last Post bobburnquist OpenFOAM Native Meshers: snappyHexMesh and Others 6 August 26, 2015 09:38 sc298 OpenFOAM Native Meshers: snappyHexMesh and Others 2 March 27, 2011 21:11 chelvistero OpenFOAM 11 January 15, 2010 20:43 adorean Open Source Meshers: Gmsh, Netgen, CGNS, ... 24 April 27, 2005 08:19 Andrea CFX 2 October 11, 2004 05:12

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