mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: AMI: behave uncoupled wherever necessary; detect geometry changes
This commit is contained in:
@ -143,21 +143,7 @@ Foam::cyclicAMIFvPatchField<Type>::cyclicAMIFvPatchField
|
||||
template<class Type>
|
||||
bool Foam::cyclicAMIFvPatchField<Type>::coupled() const
|
||||
{
|
||||
if
|
||||
(
|
||||
Pstream::parRun()
|
||||
|| (
|
||||
this->cyclicAMIPatch_.size()
|
||||
&& this->cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().size()
|
||||
)
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return cyclicAMIPatch_.coupled();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -39,60 +39,82 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::cyclicAMIFvPatch::coupled() const
|
||||
{
|
||||
return Pstream::parRun() || (this->size() && neighbFvPatch().size());
|
||||
}
|
||||
|
||||
|
||||
void Foam::cyclicAMIFvPatch::makeWeights(scalarField& w) const
|
||||
{
|
||||
const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
|
||||
|
||||
const scalarField deltas(nf() & fvPatch::delta());
|
||||
|
||||
const scalarField nbrDeltas
|
||||
(
|
||||
interpolate(nbrPatch.nf() & nbrPatch.fvPatch::delta())
|
||||
);
|
||||
|
||||
forAll(deltas, faceI)
|
||||
if (coupled())
|
||||
{
|
||||
scalar di = deltas[faceI];
|
||||
scalar dni = nbrDeltas[faceI];
|
||||
const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
|
||||
|
||||
w[faceI] = dni/(di + dni);
|
||||
const scalarField deltas(nf() & fvPatch::delta());
|
||||
|
||||
const scalarField nbrDeltas
|
||||
(
|
||||
interpolate(nbrPatch.nf() & nbrPatch.fvPatch::delta())
|
||||
);
|
||||
|
||||
forAll(deltas, faceI)
|
||||
{
|
||||
scalar di = deltas[faceI];
|
||||
scalar dni = nbrDeltas[faceI];
|
||||
|
||||
w[faceI] = dni/(di + dni);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Behave as uncoupled patch
|
||||
fvPatch::makeWeights(w);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::tmp<Foam::vectorField> Foam::cyclicAMIFvPatch::delta() const
|
||||
{
|
||||
const vectorField patchD(fvPatch::delta());
|
||||
|
||||
const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
|
||||
const vectorField nbrPatchD(interpolate(nbrPatch.fvPatch::delta()));
|
||||
|
||||
tmp<vectorField> tpdv(new vectorField(patchD.size()));
|
||||
vectorField& pdv = tpdv();
|
||||
|
||||
// do the transformation if necessary
|
||||
if (parallel())
|
||||
if (coupled())
|
||||
{
|
||||
forAll(patchD, faceI)
|
||||
{
|
||||
const vector& ddi = patchD[faceI];
|
||||
const vector& dni = nbrPatchD[faceI];
|
||||
const vectorField patchD(fvPatch::delta());
|
||||
|
||||
pdv[faceI] = ddi - dni;
|
||||
const vectorField nbrPatchD(interpolate(nbrPatch.fvPatch::delta()));
|
||||
|
||||
tmp<vectorField> tpdv(new vectorField(patchD.size()));
|
||||
vectorField& pdv = tpdv();
|
||||
|
||||
// do the transformation if necessary
|
||||
if (parallel())
|
||||
{
|
||||
forAll(patchD, faceI)
|
||||
{
|
||||
const vector& ddi = patchD[faceI];
|
||||
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;
|
||||
}
|
||||
else
|
||||
{
|
||||
forAll(patchD, faceI)
|
||||
{
|
||||
const vector& ddi = patchD[faceI];
|
||||
const vector& dni = nbrPatchD[faceI];
|
||||
|
||||
pdv[faceI] = ddi - transform(forwardT()[0], dni);
|
||||
}
|
||||
return fvPatch::delta();
|
||||
}
|
||||
|
||||
return tpdv;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -146,6 +146,11 @@ public:
|
||||
);
|
||||
}
|
||||
|
||||
//- Return true if this patch is coupled. This is equivalent
|
||||
// to the coupledPolyPatch::coupled() if parallel running or
|
||||
// both sides present, false otherwise
|
||||
virtual bool coupled() const;
|
||||
|
||||
//- Return delta (P to N) vectors across coupled patch
|
||||
virtual tmp<vectorField> delta() const;
|
||||
|
||||
|
||||
@ -965,6 +965,13 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcAddressing
|
||||
label tgtFaceI
|
||||
)
|
||||
{
|
||||
// Pre-size to handle early exit
|
||||
srcAddress_.setSize(srcPatch.size());
|
||||
srcWeights_.setSize(srcPatch.size());
|
||||
tgtAddress_.setSize(tgtPatch.size());
|
||||
tgtWeights_.setSize(tgtPatch.size());
|
||||
|
||||
|
||||
if (debug && (!srcPatch.size() || !tgtPatch.size()))
|
||||
{
|
||||
Pout<< "AMI: Patches not on processor: Source faces = "
|
||||
@ -1134,16 +1141,11 @@ void Foam::AMIInterpolation<SourcePatch, TargetPatch>::calcAddressing
|
||||
}
|
||||
|
||||
// transfer data to persistent storage
|
||||
srcAddress_.setSize(srcPatch.size());
|
||||
srcWeights_.setSize(srcPatch.size());
|
||||
forAll(srcAddr, i)
|
||||
{
|
||||
srcAddress_[i].transfer(srcAddr[i]);
|
||||
srcWeights_[i].transfer(srcWght[i]);
|
||||
}
|
||||
|
||||
tgtAddress_.setSize(tgtPatch.size());
|
||||
tgtWeights_.setSize(tgtPatch.size());
|
||||
forAll(tgtAddr, i)
|
||||
{
|
||||
tgtAddress_[i].transfer(tgtAddr[i]);
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -208,7 +208,7 @@ void Foam::cyclicAMIPolyPatch::calcTransforms
|
||||
{
|
||||
if (debug)
|
||||
{
|
||||
Pout<< " patch:" << name()
|
||||
Pout<< "patch:" << name()
|
||||
<< " Assuming cyclic AMI pairs are colocated" << endl;
|
||||
}
|
||||
|
||||
@ -282,6 +282,16 @@ void Foam::cyclicAMIPolyPatch::resetAMI() const
|
||||
AMIReverse_
|
||||
)
|
||||
);
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "cyclicAMIPolyPatch : " << name()
|
||||
<< " constructed AMI with " << nl
|
||||
<< " " << ":srcAddress:" << AMIPtr_().srcAddress().size()
|
||||
<< nl
|
||||
<< " " << " tgAddress :" << AMIPtr_().tgtAddress().size()
|
||||
<< nl << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -345,6 +355,13 @@ void Foam::cyclicAMIPolyPatch::updateMesh(PstreamBuffers& pBufs)
|
||||
}
|
||||
|
||||
|
||||
void Foam::cyclicAMIPolyPatch::clearGeom()
|
||||
{
|
||||
AMIPtr_.clear();
|
||||
polyPatch::clearGeom();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::cyclicAMIPolyPatch::cyclicAMIPolyPatch
|
||||
@ -645,16 +662,6 @@ const Foam::AMIPatchToPatchInterpolation& Foam::cyclicAMIPolyPatch::AMI() const
|
||||
resetAMI();
|
||||
}
|
||||
|
||||
|
||||
if (debug)
|
||||
{
|
||||
Pout<< "cyclicAMIPolyPatch : " << name()
|
||||
<< " constructed AMI with " << endl
|
||||
<< " " << ":srcAddress:" << AMIPtr_().srcAddress().size() << endl
|
||||
<< " " << " tgAddress :" << AMIPtr_().tgtAddress().size() << endl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
return AMIPtr_();
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -141,6 +141,9 @@ protected:
|
||||
//- Update of the patch topology
|
||||
virtual void updateMesh(PstreamBuffers&);
|
||||
|
||||
//- Clear geometry
|
||||
virtual void clearGeom();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user