Added surface following options

This commit is contained in:
mattijs
2008-05-07 12:14:34 +01:00
parent c20616c499
commit dd3a79a3d8
2 changed files with 134 additions and 95 deletions

View File

@ -36,34 +36,20 @@ License
namespace Foam namespace Foam
{ {
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // template<>
const char*
NamedEnum<surfaceSlipDisplacementPointPatchVectorField::followMode, 3>::
names[] =
{
"nearest",
"pointNormal",
"fixedNormal"
};
//Foam::vector const NamedEnum<surfaceSlipDisplacementPointPatchVectorField::followMode, 3>
// Foam::surfaceSlipDisplacementPointPatchVectorField::projectNormal surfaceSlipDisplacementPointPatchVectorField::followModeNames_;
//(
// const label pointI,
// const point& pt
//)
//{
// vector projectNormal
//
// if (wedge)
// {
// // For wedge: assume axis runs from (0 0 0) in direction axisNormal_
// //vector projectNormal(pt-axisPt);
// //projectNormal -= (axisNormal&projectNormal)*projectNormal;
//
// projectNormal = pt - (axisNormal_&pt)*axisNormal_;
// projectNormal /= mag(projectNormal) + VSMALL;
// }
// else
// {
// projectNormal = this->patch().pointNormals()[pointI];
// }
//
// return projectNormal;
//}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -77,6 +63,7 @@ surfaceSlipDisplacementPointPatchVectorField
: :
pointPatchVectorField(p, iF), pointPatchVectorField(p, iF),
surfaceNames_(), surfaceNames_(),
projectMode_(NEAREST),
projectDir_(vector::zero), projectDir_(vector::zero),
wedgePlane_(-1) wedgePlane_(-1)
{} {}
@ -92,6 +79,7 @@ surfaceSlipDisplacementPointPatchVectorField
: :
pointPatchVectorField(p, iF), pointPatchVectorField(p, iF),
surfaceNames_(dict.lookup("projectSurfaces")), surfaceNames_(dict.lookup("projectSurfaces")),
projectMode_(followModeNames_.read(dict.lookup("followMode"))),
projectDir_(dict.lookup("projectDirection")), projectDir_(dict.lookup("projectDirection")),
wedgePlane_(readLabel(dict.lookup("wedgePlane"))), wedgePlane_(readLabel(dict.lookup("wedgePlane"))),
frozenPointsZone_(dict.lookup("frozenPointsZone")) frozenPointsZone_(dict.lookup("frozenPointsZone"))
@ -109,6 +97,7 @@ surfaceSlipDisplacementPointPatchVectorField
: :
pointPatchVectorField(p, iF), pointPatchVectorField(p, iF),
surfaceNames_(ppf.surfaceNames()), surfaceNames_(ppf.surfaceNames()),
projectMode_(ppf.projectMode()),
projectDir_(ppf.projectDir()), projectDir_(ppf.projectDir()),
wedgePlane_(ppf.wedgePlane()), wedgePlane_(ppf.wedgePlane()),
frozenPointsZone_(ppf.frozenPointsZone()) frozenPointsZone_(ppf.frozenPointsZone())
@ -123,6 +112,7 @@ surfaceSlipDisplacementPointPatchVectorField
: :
pointPatchVectorField(ppf), pointPatchVectorField(ppf),
surfaceNames_(ppf.surfaceNames()), surfaceNames_(ppf.surfaceNames()),
projectMode_(ppf.projectMode()),
projectDir_(ppf.projectDir()), projectDir_(ppf.projectDir()),
wedgePlane_(ppf.wedgePlane()), wedgePlane_(ppf.wedgePlane()),
frozenPointsZone_(ppf.frozenPointsZone()) frozenPointsZone_(ppf.frozenPointsZone())
@ -138,6 +128,7 @@ surfaceSlipDisplacementPointPatchVectorField
: :
pointPatchVectorField(ppf, iF), pointPatchVectorField(ppf, iF),
surfaceNames_(ppf.surfaceNames()), surfaceNames_(ppf.surfaceNames()),
projectMode_(ppf.projectMode()),
projectDir_(ppf.projectDir()), projectDir_(ppf.projectDir()),
wedgePlane_(ppf.wedgePlane()), wedgePlane_(ppf.wedgePlane()),
frozenPointsZone_(ppf.frozenPointsZone()) frozenPointsZone_(ppf.frozenPointsZone())
@ -184,17 +175,21 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
// Construct large enough vector in direction of projectDir so // Construct large enough vector in direction of projectDir so
// we're guaranteed to hit something. // we're guaranteed to hit something.
//- Fixed projection vector: const scalar projectLen = mag(mesh.bounds().max()-mesh.bounds().min());
//vector n = projectDir_/mag(projectDir_);
//vector projectVec = n*(n&(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;
}
//- Per point projection vector: //- Per point projection vector:
const scalar projectLen = mag(mesh.bounds().max()-mesh.bounds().min());
const pointField& localPoints = patch().localPoints(); const pointField& localPoints = patch().localPoints();
const labelList& meshPoints = patch().meshPoints(); const labelList& meshPoints = patch().meshPoints();
//vectorField motionU(this->patchInternalField());
vectorField displacement(this->patchInternalField()); vectorField displacement(this->patchInternalField());
@ -234,12 +229,30 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
} }
else else
{ {
//point start(localPoints[i] + deltaT*motionU[i]);
point start(points0[meshPoints[i]] + displacement[i]); point start(points0[meshPoints[i]] + displacement[i]);
vector projectVec(projectLen*patch().pointNormals()[i]);
scalar offset = 0; scalar offset = 0;
pointIndexHit intersection;
if (projectMode_ == NEAREST)
{
surfaces().findNearest(start, sqr(projectLen), intersection);
}
else
{
// Check if already on surface
surfaces().findNearest(start, sqr(SMALL), intersection);
if (!intersection.hit())
{
// No nearest found. Do intersection
if (projectMode_ == POINTNORMAL)
{
projectVec = projectLen*patch().pointNormals()[i];
}
// Knock out any wedge component
if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents) if (wedgePlane_ >= 0 && wedgePlane_ <= vector::nComponents)
{ {
offset = start[wedgePlane_]; offset = start[wedgePlane_];
@ -247,20 +260,6 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
projectVec[wedgePlane_] = 0; projectVec[wedgePlane_] = 0;
} }
pointIndexHit intersection;
// Check if already on surface
surfaces().findNearest(start, sqr(SMALL), intersection);
if (intersection.hit())
{
//Pout<< " point:" << start << " near:" << intersection.hit()
// << endl;
}
else
{
// No nearest found. Do intersection
label rightSurf0, rightSurf1; label rightSurf0, rightSurf1;
pointIndexHit rightHit0, rightHit1; pointIndexHit rightHit0, rightHit1;
surfaces().findNearestIntersection surfaces().findNearestIntersection
@ -316,6 +315,7 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
} }
} }
} }
}
// Update *this from intersection point // Update *this from intersection point
@ -327,7 +327,6 @@ void surfaceSlipDisplacementPointPatchVectorField::evaluate
{ {
interPt[wedgePlane_] += offset; interPt[wedgePlane_] += offset;
} }
//motionU[i] = (interPt-localPoints[i])/deltaT;
displacement[i] = interPt-points0[meshPoints[i]]; displacement[i] = interPt-points0[meshPoints[i]];
} }
else else
@ -356,6 +355,8 @@ void surfaceSlipDisplacementPointPatchVectorField::write(Ostream& os) const
pointPatchVectorField::write(os); pointPatchVectorField::write(os);
os.writeKeyword("projectSurfaces") << surfaceNames_ os.writeKeyword("projectSurfaces") << surfaceNames_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("followMode") << followModeNames_[projectMode_]
<< token::END_STATEMENT << nl;
os.writeKeyword("projectDirection") << projectDir_ os.writeKeyword("projectDirection") << projectDir_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("wedgePlane") << wedgePlane_ os.writeKeyword("wedgePlane") << wedgePlane_

View File

@ -27,6 +27,21 @@ Class
Description Description
Displacement follows a triSurface. Use in a displacement fvMotionSolver. Displacement follows a triSurface. Use in a displacement fvMotionSolver.
Following is either
- NEAREST : nearest
- POINTNORMAL : intersection with point normal
- FIXEDNORMAL : intersection with fixed vector
Optionally (intersection only) removes a component ("wedgePlane") to
stay in 2D.
Needs:
- projectSurfaces : names of triSurfaceMeshes (in constant/triSurface)
- followMode : see above
- projectDirection : if followMode = fixedNormal
- wedgePlane : -1 or component to knock out of intersection normal
- frozenPointsZone : empty or name of pointZone containing points
that do not move
SourceFiles SourceFiles
surfaceSlipDisplacementPointPatchVectorField.C surfaceSlipDisplacementPointPatchVectorField.C
@ -52,11 +67,31 @@ class surfaceSlipDisplacementPointPatchVectorField
: :
public pointPatchVectorField public pointPatchVectorField
{ {
public:
// Public data types
enum followMode
{
NEAREST,
POINTNORMAL,
FIXEDNORMAL
};
private:
// Private data // Private data
//- follow mode names
static const NamedEnum<followMode, 3> followModeNames_;
//- names of surfaces //- names of surfaces
const fileNameList surfaceNames_; const fileNameList surfaceNames_;
//- How to follow/project onto surface
const followMode projectMode_;
//- direction to project //- direction to project
const vector projectDir_; const vector projectDir_;
@ -72,9 +107,6 @@ class surfaceSlipDisplacementPointPatchVectorField
// Private Member Functions // Private Member Functions
////- Calculate projection direction (normalised) at pointI.
//vector projectNormal(const label pointI, const point& pt) const;
//- Disallow default bitwise assignment //- Disallow default bitwise assignment
void operator=(const surfaceSlipDisplacementPointPatchVectorField&); void operator=(const surfaceSlipDisplacementPointPatchVectorField&);
@ -163,6 +195,12 @@ public:
//- Surface to follow. Demand loads surfaceNames. //- Surface to follow. Demand loads surfaceNames.
const triSurfaceMeshes& surfaces() const; const triSurfaceMeshes& surfaces() const;
//- Mode of projection/following
const followMode projectMode() const
{
return projectMode_;
}
//- Direction to project back onto surface //- Direction to project back onto surface
const vector& projectDir() const const vector& projectDir() const
{ {