ENH: AMI - refactored normalise->conformal

This commit is contained in:
andy
2013-05-28 15:05:41 +01:00
parent 0158cc6134
commit 16b2973fab
4 changed files with 33 additions and 29 deletions

View File

@ -200,7 +200,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
const labelListList& addr, const labelListList& addr,
scalarListList& wght, scalarListList& wght,
scalarField& wghtSum, scalarField& wghtSum,
const bool normalise, const bool conformal,
const bool output const bool output
) )
{ {
@ -214,7 +214,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::normaliseWeights
scalar s = sum(w); scalar s = sum(w);
scalar t = s/denom; scalar t = s/denom;
if (normalise) if (conformal)
{ {
denom = s; denom = s;
} }
@ -907,7 +907,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
srcAddress_, srcAddress_,
srcWeights_, srcWeights_,
srcWeightsSum_, srcWeightsSum_,
AMIPtr->normalise(), AMIPtr->conformal(),
true true
); );
normaliseWeights normaliseWeights
@ -917,7 +917,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
tgtAddress_, tgtAddress_,
tgtWeights_, tgtWeights_,
tgtWeightsSum_, tgtWeightsSum_,
AMIPtr->normalise(), AMIPtr->conformal(),
true true
); );
@ -964,7 +964,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
srcAddress_, srcAddress_,
srcWeights_, srcWeights_,
srcWeightsSum_, srcWeightsSum_,
AMIPtr->normalise(), AMIPtr->conformal(),
true true
); );
normaliseWeights normaliseWeights
@ -974,7 +974,7 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::update
tgtAddress_, tgtAddress_,
tgtWeights_, tgtWeights_,
tgtWeightsSum_, tgtWeightsSum_,
AMIPtr->normalise(), AMIPtr->conformal(),
true true
); );
} }

View File

@ -237,7 +237,7 @@ private:
const labelListList& addr, const labelListList& addr,
scalarListList& wght, scalarListList& wght,
scalarField& wghtSum, scalarField& wghtSum,
const bool normalise, const bool conformal,
const bool output const bool output
); );

View File

@ -41,24 +41,28 @@ void Foam::AMIMethod<SourcePatch, TargetPatch>::checkPatches() const
} }
const scalar maxBoundsError = 0.05; if (conformal())
// check bounds of source and target
boundBox bbSrc(srcPatch_.points(), srcPatch_.meshPoints(), true);
boundBox bbTgt(tgtPatch_.points(), tgtPatch_.meshPoints(), true);
boundBox bbTgtInf(bbTgt);
bbTgtInf.inflate(maxBoundsError);
if (!bbTgtInf.contains(bbSrc))
{ {
WarningIn("AMIMethod<SourcePatch, TargetPatch>::checkPatches()") const scalar maxBoundsError = 0.05;
<< "Source and target patch bounding boxes are not similar" << nl
<< " source box span : " << bbSrc.span() << nl // check bounds of source and target
<< " target box span : " << bbTgt.span() << nl boundBox bbSrc(srcPatch_.points(), srcPatch_.meshPoints(), true);
<< " source box : " << bbSrc << nl boundBox bbTgt(tgtPatch_.points(), tgtPatch_.meshPoints(), true);
<< " target box : " << bbTgt << nl
<< " inflated target box : " << bbTgtInf << endl; boundBox bbTgtInf(bbTgt);
bbTgtInf.inflate(maxBoundsError);
if (!bbTgtInf.contains(bbSrc))
{
WarningIn("AMIMethod<SourcePatch, TargetPatch>::checkPatches()")
<< "Source and target patch bounding boxes are not similar"
<< nl
<< " source box span : " << bbSrc.span() << nl
<< " target box span : " << bbTgt.span() << nl
<< " source box : " << bbSrc << nl
<< " target box : " << bbTgt << nl
<< " inflated target box : " << bbTgtInf << endl;
}
} }
} }
@ -74,6 +78,8 @@ bool Foam::AMIMethod<SourcePatch, TargetPatch>::initialise
label& tgtFaceI label& tgtFaceI
) )
{ {
checkPatches();
// set initial sizes for weights and addressing - must be done even if // set initial sizes for weights and addressing - must be done even if
// returns false below // returns false below
srcAddress.setSize(srcPatch_.size()); srcAddress.setSize(srcPatch_.size());
@ -333,8 +339,6 @@ Foam::AMIMethod<SourcePatch, TargetPatch>::AMIMethod
srcNonOverlap_(), srcNonOverlap_(),
triMode_(triMode) triMode_(triMode)
{ {
checkPatches();
label srcSize = returnReduce(srcPatch_.size(), sumOp<label>()); label srcSize = returnReduce(srcPatch_.size(), sumOp<label>());
label tgtSize = returnReduce(tgtPatch_.size(), sumOp<label>()); label tgtSize = returnReduce(tgtPatch_.size(), sumOp<label>());
@ -354,7 +358,7 @@ Foam::AMIMethod<SourcePatch, TargetPatch>::~AMIMethod()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class SourcePatch, class TargetPatch> template<class SourcePatch, class TargetPatch>
bool Foam::AMIMethod<SourcePatch, TargetPatch>::normalise() const bool Foam::AMIMethod<SourcePatch, TargetPatch>::conformal() const
{ {
return true; return true;
} }

View File

@ -207,8 +207,8 @@ public:
// Note: this should be empty for correct functioning // Note: this should be empty for correct functioning
inline const labelList& srcNonOverlap() const; inline const labelList& srcNonOverlap() const;
//- Flag to indicate that weights should be normalised //- Flag to indicate that interpolation patches are conformal
virtual bool normalise() const; virtual bool conformal() const;
// Manipulation // Manipulation