ENH: Added option to reverse the direction of the AMI target patch

This commit is contained in:
andy 2011-11-29 13:06:25 +00:00
parent b5936ebd90
commit 1f9fd259fd
8 changed files with 90 additions and 33 deletions

View File

@ -902,7 +902,7 @@ Foam::scalar Foam::AMIInterpolation<SourcePatch, TargetPatch>::interArea
}
// create intersection object
faceAreaIntersect inter(srcPoints, tgtPoints);
faceAreaIntersect inter(srcPoints, tgtPoints, reverseTarget_);
// crude resultant norm - face normals should be opposite
const vector n = 0.5*(tgt.normal(tgtPoints) - src.normal(srcPoints));
@ -1432,14 +1432,17 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::AMIInterpolation
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const faceAreaIntersect::triangulationMode& triMode
const faceAreaIntersect::triangulationMode& triMode,
const bool reverseTarget
)
:
reverseTarget_(reverseTarget),
singlePatchProc_(-999),
srcAddress_(),
srcWeights_(),
tgtAddress_(),
tgtWeights_(),
treePtr_(NULL),
startSeedI_(0),
triMode_(triMode),
srcMapPtr_(NULL),
@ -1462,14 +1465,17 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::AMIInterpolation
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const autoPtr<searchableSurface>& surfPtr,
const faceAreaIntersect::triangulationMode& triMode
const faceAreaIntersect::triangulationMode& triMode,
const bool reverseTarget
)
:
reverseTarget_(reverseTarget),
singlePatchProc_(-999),
srcAddress_(),
srcWeights_(),
tgtAddress_(),
tgtWeights_(),
treePtr_(NULL),
startSeedI_(0),
triMode_(triMode),
srcMapPtr_(NULL),
@ -1551,11 +1557,13 @@ Foam::AMIInterpolation<SourcePatch, TargetPatch>::AMIInterpolation
const labelList& targetRestrictAddressing
)
:
reverseTarget_(fineAMI.reverseTarget_),
singlePatchProc_(fineAMI.singlePatchProc_),
srcAddress_(),
srcWeights_(),
tgtAddress_(),
tgtWeights_(),
treePtr_(NULL),
startSeedI_(0),
triMode_(fineAMI.triMode_),
srcMapPtr_(NULL),

View File

@ -34,6 +34,10 @@ Description
projection, Farrell PE and Maddison JR, 2011, Comput. Methods Appl.
Mech Engrg, Volume 200, Issues 1-4, pp 89-100
Interpolation requires that the two patches should have opposite
orientations (opposite normals). The 'reverseTarget' flag can be used to
reverse the orientation of the target patch.
SourceFiles
AMIInterpolation.C
@ -109,6 +113,9 @@ class AMIInterpolation
// Private data
//- Flag to indicate that the two patches are co-directional and
// that the orientation of the target patch should be reversed
const bool reverseTarget_;
//- Index of processor that holds all of both sides. -1 in all other
// cases
@ -332,7 +339,8 @@ public:
(
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const faceAreaIntersect::triangulationMode& triMode
const faceAreaIntersect::triangulationMode& triMode,
const bool reverseTarget = false
);
//- Construct from components, with projection surface
@ -341,11 +349,12 @@ public:
const SourcePatch& srcPatch,
const TargetPatch& tgtPatch,
const autoPtr<searchableSurface>& surf,
const faceAreaIntersect::triangulationMode& triMode
const faceAreaIntersect::triangulationMode& triMode,
const bool reverseTarget = false
);
//- Construct from agglomeration of AMIInterpolation. Agglomeration
// passed in as new coarse size and addressing from fine from coarse.
// passed in as new coarse size and addressing from fine from coarse
AMIInterpolation
(
const AMIInterpolation<SourcePatch, TargetPatch>& fineAMI,
@ -362,9 +371,11 @@ public:
// Access
//- -1 or the processor holding all faces (both sides) of the AMI
//- Set to -1, or the processor holding all faces (both sides) of
// the AMI
label singlePatchProc() const;
// Source patch
//- Return const access to source patch face areas
@ -497,6 +508,7 @@ public:
const tmp<Field<Type> >& tFld
) const;
// Checks
//- Write face connectivity as OBJ file

View File

@ -298,11 +298,13 @@ Foam::scalar Foam::faceAreaIntersect::triangleIntersect
Foam::faceAreaIntersect::faceAreaIntersect
(
const pointField& pointsA,
const pointField& pointsB
const pointField& pointsB,
const bool reverseB
)
:
pointsA_(pointsA),
pointsB_(pointsB)
pointsB_(pointsB),
reverseB_(reverseB)
{}
@ -362,7 +364,7 @@ Foam::scalar Foam::faceAreaIntersect::calc
{
forAll(trisB, tB)
{
triPoints tpB = getTriPoints(pointsB_, trisB[tB], true);
triPoints tpB = getTriPoints(pointsB_, trisB[tB], !reverseB_);
// if (triArea(tpB) > ROOTVSMALL)
{

View File

@ -74,6 +74,9 @@ private:
//- Reference to the points of sideB
const pointField& pointsB_;
//- Flag to reverse B faces
const bool reverseB_;
// Private Member Functions
@ -142,7 +145,8 @@ public:
faceAreaIntersect
(
const pointField& pointsA,
const pointField& pointsB
const pointField& pointsB,
const bool reverseB = false
);

View File

@ -278,7 +278,8 @@ void Foam::cyclicAMIPolyPatch::resetAMI() const
*this,
nbrPatch0,
surfPtr(),
faceAreaIntersect::tmMesh
faceAreaIntersect::tmMesh,
AMIReverse_
)
);
}
@ -363,6 +364,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
rotationCentre_(point::zero),
separationVector_(vector::zero),
AMIPtr_(NULL),
AMIReverse_(false),
surfPtr_(NULL),
surfDict_(dictionary::null)
{
@ -387,6 +389,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
rotationCentre_(point::zero),
separationVector_(vector::zero),
AMIPtr_(NULL),
AMIReverse_(dict.lookupOrDefault<bool>("flipNormals", false)),
surfPtr_(NULL),
surfDict_(dict.subOrEmptyDict("surface"))
{
@ -469,6 +472,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_),
AMIPtr_(NULL),
AMIReverse_(pp.AMIReverse_),
surfPtr_(NULL),
surfDict_(dictionary::null)
{
@ -495,6 +499,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_),
AMIPtr_(NULL),
AMIReverse_(pp.AMIReverse_),
surfPtr_(NULL),
surfDict_(dictionary::null)
{
@ -535,6 +540,7 @@ Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
rotationCentre_(pp.rotationCentre_),
separationVector_(pp.separationVector_),
AMIPtr_(NULL),
AMIReverse_(pp.AMIReverse_),
surfPtr_(NULL),
surfDict_(pp.surfDict_)
{}
@ -813,6 +819,11 @@ void Foam::cyclicAMIPolyPatch::write(Ostream& os) const
}
}
if (AMIReverse_)
{
os.writeKeyword("flipNormals") << AMIReverse_
<< token::END_STATEMENT << nl;
}
if (surfDict_ != dictionary::null)
{

View File

@ -88,6 +88,9 @@ private:
//- AMI interpolation class
mutable autoPtr<AMIPatchToPatchInterpolation> AMIPtr_;
//- Flag to indicate that slave patch should be reversed for AMI
const bool AMIReverse_;
//- Projection surface
mutable autoPtr<searchableSurface> surfPtr_;

View File

@ -650,7 +650,8 @@ void Foam::mappedPatchBase::calcAMI() const
patch_,
samplePolyPatch(), // nbrPatch0,
surfPtr(),
faceAreaIntersect::tmMesh
faceAreaIntersect::tmMesh,
AMIReverse_
)
);
}
@ -674,6 +675,7 @@ Foam::mappedPatchBase::mappedPatchBase
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(NULL),
AMIPtr_(NULL),
AMIReverse_(false),
surfPtr_(NULL),
surfDict_(dictionary::null)
{}
@ -699,6 +701,7 @@ Foam::mappedPatchBase::mappedPatchBase
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(NULL),
AMIPtr_(NULL),
AMIReverse_(false),
surfPtr_(NULL),
surfDict_(dictionary::null)
{}
@ -724,6 +727,7 @@ Foam::mappedPatchBase::mappedPatchBase
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(NULL),
AMIPtr_(NULL),
AMIReverse_(false),
surfPtr_(NULL),
surfDict_(dictionary::null)
{}
@ -749,6 +753,7 @@ Foam::mappedPatchBase::mappedPatchBase
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(NULL),
AMIPtr_(NULL),
AMIReverse_(false),
surfPtr_(NULL),
surfDict_(dictionary::null)
{}
@ -778,6 +783,7 @@ Foam::mappedPatchBase::mappedPatchBase
sameRegion_(sampleRegion_ == patch_.boundaryMesh().mesh().name()),
mapPtr_(NULL),
AMIPtr_(NULL),
AMIReverse_(dict.lookupOrDefault<bool>("flipNormals", false)),
surfPtr_(NULL),
surfDict_(dict.subOrEmptyDict("surface"))
{
@ -836,45 +842,47 @@ Foam::mappedPatchBase::mappedPatchBase
Foam::mappedPatchBase::mappedPatchBase
(
const polyPatch& pp,
const mappedPatchBase& dmp
const mappedPatchBase& mpb
)
:
patch_(pp),
sampleRegion_(dmp.sampleRegion_),
mode_(dmp.mode_),
samplePatch_(dmp.samplePatch_),
offsetMode_(dmp.offsetMode_),
offset_(dmp.offset_),
offsets_(dmp.offsets_),
distance_(dmp.distance_),
sameRegion_(dmp.sameRegion_),
sampleRegion_(mpb.sampleRegion_),
mode_(mpb.mode_),
samplePatch_(mpb.samplePatch_),
offsetMode_(mpb.offsetMode_),
offset_(mpb.offset_),
offsets_(mpb.offsets_),
distance_(mpb.distance_),
sameRegion_(mpb.sameRegion_),
mapPtr_(NULL),
AMIPtr_(NULL),
AMIReverse_(mpb.AMIReverse_),
surfPtr_(NULL),
surfDict_(dmp.surfDict_)
surfDict_(mpb.surfDict_)
{}
Foam::mappedPatchBase::mappedPatchBase
(
const polyPatch& pp,
const mappedPatchBase& dmp,
const mappedPatchBase& mpb,
const labelUList& mapAddressing
)
:
patch_(pp),
sampleRegion_(dmp.sampleRegion_),
mode_(dmp.mode_),
samplePatch_(dmp.samplePatch_),
offsetMode_(dmp.offsetMode_),
offset_(dmp.offset_),
offsets_(dmp.offsets_, mapAddressing),
distance_(dmp.distance_),
sameRegion_(dmp.sameRegion_),
sampleRegion_(mpb.sampleRegion_),
mode_(mpb.mode_),
samplePatch_(mpb.samplePatch_),
offsetMode_(mpb.offsetMode_),
offset_(mpb.offset_),
offsets_(mpb.offsets_, mapAddressing),
distance_(mpb.distance_),
sameRegion_(mpb.sameRegion_),
mapPtr_(NULL),
AMIPtr_(NULL),
AMIReverse_(mpb.AMIReverse_),
surfPtr_(NULL),
surfDict_(dmp.surfDict_)
surfDict_(mpb.surfDict_)
{}
@ -991,6 +999,12 @@ void Foam::mappedPatchBase::write(Ostream& os) const
if (mode_ == NEARESTPATCHFACEAMI)
{
if (AMIReverse_)
{
os.writeKeyword("flipNormals") << AMIReverse_
<< token::END_STATEMENT << nl;
}
os.writeKeyword(surfDict_.dictName());
os << surfDict_;
}

View File

@ -192,6 +192,9 @@ protected:
//- Pointer to AMI interpolator
mutable autoPtr<AMIPatchToPatchInterpolation> AMIPtr_;
//- Flag to indicate that slave patch should be reversed for AMI
const bool AMIReverse_;
//- Pointer to projection surface employed by AMI interpolator
mutable autoPtr<searchableSurface> surfPtr_;