From bfa20286f2dbd0c42b7dca246d1fa5ea92785846 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Wed, 22 Apr 2020 17:25:55 +0200 Subject: [PATCH] STYLE: remove spurious coordinate system validity check --- .../jouleHeatingSource/jouleHeatingSource.C | 39 ++++++++----------- .../jouleHeatingSource/jouleHeatingSource.H | 9 ++--- .../coordinate/systems/coordinateSystem.H | 4 +- 3 files changed, 21 insertions(+), 31 deletions(-) diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C index 190484ea861..54cbde806a3 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2018 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -55,19 +55,6 @@ const Foam::word Foam::fv::jouleHeatingSource::sigmaName(typeName + ":sigma"); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -const Foam::coordinateSystem& Foam::fv::jouleHeatingSource::csys() const -{ - if (!csysPtr_ || !csysPtr_.valid()) - { - FatalErrorInFunction - << "Coordinate system invalid" - << abort(FatalError); - } - - return *csysPtr_; -} - - Foam::tmp<Foam::volSymmTensorField> Foam::fv::jouleHeatingSource::transformSigma ( @@ -91,15 +78,25 @@ Foam::fv::jouleHeatingSource::transformSigma ); auto& sigma = tsigma.ref(); - if (csys().uniform()) + // This check should be unnecessary + if (!csysPtr_) + { + FatalErrorInFunction + << "Coordinate system undefined" + << abort(FatalError); + } + + const auto& csys = *csysPtr_; + + if (csys.uniform()) { sigma.primitiveFieldRef() = - csys().transformPrincipal(sigmaLocal); + csys.transformPrincipal(sigmaLocal); } else { sigma.primitiveFieldRef() = - csys().transformPrincipal(mesh_.cellCentres(), sigmaLocal); + csys.transformPrincipal(mesh_.cellCentres(), sigmaLocal); } sigma.correctBoundaryConditions(); @@ -152,12 +149,6 @@ Foam::fv::jouleHeatingSource::jouleHeatingSource } -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::fv::jouleHeatingSource::~jouleHeatingSource() -{} - - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // void Foam::fv::jouleHeatingSource::addSup @@ -247,6 +238,8 @@ bool Foam::fv::jouleHeatingSource::read(const dictionary& dict) Info<< " Using scalar electrical conductivity" << endl; initialiseSigma(coeffs_, scalarSigmaVsTPtr_); + + csysPtr_.clear(); // Do not need coordinate system } return true; diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H index 2c36a4dca61..8bce699d629 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2017 OpenCFD Ltd. + Copyright (C) 2016-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -155,7 +155,7 @@ class jouleHeatingSource : public option { - // Private data + // Private Data //- Name of electrical conductivity field static const word sigmaName; @@ -190,9 +190,6 @@ class jouleHeatingSource //- No copy assignment void operator=(const jouleHeatingSource&) = delete; - //- The coordinate system for anisotropic electrical conductivity - const coordinateSystem& csys() const; - //- Transform the anisotropic electrical conductivity into global system tmp<volSymmTensorField> transformSigma ( @@ -232,7 +229,7 @@ public: //- Destructor - virtual ~jouleHeatingSource(); + virtual ~jouleHeatingSource() = default; // Member Functions diff --git a/src/meshTools/coordinate/systems/coordinateSystem.H b/src/meshTools/coordinate/systems/coordinateSystem.H index c0d81679941..42e5bc2d119 100644 --- a/src/meshTools/coordinate/systems/coordinateSystem.H +++ b/src/meshTools/coordinate/systems/coordinateSystem.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018 OpenCFD Ltd. + Copyright (C) 2018-2020 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -429,7 +429,7 @@ public: //- Considered valid if it has a specification virtual bool valid() const { - return spec_.valid(); + return spec_; } //- True if the rotation tensor is uniform for all locations -- GitLab