Compare commits
6 Commits
develop
...
feature-am
| Author | SHA1 | Date | |
|---|---|---|---|
| 1307c4eb2e | |||
| de8dd7a5cf | |||
| a083ebb7bf | |||
| 279abca7fa | |||
| 8c89c8f417 | |||
| e44184e626 |
@ -44,6 +44,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
|||||||
cyclicAMILduInterfaceField(),
|
cyclicAMILduInterfaceField(),
|
||||||
coupledFvPatchField<Type>(p, iF),
|
coupledFvPatchField<Type>(p, iF),
|
||||||
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p)),
|
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p)),
|
||||||
|
lowWeightOption_(lowWeightCorrectionBase::option::ASSIGN),
|
||||||
patchNeighbourFieldPtr_(nullptr)
|
patchNeighbourFieldPtr_(nullptr)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
@ -59,6 +60,15 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
|||||||
cyclicAMILduInterfaceField(),
|
cyclicAMILduInterfaceField(),
|
||||||
coupledFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
|
coupledFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
|
||||||
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p, dict)),
|
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p, dict)),
|
||||||
|
lowWeightOption_
|
||||||
|
(
|
||||||
|
lowWeightCorrectionBase::optionNames_.getOrDefault
|
||||||
|
(
|
||||||
|
"lowWeightOption",
|
||||||
|
dict,
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
|
)
|
||||||
|
),
|
||||||
patchNeighbourFieldPtr_(nullptr)
|
patchNeighbourFieldPtr_(nullptr)
|
||||||
{
|
{
|
||||||
if (!isA<cyclicAMIFvPatch>(p))
|
if (!isA<cyclicAMIFvPatch>(p))
|
||||||
@ -114,6 +124,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
|||||||
cyclicAMILduInterfaceField(),
|
cyclicAMILduInterfaceField(),
|
||||||
coupledFvPatchField<Type>(ptf, p, iF, mapper),
|
coupledFvPatchField<Type>(ptf, p, iF, mapper),
|
||||||
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p)),
|
cyclicAMIPatch_(refCast<const cyclicAMIFvPatch>(p)),
|
||||||
|
lowWeightOption_(ptf.lowWeightOption_),
|
||||||
patchNeighbourFieldPtr_(nullptr)
|
patchNeighbourFieldPtr_(nullptr)
|
||||||
{
|
{
|
||||||
//if (ptf.patchNeighbourFieldPtr_ && cacheNeighbourField())
|
//if (ptf.patchNeighbourFieldPtr_ && cacheNeighbourField())
|
||||||
@ -152,6 +163,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
|||||||
cyclicAMILduInterfaceField(),
|
cyclicAMILduInterfaceField(),
|
||||||
coupledFvPatchField<Type>(ptf),
|
coupledFvPatchField<Type>(ptf),
|
||||||
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
||||||
|
lowWeightOption_(ptf.lowWeightOption_),
|
||||||
patchNeighbourFieldPtr_(nullptr)
|
patchNeighbourFieldPtr_(nullptr)
|
||||||
{
|
{
|
||||||
if (debug && !ptf.all_ready())
|
if (debug && !ptf.all_ready())
|
||||||
@ -173,6 +185,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
|||||||
cyclicAMILduInterfaceField(),
|
cyclicAMILduInterfaceField(),
|
||||||
coupledFvPatchField<Type>(ptf, iF),
|
coupledFvPatchField<Type>(ptf, iF),
|
||||||
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
cyclicAMIPatch_(ptf.cyclicAMIPatch_),
|
||||||
|
lowWeightOption_(ptf.lowWeightOption_),
|
||||||
patchNeighbourFieldPtr_(nullptr)
|
patchNeighbourFieldPtr_(nullptr)
|
||||||
{
|
{
|
||||||
if (debug && !ptf.all_ready())
|
if (debug && !ptf.all_ready())
|
||||||
@ -298,7 +311,8 @@ Foam::cyclicAMIFvPatchField<Type>::patchNeighbourField
|
|||||||
defaultValues = Field<Type>(iField, cyclicAMIPatch_.faceCells());
|
defaultValues = Field<Type>(iField, cyclicAMIPatch_.faceCells());
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp<Field<Type>> tpnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
|
tmp<Field<Type>> tpnf =
|
||||||
|
cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_);
|
||||||
|
|
||||||
if (doTransform())
|
if (doTransform())
|
||||||
{
|
{
|
||||||
@ -526,7 +540,8 @@ void Foam::cyclicAMIFvPatchField<Type>::evaluate
|
|||||||
Field<Type>::null(), // Not used for distributed
|
Field<Type>::null(), // Not used for distributed
|
||||||
recvRequests_,
|
recvRequests_,
|
||||||
recvBufs_,
|
recvBufs_,
|
||||||
defaultValues
|
defaultValues,
|
||||||
|
lowWeightOption_
|
||||||
).ptr()
|
).ptr()
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -652,7 +667,8 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
|
|||||||
solveScalarField::null(), // Not used for distributed
|
solveScalarField::null(), // Not used for distributed
|
||||||
recvRequests_,
|
recvRequests_,
|
||||||
scalarRecvBufs_,
|
scalarRecvBufs_,
|
||||||
defaultValues
|
defaultValues,
|
||||||
|
lowWeightOption_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Receive requests all handled by last function call
|
// Receive requests all handled by last function call
|
||||||
@ -674,7 +690,7 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
|
|||||||
// Transform according to the transformation tensors
|
// Transform according to the transformation tensors
|
||||||
transformCoupleField(pnf, cmpt);
|
transformCoupleField(pnf, cmpt);
|
||||||
|
|
||||||
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
|
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply the field by coefficients and add into the result
|
// Multiply the field by coefficients and add into the result
|
||||||
@ -786,7 +802,8 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
|
|||||||
Field<Type>::null(), // Not used for distributed
|
Field<Type>::null(), // Not used for distributed
|
||||||
recvRequests_,
|
recvRequests_,
|
||||||
recvBufs_,
|
recvBufs_,
|
||||||
defaultValues
|
defaultValues,
|
||||||
|
lowWeightOption_
|
||||||
);
|
);
|
||||||
|
|
||||||
// Receive requests all handled by last function call
|
// Receive requests all handled by last function call
|
||||||
@ -808,7 +825,7 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix
|
|||||||
defaultValues = Field<Type>(psiInternal, faceCells);
|
defaultValues = Field<Type>(psiInternal, faceCells);
|
||||||
}
|
}
|
||||||
|
|
||||||
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues);
|
pnf = cyclicAMIPatch_.interpolate(pnf, defaultValues, lowWeightOption_);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply the field by coefficients and add into the result
|
// Multiply the field by coefficients and add into the result
|
||||||
@ -994,6 +1011,12 @@ void Foam::cyclicAMIFvPatchField<Type>::write(Ostream& os) const
|
|||||||
{
|
{
|
||||||
patchNeighbourFieldPtr_->writeEntry("neighbourValue", os);
|
patchNeighbourFieldPtr_->writeEntry("neighbourValue", os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
os.writeEntry
|
||||||
|
(
|
||||||
|
"lowWeightOption",
|
||||||
|
lowWeightCorrectionBase::optionNames_[lowWeightOption_]
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -71,6 +71,7 @@ SourceFiles
|
|||||||
#include "cyclicAMIFvPatch.H"
|
#include "cyclicAMIFvPatch.H"
|
||||||
#include "coupledFvPatchField.H"
|
#include "coupledFvPatchField.H"
|
||||||
#include "cyclicAMILduInterfaceField.H"
|
#include "cyclicAMILduInterfaceField.H"
|
||||||
|
#include "lowWeightCorrectionBase.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -92,6 +93,10 @@ class cyclicAMIFvPatchField
|
|||||||
//- Local reference cast into the cyclic patch
|
//- Local reference cast into the cyclic patch
|
||||||
const cyclicAMIFvPatch& cyclicAMIPatch_;
|
const cyclicAMIFvPatch& cyclicAMIPatch_;
|
||||||
|
|
||||||
|
//- Low weight correction mode
|
||||||
|
// Default: assign (same as v2312 and earlier)
|
||||||
|
lowWeightCorrectionBase::option lowWeightOption_;
|
||||||
|
|
||||||
|
|
||||||
// Sending and receiving (distributed AMI)
|
// Sending and receiving (distributed AMI)
|
||||||
|
|
||||||
|
|||||||
@ -29,6 +29,7 @@ License
|
|||||||
#include "addToRunTimeSelectionTable.H"
|
#include "addToRunTimeSelectionTable.H"
|
||||||
#include "faceAreaWeightAMI.H"
|
#include "faceAreaWeightAMI.H"
|
||||||
#include "turbulentDFSEMInletFvPatchVectorField.H"
|
#include "turbulentDFSEMInletFvPatchVectorField.H"
|
||||||
|
#include "AMIFieldOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -82,14 +83,8 @@ void Foam::turbulentDigitalFilterInletFvPatchField<Type>::mapL
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Map two-point correlations (integral scales)
|
// Map two-point correlations (integral scales)
|
||||||
plusEqOp<Type> cop;
|
AMIMultiplyWeightedOp<Type> cop(AMIPtr_(), true);
|
||||||
AMIPtr_->interpolateToSource
|
AMIPtr_->interpolate(sourceFld, cop, fld, UList<Type>::null());
|
||||||
(
|
|
||||||
sourceFld,
|
|
||||||
multiplyWeightedOp<Type, plusEqOp<Type>>(cop),
|
|
||||||
fld,
|
|
||||||
UList<Type>::null()
|
|
||||||
);
|
|
||||||
|
|
||||||
// Map forward-stepwise method correlations if requested
|
// Map forward-stepwise method correlations if requested
|
||||||
if (L_.fsm())
|
if (L_.fsm())
|
||||||
|
|||||||
@ -100,12 +100,19 @@ void Foam::cyclicACMIFvPatch::makeWeights(scalarField& w) const
|
|||||||
|
|
||||||
// These deltas are of the cyclic part alone - they are
|
// These deltas are of the cyclic part alone - they are
|
||||||
// not affected by the amount of overlap with the nonOverlapPatch
|
// not affected by the amount of overlap with the nonOverlapPatch
|
||||||
scalarField nbrDeltas
|
scalarField nbrDeltas;
|
||||||
|
|
||||||
|
const auto& AMI = owner() ? this->AMI() : nbrPatch.AMI();
|
||||||
|
|
||||||
|
// Multiply-weighted op - no low weight correction
|
||||||
|
auto cop = AMIMultiplyWeightedOp<scalar>(AMI, owner());
|
||||||
|
|
||||||
|
AMI.interpolate
|
||||||
(
|
(
|
||||||
interpolate
|
(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta())(),
|
||||||
(
|
cop,
|
||||||
nbrPatch.nf() & nbrPatch.coupledFvPatch::delta()
|
nbrDeltas,
|
||||||
)
|
UList<scalar>()
|
||||||
);
|
);
|
||||||
|
|
||||||
const scalar tol = cyclicACMIPolyPatch::tolerance();
|
const scalar tol = cyclicACMIPolyPatch::tolerance();
|
||||||
@ -244,31 +251,35 @@ Foam::tmp<Foam::vectorField> Foam::cyclicACMIFvPatch::delta() const
|
|||||||
|
|
||||||
const vectorField patchD(coupledFvPatch::delta());
|
const vectorField patchD(coupledFvPatch::delta());
|
||||||
|
|
||||||
vectorField nbrPatchD(interpolate(nbrPatch.coupledFvPatch::delta()));
|
const auto& AMI = owner() ? this->AMI() : nbrPatch.AMI();
|
||||||
|
|
||||||
|
// Multiply-weighted op - no low weight correction
|
||||||
|
auto cop = AMIMultiplyWeightedOp<vector>(AMI, owner());
|
||||||
|
|
||||||
|
vectorField nbrPatchD;
|
||||||
|
AMI.interpolate
|
||||||
|
(
|
||||||
|
nbrPatch.coupledFvPatch::delta()(),
|
||||||
|
cop,
|
||||||
|
nbrPatchD,
|
||||||
|
UList<vector>()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Do the transformation if necessary
|
||||||
|
if (!parallel())
|
||||||
|
{
|
||||||
|
transform(nbrPatchD, forwardT()[0], nbrPatchD);
|
||||||
|
}
|
||||||
|
|
||||||
auto tpdv = tmp<vectorField>::New(patchD.size());
|
auto tpdv = tmp<vectorField>::New(patchD.size());
|
||||||
vectorField& pdv = tpdv.ref();
|
vectorField& pdv = tpdv.ref();
|
||||||
|
|
||||||
// do the transformation if necessary
|
forAll(patchD, facei)
|
||||||
if (parallel())
|
|
||||||
{
|
{
|
||||||
forAll(patchD, facei)
|
const vector& ddi = patchD[facei];
|
||||||
{
|
const vector& dni = nbrPatchD[facei];
|
||||||
const vector& ddi = patchD[facei];
|
pdv[facei] = ddi - dni;
|
||||||
const vector& dni = nbrPatchD[facei];
|
pdv[facei] = ddi - dni;
|
||||||
|
|
||||||
pdv[facei] = ddi - dni;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(patchD, facei)
|
|
||||||
{
|
|
||||||
const vector& ddi = patchD[facei];
|
|
||||||
const vector& dni = nbrPatchD[facei];
|
|
||||||
|
|
||||||
pdv[facei] = ddi - transform(forwardT()[0], dni);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tpdv;
|
return tpdv;
|
||||||
|
|||||||
@ -251,7 +251,7 @@ public:
|
|||||||
localFld,
|
localFld,
|
||||||
requests,
|
requests,
|
||||||
recvBuffers,
|
recvBuffers,
|
||||||
UList<Type>()
|
UList<Type>::null()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,32 +97,50 @@ void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const
|
|||||||
{
|
{
|
||||||
const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
|
const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
|
||||||
|
|
||||||
const scalarField deltas(nf() & coupledFvPatch::delta());
|
const auto& AMI = owner() ? this->AMI() : nbrPatch.AMI();
|
||||||
|
|
||||||
tmp<scalarField> tnbrDeltas;
|
auto tnbrDeltas = tmp<scalarField>::New();
|
||||||
if (applyLowWeightCorrection())
|
if (applyLowWeightCorrection())
|
||||||
{
|
{
|
||||||
tnbrDeltas =
|
// Use 'assign' correction for geometric interpolation
|
||||||
interpolate
|
auto cop = AMICorrectedMultiplyWeightedOp<scalar>
|
||||||
(
|
(
|
||||||
nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(),
|
AMI,
|
||||||
scalarField(this->size(), 1.0)
|
owner(),
|
||||||
);
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
|
);
|
||||||
|
|
||||||
|
// Faces with invalid interpolation weights converted to one-sided
|
||||||
|
AMI.interpolate
|
||||||
|
(
|
||||||
|
(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta())(),
|
||||||
|
cop,
|
||||||
|
tnbrDeltas.ref(),
|
||||||
|
scalarList(this->size(), 1.0)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tnbrDeltas =
|
// Multiply-weighted op - no low weight correction
|
||||||
interpolate(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta());
|
auto cop = AMIMultiplyWeightedOp<scalar>(AMI, owner());
|
||||||
|
|
||||||
|
AMI.interpolate
|
||||||
|
(
|
||||||
|
(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta())(),
|
||||||
|
cop,
|
||||||
|
tnbrDeltas.ref(),
|
||||||
|
UList<scalar>::null()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const scalarField& nbrDeltas = tnbrDeltas();
|
const scalarField& nbrDeltas = tnbrDeltas();
|
||||||
|
const scalarField deltas(nf() & coupledFvPatch::delta());
|
||||||
|
|
||||||
forAll(deltas, facei)
|
forAll(deltas, facei)
|
||||||
{
|
{
|
||||||
// Note use of mag
|
// Note use of mag
|
||||||
scalar di = mag(deltas[facei]);
|
scalar di = mag(deltas[facei]);
|
||||||
scalar dni = mag(nbrDeltas[facei]);
|
scalar dni = mag(nbrDeltas[facei]);
|
||||||
|
|
||||||
w[facei] = dni/(di + dni);
|
w[facei] = dni/(di + dni);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -162,46 +180,58 @@ Foam::tmp<Foam::vectorField> Foam::cyclicAMIFvPatch::delta() const
|
|||||||
{
|
{
|
||||||
const vectorField patchD(coupledFvPatch::delta());
|
const vectorField patchD(coupledFvPatch::delta());
|
||||||
|
|
||||||
tmp<vectorField> tnbrPatchD;
|
const auto& AMI = owner() ? this->AMI() : nbrPatch.AMI();
|
||||||
|
|
||||||
|
auto tnbrPatchD = tmp<vectorField>::New();
|
||||||
if (applyLowWeightCorrection())
|
if (applyLowWeightCorrection())
|
||||||
{
|
{
|
||||||
tnbrPatchD =
|
// Use 'assign' correction for geometric interpolation
|
||||||
interpolate
|
auto cop = AMICorrectedMultiplyWeightedOp<vector>
|
||||||
(
|
(
|
||||||
nbrPatch.coupledFvPatch::delta(),
|
AMI,
|
||||||
vectorField(this->size(), Zero)
|
owner(),
|
||||||
);
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
|
);
|
||||||
|
|
||||||
|
// Faces with invalid interpolation weights converted to one-sided
|
||||||
|
AMI.interpolate
|
||||||
|
(
|
||||||
|
nbrPatch.coupledFvPatch::delta()(),
|
||||||
|
cop,
|
||||||
|
tnbrPatchD.ref(),
|
||||||
|
vectorField(this->size(), Zero)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
tnbrPatchD = interpolate(nbrPatch.coupledFvPatch::delta());
|
// Multiply-weighted op - no low weight correction
|
||||||
|
auto cop = AMIMultiplyWeightedOp<vector>(AMI, owner());
|
||||||
|
|
||||||
|
AMI.interpolate
|
||||||
|
(
|
||||||
|
nbrPatch.coupledFvPatch::delta()(),
|
||||||
|
cop,
|
||||||
|
tnbrPatchD.ref(),
|
||||||
|
UList<vector>::null()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const vectorField& nbrPatchD = tnbrPatchD();
|
vectorField& nbrPatchD = tnbrPatchD.ref();
|
||||||
|
|
||||||
|
// Do the transformation if necessary
|
||||||
|
if (!parallel())
|
||||||
|
{
|
||||||
|
transform(nbrPatchD, forwardT()[0], nbrPatchD);
|
||||||
|
}
|
||||||
|
|
||||||
auto tpdv = tmp<vectorField>::New(patchD.size());
|
auto tpdv = tmp<vectorField>::New(patchD.size());
|
||||||
vectorField& pdv = tpdv.ref();
|
vectorField& pdv = tpdv.ref();
|
||||||
|
|
||||||
// do the transformation if necessary
|
forAll(patchD, facei)
|
||||||
if (parallel())
|
|
||||||
{
|
{
|
||||||
forAll(patchD, facei)
|
const vector& ddi = patchD[facei];
|
||||||
{
|
const vector& dni = nbrPatchD[facei];
|
||||||
const vector& ddi = patchD[facei];
|
pdv[facei] = ddi - dni;
|
||||||
const vector& dni = nbrPatchD[facei];
|
|
||||||
|
|
||||||
pdv[facei] = ddi - dni;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
forAll(patchD, facei)
|
|
||||||
{
|
|
||||||
const vector& ddi = patchD[facei];
|
|
||||||
const vector& dni = nbrPatchD[facei];
|
|
||||||
|
|
||||||
pdv[facei] = ddi - transform(forwardT()[0], dni);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return tpdv;
|
return tpdv;
|
||||||
|
|||||||
@ -217,20 +217,34 @@ public:
|
|||||||
tmp<Field<Type>> interpolate
|
tmp<Field<Type>> interpolate
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues = UList<Type>()
|
const UList<Type>& defaultValues = UList<Type>::null(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return cyclicAMIPolyPatch_.interpolate(fld, defaultValues);
|
return cyclicAMIPolyPatch_.interpolate
|
||||||
|
(
|
||||||
|
fld,
|
||||||
|
defaultValues,
|
||||||
|
lwOption
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
tmp<Field<Type>> interpolate
|
tmp<Field<Type>> interpolate
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const UList<Type>& defaultValues = UList<Type>()
|
const UList<Type>& defaultValues = UList<Type>::null(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return cyclicAMIPolyPatch_.interpolate(tFld, defaultValues);
|
return cyclicAMIPolyPatch_.interpolate
|
||||||
|
(
|
||||||
|
tFld,
|
||||||
|
defaultValues,
|
||||||
|
lwOption
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,114 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2024 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::AMIFieldOP
|
||||||
|
|
||||||
|
Description
|
||||||
|
General template for AMI field operations
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef AMIFieldOp_H
|
||||||
|
#define AMIFieldOp_H
|
||||||
|
|
||||||
|
#include "AMIFieldOpBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class AMIFieldOp Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type, class CombineOp>
|
||||||
|
class AMIFieldOp
|
||||||
|
:
|
||||||
|
public AMIFieldOpBase
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Combine operator, e.g. plusEqOp<Type>()
|
||||||
|
// Note: must be null-constructed
|
||||||
|
CombineOp cop_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef Type value_type;
|
||||||
|
|
||||||
|
//- Constructor
|
||||||
|
AMIFieldOp(const AMIInterpolation& ami, bool toSource)
|
||||||
|
:
|
||||||
|
AMIFieldOpBase(ami, toSource),
|
||||||
|
cop_()
|
||||||
|
{}
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~AMIFieldOp() = default;
|
||||||
|
|
||||||
|
|
||||||
|
//- Apply the op
|
||||||
|
// Note: does not use default values
|
||||||
|
void operator()
|
||||||
|
(
|
||||||
|
List<value_type>& result,
|
||||||
|
const UList<value_type>& fld,
|
||||||
|
const UList<value_type>& /* unused defaultValues */
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const auto& address = this->address();
|
||||||
|
|
||||||
|
forAll(result, facei)
|
||||||
|
{
|
||||||
|
const labelList& faceSlots = address[facei];
|
||||||
|
|
||||||
|
forAll(faceSlots, i)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
result[facei] = fld[faceSlots[i]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cop_(result[facei], fld[faceSlots[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,105 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2024 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::AMIFieldOpBase
|
||||||
|
|
||||||
|
Description
|
||||||
|
Base class for AMI field operations
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef AMIFieldOpsBase_H
|
||||||
|
#define AMIFieldOpsBase_H
|
||||||
|
|
||||||
|
#include "AMIInterpolation.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class AMIFieldOpBase Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class AMIFieldOpBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
//- Reference to the AMI
|
||||||
|
const AMIInterpolation& ami_;
|
||||||
|
|
||||||
|
//- Interpolation to source; false=interpolate to target
|
||||||
|
const bool toSource_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Constructor
|
||||||
|
AMIFieldOpBase(const AMIInterpolation& ami, const bool toSource)
|
||||||
|
:
|
||||||
|
ami_(ami),
|
||||||
|
toSource_(toSource)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Return the 'toSource' flag
|
||||||
|
bool toSource() const
|
||||||
|
{
|
||||||
|
return toSource_;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the AMI addressing
|
||||||
|
const labelListList& address() const
|
||||||
|
{
|
||||||
|
return toSource_ ? ami_.srcAddress() : ami_.tgtAddress();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the AMI weights
|
||||||
|
const scalarListList& weights() const
|
||||||
|
{
|
||||||
|
return toSource_ ? ami_.srcWeights() : ami_.tgtWeights();
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Return the AMI sum of weights
|
||||||
|
const scalarList& weightsSum() const
|
||||||
|
{
|
||||||
|
return toSource_ ? ami_.srcWeightsSum() : ami_.tgtWeightsSum();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,58 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2024 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef AMIFieldOps_H
|
||||||
|
#define AMIFieldOps_H
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#include "ops.H"
|
||||||
|
#include "AMIFieldOp.H"
|
||||||
|
#include "AMIMultiplyWeightedOp.H"
|
||||||
|
#include "LowWeightCorrection.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
using AMIMaxOp = AMIFieldOp<Type, maxEqOp<Type>>;
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
using AMIMinOp = AMIFieldOp<Type, minEqOp<Type>>;
|
||||||
|
|
||||||
|
template<class Type>
|
||||||
|
using AMICorrectedMultiplyWeightedOp =
|
||||||
|
LowWeightCorrection<AMIMultiplyWeightedOp<Type>, plusEqOp<Type>>;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,112 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2024 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef AMIMultiplyWeightedOp_H
|
||||||
|
#define AMIMultiplyWeightedOp_H
|
||||||
|
|
||||||
|
#include "AMIFieldOpBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class AMIMultiplyWeightedOp Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class Type, class CombineOp = plusEqOp<Type>>
|
||||||
|
class AMIMultiplyWeightedOp
|
||||||
|
:
|
||||||
|
public AMIFieldOpBase
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
//- Combine operator, e.g. plusEqOp<Type>()
|
||||||
|
// Note: must be null-constructed
|
||||||
|
CombineOp cop_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
typedef Type value_type;
|
||||||
|
|
||||||
|
|
||||||
|
//- Constructor
|
||||||
|
AMIMultiplyWeightedOp
|
||||||
|
(
|
||||||
|
const AMIInterpolation& ami,
|
||||||
|
const bool toSource
|
||||||
|
)
|
||||||
|
:
|
||||||
|
AMIFieldOpBase(ami, toSource),
|
||||||
|
cop_()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
//- Multiply-weighted op
|
||||||
|
// Note: does not use default values
|
||||||
|
void operator()
|
||||||
|
(
|
||||||
|
List<value_type>& result,
|
||||||
|
const UList<value_type>& fld,
|
||||||
|
const UList<value_type>& /* unused defaultValues */
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const auto& address = this->address();
|
||||||
|
const auto& weights = this->weights();
|
||||||
|
|
||||||
|
forAll(result, facei)
|
||||||
|
{
|
||||||
|
const labelList& faceSlots = address[facei];
|
||||||
|
const scalarList& faceWeights = weights[facei];
|
||||||
|
|
||||||
|
forAll(faceSlots, i)
|
||||||
|
{
|
||||||
|
if (i == 0)
|
||||||
|
{
|
||||||
|
result[facei] = faceWeights[i]*fld[faceSlots[i]];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cop_(result[facei], faceWeights[i]*fld[faceSlots[i]]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,176 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2024 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::LowWeightCorrection
|
||||||
|
|
||||||
|
Description
|
||||||
|
Wrapper around the AMI field op
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef LowWeightCorrection_H
|
||||||
|
#define LowWeightCorrection_H
|
||||||
|
|
||||||
|
#include "lowWeightCorrectionBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class LowWeightCorrection Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
template<class AMIOpType, class CombineOp>
|
||||||
|
class LowWeightCorrection
|
||||||
|
:
|
||||||
|
public lowWeightCorrectionBase,
|
||||||
|
public AMIOpType
|
||||||
|
{
|
||||||
|
typedef typename AMIOpType::value_type value_type;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Constructor
|
||||||
|
LowWeightCorrection
|
||||||
|
(
|
||||||
|
const AMIInterpolation& ami,
|
||||||
|
const bool toSource,
|
||||||
|
const lowWeightCorrectionBase::option& opt =
|
||||||
|
lowWeightCorrectionBase::option::NONE
|
||||||
|
)
|
||||||
|
:
|
||||||
|
lowWeightCorrectionBase(opt),
|
||||||
|
AMIOpType(ami, toSource)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Helper function to ensure default value field is valid
|
||||||
|
bool validDefaults(const UList<value_type>& defaultValues) const
|
||||||
|
{
|
||||||
|
const auto& ami = AMIOpType::ami_;
|
||||||
|
|
||||||
|
if (ami.lowWeightCorrection() > 0)
|
||||||
|
{
|
||||||
|
const auto& weightsSum = this->weightsSum();
|
||||||
|
|
||||||
|
if (defaultValues.size() != weightsSum.size())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Employing default values when sum of weights "
|
||||||
|
<< "falls below " << ami.lowWeightCorrection()
|
||||||
|
<< " but number of default values is not equal to "
|
||||||
|
<< "addressing size" << nl
|
||||||
|
<< " default values size = "
|
||||||
|
<< defaultValues.size() << nl
|
||||||
|
<< " addressing size = "
|
||||||
|
<< weightsSum.size() << nl
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//- Correction operator
|
||||||
|
void operator()
|
||||||
|
(
|
||||||
|
List<value_type>& result,
|
||||||
|
const UList<value_type>& fld,
|
||||||
|
const UList<value_type>& defaultValues
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Apply AMI interpolator
|
||||||
|
AMIOpType::operator()(result, fld, UList<value_type>::null());
|
||||||
|
|
||||||
|
if (!validDefaults(defaultValues)) return;
|
||||||
|
|
||||||
|
switch (opt_)
|
||||||
|
{
|
||||||
|
case option::NONE:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case option::ASSIGN:
|
||||||
|
{
|
||||||
|
const auto& ami = AMIOpType::ami_;
|
||||||
|
const auto& weightsSum = this->weightsSum();
|
||||||
|
|
||||||
|
forAll(result, facei)
|
||||||
|
{
|
||||||
|
if (weightsSum[facei] < ami.lowWeightCorrection())
|
||||||
|
{
|
||||||
|
// Assign default value
|
||||||
|
result[facei] = defaultValues[facei];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case option::BLEND:
|
||||||
|
{
|
||||||
|
const auto& ami = AMIOpType::ami_;
|
||||||
|
const auto& weightsSum = this->weightsSum();
|
||||||
|
|
||||||
|
forAll(result, facei)
|
||||||
|
{
|
||||||
|
if (weightsSum[facei] < ami.lowWeightCorrection())
|
||||||
|
{
|
||||||
|
// Already have 'weightSum' contribution in result
|
||||||
|
// - blend 'missing' contribution into result
|
||||||
|
const scalar w = min(1, max(0, weightsSum[facei]));
|
||||||
|
result[facei] += (1 - w)*defaultValues[facei];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Unhandled enumeration " << static_cast<int>(opt_)
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,49 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2024 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "lowWeightCorrectionBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
const Foam::Enum<Foam::lowWeightCorrectionBase::option>
|
||||||
|
Foam::lowWeightCorrectionBase::optionNames_
|
||||||
|
({
|
||||||
|
{ option::NONE, "none" },
|
||||||
|
{ option::ASSIGN, "assign" },
|
||||||
|
{ option::BLEND, "blend" },
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::lowWeightCorrectionBase::lowWeightCorrectionBase(const option& opt)
|
||||||
|
:
|
||||||
|
opt_(opt)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -0,0 +1,90 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2024 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::lowWeightCorrectionBase
|
||||||
|
|
||||||
|
Description
|
||||||
|
Base class for AMI low weight corrections
|
||||||
|
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef lowWeightCorrectionBase_H
|
||||||
|
#define lowWeightCorrectionBase_H
|
||||||
|
|
||||||
|
#include "Enum.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class lowWeightCorrectionBase Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class lowWeightCorrectionBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
enum class option
|
||||||
|
{
|
||||||
|
NONE,
|
||||||
|
ASSIGN,
|
||||||
|
BLEND
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Enum<option> optionNames_;
|
||||||
|
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected Data
|
||||||
|
|
||||||
|
//- Option
|
||||||
|
option opt_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Constructors
|
||||||
|
lowWeightCorrectionBase(const option& opt = option::NONE);
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
~lowWeightCorrectionBase() = default;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -1123,6 +1123,36 @@ void Foam::AMIInterpolation::normaliseWeights
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::AMIInterpolation::removeSourceConnection(const label facei)
|
||||||
|
{
|
||||||
|
if (facei < 0 || facei > srcAddress_.size())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Face index " << facei << " out of bonds"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
srcWeightsSum_[facei] = 0;
|
||||||
|
srcWeights_[facei].clear();
|
||||||
|
srcAddress_[facei].clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::AMIInterpolation::removeTargetConnection(const label facei)
|
||||||
|
{
|
||||||
|
if (facei < 0 || facei > tgtAddress_.size())
|
||||||
|
{
|
||||||
|
FatalErrorInFunction
|
||||||
|
<< "Face index " << facei << " out of bonds"
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
tgtWeightsSum_[facei] = 0;
|
||||||
|
tgtWeights_[facei].clear();
|
||||||
|
tgtAddress_[facei].clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Foam::label Foam::AMIInterpolation::srcPointFace
|
Foam::label Foam::AMIInterpolation::srcPointFace
|
||||||
(
|
(
|
||||||
const primitivePatch& srcPatch,
|
const primitivePatch& srcPatch,
|
||||||
|
|||||||
@ -61,7 +61,7 @@ SourceFiles
|
|||||||
#include "indexedOctree.H"
|
#include "indexedOctree.H"
|
||||||
#include "treeDataPrimitivePatch.H"
|
#include "treeDataPrimitivePatch.H"
|
||||||
#include "runTimeSelectionTables.H"
|
#include "runTimeSelectionTables.H"
|
||||||
|
#include "lowWeightCorrectionBase.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -512,39 +512,21 @@ public:
|
|||||||
//- Normalise the weights
|
//- Normalise the weights
|
||||||
void normaliseWeights(const bool conformal, const bool output);
|
void normaliseWeights(const bool conformal, const bool output);
|
||||||
|
|
||||||
|
//- Remove source face connection
|
||||||
|
void removeSourceConnection(const label facei);
|
||||||
|
|
||||||
|
//- Remove target face connection
|
||||||
|
void removeTargetConnection(const label facei);
|
||||||
|
|
||||||
|
|
||||||
// Evaluation
|
// Evaluation
|
||||||
|
|
||||||
// Low-level
|
// Low-level
|
||||||
|
|
||||||
//- Weighted sum of contributions
|
//- Interpolate with supplied op to combine existing value
|
||||||
|
//- with remote value and weight
|
||||||
template<class Type, class CombineOp>
|
template<class Type, class CombineOp>
|
||||||
static void weightedSum
|
void interpolate
|
||||||
(
|
|
||||||
const scalar lowWeightCorrection,
|
|
||||||
const labelListList& allSlots,
|
|
||||||
const scalarListList& allWeights,
|
|
||||||
const scalarField& weightsSum,
|
|
||||||
const UList<Type>& fld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
List<Type>& result,
|
|
||||||
const UList<Type>& defaultValues
|
|
||||||
);
|
|
||||||
|
|
||||||
//- Weighted sum of contributions
|
|
||||||
template<class Type>
|
|
||||||
void weightedSum
|
|
||||||
(
|
|
||||||
const bool interpolateToSource,
|
|
||||||
const UList<Type>& fld,
|
|
||||||
List<Type>& result,
|
|
||||||
const UList<Type>& defaultValues
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Interpolate from target to source with supplied op
|
|
||||||
//- to combine existing value with remote value and weight
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
void interpolateToSource
|
|
||||||
(
|
(
|
||||||
const UList<Type>& fld,
|
const UList<Type>& fld,
|
||||||
const CombineOp& cop,
|
const CombineOp& cop,
|
||||||
@ -552,48 +534,18 @@ public:
|
|||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
const UList<Type>& defaultValues = UList<Type>::null()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate from source to target with supplied op
|
//- Interpolate with supplied op
|
||||||
//- to combine existing value with remote value and weight
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
void interpolateToTarget
|
|
||||||
(
|
|
||||||
const UList<Type>& fld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
List<Type>& result,
|
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
|
||||||
) const;
|
|
||||||
|
|
||||||
|
|
||||||
//- Interpolate from target to source with supplied op
|
|
||||||
template<class Type, class CombineOp>
|
template<class Type, class CombineOp>
|
||||||
tmp<Field<Type>> interpolateToSource
|
tmp<Field<Type>> interpolate
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const CombineOp& cop,
|
const CombineOp& cop,
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
const UList<Type>& defaultValues = UList<Type>::null()
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate from target tmp field to source with supplied op
|
//- Interpolate with supplied op
|
||||||
template<class Type, class CombineOp>
|
template<class Type, class CombineOp>
|
||||||
tmp<Field<Type>> interpolateToSource
|
tmp<Field<Type>> interpolate
|
||||||
(
|
|
||||||
const tmp<Field<Type>>& tFld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Interpolate from source to target with supplied op
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
tmp<Field<Type>> interpolateToTarget
|
|
||||||
(
|
|
||||||
const Field<Type>& fld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
|
||||||
) const;
|
|
||||||
|
|
||||||
//- Interpolate from source tmp field to target with supplied op
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
tmp<Field<Type>> interpolateToTarget
|
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const CombineOp& cop,
|
const CombineOp& cop,
|
||||||
@ -605,7 +557,9 @@ public:
|
|||||||
tmp<Field<Type>> interpolateToSource
|
tmp<Field<Type>> interpolateToSource
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
const UList<Type>& defaultValues = UList<Type>::null(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate from target tmp field
|
//- Interpolate from target tmp field
|
||||||
@ -613,7 +567,9 @@ public:
|
|||||||
tmp<Field<Type>> interpolateToSource
|
tmp<Field<Type>> interpolateToSource
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
const UList<Type>& defaultValues = UList<Type>::null(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate from source to target
|
//- Interpolate from source to target
|
||||||
@ -621,7 +577,9 @@ public:
|
|||||||
tmp<Field<Type>> interpolateToTarget
|
tmp<Field<Type>> interpolateToTarget
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
const UList<Type>& defaultValues = UList<Type>::null(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate from source tmp field
|
//- Interpolate from source tmp field
|
||||||
@ -629,7 +587,9 @@ public:
|
|||||||
tmp<Field<Type>> interpolateToTarget
|
tmp<Field<Type>> interpolateToTarget
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const UList<Type>& defaultValues = UList<Type>::null()
|
const UList<Type>& defaultValues = UList<Type>::null(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -28,266 +28,80 @@ License
|
|||||||
|
|
||||||
#include "profiling.H"
|
#include "profiling.H"
|
||||||
#include "mapDistribute.H"
|
#include "mapDistribute.H"
|
||||||
|
#include "AMIFieldOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type, class CombineOp>
|
template<class Type, class CombineOp>
|
||||||
void Foam::AMIInterpolation::weightedSum
|
void Foam::AMIInterpolation::interpolate
|
||||||
(
|
(
|
||||||
const scalar lowWeightCorrection,
|
|
||||||
const labelListList& allSlots,
|
|
||||||
const scalarListList& allWeights,
|
|
||||||
const scalarField& weightsSum,
|
|
||||||
const UList<Type>& fld,
|
const UList<Type>& fld,
|
||||||
const CombineOp& cop,
|
const CombineOp& cop,
|
||||||
List<Type>& result,
|
List<Type>& result,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues
|
||||||
)
|
) const
|
||||||
{
|
{
|
||||||
if (lowWeightCorrection > 0)
|
addProfiling(ami, "AMIInterpolation::interpolate");
|
||||||
{
|
|
||||||
forAll(result, facei)
|
|
||||||
{
|
|
||||||
if (weightsSum[facei] < lowWeightCorrection)
|
|
||||||
{
|
|
||||||
result[facei] = defaultValues[facei];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
const labelList& slots = allSlots[facei];
|
|
||||||
const scalarList& weights = allWeights[facei];
|
|
||||||
|
|
||||||
forAll(slots, i)
|
label inSize = cop.toSource() ? tgtAddress_.size() : srcAddress_.size();
|
||||||
{
|
|
||||||
cop(result[facei], facei, fld[slots[i]], weights[i]);
|
if (fld.size() != inSize)
|
||||||
}
|
{
|
||||||
}
|
FatalErrorInFunction
|
||||||
}
|
<< "Supplied field size is not equal to expected field size ("
|
||||||
|
<< inSize << ")" << nl
|
||||||
|
<< " source patch = " << srcAddress_.size() << nl
|
||||||
|
<< " target patch = " << tgtAddress_.size() << nl
|
||||||
|
<< " supplied field = " << fld.size()
|
||||||
|
<< abort(FatalError);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
label outSize = cop.toSource() ? srcAddress_.size() : tgtAddress_.size();
|
||||||
|
result.resize_nocopy(outSize);
|
||||||
|
|
||||||
|
if (distributed())
|
||||||
|
{
|
||||||
|
const auto& map = cop.toSource() ? tgtMapPtr_() : srcMapPtr_();
|
||||||
|
List<Type> work = fld; // deep copy
|
||||||
|
map.distribute(work);
|
||||||
|
|
||||||
|
// Apply interpolation
|
||||||
|
cop(result, work, defaultValues);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
forAll(result, facei)
|
// Apply interpolation
|
||||||
{
|
cop(result, fld, defaultValues);
|
||||||
const labelList& slots = allSlots[facei];
|
|
||||||
const scalarList& weights = allWeights[facei];
|
|
||||||
|
|
||||||
forAll(slots, i)
|
|
||||||
{
|
|
||||||
cop(result[facei], facei, fld[slots[i]], weights[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
|
||||||
void Foam::AMIInterpolation::weightedSum
|
|
||||||
(
|
|
||||||
const bool interpolateToSource,
|
|
||||||
const UList<Type>& fld,
|
|
||||||
List<Type>& result,
|
|
||||||
const UList<Type>& defaultValues
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
weightedSum
|
|
||||||
(
|
|
||||||
lowWeightCorrection_,
|
|
||||||
(interpolateToSource ? srcAddress_ : tgtAddress_),
|
|
||||||
(interpolateToSource ? srcWeights_ : tgtWeights_),
|
|
||||||
(interpolateToSource ? srcWeightsSum_ : tgtWeightsSum_),
|
|
||||||
fld,
|
|
||||||
multiplyWeightedOp<Type, plusEqOp<Type>>(plusEqOp<Type>()),
|
|
||||||
result,
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class CombineOp>
|
template<class Type, class CombineOp>
|
||||||
void Foam::AMIInterpolation::interpolateToTarget
|
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolate
|
||||||
(
|
|
||||||
const UList<Type>& fld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
List<Type>& result,
|
|
||||||
const UList<Type>& defaultValues
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
addProfiling(ami, "AMIInterpolation::interpolateToTarget");
|
|
||||||
|
|
||||||
if (fld.size() != srcAddress_.size())
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Supplied field size is not equal to source patch size" << nl
|
|
||||||
<< " source patch = " << srcAddress_.size() << nl
|
|
||||||
<< " target patch = " << tgtAddress_.size() << nl
|
|
||||||
<< " supplied field = " << fld.size()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
(lowWeightCorrection_ > 0)
|
|
||||||
&& (defaultValues.size() != tgtAddress_.size())
|
|
||||||
)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Employing default values when sum of weights falls below "
|
|
||||||
<< lowWeightCorrection_
|
|
||||||
<< " but supplied default field size is not equal to target "
|
|
||||||
<< "patch size" << nl
|
|
||||||
<< " default values = " << defaultValues.size() << nl
|
|
||||||
<< " target patch = " << tgtAddress_.size() << nl
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.setSize(tgtAddress_.size());
|
|
||||||
List<Type> work;
|
|
||||||
|
|
||||||
if (distributed())
|
|
||||||
{
|
|
||||||
const mapDistribute& map = srcMapPtr_();
|
|
||||||
work = fld; // deep copy
|
|
||||||
map.distribute(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
weightedSum
|
|
||||||
(
|
|
||||||
lowWeightCorrection_,
|
|
||||||
tgtAddress_,
|
|
||||||
tgtWeights_,
|
|
||||||
tgtWeightsSum_,
|
|
||||||
(distributed() ? work : fld),
|
|
||||||
cop,
|
|
||||||
result,
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
void Foam::AMIInterpolation::interpolateToSource
|
|
||||||
(
|
|
||||||
const UList<Type>& fld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
List<Type>& result,
|
|
||||||
const UList<Type>& defaultValues
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
addProfiling(ami, "AMIInterpolation::interpolateToSource");
|
|
||||||
|
|
||||||
if (fld.size() != tgtAddress_.size())
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Supplied field size is not equal to target patch size" << nl
|
|
||||||
<< " source patch = " << srcAddress_.size() << nl
|
|
||||||
<< " target patch = " << tgtAddress_.size() << nl
|
|
||||||
<< " supplied field = " << fld.size()
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
else if
|
|
||||||
(
|
|
||||||
(lowWeightCorrection_ > 0)
|
|
||||||
&& (defaultValues.size() != srcAddress_.size())
|
|
||||||
)
|
|
||||||
{
|
|
||||||
FatalErrorInFunction
|
|
||||||
<< "Employing default values when sum of weights falls below "
|
|
||||||
<< lowWeightCorrection_
|
|
||||||
<< " but number of default values is not equal to source "
|
|
||||||
<< "patch size" << nl
|
|
||||||
<< " default values = " << defaultValues.size() << nl
|
|
||||||
<< " source patch = " << srcAddress_.size() << nl
|
|
||||||
<< abort(FatalError);
|
|
||||||
}
|
|
||||||
|
|
||||||
result.setSize(srcAddress_.size());
|
|
||||||
List<Type> work;
|
|
||||||
|
|
||||||
if (distributed())
|
|
||||||
{
|
|
||||||
const mapDistribute& map = tgtMapPtr_();
|
|
||||||
work = fld; // deep copy
|
|
||||||
map.distribute(work);
|
|
||||||
}
|
|
||||||
|
|
||||||
weightedSum
|
|
||||||
(
|
|
||||||
lowWeightCorrection_,
|
|
||||||
srcAddress_,
|
|
||||||
srcWeights_,
|
|
||||||
srcWeightsSum_,
|
|
||||||
(distributed() ? work : fld),
|
|
||||||
cop,
|
|
||||||
result,
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToSource
|
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const CombineOp& cop,
|
const CombineOp& cop,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
auto tresult = tmp<Field<Type>>::New(srcAddress_.size(), Zero);
|
auto tresult = tmp<Field<Type>>::New();
|
||||||
|
|
||||||
interpolateToSource
|
interpolate(fld, cop, tresult.ref(), defaultValues);
|
||||||
(
|
|
||||||
fld,
|
|
||||||
multiplyWeightedOp<Type, CombineOp>(cop),
|
|
||||||
tresult.ref(),
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
|
|
||||||
return tresult;
|
return tresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class CombineOp>
|
template<class Type, class CombineOp>
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToSource
|
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolate
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const CombineOp& cop,
|
const CombineOp& cop,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return interpolateToSource(tFld(), cop, defaultValues);
|
return interpolate(tFld(), cop, defaultValues);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToTarget
|
|
||||||
(
|
|
||||||
const Field<Type>& fld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
const UList<Type>& defaultValues
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
auto tresult = tmp<Field<Type>>::New(tgtAddress_.size(), Zero);
|
|
||||||
|
|
||||||
interpolateToTarget
|
|
||||||
(
|
|
||||||
fld,
|
|
||||||
multiplyWeightedOp<Type, CombineOp>(cop),
|
|
||||||
tresult.ref(),
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
|
|
||||||
return tresult;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, class CombineOp>
|
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToTarget
|
|
||||||
(
|
|
||||||
const tmp<Field<Type>>& tFld,
|
|
||||||
const CombineOp& cop,
|
|
||||||
const UList<Type>& defaultValues
|
|
||||||
) const
|
|
||||||
{
|
|
||||||
return interpolateToTarget(tFld(), cop, defaultValues);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -295,10 +109,13 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToSource
|
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToSource
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return interpolateToSource(fld, plusEqOp<Type>(), defaultValues);
|
AMICorrectedMultiplyWeightedOp<Type> cop(*this, true, lwOption);
|
||||||
|
|
||||||
|
return interpolate(fld, cop, defaultValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -306,10 +123,11 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToSource
|
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToSource
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return interpolateToSource(tFld(), plusEqOp<Type>(), defaultValues);
|
return interpolateToSource(tFld(), defaultValues, lwOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -317,10 +135,13 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToTarget
|
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToTarget
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return interpolateToTarget(fld, plusEqOp<Type>(), defaultValues);
|
AMICorrectedMultiplyWeightedOp<Type> cop(*this, false, lwOption);
|
||||||
|
|
||||||
|
return interpolate(fld, cop, defaultValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -328,10 +149,11 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToTarget
|
Foam::tmp<Foam::Field<Type>> Foam::AMIInterpolation::interpolateToTarget
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return interpolateToTarget(tFld(), plusEqOp<Type>(), defaultValues);
|
return interpolateToTarget(tFld(), defaultValues, lwOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -292,14 +292,15 @@ void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix
|
|||||||
recvRequests_.clear();
|
recvRequests_.clear();
|
||||||
|
|
||||||
solveScalarField pnf(faceCells.size(), Zero);
|
solveScalarField pnf(faceCells.size(), Zero);
|
||||||
AMI.weightedSum
|
|
||||||
|
AMIMultiplyWeightedOp<solveScalar> cop
|
||||||
(
|
(
|
||||||
cyclicACMIInterface_.owner(),
|
AMI,
|
||||||
work,
|
cyclicACMIInterface_.owner()
|
||||||
pnf, // result
|
|
||||||
solveScalarField::null()
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
cop(pnf, work, solveScalarField::null());
|
||||||
|
|
||||||
// Add result using coefficients
|
// Add result using coefficients
|
||||||
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
|
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -306,13 +306,14 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
|
|||||||
recvRequests_.clear();
|
recvRequests_.clear();
|
||||||
|
|
||||||
solveScalarField pnf(faceCells.size(), Zero);
|
solveScalarField pnf(faceCells.size(), Zero);
|
||||||
AMI.weightedSum
|
|
||||||
|
// Note: no low-weight correction
|
||||||
|
AMIMultiplyWeightedOp<solveScalar> cop
|
||||||
(
|
(
|
||||||
cyclicAMIInterface_.owner(),
|
AMI,
|
||||||
work,
|
cyclicAMIInterface_.owner()
|
||||||
pnf, // result
|
|
||||||
defaultValues
|
|
||||||
);
|
);
|
||||||
|
cop(pnf, work, defaultValues);
|
||||||
|
|
||||||
// Add result using coefficients
|
// Add result using coefficients
|
||||||
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
|
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
|
||||||
@ -329,13 +330,14 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix
|
|||||||
transformCoupleField(work, cmpt);
|
transformCoupleField(work, cmpt);
|
||||||
|
|
||||||
solveScalarField pnf(faceCells.size(), Zero);
|
solveScalarField pnf(faceCells.size(), Zero);
|
||||||
AMI.weightedSum
|
|
||||||
|
// Note: no low-weight correction
|
||||||
|
AMIMultiplyWeightedOp<solveScalar> cop
|
||||||
(
|
(
|
||||||
cyclicAMIInterface_.owner(),
|
AMI,
|
||||||
work,
|
cyclicAMIInterface_.owner()
|
||||||
pnf, // result
|
|
||||||
defaultValues
|
|
||||||
);
|
);
|
||||||
|
cop(pnf, work, defaultValues);
|
||||||
|
|
||||||
// Add result using coefficients
|
// Add result using coefficients
|
||||||
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
|
this->addToInternalField(result, !add, faceCells, coeffs, pnf);
|
||||||
|
|||||||
@ -446,6 +446,54 @@ void Foam::cyclicAMIPolyPatch::resetAMI(const UList<point>& points) const
|
|||||||
{
|
{
|
||||||
AMIPtr_->checkSymmetricWeights(true);
|
AMIPtr_->checkSymmetricWeights(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check connectivity
|
||||||
|
if (applyLowWeightCorrection() || !AMIPtr_->requireMatch())
|
||||||
|
{
|
||||||
|
Info<< "AMI: performing connectivity checks" << endl;
|
||||||
|
|
||||||
|
const auto& C = boundaryMesh().mesh().cellCentres();
|
||||||
|
|
||||||
|
auto cosTheta =
|
||||||
|
[&](const polyPatch& p1, const polyPatch& p2, const bool toSource)
|
||||||
|
{
|
||||||
|
const auto& Cf1 = p1.faceCentres();
|
||||||
|
const auto& faceCells1 = p1.faceCells();
|
||||||
|
|
||||||
|
vectorField delta1(p1.size());
|
||||||
|
forAll(delta1, i)
|
||||||
|
{
|
||||||
|
delta1[i] = Cf1[i] - C[faceCells1[i]];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Interpolate nbr delta to local (src) side using (uncorrected)
|
||||||
|
// multiply-weighted op
|
||||||
|
const AMIMultiplyWeightedOp<vector> cop(*AMIPtr_, toSource);
|
||||||
|
AMIPtr_->interpolate(delta1, cop, UList<vector>::null());
|
||||||
|
delta1.normalise();
|
||||||
|
|
||||||
|
return delta1 & p2.faceNormals();
|
||||||
|
};
|
||||||
|
|
||||||
|
const scalarField ctSrc(cosTheta(*this, nbr, true));
|
||||||
|
forAll(ctSrc, facei)
|
||||||
|
{
|
||||||
|
if (ctSrc[facei] < 0)
|
||||||
|
{
|
||||||
|
AMIPtr_->removeSourceConnection(facei);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const scalarField ctTgt(cosTheta(nbr, *this, false));
|
||||||
|
forAll(ctTgt, facei)
|
||||||
|
{
|
||||||
|
if (ctTgt[facei] < 0)
|
||||||
|
{
|
||||||
|
AMIPtr_->removeTargetConnection(facei);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -483,7 +483,9 @@ public:
|
|||||||
tmp<Field<Type>> interpolate
|
tmp<Field<Type>> interpolate
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues = UList<Type>()
|
const UList<Type>& defaultValues = UList<Type>(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate tmp field
|
//- Interpolate tmp field
|
||||||
@ -491,7 +493,9 @@ public:
|
|||||||
tmp<Field<Type>> interpolate
|
tmp<Field<Type>> interpolate
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const UList<Type>& defaultValues = UList<Type>()
|
const UList<Type>& defaultValues = UList<Type>(),
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Interpolate without periodic
|
//- Interpolate without periodic
|
||||||
@ -499,7 +503,9 @@ public:
|
|||||||
tmp<Field<Type>> interpolateUntransformed
|
tmp<Field<Type>> interpolateUntransformed
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- Low-level interpolate List
|
//- Low-level interpolate List
|
||||||
@ -541,7 +547,9 @@ public:
|
|||||||
const Field<Type>& localFld,
|
const Field<Type>& localFld,
|
||||||
const labelRange& requests, // The receive requests
|
const labelRange& requests, // The receive requests
|
||||||
const PtrList<List<Type>>& recvBuffers,
|
const PtrList<List<Type>>& recvBuffers,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption =
|
||||||
|
lowWeightCorrectionBase::option::ASSIGN
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -26,22 +26,30 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "AMIFieldOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolateUntransformed
|
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolateUntransformed
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
if (owner())
|
if (owner())
|
||||||
{
|
{
|
||||||
return AMI().interpolateToSource(fld, defaultValues);
|
return AMI().interpolateToSource(fld, defaultValues, lwOption);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return neighbPatch().AMI().interpolateToTarget(fld, defaultValues);
|
return neighbPatch().AMI().interpolateToTarget
|
||||||
|
(
|
||||||
|
fld,
|
||||||
|
defaultValues,
|
||||||
|
lwOption
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,7 +58,8 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
||||||
(
|
(
|
||||||
const Field<Type>& fld,
|
const Field<Type>& fld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
autoPtr<coordSystem::cylindrical> cs;
|
autoPtr<coordSystem::cylindrical> cs;
|
||||||
@ -65,7 +74,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
|||||||
|
|
||||||
if (!cs)
|
if (!cs)
|
||||||
{
|
{
|
||||||
return interpolateUntransformed(fld, defaultValues);
|
return interpolateUntransformed(fld, defaultValues, lwOption);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -141,7 +150,7 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
|||||||
return Foam::transform
|
return Foam::transform
|
||||||
(
|
(
|
||||||
ownT,
|
ownT,
|
||||||
interpolateUntransformed(localFld, localDeflt)
|
interpolateUntransformed(localFld, localDeflt, lwOption)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -151,10 +160,11 @@ template<class Type>
|
|||||||
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
||||||
(
|
(
|
||||||
const tmp<Field<Type>>& tFld,
|
const tmp<Field<Type>>& tFld,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return interpolate(tFld(), defaultValues);
|
return interpolate(tFld(), defaultValues, lwOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -245,7 +255,8 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
|||||||
const Field<Type>& localFld,
|
const Field<Type>& localFld,
|
||||||
const labelRange& requests,
|
const labelRange& requests,
|
||||||
const PtrList<List<Type>>& recvBuffers,
|
const PtrList<List<Type>>& recvBuffers,
|
||||||
const UList<Type>& defaultValues
|
const UList<Type>& defaultValues,
|
||||||
|
const lowWeightCorrectionBase::option& lwOption
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
const auto& AMI = (owner() ? this->AMI() : neighbPatch().AMI());
|
const auto& AMI = (owner() ? this->AMI() : neighbPatch().AMI());
|
||||||
@ -272,13 +283,9 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
|||||||
|
|
||||||
if (!cs)
|
if (!cs)
|
||||||
{
|
{
|
||||||
AMI.weightedSum
|
AMICorrectedMultiplyWeightedOp<Type> cop(AMI, owner(), lwOption);
|
||||||
(
|
|
||||||
owner(),
|
cop(tresult.ref(), fld, defaultValues);
|
||||||
fld,
|
|
||||||
tresult.ref(),
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -296,13 +303,8 @@ Foam::tmp<Foam::Field<Type>> Foam::cyclicAMIPolyPatch::interpolate
|
|||||||
Foam::invTransform(localDeflt, ownT, defaultFld);
|
Foam::invTransform(localDeflt, ownT, defaultFld);
|
||||||
}
|
}
|
||||||
|
|
||||||
AMI.weightedSum
|
AMICorrectedMultiplyWeightedOp<Type> cop(AMI, owner(), lwOption);
|
||||||
(
|
cop(tresult.ref(), fld, defaultValues);
|
||||||
owner(),
|
|
||||||
fld,
|
|
||||||
tresult.ref(),
|
|
||||||
localDeflt
|
|
||||||
);
|
|
||||||
|
|
||||||
// Transform back
|
// Transform back
|
||||||
Foam::transform(tresult.ref(), ownT, tresult());
|
Foam::transform(tresult.ref(), ownT, tresult());
|
||||||
@ -356,26 +358,7 @@ void Foam::cyclicAMIPolyPatch::interpolate
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do actual AMI interpolation
|
// Do actual AMI interpolation
|
||||||
if (owner())
|
AMI().interpolate(fld, cop, result, defaultValues);
|
||||||
{
|
|
||||||
AMI().interpolateToSource
|
|
||||||
(
|
|
||||||
fld,
|
|
||||||
cop,
|
|
||||||
result,
|
|
||||||
localDeflt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
neighbPatch().AMI().interpolateToTarget
|
|
||||||
(
|
|
||||||
fld,
|
|
||||||
cop,
|
|
||||||
result,
|
|
||||||
localDeflt
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Transform back. Result is now at *this
|
// Transform back. Result is now at *this
|
||||||
Foam::transform(result, ownT, result);
|
Foam::transform(result, ownT, result);
|
||||||
@ -383,26 +366,7 @@ void Foam::cyclicAMIPolyPatch::interpolate
|
|||||||
else
|
else
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
if (owner())
|
AMI().interpolate(fld, cop, result, defaultValues);
|
||||||
{
|
|
||||||
AMI().interpolateToSource
|
|
||||||
(
|
|
||||||
fld,
|
|
||||||
cop,
|
|
||||||
result,
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
neighbPatch().AMI().interpolateToTarget
|
|
||||||
(
|
|
||||||
fld,
|
|
||||||
cop,
|
|
||||||
result,
|
|
||||||
defaultValues
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -276,6 +276,7 @@ processorLOD/cellBox/cellBox.C
|
|||||||
processorLOD/faceBox/faceBox.C
|
processorLOD/faceBox/faceBox.C
|
||||||
|
|
||||||
AMI=AMIInterpolation
|
AMI=AMIInterpolation
|
||||||
|
$(AMI)/AMIInterpolation/AMIFieldOps/lowWeightCorrectionBase.C
|
||||||
$(AMI)/AMIInterpolation/AMIInterpolation.C
|
$(AMI)/AMIInterpolation/AMIInterpolation.C
|
||||||
$(AMI)/AMIInterpolation/AMIInterpolationNew.C
|
$(AMI)/AMIInterpolation/AMIInterpolationNew.C
|
||||||
$(AMI)/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C
|
$(AMI)/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C
|
||||||
|
|||||||
@ -38,6 +38,7 @@ License
|
|||||||
#include "typeInfo.H"
|
#include "typeInfo.H"
|
||||||
#include "SubField.H"
|
#include "SubField.H"
|
||||||
#include "globalMeshData.H"
|
#include "globalMeshData.H"
|
||||||
|
#include "AMIFieldOps.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
@ -95,6 +96,73 @@ namespace Foam
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Combine operator for AMIInterpolation
|
||||||
|
template<class Type, class TrackingData>
|
||||||
|
class combineField
|
||||||
|
:
|
||||||
|
public AMIFieldOpBase
|
||||||
|
{
|
||||||
|
// Private Data
|
||||||
|
|
||||||
|
FaceCellWave<Type, TrackingData>& solver_;
|
||||||
|
|
||||||
|
const cyclicAMIPolyPatch& patch_;
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
combineField
|
||||||
|
(
|
||||||
|
FaceCellWave<Type, TrackingData>& solver,
|
||||||
|
const cyclicAMIPolyPatch& patch
|
||||||
|
)
|
||||||
|
:
|
||||||
|
AMIFieldOpBase(patch.AMI(), patch.owner()),
|
||||||
|
solver_(solver),
|
||||||
|
patch_(patch)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void operator()
|
||||||
|
(
|
||||||
|
List<Type>& result,
|
||||||
|
const UList<Type>& fld,
|
||||||
|
const UList<Type>& /* unused defaultValues */
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
const auto& allSlots = address();
|
||||||
|
|
||||||
|
forAll(result, facei)
|
||||||
|
{
|
||||||
|
const labelList& slots = allSlots[facei];
|
||||||
|
|
||||||
|
for (const label sloti : slots)
|
||||||
|
{
|
||||||
|
if (fld[sloti].valid(solver_.data()))
|
||||||
|
{
|
||||||
|
label meshFacei = -1;
|
||||||
|
if (patch_.owner())
|
||||||
|
{
|
||||||
|
meshFacei = patch_.start() + facei;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
meshFacei =
|
||||||
|
patch_.neighbPatch().start() + facei;
|
||||||
|
}
|
||||||
|
result[facei].updateFace
|
||||||
|
(
|
||||||
|
solver_.mesh(),
|
||||||
|
meshFacei,
|
||||||
|
fld[sloti],
|
||||||
|
solver_.propagationTol(),
|
||||||
|
solver_.data()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -782,7 +850,7 @@ void Foam::FaceCellWave<Type, TrackingData>::handleAMICyclicPatches()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Transfer sendInfo to cycPatch
|
// Transfer sendInfo to cycPatch
|
||||||
combine<Type, TrackingData> cmb(*this, cycPatch);
|
combineField<Type, TrackingData> cmb(*this, cycPatch);
|
||||||
|
|
||||||
if (cycPatch.applyLowWeightCorrection())
|
if (cycPatch.applyLowWeightCorrection())
|
||||||
{
|
{
|
||||||
|
|||||||
@ -26,6 +26,9 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "AMIFieldOps.H"
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::mappedPatchBase::distribute(List<Type>& lst) const
|
void Foam::mappedPatchBase::distribute(List<Type>& lst) const
|
||||||
{
|
{
|
||||||
@ -120,7 +123,9 @@ void Foam::mappedPatchBase::distribute
|
|||||||
const label oldWarnComm = UPstream::commWarn(myComm);
|
const label oldWarnComm = UPstream::commWarn(myComm);
|
||||||
const label oldWorldComm = UPstream::commWorld(myComm);
|
const label oldWorldComm = UPstream::commWorld(myComm);
|
||||||
|
|
||||||
lst = interp.interpolateToSource(Field<Type>(std::move(lst)), cop);
|
const auto op = AMIFieldOp<Type, CombineOp>(interp, cop, true);
|
||||||
|
|
||||||
|
lst = interp.interpolate(Field<Type>(std::move(lst)), op);
|
||||||
|
|
||||||
UPstream::commWarn(oldWarnComm);
|
UPstream::commWarn(oldWarnComm);
|
||||||
UPstream::commWorld(oldWorldComm);
|
UPstream::commWorld(oldWorldComm);
|
||||||
@ -206,7 +211,9 @@ void Foam::mappedPatchBase::reverseDistribute
|
|||||||
const label oldWarnComm = UPstream::commWarn(myComm);
|
const label oldWarnComm = UPstream::commWarn(myComm);
|
||||||
const label oldWorldComm = UPstream::commWorld(myComm);
|
const label oldWorldComm = UPstream::commWorld(myComm);
|
||||||
|
|
||||||
lst = interp.interpolateToTarget(Field<Type>(std::move(lst)), cop);
|
const auto op = AMIFieldOp<Type, CombineOp>(interp, false);
|
||||||
|
|
||||||
|
lst = interp.interpolate(Field<Type>(std::move(lst)), op);
|
||||||
|
|
||||||
UPstream::commWarn(oldWarnComm);
|
UPstream::commWarn(oldWarnComm);
|
||||||
UPstream::commWorld(oldWorldComm);
|
UPstream::commWorld(oldWorldComm);
|
||||||
|
|||||||
@ -78,44 +78,8 @@ void Foam::decompositionConstraint::getMinBoundaryValue
|
|||||||
const labelList nbrDecomp(decomposition, nbrPp.faceCells());
|
const labelList nbrDecomp(decomposition, nbrPp.faceCells());
|
||||||
labelList thisDecomp(decomposition, cycPp.faceCells());
|
labelList thisDecomp(decomposition, cycPp.faceCells());
|
||||||
|
|
||||||
if (cycPp.owner())
|
AMIMinOp<label> cop(cycPp.AMI(), cycPp.owner());
|
||||||
{
|
cop(thisDecomp, nbrDecomp, thisDecomp);
|
||||||
cycPp.AMI().interpolateToSource
|
|
||||||
(
|
|
||||||
nbrDecomp,
|
|
||||||
[]
|
|
||||||
(
|
|
||||||
label& res,
|
|
||||||
const label facei,
|
|
||||||
const label& fld,
|
|
||||||
const scalar& w
|
|
||||||
)
|
|
||||||
{
|
|
||||||
res = min(res, fld);
|
|
||||||
},
|
|
||||||
thisDecomp,
|
|
||||||
thisDecomp // used in case of low-weight-corr
|
|
||||||
);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nbrPp.AMI().interpolateToTarget
|
|
||||||
(
|
|
||||||
nbrDecomp,
|
|
||||||
[]
|
|
||||||
(
|
|
||||||
label& res,
|
|
||||||
const label facei,
|
|
||||||
const label& fld,
|
|
||||||
const scalar& w
|
|
||||||
)
|
|
||||||
{
|
|
||||||
res = min(res, fld);
|
|
||||||
},
|
|
||||||
thisDecomp,
|
|
||||||
thisDecomp // used in case of low-weight-corr
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
forAll(thisDecomp, i)
|
forAll(thisDecomp, i)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -492,13 +492,9 @@ void Foam::meshToMesh::mapAndOpSrcToTgt
|
|||||||
{
|
{
|
||||||
tgtField = Type(Zero);
|
tgtField = Type(Zero);
|
||||||
|
|
||||||
AMI.interpolateToTarget
|
const AMIMultiplyWeightedOp<Type, CombineOp> amicop(AMI, false);
|
||||||
(
|
|
||||||
srcField,
|
AMI.interpolate(srcField, amicop, tgtField, UList<Type>::null());
|
||||||
multiplyWeightedOp<Type, CombineOp>(cop),
|
|
||||||
tgtField,
|
|
||||||
UList<Type>::null()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -725,13 +721,9 @@ void Foam::meshToMesh::mapAndOpTgtToSrc
|
|||||||
{
|
{
|
||||||
srcField = Type(Zero);
|
srcField = Type(Zero);
|
||||||
|
|
||||||
AMI.interpolateToSource
|
const AMIMultiplyWeightedOp<Type, CombineOp> amicop(AMI, true);
|
||||||
(
|
|
||||||
tgtField,
|
AMI.interpolate(tgtField, amicop, srcField, UList<Type>::null());
|
||||||
multiplyWeightedOp<Type, CombineOp>(cop),
|
|
||||||
srcField,
|
|
||||||
UList<Type>::null()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user