Delayed initialisation of the immersed boundary patch: avoid cutting at patchField initialisation and delay until fvMesh init

This commit is contained in:
Hrvoje Jasak 2019-01-25 16:16:16 +00:00
parent 17632aaa21
commit 0da8433b5d
7 changed files with 37 additions and 38 deletions

View file

@ -360,6 +360,18 @@ Foam::label Foam::immersedBoundaryFvPatch::size() const
{ {
// Immersed boundary patch size equals to the number of intersected cells // Immersed boundary patch size equals to the number of intersected cells
// HJ, 28/Nov/2017 // HJ, 28/Nov/2017
// Note: asking for patch size triggers the cutting which involves
// parallel communication. This should be avoided under read/write, ie
// when the ibPolyPatch_ is not initialised.
// Initialisation happens when the fvMesh is initialised, which should be
// sufficient
// HJ, 12/Dec/2018
if (!ibPolyPatch_.active())
{
return 0;
}
return ibPolyPatch_.ibCells().size(); return ibPolyPatch_.ibCells().size();
} }
@ -371,16 +383,4 @@ Foam::immersedBoundaryFvPatch::faceCells() const
} }
// Foam::tmp<Foam::vectorField> Foam::immersedBoundaryFvPatch::nf() const
// {
// return ibPolyPatch_.ibPatch().faceNormals();
// }
// Foam::tmp<Foam::vectorField> Foam::immersedBoundaryFvPatch::delta() const
// {
// return ibPolyPatch_.ibPatch().faceCentres() - ibPolyPatch_.ibCellCentres();
// }
// ************************************************************************* // // ************************************************************************* //

View file

@ -153,6 +153,9 @@ public:
// Access // Access
//- Return size equal to number of intersected cells //- Return size equal to number of intersected cells
// Note: if the ibPolyPatch is not initialised, return zero size
// to avoid triggering cutting (with parallel communications).
// HJ, 12/Dec/2018
virtual label size() const; virtual label size() const;
//- Return patch slice size //- Return patch slice size
@ -167,17 +170,6 @@ public:
virtual const unallocLabelList& faceCells() const; virtual const unallocLabelList& faceCells() const;
// Access functions for geometrical data
// //- Return face normals
// // Reconsider. HJ, 11/Dec/2017
// tmp<vectorField> nf() const;
// //- Return cell-centre to face-centre vector
// // Reconsider. HJ, 11/Dec/2017
// virtual tmp<vectorField> delta() const;
// Access to immersed boundary components // Access to immersed boundary components
//- Return reference to immersed boundary polyPatch //- Return reference to immersed boundary polyPatch

View file

@ -66,7 +66,7 @@ fixedValueIbFvPatchField<Type>::fixedValueIbFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchField<Type>(p, iF), // Do not read mixed data fixedValueFvPatchField<Type>(p, iF, dict),
immersedBoundaryFieldBase<Type> immersedBoundaryFieldBase<Type>
( (
p, p,
@ -115,7 +115,7 @@ fixedValueIbFvPatchField<Type>::fixedValueIbFvPatchField
const fvPatchFieldMapper& mapper const fvPatchFieldMapper& mapper
) )
: :
fixedValueFvPatchField<Type>(p, iF), // Do not map mixed data fixedValueFvPatchField<Type>(p, iF), // Do not map fixed data
immersedBoundaryFieldBase<Type> immersedBoundaryFieldBase<Type>
( (
p, p,

View file

@ -70,7 +70,7 @@ mixedIbFvPatchField<Type>::mixedIbFvPatchField
const dictionary& dict const dictionary& dict
) )
: :
mixedFvPatchField<Type>(p, iF), // Do not read mixed data mixedFvPatchField<Type>(p, iF),
immersedBoundaryFieldBase<Type> immersedBoundaryFieldBase<Type>
( (
p, p,
@ -105,15 +105,17 @@ mixedIbFvPatchField<Type>::mixedIbFvPatchField
<< exit(FatalIOError); << exit(FatalIOError);
} }
// Re-interpolate the data related to immersed boundary // On creation of the field, intersection cannot be called unless
this->updateIbValues(); // the patch is active
// mixedFvPatchField<Type>::evaluate();
// On creation of the field, intersection cannot be called.
// Initialise the value to avoid errors // Initialise the value to avoid errors
// HJ, 1/Dec/2017 // HJ, 1/Dec/2017
Field<Type>::operator=(pTraits<Type>::zero); if (this->ibPatch().ibPolyPatch().active())
{
// Re-interpolate the data related to immersed boundary
this->updateIbValues();
mixedFvPatchField<Type>::evaluate();
}
} }

View file

@ -65,7 +65,7 @@ movingImmersedBoundaryVelocityFvPatchVectorField
const dictionary& dict const dictionary& dict
) )
: :
fixedValueFvPatchVectorField(p, iF), // Do not read data fixedValueFvPatchVectorField(p, iF, dict),
immersedBoundaryFieldBase<vector> immersedBoundaryFieldBase<vector>
( (
p, p,

View file

@ -66,11 +66,9 @@ immersedBoundaryFvsPatchField<Type>::immersedBoundaryFvsPatchField
const dictionary& dict const dictionary& dict
) )
: :
fvsPatchField<Type>(p, iF), // Do not read base data fvsPatchField<Type>(p, iF, dict),
ibPatch_(refCast<const immersedBoundaryFvPatch>(p)) ibPatch_(refCast<const immersedBoundaryFvPatch>(p))
{ {}
operator=(pTraits<Type>::zero);
}
template<class Type> template<class Type>

View file

@ -308,6 +308,13 @@ public:
// Immersed boundary patch data // Immersed boundary patch data
//- Is the immersed boundary patch active?
// (is the intersection patch calculated?)
bool active() const
{
return ibPatchPtr_ != NULL;
}
//- Return primitivePatch of cell-intersected faces //- Return primitivePatch of cell-intersected faces
// Faces are calculated as intesection between the volume mesh // Faces are calculated as intesection between the volume mesh
// and the ibMesh // and the ibMesh