CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Ray intersecting BoundaryMesh (https://www.cfd-online.com/Forums/openfoam-programming-development/164874-ray-intersecting-boundarymesh.html)

David* January 4, 2016 10:30

Ray intersecting BoundaryMesh
 
Hi,

I try to compute the intersection point of a given line (2 points) and the polyBoundaryMesh of my OF case.

Following this thread (http://www.cfd-online.com/Forums/ope...-openfoam.html), I'm using an object of type Foam::indexedOctree<treeDataTriSurface>. I construct the required triSurface from the STLs used to generate the mesh.

Unfortunately, the STLs are not exactly identical to the BoundaryMesh, causing errors. Therefore, I tried to construct a Foam::indexedOctree<treeDataPrimitivePatch> from the BoundaryMesh patches to use as a basis, but failed. It should look something like this:
Code:

Foam::indexedOctree<treeDataPrimitivePatch>& octree1(???);
Foam::pointIndexHit pHit = octree1.findLine(insideP, outsideP);

Can you tell me how to create my object "octree1"? Or any alternative way of computing the intersection?

Thanks a lot!
David

David* February 16, 2016 04:50

sorry for reply, the edit button is gone...
I fixed it :cool: using
Code:

#include "volFields.H"          // Diverse fields called by fvCFD.H
#include "fvCFD.H"              // OpenFOAM Finite Volume tools
#include "treeDataFace.H"      // Search faces

using namespace Foam;

...

    Foam::point outsideP(xEnd, yEnd, zEnd);
    Foam::point insideP(xStart, yStart, zStart);
    const Foam::fvPatchList& patches = mesh.boundary();

    forAll(patches, patchI)
    {
        const polyPatch& polyPatch1 = patches[patchI].patch();

        treeBoundBox allBoundingBox(polyPatch1.points());

        const indexedOctree<treeDataFace> octree1
        (
            treeDataFace(false, polyPatch1),
            allBoundingBox, // overall search domain
            8,      // maxLevel
            10,    // leafsize
            3.0    // duplicity
        );

        pointIndexHit pHit = octree1.findLine(insideP, outsideP);

    ...
    }

Cheers,
David


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