Commit 2d96fc50 authored by Andrew Heather's avatar Andrew Heather
Browse files

BUG: mapFields function object - evaluate constraint patches after mapping. Fixes #190

parent cd8be89b
......@@ -122,6 +122,13 @@ class mapFieldsFO
//- Helper function to create the mesh-to-mesh interpolation
void createInterpolation(const dictionary& dict);
//- Helper function to evaluate constraint patches after mapping
template<class Type>
void evaluateConstraintTypes
(
GeometricField<Type, fvPatchField, volMesh>& fld
) const;
//- Helper function to interpolate and write the fied
template<class Type>
bool writeFieldType() const;
......
......@@ -25,6 +25,91 @@ License
#include "meshToMesh.H"
template<class Type>
void Foam::mapFieldsFO::evaluateConstraintTypes
(
GeometricField<Type, fvPatchField, volMesh>& fld
) const
{
typename GeometricField<Type, fvPatchField, volMesh>::
GeometricBoundaryField& fldBf = fld.boundaryField();
if
(
Pstream::defaultCommsType == Pstream::blocking
|| Pstream::defaultCommsType == Pstream::nonBlocking
)
{
label nReq = Pstream::nRequests();
forAll(fldBf, patchi)
{
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
tgtField.initEvaluate(Pstream::defaultCommsType);
}
}
// Block for any outstanding requests
if
(
Pstream::parRun()
&& Pstream::defaultCommsType == Pstream::nonBlocking
)
{
Pstream::waitRequests(nReq);
}
forAll(fldBf, patchi)
{
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
tgtField.evaluate(Pstream::defaultCommsType);
}
}
}
else if (Pstream::defaultCommsType == Pstream::scheduled)
{
const lduSchedule& patchSchedule =
fld.mesh().globalData().patchSchedule();
forAll(patchSchedule, patchEvali)
{
label patchi = patchSchedule[patchEvali].patch;
fvPatchField<Type>& tgtField = fldBf[patchi];
if
(
tgtField.type() == tgtField.patch().patch().type()
&& polyPatch::constraintType(tgtField.patch().patch().type())
)
{
if (patchSchedule[patchEvali].init)
{
tgtField.initEvaluate(Pstream::scheduled);
}
else
{
tgtField.evaluate(Pstream::scheduled);
}
}
}
}
}
template<class Type>
bool Foam::mapFieldsFO::writeFieldType() const
{
......@@ -53,6 +138,9 @@ bool Foam::mapFieldsFO::writeFieldType() const
if (log_) Info<< ": interpolated";
FieldType fieldMapRegion(mapRegionIO, tfieldMapRegion);
evaluateConstraintTypes(fieldMapRegion);
fieldMapRegion.write();
if (log_) Info<< " and written" << nl;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment