From aa5131b1140b71d9a50f745739734e9b6620e431 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Thu, 6 Sep 2018 18:23:21 +0100 Subject: [PATCH] Dynamic refinement with immersed boundary wall function: fixes --- ...aryEpsilonWallFunctionFvPatchScalarField.C | 55 +++++++++++++- ...aryEpsilonWallFunctionFvPatchScalarField.H | 13 ++++ ...ersedBoundaryKqRWallFunctionFvPatchField.C | 49 ++++++++++-- ...ersedBoundaryKqRWallFunctionFvPatchField.H | 13 ++++ ...oundaryNutWallFunctionFvPatchScalarField.C | 41 ++++++++++ ...oundaryNutWallFunctionFvPatchScalarField.H | 22 ++++++ ...ndaryOmegaWallFunctionFvPatchScalarField.C | 76 +++++++++++++++++-- ...ndaryOmegaWallFunctionFvPatchScalarField.H | 19 +++++ 8 files changed, 273 insertions(+), 15 deletions(-) diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C index 40f7fe786..1d0d64fdf 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.C @@ -63,7 +63,12 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField ) : epsilonWallFunctionFvPatchScalarField(p, iF, dict), - immersedBoundaryFieldBase(p, true, 0.09) + immersedBoundaryFieldBase + ( + p, + Switch(dict.lookup("setDeadValue")), + readScalar(dict.lookup("deadValue")) + ) {} @@ -77,7 +82,12 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField ) : epsilonWallFunctionFvPatchScalarField(ptf, p, iF, mapper), - immersedBoundaryFieldBase(p, true, 0.09) + immersedBoundaryFieldBase + ( + p, + ptf.setDeadValue(), + ptf.deadValue() + ) {} @@ -88,7 +98,12 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField ) : epsilonWallFunctionFvPatchScalarField(ptf), - immersedBoundaryFieldBase(ptf.ibPatch(), true, 0.09) + immersedBoundaryFieldBase + ( + ptf.ibPatch(), + ptf.setDeadValue(), + ptf.deadValue() + ) {} @@ -100,12 +115,37 @@ immersedBoundaryEpsilonWallFunctionFvPatchScalarField ) : epsilonWallFunctionFvPatchScalarField(ptf, iF), - immersedBoundaryFieldBase(ptf.ibPatch(), true, 0.09) + immersedBoundaryFieldBase + ( + ptf.ibPatch(), + ptf.setDeadValue(), + ptf.deadValue() + ) {} // * * * * * * * * * * * * * * * 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() { if (size() != ibPatch().size()) @@ -163,6 +203,12 @@ void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::evaluate refValue() = patchInternalField(); } + // Get non-constant reference to internal field + scalarField& intField = const_cast(this->internalField()); + + // Set dead value + this->setDeadValues(intField); + epsilonWallFunctionFvPatchScalarField::evaluate(commsType); } @@ -174,6 +220,7 @@ void immersedBoundaryEpsilonWallFunctionFvPatchScalarField::write { fvPatchScalarField::write(os); writeLocalEntries(os); + this->writeDeadData(os); // The value entry needs to be written with zero size scalarField::null().writeEntry("value", os); diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.H b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.H index 2ce007308..f12d2b17a 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.H +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryEpsilonWallFunction/immersedBoundaryEpsilonWallFunctionFvPatchScalarField.H @@ -142,6 +142,19 @@ public: // 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 virtual void updateOnMotion(); diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C index d8b3339d7..4fc53997a 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.C @@ -83,7 +83,12 @@ immersedBoundaryKqRWallFunctionFvPatchField ) : kqRWallFunctionFvPatchField(p, iF), - immersedBoundaryFieldBase(p, true, pTraits::one*SMALL) + immersedBoundaryFieldBase + ( + p, + Switch(dict.lookup("setDeadValue")), + pTraits(dict.lookup("deadValue")) + ) { this->checkType(); @@ -102,7 +107,12 @@ immersedBoundaryKqRWallFunctionFvPatchField ) : kqRWallFunctionFvPatchField(ptf, p, iF, mapper), - immersedBoundaryFieldBase(p, true, pTraits::one*SMALL) + immersedBoundaryFieldBase + ( + p, + ptf.setDeadValue(), + ptf.deadValue() + ) { this->checkType(); } @@ -119,8 +129,8 @@ immersedBoundaryKqRWallFunctionFvPatchField immersedBoundaryFieldBase ( ptf.ibPatch(), - true, - pTraits::one*SMALL + ptf.setDeadValue(), + ptf.deadValue() ) { this->checkType(); @@ -139,8 +149,8 @@ immersedBoundaryKqRWallFunctionFvPatchField immersedBoundaryFieldBase ( ptf.ibPatch(), - true, - pTraits::one*SMALL + ptf.setDeadValue(), + ptf.deadValue() ) { this->checkType(); @@ -149,6 +159,25 @@ immersedBoundaryKqRWallFunctionFvPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +void immersedBoundaryKqRWallFunctionFvPatchField::autoMap +( + const fvPatchFieldMapper& +) +{ + Field::operator=(this->patchInternalField()); +} + + +template +void immersedBoundaryKqRWallFunctionFvPatchField::rmap +( + const fvPatchField& ptf, + const labelList& +) +{} + + template void immersedBoundaryKqRWallFunctionFvPatchField::updateOnMotion() { @@ -173,6 +202,12 @@ void immersedBoundaryKqRWallFunctionFvPatchField::evaluate Field::operator=(this->patchInternalField()); } + // Get non-constant reference to internal field + Field& intField = const_cast&>(this->internalField()); + + // Set dead value + this->setDeadValues(intField); + kqRWallFunctionFvPatchField::evaluate(commsType); } @@ -181,6 +216,8 @@ template void immersedBoundaryKqRWallFunctionFvPatchField::write(Ostream& os) const { fvPatchField::write(os); + this->writeDeadData(os); + // The value entry needs to be written with zero size Field::null().writeEntry("value", os); // this->writeEntry("value", os); diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.H b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.H index 505ef0eb5..49a15108d 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.H +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryKqRWallFunction/immersedBoundaryKqRWallFunctionFvPatchField.H @@ -142,6 +142,19 @@ public: // 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&, + const labelList& + ); + //- Update on mesh motion virtual void updateOnMotion(); diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C index 2706a97d3..0c85936a5 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.C @@ -105,6 +105,23 @@ immersedBoundaryNutWallFunctionFvPatchScalarField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void immersedBoundaryNutWallFunctionFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& +) +{ + scalarField::operator=(this->patchInternalField()); +} + + +void immersedBoundaryNutWallFunctionFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& +) +{} + + void immersedBoundaryNutWallFunctionFvPatchScalarField::updateOnMotion() { 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(this->internalField()); + + // Set dead value + this->setDeadValues(intField); + + nutkWallFunctionFvPatchScalarField::evaluate(commsType); +} + + void immersedBoundaryNutWallFunctionFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.H b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.H index ba2624f25..6beccc705 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.H +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryNutWallFunction/immersedBoundaryNutWallFunctionFvPatchScalarField.H @@ -136,10 +136,32 @@ public: // 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 virtual void updateOnMotion(); + // Evaluation functions + + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes = Pstream::blocking + ); + + // I-O //- Write diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C index 582b46b74..2e8fc4c1e 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.C @@ -61,7 +61,12 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField ) : omegaWallFunctionFvPatchScalarField(p, iF, dict), - immersedBoundaryFieldBase(p, true, 90) + immersedBoundaryFieldBase + ( + p, + Switch(dict.lookup("setDeadValue")), + readScalar(dict.lookup("deadValue")) + ) {} @@ -75,7 +80,12 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField ) : omegaWallFunctionFvPatchScalarField(ptf, p, iF, mapper), - immersedBoundaryFieldBase(p, true, 90) + immersedBoundaryFieldBase + ( + p, + ptf.setDeadValue(), + ptf.deadValue() + ) {} @@ -86,7 +96,12 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField ) : omegaWallFunctionFvPatchScalarField(ptf), - immersedBoundaryFieldBase(ptf.ibPatch(), true, 90) + immersedBoundaryFieldBase + ( + ptf.ibPatch(), + ptf.setDeadValue(), + ptf.deadValue() + ) {} @@ -98,12 +113,37 @@ immersedBoundaryOmegaWallFunctionFvPatchScalarField ) : omegaWallFunctionFvPatchScalarField(ptf, iF), - immersedBoundaryFieldBase(ptf.ibPatch(), true, 90) + immersedBoundaryFieldBase + ( + ptf.ibPatch(), + ptf.setDeadValue(), + ptf.deadValue() + ) {} // * * * * * * * * * * * * * * * 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() { if (size() != ibPatch().size()) @@ -127,7 +167,7 @@ void immersedBoundaryOmegaWallFunctionFvPatchScalarField::updateCoeffs() // Resize fields if (size() != patch().size()) { - Info<< "Resizing immersedBoundaryEpsilonWallFunction in evaluate: " + Info<< "Resizing immersedBoundaryOmegaWallFunction in evaluate: " << "patch: " << patch().size() << " field: " << size() << 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(this->internalField()); + + // Set dead value + this->setDeadValues(intField); + + omegaWallFunctionFvPatchScalarField::evaluate(commsType); +} + + void immersedBoundaryOmegaWallFunctionFvPatchScalarField::write ( Ostream& os @@ -152,6 +217,7 @@ void immersedBoundaryOmegaWallFunctionFvPatchScalarField::write { fvPatchScalarField::write(os); writeLocalEntries(os); + this->writeDeadData(os); // The value entry needs to be written with zero size scalarField::null().writeEntry("value", os); diff --git a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.H b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.H index c4ce9e67f..f39b415b1 100644 --- a/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.H +++ b/src/immersedBoundary/immersedBoundaryTurbulence/wallFunctions/immersedBoundaryOmegaWallFunctions/immersedBoundaryOmegaWallFunctionFvPatchScalarField.H @@ -156,6 +156,19 @@ public: // 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 virtual void updateOnMotion(); @@ -165,6 +178,12 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); + //- Evaluate the patchField + virtual void evaluate + ( + const Pstream::commsTypes = Pstream::blocking + ); + // I-O