ENH: redistributePar: suppress warning. Fixes #1937.

This commit is contained in:
mattijs
2020-11-26 13:45:53 +00:00
parent 9c86b5d722
commit c879c24412
3 changed files with 70 additions and 16 deletions

View File

@ -372,7 +372,9 @@ void Foam::fvMeshDistribute::sendFields
const GeoField& fld = const GeoField& fld =
subsetter.baseMesh().lookupObject<GeoField>(fieldName); subsetter.baseMesh().lookupObject<GeoField>(fieldName);
tmp<GeoField> tsubfld = subsetter.interpolate(fld); // Note: use subsetter to get sub field. Override default behaviour
// to warn for unset fields since they will be reset later on
tmp<GeoField> tsubfld = subsetter.interpolate(fld, true);
toNbr toNbr
<< fieldName << token::NL << token::BEGIN_BLOCK << fieldName << token::NL << token::BEGIN_BLOCK

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd. Copyright (C) 2016-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -339,7 +339,8 @@ public:
// Field Mapping // Field Mapping
//- Map volume field //- Map volume field. Optionally allow unmapped faces not to produce
// a warning
template<class Type> template<class Type>
static tmp<GeometricField<Type, fvPatchField, volMesh>> static tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate interpolate
@ -348,14 +349,16 @@ public:
const fvMesh& sMesh, const fvMesh& sMesh,
const labelUList& patchMap, const labelUList& patchMap,
const labelUList& cellMap, const labelUList& cellMap,
const labelUList& faceMap const labelUList& faceMap,
const bool allowUnmapped = false
); );
template<class Type> template<class Type>
tmp<GeometricField<Type, fvPatchField, volMesh>> tmp<GeometricField<Type, fvPatchField, volMesh>>
interpolate interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>& const GeometricField<Type, fvPatchField, volMesh>&,
const bool allowUnmapped = false
) const; ) const;
//- Map surface field. Optionally negates value if flipping //- Map surface field. Optionally negates value if flipping
@ -371,11 +374,14 @@ public:
const labelUList& faceMap const labelUList& faceMap
); );
//- Map surface field. Optionally allow unmapped faces not to produce
// a warning (not currently used)
template<class Type> template<class Type>
tmp<GeometricField<Type, fvsPatchField, surfaceMesh>> tmp<GeometricField<Type, fvsPatchField, surfaceMesh>>
interpolate interpolate
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& const GeometricField<Type, fvsPatchField, surfaceMesh>&,
const bool allowUnmapped = false
) const; ) const;
//- Map point field //- Map point field
@ -389,11 +395,14 @@ public:
const labelUList& pointMap const labelUList& pointMap
); );
//- Map point field. Optionally allow unmapped points not to produce
// a warning (not currently used)
template<class Type> template<class Type>
tmp<GeometricField<Type, pointPatchField, pointMesh>> tmp<GeometricField<Type, pointPatchField, pointMesh>>
interpolate interpolate
( (
const GeometricField<Type, pointPatchField, pointMesh>& const GeometricField<Type, pointPatchField, pointMesh>&,
const bool allowUnmapped = false
) const; ) const;
//- Map dimensioned field //- Map dimensioned field
@ -406,9 +415,14 @@ public:
const labelUList& cellMap const labelUList& cellMap
); );
//- Map Dimensioned. Optional unmapped argument not used
template<class Type> template<class Type>
tmp<DimensionedField<Type, volMesh>> tmp<DimensionedField<Type, volMesh>>
interpolate(const DimensionedField<Type, volMesh>&) const; interpolate
(
const DimensionedField<Type, volMesh>&,
const bool allowUnmapped = false
) const;
// Compatibility // Compatibility

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,7 +47,8 @@ Foam::fvMeshSubset::interpolate
const fvMesh& sMesh, const fvMesh& sMesh,
const labelUList& patchMap, const labelUList& patchMap,
const labelUList& cellMap, const labelUList& cellMap,
const labelUList& faceMap const labelUList& faceMap,
const bool allowUnmapped
) )
{ {
// 1. Create the complete field with dummy patch fields // 1. Create the complete field with dummy patch fields
@ -139,6 +140,17 @@ Foam::fvMeshSubset::interpolate
} }
} }
directFvPatchFieldMapper mapper(directAddressing);
// allowUnmapped : special mode for if we do not want to be
// warned for unmapped faces (e.g. from fvMeshDistribute).
const bool hasUnmapped = mapper.hasUnmapped();
if (allowUnmapped)
{
mapper.hasUnmapped() = false;
}
bf.set bf.set
( (
patchi, patchi,
@ -147,9 +159,30 @@ Foam::fvMeshSubset::interpolate
vf.boundaryField()[basePatchId], vf.boundaryField()[basePatchId],
subPatch, subPatch,
result(), result(),
directFvPatchFieldMapper(directAddressing) mapper
) )
); );
if (allowUnmapped && hasUnmapped)
{
// Set unmapped values to zeroGradient. This is the default
// action for unmapped fvPatchFields. Note that this bypasses
// any special logic for handling unmapped fvPatchFields but
// since this is only used inside fvMeshDistribute ...
tmp<Field<Type>> tfld(bf[patchi].patchInternalField());
const Field<Type>& fld = tfld();
Field<Type> value(bf[patchi]);
forAll(directAddressing, i)
{
if (directAddressing[i] == -1)
{
value[i] = fld[i];
}
}
bf[patchi].fvPatchField<Type>::operator=(value);
}
} }
} }
@ -164,7 +197,8 @@ Foam::tmp
> >
Foam::fvMeshSubset::interpolate Foam::fvMeshSubset::interpolate
( (
const GeometricField<Type, fvPatchField, volMesh>& vf const GeometricField<Type, fvPatchField, volMesh>& vf,
const bool allowUnmapped
) const ) const
{ {
return interpolate return interpolate
@ -173,7 +207,8 @@ Foam::fvMeshSubset::interpolate
subMesh(), subMesh(),
patchMap(), patchMap(),
cellMap(), cellMap(),
faceMap() faceMap(),
allowUnmapped
); );
} }
@ -347,7 +382,8 @@ Foam::tmp
> >
Foam::fvMeshSubset::interpolate Foam::fvMeshSubset::interpolate
( (
const GeometricField<Type, fvsPatchField, surfaceMesh>& sf const GeometricField<Type, fvsPatchField, surfaceMesh>& sf,
const bool allowUnmapped
) const ) const
{ {
return interpolate return interpolate
@ -499,7 +535,8 @@ Foam::tmp
> >
Foam::fvMeshSubset::interpolate Foam::fvMeshSubset::interpolate
( (
const GeometricField<Type, pointPatchField, pointMesh>& sf const GeometricField<Type, pointPatchField, pointMesh>& sf,
const bool allowUnmapped
) const ) const
{ {
return interpolate return interpolate
@ -551,7 +588,8 @@ Foam::tmp
> >
Foam::fvMeshSubset::interpolate Foam::fvMeshSubset::interpolate
( (
const DimensionedField<Type, volMesh>& df const DimensionedField<Type, volMesh>& df,
const bool allowUnmapped
) const ) const
{ {
return interpolate(df, subMesh(), cellMap()); return interpolate(df, subMesh(), cellMap());