mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
moved code
This commit is contained in:
@ -52,6 +52,254 @@ const NamedEnum<surfaceSlipDisplacementPointPatchVectorField::followMode, 3>
|
||||
surfaceSlipDisplacementPointPatchVectorField::followModeNames_;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void surfaceSlipDisplacementPointPatchVectorField::calcProjection
|
||||
(
|
||||
vectorField& displacement
|
||||
) const
|
||||
{
|
||||
const polyMesh& mesh = patch().boundaryMesh().mesh()();
|
||||
const pointField& localPoints = patch().localPoints();
|
||||
const labelList& meshPoints = patch().meshPoints();
|
||||
|
||||
//const scalar deltaT = mesh.time().deltaT().value();
|
||||
|
||||
// Construct large enough vector in direction of projectDir so
|
||||
// we're guaranteed to hit something.
|
||||
|
||||
//- Per point projection vector:
|
||||
const scalar projectLen = mag(mesh.bounds().max()-mesh.bounds().min());
|
||||
|
||||
// For case of fixed projection vector:
|
||||
vector projectVec;
|
||||
if (projectMode_ == FIXEDNORMAL)
|
||||
{
|
||||
vector n = projectDir_/mag(projectDir_);
|
||||
projectVec = projectLen*n;
|
||||
}
|
||||
|
||||
|
||||
// Get fixed points (bit of a hack)
|
||||
const pointZone* zonePtr = NULL;
|
||||
|
||||
if (frozenPointsZone_.size() > 0)
|
||||
{
|
||||
const pointZoneMesh& pZones = mesh.pointZones();
|
||||
|
||||
zonePtr = &pZones[pZones.findZoneID(frozenPointsZone_)];
|
||||
|
||||
Pout<< "surfaceSlipDisplacementPointPatchVectorField : Fixing all "
|
||||
<< zonePtr->size() << " points in pointZone " << zonePtr->name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Get the starting locations from the motionSolver
|
||||
const displacementLaplacianFvMotionSolver& motionSolver =
|
||||
mesh.lookupObject<displacementLaplacianFvMotionSolver>
|
||||
(
|
||||
"dynamicMeshDict"
|
||||
);
|
||||
const pointField& points0 = motionSolver.points0();
|
||||
|
||||
|
||||
pointField start(meshPoints.size());
|
||||
forAll(start, i)
|
||||
{
|
||||
start[i] = points0[meshPoints[i]] + displacement[i];
|
||||
}
|
||||
|
||||
label nNotProjected = 0;
|
||||
|
||||
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
|
||||
{
|
||||
nNotProjected++;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " point:" << meshPoints[i]
|
||||
<< " coord:" << localPoints[i]
|
||||
<< " did not find any surface within " << projectLen
|
||||
<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Do tests on all points. Combine later on.
|
||||
|
||||
// 1. Check if already on surface
|
||||
List<pointIndexHit> nearest;
|
||||
{
|
||||
labelList nearestSurface;
|
||||
surfaces().findNearest
|
||||
(
|
||||
start,
|
||||
scalarField(start.size(), sqr(SMALL)),
|
||||
nearestSurface,
|
||||
nearest
|
||||
);
|
||||
}
|
||||
|
||||
// 2. intersection. (combined later on with information from nearest
|
||||
// above)
|
||||
vectorField projectVecs(start.size(), projectVec);
|
||||
|
||||
if (projectMode_ == POINTNORMAL)
|
||||
{
|
||||
projectVecs = projectLen*patch().pointNormals();
|
||||
}
|
||||
|
||||
// Knock out any wedge component
|
||||
scalarField offset(start.size(), 0.0);
|
||||
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
|
||||
{
|
||||
forAll(offset, i)
|
||||
{
|
||||
offset[i] = start[i][wedgePlane_];
|
||||
start[i][wedgePlane_] = 0;
|
||||
projectVecs[i][wedgePlane_] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
List<pointIndexHit> rightHit;
|
||||
{
|
||||
labelList rightSurf;
|
||||
surfaces().findAnyIntersection
|
||||
(
|
||||
start,
|
||||
start+projectVecs,
|
||||
rightSurf,
|
||||
rightHit
|
||||
);
|
||||
}
|
||||
|
||||
List<pointIndexHit> leftHit;
|
||||
{
|
||||
labelList leftSurf;
|
||||
surfaces().findAnyIntersection
|
||||
(
|
||||
start,
|
||||
start-projectVecs,
|
||||
leftSurf,
|
||||
leftHit
|
||||
);
|
||||
}
|
||||
|
||||
// 3. Choose either -fixed, nearest, right, left.
|
||||
forAll(displacement, 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())
|
||||
{
|
||||
// Found nearest.
|
||||
displacement[i] =
|
||||
nearest[i].hitPoint()
|
||||
- points0[meshPoints[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
pointIndexHit interPt;
|
||||
|
||||
if (rightHit[i].hit())
|
||||
{
|
||||
if (leftHit[i].hit())
|
||||
{
|
||||
if
|
||||
(
|
||||
magSqr(rightHit[i].hitPoint()-start[i])
|
||||
< magSqr(leftHit[i].hitPoint()-start[i])
|
||||
)
|
||||
{
|
||||
interPt = rightHit[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
interPt = leftHit[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
interPt = rightHit[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (leftHit[i].hit())
|
||||
{
|
||||
interPt = leftHit[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (interPt.hit())
|
||||
{
|
||||
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
|
||||
{
|
||||
interPt.rawPoint()[wedgePlane_] += offset[i];
|
||||
}
|
||||
displacement[i] = interPt.rawPoint()-points0[meshPoints[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
nNotProjected++;
|
||||
|
||||
if (debug)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
reduce(nNotProjected, sumOp<label>());
|
||||
|
||||
if (nNotProjected > 0)
|
||||
{
|
||||
Info<< "surfaceSlipDisplacement :"
|
||||
<< " on patch " << patch().name()
|
||||
<< " did not project " << nNotProjected
|
||||
<< " out of " << returnReduce(localPoints.size(), sumOp<label>())
|
||||
<< " points." << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
surfaceSlipDisplacementPointPatchVectorField::
|
||||
@ -81,7 +329,7 @@ surfaceSlipDisplacementPointPatchVectorField
|
||||
projectMode_(followModeNames_.read(dict.lookup("followMode"))),
|
||||
projectDir_(dict.lookup("projectDirection")),
|
||||
wedgePlane_(readLabel(dict.lookup("wedgePlane"))),
|
||||
frozenPointsZone_(dict.lookup("frozenPointsZone"))
|
||||
frozenPointsZone_(dict.lookupOrDefault("frozenPointsZone", word::null))
|
||||
{}
|
||||
|
||||
|
||||
@ -167,229 +415,10 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
|
||||
const Pstream::commsTypes commsType
|
||||
)
|
||||
{
|
||||
const polyMesh& mesh = patch().boundaryMesh().mesh()();
|
||||
|
||||
// const scalar deltaT = mesh.time().deltaT().value();
|
||||
|
||||
// Construct large enough vector in direction of projectDir so
|
||||
// we're guaranteed to hit something.
|
||||
|
||||
const scalar projectLen = mesh.bounds().mag();
|
||||
|
||||
// For case of fixed projection vector:
|
||||
vector projectVec;
|
||||
if (projectMode_ == FIXEDNORMAL)
|
||||
{
|
||||
vector n = projectDir_/mag(projectDir_);
|
||||
projectVec = projectLen*n;
|
||||
}
|
||||
|
||||
//- Per point projection vector:
|
||||
|
||||
const pointField& localPoints = patch().localPoints();
|
||||
const labelList& meshPoints = patch().meshPoints();
|
||||
|
||||
vectorField displacement(this->patchInternalField());
|
||||
|
||||
|
||||
// Get fixed points (bit of a hack)
|
||||
const pointZone* zonePtr = NULL;
|
||||
|
||||
if (frozenPointsZone_.size())
|
||||
{
|
||||
const pointZoneMesh& pZones = mesh.pointZones();
|
||||
|
||||
zonePtr = &pZones[pZones.findZoneID(frozenPointsZone_)];
|
||||
|
||||
Pout<< "surfaceSlipDisplacementPointPatchVectorField : Fixing all "
|
||||
<< zonePtr->size() << " points in pointZone " << zonePtr->name()
|
||||
<< endl;
|
||||
}
|
||||
|
||||
// Get the starting locations from the motionSolver
|
||||
const displacementLaplacianFvMotionSolver& motionSolver =
|
||||
mesh.lookupObject<displacementLaplacianFvMotionSolver>
|
||||
(
|
||||
"dynamicMeshDict"
|
||||
);
|
||||
const pointField& points0 = motionSolver.points0();
|
||||
|
||||
|
||||
//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
|
||||
{
|
||||
// Do tests on all points. Combine later on.
|
||||
|
||||
// 1. Check if already on surface
|
||||
List<pointIndexHit> nearest;
|
||||
{
|
||||
labelList nearestSurface;
|
||||
surfaces().findNearest
|
||||
(
|
||||
start,
|
||||
scalarField(start.size(), sqr(SMALL)),
|
||||
nearestSurface,
|
||||
nearest
|
||||
);
|
||||
}
|
||||
|
||||
// 2. intersection. (combined later on with information from nearest
|
||||
// above)
|
||||
vectorField projectVecs(start.size(), projectVec);
|
||||
|
||||
if (projectMode_ == POINTNORMAL)
|
||||
{
|
||||
projectVecs = projectLen*patch().pointNormals();
|
||||
}
|
||||
|
||||
// Knock out any wedge component
|
||||
scalarField offset(start.size(), 0.0);
|
||||
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
|
||||
{
|
||||
forAll(offset, i)
|
||||
{
|
||||
offset[i] = start[i][wedgePlane_];
|
||||
start[i][wedgePlane_] = 0;
|
||||
projectVecs[i][wedgePlane_] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
List<pointIndexHit> rightHit;
|
||||
{
|
||||
labelList rightSurf;
|
||||
surfaces().findAnyIntersection
|
||||
(
|
||||
start,
|
||||
start+projectVecs,
|
||||
rightSurf,
|
||||
rightHit
|
||||
);
|
||||
}
|
||||
|
||||
List<pointIndexHit> leftHit;
|
||||
{
|
||||
labelList leftSurf;
|
||||
surfaces().findAnyIntersection
|
||||
(
|
||||
start,
|
||||
start-projectVecs,
|
||||
leftSurf,
|
||||
leftHit
|
||||
);
|
||||
}
|
||||
|
||||
// 3. Choose either -fixed, nearest, right, left.
|
||||
forAll(displacement, 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())
|
||||
{
|
||||
// Found nearest.
|
||||
displacement[i] =
|
||||
nearest[i].hitPoint()
|
||||
- points0[meshPoints[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
pointIndexHit interPt;
|
||||
|
||||
if (rightHit[i].hit())
|
||||
{
|
||||
if (leftHit[i].hit())
|
||||
{
|
||||
if
|
||||
(
|
||||
magSqr(rightHit[i].hitPoint()-start[i])
|
||||
< magSqr(leftHit[i].hitPoint()-start[i])
|
||||
)
|
||||
{
|
||||
interPt = rightHit[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
interPt = leftHit[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
interPt = rightHit[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (leftHit[i].hit())
|
||||
{
|
||||
interPt = leftHit[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (interPt.hit())
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Calculate displacement to project points onto surface
|
||||
calcProjection(displacement);
|
||||
|
||||
// Get internal field to insert values into
|
||||
Field<vector>& iF = const_cast<Field<vector>&>(this->internalField());
|
||||
@ -412,8 +441,11 @@ void surfaceSlipDisplacementPointPatchVectorField::write(Ostream& os) const
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("wedgePlane") << wedgePlane_
|
||||
<< token::END_STATEMENT << nl;
|
||||
os.writeKeyword("frozenPointsZone") << frozenPointsZone_
|
||||
<< token::END_STATEMENT << nl;
|
||||
if (frozenPointsZone_ != word::null)
|
||||
{
|
||||
os.writeKeyword("frozenPointsZone") << frozenPointsZone_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -107,6 +107,9 @@ private:
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Calculate displacement to project onto surface
|
||||
void calcProjection(vectorField& displacement) const;
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const surfaceSlipDisplacementPointPatchVectorField&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user