From 0e5dfb1f6437926ffb270428c81950da3acf5105 Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Tue, 29 Mar 2022 13:16:14 +0100 Subject: [PATCH] BUG: atmosphericModels: add missing clone functions (fixes #2428) --- .../atmBoundaryLayer/atmBoundaryLayer.C | 30 +++++++++++++------ ...atmAlphatkWallFunctionFvPatchScalarField.C | 21 +++++++++---- 2 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/atmosphericModels/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C b/src/atmosphericModels/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C index 5c5d0b5acb..3c77cefdb6 100644 --- a/src/atmosphericModels/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C +++ b/src/atmosphericModels/derivedFvPatchFields/atmBoundaryLayer/atmBoundaryLayer.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2014-2016 OpenFOAM Foundation - Copyright (C) 2018-2021 OpenCFD Ltd. + Copyright (C) 2018-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -115,10 +115,10 @@ atmBoundaryLayer::atmBoundaryLayer(const atmBoundaryLayer& abl) ppMin_(abl.ppMin_), time_(abl.time_), patch_(abl.patch_), - flowDir_(abl.flowDir_), - zDir_(abl.zDir_), - Uref_(abl.Uref_), - Zref_(abl.Zref_), + flowDir_(abl.flowDir_.clone()), + zDir_(abl.zDir_.clone()), + Uref_(abl.Uref_.clone()), + Zref_(abl.Zref_.clone()), z0_(abl.z0_.clone(patch_)), d_(abl.d_.clone(patch_)) {} @@ -274,10 +274,22 @@ void atmBoundaryLayer::write(Ostream& os) const os.writeEntry("Cmu", Cmu_); os.writeEntry("C1", C1_); os.writeEntry("C2", C2_); - flowDir_->writeData(os); - zDir_->writeData(os); - Uref_->writeData(os); - Zref_->writeData(os); + if (flowDir_) + { + flowDir_->writeData(os); + } + if (zDir_) + { + zDir_->writeData(os); + } + if (Uref_) + { + Uref_->writeData(os); + } + if (Zref_) + { + Zref_->writeData(os); + } if (z0_) { z0_->writeData(os) ; diff --git a/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmAlphatkWallFunction/atmAlphatkWallFunctionFvPatchScalarField.C b/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmAlphatkWallFunction/atmAlphatkWallFunctionFvPatchScalarField.C index 0f0be2ac92..32f69fb255 100644 --- a/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmAlphatkWallFunction/atmAlphatkWallFunctionFvPatchScalarField.C +++ b/src/atmosphericModels/derivedFvPatchFields/wallFunctions/atmAlphatkWallFunction/atmAlphatkWallFunctionFvPatchScalarField.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020-2021 OpenCFD Ltd. + Copyright (C) 2020-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -145,7 +145,7 @@ atmAlphatkWallFunctionFvPatchScalarField fixedValueFvPatchScalarField(wfpsf), Cmu_(wfpsf.Cmu_), kappa_(wfpsf.kappa_), - Pr_(wfpsf.Pr_), + Pr_(wfpsf.Pr_.clone()), Prt_(wfpsf.Prt_.clone(this->patch().patch())), z0_(wfpsf.z0_.clone(this->patch().patch())) { @@ -163,7 +163,7 @@ atmAlphatkWallFunctionFvPatchScalarField fixedValueFvPatchScalarField(wfpsf, iF), Cmu_(wfpsf.Cmu_), kappa_(wfpsf.kappa_), - Pr_(wfpsf.Pr_), + Pr_(wfpsf.Pr_.clone()), Prt_(wfpsf.Prt_.clone(this->patch().patch())), z0_(wfpsf.z0_.clone(this->patch().patch())) { @@ -289,9 +289,18 @@ void atmAlphatkWallFunctionFvPatchScalarField::write(Ostream& os) const fvPatchField::write(os); os.writeEntry("Cmu", Cmu_); os.writeEntry("kappa", kappa_); - Pr_->writeData(os); - Prt_->writeData(os); - z0_->writeData(os); + if (Pr_) + { + Pr_->writeData(os); + } + if (Prt_) + { + Prt_->writeData(os); + } + if (z0_) + { + z0_->writeData(os); + } writeEntry("value", os); }