ENH: when using (E)SI sensitivities and a symmetry(Plane) is included

in the sensitivity patches, symmetry::evaluate() needs access to the
internalField which does exist, leading to wrong memory access.

Fixed by specifying a calculated type fvPatchField for all patches when
creating a boundaryField<Type>

Using a symmetry(Plane) as a sensitivity patch is quite rare and
borderline wrong, but this provides a fix nonetheless.
This commit is contained in:
Vaggelis Papoutsis
2021-12-03 13:19:06 +02:00
committed by Andrew Heather
parent 36ca117192
commit 803caa4078

View File

@ -88,13 +88,30 @@ createZeroBoundaryPtr
typedef typename GeometricField<Type, fvPatchField, volMesh>::Boundary
Boundary;
// Make sure that the patchFields to be generated will be of type
// calculated, even if they are of constraint type
// Necessary to avoid unexpected behaviour when computing sensitivities
// on symmetry patches (not a good practice either way)
const fvBoundaryMesh& bm = mesh.boundary();
wordList actualPatchTypes(bm.size(), word::null);
forAll(actualPatchTypes, pI)
{
auto patchTypeCstrIter =
fvPatchField<Type>::patchConstructorTablePtr_->cfind(bm[pI].type());
if (patchTypeCstrIter.found())
{
actualPatchTypes[pI] = bm[pI].type();
}
}
autoPtr<Boundary> bPtr
(
new Boundary
(
mesh.boundary(),
mesh.V()*pTraits<Type>::zero, // Dummy internal field,
calculatedFvPatchField<Type>::typeName
wordList(bm.size(), calculatedFvPatchField<Type>::typeName),
actualPatchTypes
)
);