Skip to content
Snippets Groups Projects
Commit b7bb04e8 authored by Mattijs Janssens's avatar Mattijs Janssens
Browse files

trisurfaceMeshes superceded by searchableSurfaces

parent e3ee5fcf
Branches
Tags
No related merge requests found
......@@ -62,7 +62,6 @@ surfaceSlipDisplacementPointPatchVectorField
)
:
pointPatchVectorField(p, iF),
surfaceNames_(),
projectMode_(NEAREST),
projectDir_(vector::zero),
wedgePlane_(-1)
......@@ -78,7 +77,7 @@ surfaceSlipDisplacementPointPatchVectorField
)
:
pointPatchVectorField(p, iF, dict),
surfaceNames_(dict.lookup("projectSurfaces")),
surfacesDict_(dict.subDict("geometry")),
projectMode_(followModeNames_.read(dict.lookup("followMode"))),
projectDir_(dict.lookup("projectDirection")),
wedgePlane_(readLabel(dict.lookup("wedgePlane"))),
......@@ -96,7 +95,7 @@ surfaceSlipDisplacementPointPatchVectorField
)
:
pointPatchVectorField(p, iF),
surfaceNames_(ppf.surfaceNames()),
surfacesDict_(ppf.surfacesDict()),
projectMode_(ppf.projectMode()),
projectDir_(ppf.projectDir()),
wedgePlane_(ppf.wedgePlane()),
......@@ -111,7 +110,7 @@ surfaceSlipDisplacementPointPatchVectorField
)
:
pointPatchVectorField(ppf),
surfaceNames_(ppf.surfaceNames()),
surfacesDict_(ppf.surfacesDict()),
projectMode_(ppf.projectMode()),
projectDir_(ppf.projectDir()),
wedgePlane_(ppf.wedgePlane()),
......@@ -127,7 +126,7 @@ surfaceSlipDisplacementPointPatchVectorField
)
:
pointPatchVectorField(ppf, iF),
surfaceNames_(ppf.surfaceNames()),
surfacesDict_(ppf.surfacesDict()),
projectMode_(ppf.projectMode()),
projectDir_(ppf.projectDir()),
wedgePlane_(ppf.wedgePlane()),
......@@ -137,14 +136,14 @@ surfaceSlipDisplacementPointPatchVectorField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const triSurfaceMeshes& surfaceSlipDisplacementPointPatchVectorField::
const searchableSurfaces& surfaceSlipDisplacementPointPatchVectorField::
surfaces() const
{
if (!surfacesPtr_.valid())
{
surfacesPtr_.reset
(
new triSurfaceMeshes
new searchableSurfaces
(
IOobject
(
......@@ -155,7 +154,7 @@ surfaces() const
IOobject::MUST_READ,
IOobject::NO_WRITE
),
surfaceNames_
surfacesDict_
)
);
}
......@@ -215,128 +214,180 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
);
const pointField& points0 = motionSolver.points0();
forAll(localPoints, i)
//XXXXXX
pointField start(meshPoints.size());
forAll(start, i)
{
start[i] = points0[meshPoints[i]] + displacement[i];
}
if (projectMode_ == NEAREST)
{
List<pointIndexHit> nearest;
labelList hitSurfaces;
surfaces().findNearest
(
start,
scalarField(start.size(), sqr(projectLen)),
hitSurfaces,
nearest
);
forAll(nearest, i)
{
if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
{
// Fixed point. Reset to point0 location.
displacement[i] = points0[meshPoints[i]] - localPoints[i];
}
else if (nearest[i].hit())
{
displacement[i] =
nearest[i].hitPoint()
- points0[meshPoints[i]];
}
else
{
Pout<< " point:" << meshPoints[i]
<< " coord:" << localPoints[i]
<< " did not find any surface within " << projectLen
<< endl;
}
}
}
else
{
if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
// Do tests on all points. Combine later on.
// 1. Check if already on surface
List<pointIndexHit> nearest;
{
// Fixed point. Reset to point0 location.
labelList nearestSurface;
surfaces().findNearest
(
start,
scalarField(start.size(), sqr(SMALL)),
nearestSurface,
nearest
);
}
//Pout<< " Fixed point:" << meshPoints[i]
// << " coord:" << localPoints[i]
// << " should be at:" << points0[meshPoints[i]]
// << endl;
displacement[i] = points0[meshPoints[i]] - localPoints[i];
// 2. intersection. (combined later on with information from nearest
// above)
vectorField projectVecs(start.size(), projectVec);
if (projectMode_ == POINTNORMAL)
{
projectVecs = projectLen*patch().pointNormals();
}
else
// Knock out any wedge component
scalarField offset(start.size(), 0.0);
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
{
point start(points0[meshPoints[i]] + displacement[i]);
forAll(offset, i)
{
offset[i] = start[i][wedgePlane_];
start[i][wedgePlane_] = 0;
projectVecs[i][wedgePlane_] = 0;
}
}
scalar offset = 0;
pointIndexHit intersection;
List<pointIndexHit> rightHit;
{
labelList rightSurf;
surfaces().findAnyIntersection
(
start,
start+projectVecs,
rightSurf,
rightHit
);
}
List<pointIndexHit> leftHit;
{
labelList leftSurf;
surfaces().findAnyIntersection
(
start,
start-projectVecs,
leftSurf,
leftHit
);
}
if (projectMode_ == NEAREST)
// 3. Choose either -fixed, nearest, right, left.
forAll(displacement, i)
{
if (zonePtr && (zonePtr->whichPoint(meshPoints[i]) >= 0))
{
surfaces().findNearest(start, sqr(projectLen), intersection);
// Fixed point. Reset to point0 location.
displacement[i] = points0[meshPoints[i]] - localPoints[i];
}
else if (nearest[i].hit())
{
// Found nearest.
displacement[i] =
nearest[i].hitPoint()
- points0[meshPoints[i]];
}
else
{
// Check if already on surface
surfaces().findNearest(start, sqr(SMALL), intersection);
pointIndexHit interPt;
if (!intersection.hit())
if (rightHit[i].hit())
{
// No nearest found. Do intersection
if (projectMode_ == POINTNORMAL)
if (leftHit[i].hit())
{
projectVec = projectLen*patch().pointNormals()[i];
}
// Knock out any wedge component
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
{
offset = start[wedgePlane_];
start[wedgePlane_] = 0;
projectVec[wedgePlane_] = 0;
}
label rightSurf0, rightSurf1;
pointIndexHit rightHit0, rightHit1;
surfaces().findNearestIntersection
(
start,
start+projectVec,
rightSurf0,
rightHit0,
rightSurf1,
rightHit1
);
// Do intersection
label leftSurf0, leftSurf1;
pointIndexHit leftHit0, leftHit1;
surfaces().findNearestIntersection
(
start,
start-projectVec,
leftSurf0,
leftHit0,
leftSurf1,
leftHit1
);
if (rightHit0.hit())
{
if (leftHit0.hit())
if
(
magSqr(rightHit[i].hitPoint()-start[i])
< magSqr(leftHit[i].hitPoint()-start[i])
)
{
if
(
magSqr(rightHit0.hitPoint()-start)
< magSqr(leftHit0.hitPoint()-start)
)
{
intersection = rightHit0;
}
else
{
intersection = leftHit0;
}
interPt = rightHit[i];
}
else
{
intersection = rightHit0;
interPt = leftHit[i];
}
}
else
{
if (leftHit0.hit())
{
intersection = leftHit0;
}
interPt = rightHit[i];
}
}
else
{
if (leftHit[i].hit())
{
interPt = leftHit[i];
}
}
}
// Update *this from intersection point
if (intersection.hit())
{
point interPt = intersection.hitPoint();
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
if (interPt.hit())
{
interPt[wedgePlane_] += offset;
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
{
interPt.rawPoint()[wedgePlane_] += offset[i];
}
displacement[i] = interPt.rawPoint()-points0[meshPoints[i]];
}
else
{
Pout<< " point:" << meshPoints[i]
<< " coord:" << localPoints[i]
<< " did not find any intersection between ray from "
<< start[i]-projectVecs[i]
<< " to " << start[i]+projectVecs[i]
<< endl;
}
displacement[i] = interPt-points0[meshPoints[i]];
}
else
{
Pout<< " point:" << meshPoints[i]
<< " coord:" << localPoints[i]
<< " did not find any intersection between ray from "
<< start-projectVec << " to " << start+projectVec
<< endl;
}
}
}
......@@ -353,7 +404,7 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
void surfaceSlipDisplacementPointPatchVectorField::write(Ostream& os) const
{
pointPatchVectorField::write(os);
os.writeKeyword("projectSurfaces") << surfaceNames_
os.writeKeyword("geometry") << surfacesDict_
<< token::END_STATEMENT << nl;
os.writeKeyword("followMode") << followModeNames_[projectMode_]
<< token::END_STATEMENT << nl;
......
......@@ -52,7 +52,7 @@ SourceFiles
#define surfaceSlipDisplacementPointPatchVectorField_H
#include "pointPatchFields.H"
#include "triSurfaceMeshes.H"
#include "searchableSurfaces.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -87,7 +87,7 @@ private:
static const NamedEnum<followMode, 3> followModeNames_;
//- names of surfaces
const fileNameList surfaceNames_;
const dictionary surfacesDict_;
//- How to follow/project onto surface
const followMode projectMode_;
......@@ -102,7 +102,7 @@ private:
const word frozenPointsZone_;
//- Demand driven: surface to follow
mutable autoPtr<triSurfaceMeshes> surfacesPtr_;
mutable autoPtr<searchableSurfaces> surfacesPtr_;
// Private Member Functions
......@@ -187,13 +187,13 @@ public:
// Member Functions
//- Surfaces to follow
const fileNameList& surfaceNames() const
const dictionary& surfacesDict() const
{
return surfaceNames_;
return surfacesDict_;
}
//- Surface to follow. Demand loads surfaceNames.
const triSurfaceMeshes& surfaces() const;
const searchableSurfaces& surfaces() const;
//- Mode of projection/following
followMode projectMode() const
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment