Reset field to zero if size is updated

This commit is contained in:
Hrvoje Jasak 2019-03-28 15:09:12 +00:00
parent 6c2263a2bf
commit 1ce46b1f08
2 changed files with 28 additions and 11 deletions

View file

@ -35,11 +35,18 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Type> template<class Type>
void immersedBoundaryFvsPatchField<Type>::updateSize() bool immersedBoundaryFvsPatchField<Type>::updateSize()
{ {
if (this->patch().size() != this->size()) if (this->patch().size() != this->size())
{ {
this->setSize(this->patch().size()); this->setSize(this->patch().size());
// Size has changed
return true;
}
else
{
return false;
} }
} }
@ -140,7 +147,14 @@ void immersedBoundaryFvsPatchField<Type>::rmap
template<class Type> template<class Type>
void immersedBoundaryFvsPatchField<Type>::updateOnMotion() void immersedBoundaryFvsPatchField<Type>::updateOnMotion()
{ {
this->updateSize(); if (this->updateSize())
{
// Size changed: must reset values. HJ, 28/Mar/2019
Field<Type>::operator=
(
Field<Type>(this->patch().size(), pTraits<Type>::zero)
);
}
} }
@ -150,12 +164,14 @@ void immersedBoundaryFvsPatchField<Type>::evaluate
const Pstream::commsTypes const Pstream::commsTypes
) )
{ {
this->updateSize(); if (this->updateSize())
{
Field<Type>::operator= // Size changed: must reset values. HJ, 28/Mar/2019
( Field<Type>::operator=
Field<Type>(this->patch().size(), pTraits<Type>::zero) (
); Field<Type>(this->patch().size(), pTraits<Type>::zero)
);
}
} }
@ -164,8 +180,8 @@ void immersedBoundaryFvsPatchField<Type>::write(Ostream& os) const
{ {
fvsPatchField<Type>::write(os); fvsPatchField<Type>::write(os);
// The value entry needs to be written with zero size // The value entry needs to be written with zero size
Field<Type>::null().writeEntry("value", os); // Field<Type>::null().writeEntry("value", os);
// this->writeEntry("value", os); this->writeEntry("value", os);
} }

View file

@ -69,7 +69,8 @@ class immersedBoundaryFvsPatchField
// Private Member Functions // Private Member Functions
//- Update field size to match the patch //- Update field size to match the patch
void updateSize(); // Return true if size has changed
bool updateSize();
public: public: