mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: ACMI - code updates to avoid FPEs
This commit is contained in:
@ -90,16 +90,16 @@ void Foam::cyclicACMIPolyPatch::resetAMI
|
|||||||
AMIPatchToPatchInterpolation::imPartialFaceAreaWeight
|
AMIPatchToPatchInterpolation::imPartialFaceAreaWeight
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalarField& srcWeightSum = AMI().srcWeightsSum();
|
srcMask_ =
|
||||||
|
min(1.0 - tolerance_, max(tolerance_, AMI().srcWeightsSum()));
|
||||||
|
|
||||||
|
tgtMask_ =
|
||||||
|
min(1.0 - tolerance_, max(tolerance_, AMI().tgtWeightsSum()));
|
||||||
|
|
||||||
// set patch face areas based on sum of AMI weights per face
|
|
||||||
forAll(Sf, faceI)
|
forAll(Sf, faceI)
|
||||||
{
|
{
|
||||||
scalar w = srcWeightSum[faceI];
|
Sf[faceI] *= srcMask_[faceI];
|
||||||
w = min(1.0 - tolerance_, max(tolerance_, w));
|
noSf[faceI] *= 1.0 - srcMask_[faceI];
|
||||||
|
|
||||||
Sf[faceI] *= w;
|
|
||||||
noSf[faceI] *= 1.0 - w;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setNeighbourFaceAreas();
|
setNeighbourFaceAreas();
|
||||||
@ -116,8 +116,6 @@ void Foam::cyclicACMIPolyPatch::setNeighbourFaceAreas() const
|
|||||||
refCast<const cyclicACMIPolyPatch>(this->neighbPatch());
|
refCast<const cyclicACMIPolyPatch>(this->neighbPatch());
|
||||||
const polyPatch& pp = cp.nonOverlapPatch();
|
const polyPatch& pp = cp.nonOverlapPatch();
|
||||||
|
|
||||||
const scalarField& tgtWeightSum = AMI().tgtWeightsSum();
|
|
||||||
|
|
||||||
const vectorField& faceAreas0 = cp.faceAreas0();
|
const vectorField& faceAreas0 = cp.faceAreas0();
|
||||||
|
|
||||||
vectorField::subField Sf = cp.faceAreas();
|
vectorField::subField Sf = cp.faceAreas();
|
||||||
@ -125,11 +123,8 @@ void Foam::cyclicACMIPolyPatch::setNeighbourFaceAreas() const
|
|||||||
|
|
||||||
forAll(Sf, faceI)
|
forAll(Sf, faceI)
|
||||||
{
|
{
|
||||||
scalar w = tgtWeightSum[faceI];
|
Sf[faceI] = tgtMask_[faceI]*faceAreas0[faceI];
|
||||||
w = min(1.0 - tolerance_, max(tolerance_, w));
|
noSf[faceI] = (1.0 - tgtMask_[faceI])*faceAreas0[faceI];
|
||||||
|
|
||||||
Sf[faceI] = w*faceAreas0[faceI];
|
|
||||||
noSf[faceI] = (1.0 - w)*faceAreas0[faceI];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,6 +179,18 @@ void Foam::cyclicACMIPolyPatch::clearGeom()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::scalarField& Foam::cyclicACMIPolyPatch::srcMask() const
|
||||||
|
{
|
||||||
|
return srcMask_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::scalarField& Foam::cyclicACMIPolyPatch::tgtMask() const
|
||||||
|
{
|
||||||
|
return tgtMask_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
|
Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
|
||||||
@ -201,6 +208,8 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
|
|||||||
faceAreas0_(),
|
faceAreas0_(),
|
||||||
nonOverlapPatchName_(word::null),
|
nonOverlapPatchName_(word::null),
|
||||||
nonOverlapPatchID_(-1),
|
nonOverlapPatchID_(-1),
|
||||||
|
srcMask_(),
|
||||||
|
tgtMask_(),
|
||||||
updated_(false)
|
updated_(false)
|
||||||
{
|
{
|
||||||
// Non-overlapping patch might not be valid yet so cannot determine
|
// Non-overlapping patch might not be valid yet so cannot determine
|
||||||
@ -221,6 +230,8 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
|
|||||||
faceAreas0_(),
|
faceAreas0_(),
|
||||||
nonOverlapPatchName_(dict.lookup("nonOverlapPatch")),
|
nonOverlapPatchName_(dict.lookup("nonOverlapPatch")),
|
||||||
nonOverlapPatchID_(-1),
|
nonOverlapPatchID_(-1),
|
||||||
|
srcMask_(),
|
||||||
|
tgtMask_(),
|
||||||
updated_(false)
|
updated_(false)
|
||||||
{
|
{
|
||||||
if (nonOverlapPatchName_ == name)
|
if (nonOverlapPatchName_ == name)
|
||||||
@ -256,6 +267,8 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
|
|||||||
faceAreas0_(),
|
faceAreas0_(),
|
||||||
nonOverlapPatchName_(pp.nonOverlapPatchName_),
|
nonOverlapPatchName_(pp.nonOverlapPatchName_),
|
||||||
nonOverlapPatchID_(-1),
|
nonOverlapPatchID_(-1),
|
||||||
|
srcMask_(),
|
||||||
|
tgtMask_(),
|
||||||
updated_(false)
|
updated_(false)
|
||||||
{
|
{
|
||||||
// Non-overlapping patch might not be valid yet so cannot determine
|
// Non-overlapping patch might not be valid yet so cannot determine
|
||||||
@ -278,6 +291,8 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
|
|||||||
faceAreas0_(),
|
faceAreas0_(),
|
||||||
nonOverlapPatchName_(nonOverlapPatchName),
|
nonOverlapPatchName_(nonOverlapPatchName),
|
||||||
nonOverlapPatchID_(-1),
|
nonOverlapPatchID_(-1),
|
||||||
|
srcMask_(),
|
||||||
|
tgtMask_(),
|
||||||
updated_(false)
|
updated_(false)
|
||||||
{
|
{
|
||||||
if (nonOverlapPatchName_ == name())
|
if (nonOverlapPatchName_ == name())
|
||||||
@ -314,6 +329,8 @@ Foam::cyclicACMIPolyPatch::cyclicACMIPolyPatch
|
|||||||
faceAreas0_(),
|
faceAreas0_(),
|
||||||
nonOverlapPatchName_(pp.nonOverlapPatchName_),
|
nonOverlapPatchName_(pp.nonOverlapPatchName_),
|
||||||
nonOverlapPatchID_(-1),
|
nonOverlapPatchID_(-1),
|
||||||
|
srcMask_(),
|
||||||
|
tgtMask_(),
|
||||||
updated_(false)
|
updated_(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -326,6 +343,13 @@ Foam::cyclicACMIPolyPatch::~cyclicACMIPolyPatch()
|
|||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::cyclicACMIPolyPatch& Foam::cyclicACMIPolyPatch::neighbPatch() const
|
||||||
|
{
|
||||||
|
const polyPatch& pp = this->boundaryMesh()[neighbPatchID()];
|
||||||
|
return refCast<const cyclicACMIPolyPatch>(pp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::cyclicACMIPolyPatch::nonOverlapPatchID() const
|
Foam::label Foam::cyclicACMIPolyPatch::nonOverlapPatchID() const
|
||||||
{
|
{
|
||||||
if (nonOverlapPatchID_ == -1)
|
if (nonOverlapPatchID_ == -1)
|
||||||
|
|||||||
@ -66,6 +66,12 @@ private:
|
|||||||
//- Index of non-overlapping patch
|
//- Index of non-overlapping patch
|
||||||
mutable label nonOverlapPatchID_;
|
mutable label nonOverlapPatchID_;
|
||||||
|
|
||||||
|
//- Mask/weighting for source patch
|
||||||
|
mutable scalarField srcMask_;
|
||||||
|
|
||||||
|
//- Mask/weighting for target patch
|
||||||
|
mutable scalarField tgtMask_;
|
||||||
|
|
||||||
//- Flag to indicate that AMI has been updated
|
//- Flag to indicate that AMI has been updated
|
||||||
mutable bool updated_;
|
mutable bool updated_;
|
||||||
|
|
||||||
@ -111,6 +117,12 @@ protected:
|
|||||||
//- Clear geometry
|
//- Clear geometry
|
||||||
virtual void clearGeom();
|
virtual void clearGeom();
|
||||||
|
|
||||||
|
//- Return the mask/weighting for the source patch
|
||||||
|
virtual const scalarField& srcMask() const;
|
||||||
|
|
||||||
|
//- Return the mask/weighting for the target patch
|
||||||
|
virtual const scalarField& tgtMask() const;
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -245,6 +257,9 @@ public:
|
|||||||
//- Return access to the original patch face areas
|
//- Return access to the original patch face areas
|
||||||
inline const vectorField& faceAreas0() const;
|
inline const vectorField& faceAreas0() const;
|
||||||
|
|
||||||
|
//- Return a reference to the neighbour patch
|
||||||
|
virtual const cyclicACMIPolyPatch& neighbPatch() const;
|
||||||
|
|
||||||
//- Non-overlapping patch name
|
//- Non-overlapping patch name
|
||||||
inline const word& nonOverlapPatchName() const;
|
inline const word& nonOverlapPatchName() const;
|
||||||
|
|
||||||
|
|||||||
@ -67,15 +67,15 @@ inline Foam::polyPatch& Foam::cyclicACMIPolyPatch::nonOverlapPatch()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::scalarField& Foam::cyclicACMIPolyPatch::mask() const
|
inline const scalarField& Foam::cyclicACMIPolyPatch::mask() const
|
||||||
{
|
{
|
||||||
if (owner())
|
if (owner())
|
||||||
{
|
{
|
||||||
return AMI().srcWeightsSum();
|
return srcMask_;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return neighbPatch().AMI().tgtWeightsSum();
|
return neighbPatch().tgtMask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,7 +34,7 @@ Foam::tmp<Foam::Field<Type> > Foam::cyclicACMIPolyPatch::interpolate
|
|||||||
{
|
{
|
||||||
if (owner())
|
if (owner())
|
||||||
{
|
{
|
||||||
const scalarField& w = AMI().srcWeightsSum();
|
const scalarField& w = srcMask_;
|
||||||
|
|
||||||
return
|
return
|
||||||
w*AMI().interpolateToSource(fldCouple)
|
w*AMI().interpolateToSource(fldCouple)
|
||||||
@ -42,7 +42,7 @@ Foam::tmp<Foam::Field<Type> > Foam::cyclicACMIPolyPatch::interpolate
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const scalarField& w = neighbPatch().AMI().tgtWeightsSum();
|
const scalarField& w = neighbPatch().tgtMask();
|
||||||
|
|
||||||
return
|
return
|
||||||
w*neighbPatch().AMI().interpolateToTarget(fldCouple)
|
w*neighbPatch().AMI().interpolateToTarget(fldCouple)
|
||||||
@ -73,14 +73,14 @@ void Foam::cyclicACMIPolyPatch::interpolate
|
|||||||
{
|
{
|
||||||
if (owner())
|
if (owner())
|
||||||
{
|
{
|
||||||
const scalarField& w = AMI().srcWeightsSum();
|
const scalarField& w = srcMask_;
|
||||||
|
|
||||||
AMI().interpolateToSource(fldCouple, cop, result);
|
AMI().interpolateToSource(fldCouple, cop, result);
|
||||||
result = w*result + (1.0 - w)*fldNonOverlap;
|
result = w*result + (1.0 - w)*fldNonOverlap;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const scalarField& w = neighbPatch().AMI().tgtWeightsSum();
|
const scalarField& w = neighbPatch().tgtMask();
|
||||||
|
|
||||||
neighbPatch().AMI().interpolateToTarget(fldCouple, cop, result);
|
neighbPatch().AMI().interpolateToTarget(fldCouple, cop, result);
|
||||||
result = w*result + (1.0 - w)*fldNonOverlap;
|
result = w*result + (1.0 - w)*fldNonOverlap;
|
||||||
|
|||||||
@ -642,6 +642,13 @@ bool Foam::cyclicAMIPolyPatch::owner() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::cyclicAMIPolyPatch& Foam::cyclicAMIPolyPatch::neighbPatch() const
|
||||||
|
{
|
||||||
|
const polyPatch& pp = this->boundaryMesh()[neighbPatchID()];
|
||||||
|
return refCast<const cyclicAMIPolyPatch>(pp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const Foam::autoPtr<Foam::searchableSurface>&
|
const Foam::autoPtr<Foam::searchableSurface>&
|
||||||
Foam::cyclicAMIPolyPatch::surfPtr() const
|
Foam::cyclicAMIPolyPatch::surfPtr() const
|
||||||
{
|
{
|
||||||
|
|||||||
@ -284,7 +284,7 @@ public:
|
|||||||
virtual bool owner() const;
|
virtual bool owner() const;
|
||||||
|
|
||||||
//- Return a reference to the neighbour patch
|
//- Return a reference to the neighbour patch
|
||||||
inline const cyclicAMIPolyPatch& neighbPatch() const;
|
virtual const cyclicAMIPolyPatch& neighbPatch() const;
|
||||||
|
|
||||||
//- Return a reference to the projection surface
|
//- Return a reference to the projection surface
|
||||||
const autoPtr<searchableSurface>& surfPtr() const;
|
const autoPtr<searchableSurface>& surfPtr() const;
|
||||||
|
|||||||
@ -38,14 +38,6 @@ inline const Foam::word& Foam::cyclicAMIPolyPatch::neighbPatchName() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::cyclicAMIPolyPatch&
|
|
||||||
Foam::cyclicAMIPolyPatch::neighbPatch() const
|
|
||||||
{
|
|
||||||
const polyPatch& pp = this->boundaryMesh()[neighbPatchID()];
|
|
||||||
return refCast<const cyclicAMIPolyPatch>(pp);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
inline const Foam::vector& Foam::cyclicAMIPolyPatch::rotationAxis() const
|
inline const Foam::vector& Foam::cyclicAMIPolyPatch::rotationAxis() const
|
||||||
{
|
{
|
||||||
return rotationAxis_;
|
return rotationAxis_;
|
||||||
|
|||||||
Reference in New Issue
Block a user