From eaffe4c2cf1bc02140f9973d4e2f966f31c8b346 Mon Sep 17 00:00:00 2001 From: Kutalmis Bercin Date: Wed, 14 Sep 2022 15:51:28 +0100 Subject: [PATCH] ENH: solarLoadBase: new base class to access various solar-load data --- src/thermophysicalModels/radiation/Make/files | 1 + .../radiationModels/solarLoad/solarLoad.C | 16 +++ .../radiationModels/solarLoad/solarLoad.H | 10 +- .../radiationModels/solarLoad/solarLoadBase.C | 60 ++++++++++ .../radiationModels/solarLoad/solarLoadBase.H | 105 ++++++++++++++++++ 5 files changed, 191 insertions(+), 1 deletion(-) create mode 100644 src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.C create mode 100644 src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.H diff --git a/src/thermophysicalModels/radiation/Make/files b/src/thermophysicalModels/radiation/Make/files index acd357afac..08c27f94bd 100644 --- a/src/thermophysicalModels/radiation/Make/files +++ b/src/thermophysicalModels/radiation/Make/files @@ -12,6 +12,7 @@ radiationModels/opaqueSolid/opaqueSolid.C radiationModels/solarLoad/solarLoad.C radiationModels/solarLoad/faceShading/faceShading.C radiationModels/solarLoad/faceReflecting/faceReflecting.C +radiationModels/solarLoad/solarLoadBase.C /* Scatter model */ submodels/scatterModel/scatterModel/scatterModel.C diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C index 017ea2a192..90dc9490d0 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.C @@ -760,6 +760,7 @@ void Foam::radiation::solarLoad::calculateQdiff Foam::radiation::solarLoad::solarLoad(const volScalarField& T) : radiationModel(typeName, T), + solarLoadBase(mesh_), solarCalc_(coeffs_, mesh_), dict_(coeffs_), qr_ @@ -814,6 +815,7 @@ Foam::radiation::solarLoad::solarLoad ) : radiationModel(typeName, dict, T), + solarLoadBase(mesh_), solarCalc_(dict, mesh_), dict_(dict), qr_ @@ -985,4 +987,18 @@ Foam::radiation::solarLoad::Ru() const } +const Foam::solarCalculator& +Foam::radiation::solarLoad::solarCalculatorRef() const +{ + return solarCalc_; +} + + +const Foam::faceShading& +Foam::radiation::solarLoad::faceShadingRef() const +{ + return hitFaces_(); +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H index f657fac0bd..5777e9dc2a 100644 --- a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoad.H @@ -99,6 +99,7 @@ SourceFiles #define radiation_solarLoad_H #include "radiationModel.H" +#include "solarLoadBase.H" #include "volFields.H" #include "faceShading.H" #include "faceReflecting.H" @@ -118,7 +119,8 @@ namespace radiation class solarLoad : - public radiationModel + public radiationModel, + public solarLoadBase { // Private Data @@ -262,6 +264,12 @@ public: { return qprimaryRad_[bandI]; } + + //- Return const reference to the solar calculator + virtual const solarCalculator& solarCalculatorRef() const; + + //- Return const reference to the face shading calculator + virtual const faceShading& faceShadingRef() const; }; diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.C b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.C new file mode 100644 index 0000000000..617e2778fb --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.C @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "solarLoadBase.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + defineTypeNameAndDebug(solarLoadBase, 0); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::radiation::solarLoadBase::solarLoadBase +( + const fvMesh& mesh +) +: + regIOobject + ( + IOobject + ( + solarLoadBase::typeName, + mesh.polyMesh::instance(), + mesh + ) + ) +{} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.H b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.H new file mode 100644 index 0000000000..5398c5a8b7 --- /dev/null +++ b/src/thermophysicalModels/radiation/radiationModels/solarLoad/solarLoadBase.H @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | www.openfoam.com + \\/ M anipulation | +------------------------------------------------------------------------------- + Copyright (C) 2022 OpenCFD Ltd. +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::radiation::solarLoadBase + +Group + grpRadiationModels + +Description + Base class for solarLoad models. + +\*---------------------------------------------------------------------------*/ + +#ifndef radiation_solarLoadBase_H +#define radiation_solarLoadBase_H + +#include "regIOobject.H" +#include "fvMesh.H" +#include "solarCalculator.H" +#include "faceShading.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace radiation +{ + +/*---------------------------------------------------------------------------*\ + Class solarLoadBase Declaration +\*---------------------------------------------------------------------------*/ + +class solarLoadBase +: + public regIOobject +{ +public: + + //- Runtime type information + TypeName("solarLoadBase"); + + + // Constructors + + //- Construct + solarLoadBase(const fvMesh& mesh); + + + //- Destructor + virtual ~solarLoadBase() = default; + + + // Member Functions + + // Access + + //- Return const reference to the solar calculator + virtual const solarCalculator& solarCalculatorRef() const = 0; + + //- Return const reference to the face shading calculator + virtual const faceShading& faceShadingRef() const = 0; + + + // IO + + bool writeData(Foam::Ostream&) const + { + return true; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace radiation +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //