Dynamic refinement with immersed boundary wall function: fixes

This commit is contained in:
Hrvoje Jasak 2018-09-06 18:23:21 +01:00
parent e97fa4ed9e
commit aa5131b114
8 changed files with 273 additions and 15 deletions

View file

@ -63,7 +63,12 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField
) )
: :
epsilonWallFunctionFvPatchScalarField(p, iF, dict), epsilonWallFunctionFvPatchScalarField(p, iF, dict),
immersedBoundaryFieldBase<scalar>(p, true, 0.09) immersedBoundaryFieldBase<scalar>
(
p,
Switch(dict.lookup("setDeadValue")),
readScalar(dict.lookup("deadValue"))
)
{} {}
@ -77,7 +82,12 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField
) )
: :
epsilonWallFunctionFvPatchScalarField(ptf, p, iF, mapper), epsilonWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
immersedBoundaryFieldBase<scalar>(p, true, 0.09) immersedBoundaryFieldBase<scalar>
(
p,
ptf.setDeadValue(),
ptf.deadValue()
)
{} {}
@ -88,7 +98,12 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField
) )
: :
epsilonWallFunctionFvPatchScalarField(ptf), epsilonWallFunctionFvPatchScalarField(ptf),
immersedBoundaryFieldBase<scalar>(ptf.ibPatch(), true, 0.09) immersedBoundaryFieldBase<scalar>
(
ptf.ibPatch(),
ptf.setDeadValue(),
ptf.deadValue()
)
{} {}
@ -100,12 +115,37 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField
) )
: :
epsilonWallFunctionFvPatchScalarField(ptf, iF), epsilonWallFunctionFvPatchScalarField(ptf, iF),
immersedBoundaryFieldBase<scalar>(ptf.ibPatch(), true, 0.09) immersedBoundaryFieldBase<scalar>
(
ptf.ibPatch(),
ptf.setDeadValue(),
ptf.deadValue()
)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::autoMap
(
const fvPatchFieldMapper&
)
{
scalarField::operator=(this->patchInternalField());
// Resize refValue as well. HJ, 10/Jul/2018
refValue() = this->patchInternalField();
}
void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList&
)
{}
void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::updateOnMotion() void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::updateOnMotion()
{ {
if (size() != ibPatch().size()) if (size() != ibPatch().size())
@ -163,6 +203,12 @@ void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::evaluate
refValue() = patchInternalField(); refValue() = patchInternalField();
} }
// Get non-constant reference to internal field
scalarField& intField = const_cast<scalarField&>(this->internalField());
// Set dead value
this->setDeadValues(intField);
epsilonWallFunctionFvPatchScalarField::evaluate(commsType); epsilonWallFunctionFvPatchScalarField::evaluate(commsType);
} }
@ -174,6 +220,7 @@ void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::write
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
writeLocalEntries(os); writeLocalEntries(os);
this->writeDeadData(os);
// The value entry needs to be written with zero size // The value entry needs to be written with zero size
scalarField::null().writeEntry("value", os); scalarField::null().writeEntry("value", os);

View file

@ -142,6 +142,19 @@ public:
// Mapping functions // Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
//- Update on mesh motion //- Update on mesh motion
virtual void updateOnMotion(); virtual void updateOnMotion();

View file

@ -83,7 +83,12 @@ immersedBoundaryKqRWallFunctionFvPatchField
) )
: :
kqRWallFunctionFvPatchField<Type>(p, iF), kqRWallFunctionFvPatchField<Type>(p, iF),
immersedBoundaryFieldBase<Type>(p, true, pTraits<Type>::one*SMALL) immersedBoundaryFieldBase<Type>
(
p,
Switch(dict.lookup("setDeadValue")),
pTraits<Type>(dict.lookup("deadValue"))
)
{ {
this->checkType(); this->checkType();
@ -102,7 +107,12 @@ immersedBoundaryKqRWallFunctionFvPatchField
) )
: :
kqRWallFunctionFvPatchField<Type>(ptf, p, iF, mapper), kqRWallFunctionFvPatchField<Type>(ptf, p, iF, mapper),
immersedBoundaryFieldBase<Type>(p, true, pTraits<Type>::one*SMALL) immersedBoundaryFieldBase<Type>
(
p,
ptf.setDeadValue(),
ptf.deadValue()
)
{ {
this->checkType(); this->checkType();
} }
@ -119,8 +129,8 @@ immersedBoundaryKqRWallFunctionFvPatchField
immersedBoundaryFieldBase<Type> immersedBoundaryFieldBase<Type>
( (
ptf.ibPatch(), ptf.ibPatch(),
true, ptf.setDeadValue(),
pTraits<Type>::one*SMALL ptf.deadValue()
) )
{ {
this->checkType(); this->checkType();
@ -139,8 +149,8 @@ immersedBoundaryKqRWallFunctionFvPatchField
immersedBoundaryFieldBase<Type> immersedBoundaryFieldBase<Type>
( (
ptf.ibPatch(), ptf.ibPatch(),
true, ptf.setDeadValue(),
pTraits<Type>::one*SMALL ptf.deadValue()
) )
{ {
this->checkType(); this->checkType();
@ -149,6 +159,25 @@ immersedBoundaryKqRWallFunctionFvPatchField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void immersedBoundaryKqRWallFunctionFvPatchField<Type>::autoMap
(
const fvPatchFieldMapper&
)
{
Field<Type>::operator=(this->patchInternalField());
}
template<class Type>
void immersedBoundaryKqRWallFunctionFvPatchField<Type>::rmap
(
const fvPatchField<Type>& ptf,
const labelList&
)
{}
template<class Type> template<class Type>
void immersedBoundaryKqRWallFunctionFvPatchField<Type>::updateOnMotion() void immersedBoundaryKqRWallFunctionFvPatchField<Type>::updateOnMotion()
{ {
@ -173,6 +202,12 @@ void immersedBoundaryKqRWallFunctionFvPatchField<Type>::evaluate
Field<Type>::operator=(this->patchInternalField()); Field<Type>::operator=(this->patchInternalField());
} }
// Get non-constant reference to internal field
Field<Type>& intField = const_cast<Field<Type>&>(this->internalField());
// Set dead value
this->setDeadValues(intField);
kqRWallFunctionFvPatchField<Type>::evaluate(commsType); kqRWallFunctionFvPatchField<Type>::evaluate(commsType);
} }
@ -181,6 +216,8 @@ template<class Type>
void immersedBoundaryKqRWallFunctionFvPatchField<Type>::write(Ostream& os) const void immersedBoundaryKqRWallFunctionFvPatchField<Type>::write(Ostream& os) const
{ {
fvPatchField<Type>::write(os); fvPatchField<Type>::write(os);
this->writeDeadData(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

@ -142,6 +142,19 @@ public:
// Mapping functions // Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchField<Type>&,
const labelList&
);
//- Update on mesh motion //- Update on mesh motion
virtual void updateOnMotion(); virtual void updateOnMotion();

View file

@ -105,6 +105,23 @@ immersedBoundaryNutWallFunctionFvPatchScalarField
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void immersedBoundaryNutWallFunctionFvPatchScalarField::autoMap
(
const fvPatchFieldMapper&
)
{
scalarField::operator=(this->patchInternalField());
}
void immersedBoundaryNutWallFunctionFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList&
)
{}
void immersedBoundaryNutWallFunctionFvPatchScalarField::updateOnMotion() void immersedBoundaryNutWallFunctionFvPatchScalarField::updateOnMotion()
{ {
if (size() != ibPatch().size()) if (size() != ibPatch().size())
@ -115,6 +132,30 @@ void immersedBoundaryNutWallFunctionFvPatchScalarField::updateOnMotion()
} }
void immersedBoundaryNutWallFunctionFvPatchScalarField::evaluate
(
const Pstream::commsTypes commsType
)
{
// Resize fields
if (size() != patch().size())
{
Info<< "Resizing immersedBoundaryNutWallFunction in evaluate"
<< endl;
*this == patchInternalField();
}
// Get non-constant reference to internal field
scalarField& intField = const_cast<scalarField&>(this->internalField());
// Set dead value
this->setDeadValues(intField);
nutkWallFunctionFvPatchScalarField::evaluate(commsType);
}
void immersedBoundaryNutWallFunctionFvPatchScalarField::write(Ostream& os) const void immersedBoundaryNutWallFunctionFvPatchScalarField::write(Ostream& os) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);

View file

@ -136,10 +136,32 @@ public:
// Mapping functions // Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
//- Update on mesh motion //- Update on mesh motion
virtual void updateOnMotion(); virtual void updateOnMotion();
// Evaluation functions
//- Evaluate the patchField
virtual void evaluate
(
const Pstream::commsTypes = Pstream::blocking
);
// I-O // I-O
//- Write //- Write

View file

@ -61,7 +61,12 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField
) )
: :
omegaWallFunctionFvPatchScalarField(p, iF, dict), omegaWallFunctionFvPatchScalarField(p, iF, dict),
immersedBoundaryFieldBase<scalar>(p, true, 90) immersedBoundaryFieldBase<scalar>
(
p,
Switch(dict.lookup("setDeadValue")),
readScalar(dict.lookup("deadValue"))
)
{} {}
@ -75,7 +80,12 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField
) )
: :
omegaWallFunctionFvPatchScalarField(ptf, p, iF, mapper), omegaWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
immersedBoundaryFieldBase<scalar>(p, true, 90) immersedBoundaryFieldBase<scalar>
(
p,
ptf.setDeadValue(),
ptf.deadValue()
)
{} {}
@ -86,7 +96,12 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField
) )
: :
omegaWallFunctionFvPatchScalarField(ptf), omegaWallFunctionFvPatchScalarField(ptf),
immersedBoundaryFieldBase<scalar>(ptf.ibPatch(), true, 90) immersedBoundaryFieldBase<scalar>
(
ptf.ibPatch(),
ptf.setDeadValue(),
ptf.deadValue()
)
{} {}
@ -98,12 +113,37 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField
) )
: :
omegaWallFunctionFvPatchScalarField(ptf, iF), omegaWallFunctionFvPatchScalarField(ptf, iF),
immersedBoundaryFieldBase<scalar>(ptf.ibPatch(), true, 90) immersedBoundaryFieldBase<scalar>
(
ptf.ibPatch(),
ptf.setDeadValue(),
ptf.deadValue()
)
{} {}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::autoMap
(
const fvPatchFieldMapper&
)
{
scalarField::operator=(this->patchInternalField());
// Resize refValue as well. HJ, 10/Jul/2018
refValue() = this->patchInternalField();
}
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList&
)
{}
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::updateOnMotion() void immersedBoundaryOmegaWallFunctionFvPatchScalarField::updateOnMotion()
{ {
if (size() != ibPatch().size()) if (size() != ibPatch().size())
@ -127,7 +167,7 @@ void immersedBoundaryOmegaWallFunctionFvPatchScalarField::updateCoeffs()
// Resize fields // Resize fields
if (size() != patch().size()) if (size() != patch().size())
{ {
Info<< "Resizing immersedBoundaryEpsilonWallFunction in evaluate: " Info<< "Resizing immersedBoundaryOmegaWallFunction in evaluate: "
<< "patch: " << patch().size() << " field: " << size() << "patch: " << patch().size() << " field: " << size()
<< endl; << endl;
@ -145,6 +185,31 @@ void immersedBoundaryOmegaWallFunctionFvPatchScalarField::updateCoeffs()
} }
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::evaluate
(
const Pstream::commsTypes commsType
)
{
// Resize fields
if (size() != patch().size())
{
Info<< "Resizing immersedBoundaryOmegaWallFunction in evaluate"
<< endl;
*this == patchInternalField();
refValue() = patchInternalField();
}
// Get non-constant reference to internal field
scalarField& intField = const_cast<scalarField&>(this->internalField());
// Set dead value
this->setDeadValues(intField);
omegaWallFunctionFvPatchScalarField::evaluate(commsType);
}
void immersedBoundaryOmegaWallFunctionFvPatchScalarField::write void immersedBoundaryOmegaWallFunctionFvPatchScalarField::write
( (
Ostream& os Ostream& os
@ -152,6 +217,7 @@ void immersedBoundaryOmegaWallFunctionFvPatchScalarField::write
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
writeLocalEntries(os); writeLocalEntries(os);
this->writeDeadData(os);
// The value entry needs to be written with zero size // The value entry needs to be written with zero size
scalarField::null().writeEntry("value", os); scalarField::null().writeEntry("value", os);

View file

@ -156,6 +156,19 @@ public:
// Mapping functions // Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
//- Update on mesh motion //- Update on mesh motion
virtual void updateOnMotion(); virtual void updateOnMotion();
@ -165,6 +178,12 @@ public:
//- Update the coefficients associated with the patch field //- Update the coefficients associated with the patch field
virtual void updateCoeffs(); virtual void updateCoeffs();
//- Evaluate the patchField
virtual void evaluate
(
const Pstream::commsTypes = Pstream::blocking
);
// I-O // I-O