/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2026 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- 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 "solidElectricalConduction.H" #include "FunctionalGeometricField.H" #include "basicThermo.H" #include "fvmLaplacian.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // namespace Foam { namespace fv { defineTypeNameAndDebug(solidElectricalConduction, 0); addToRunTimeSelectionTable(fvModel, solidElectricalConduction, dictionary); } } // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::fv::solidElectricalConduction::readCoeffs(const dictionary& dict) { const word sigmaKey = "sigma"; const word sigmaScalarKey ( sigmaKey, '<', pTraits::typeName, '>' ); const word sigmaTensorKey ( sigmaKey, '<', pTraits::typeName, '>' ); const bool haveSigma = dict.found(sigmaKey); const bool haveScalarSigma = dict.found(sigmaScalarKey); const bool haveTensorSigma = dict.found(sigmaTensorKey); const label nHaveSigmas = label(haveSigma) + label(haveScalarSigma) + label(haveTensorSigma); if (nHaveSigmas != 1) { FatalIOErrorInFunction(dict) << (nHaveSigmas ? "multiple" : "none") << " of keywords " << sigmaKey << ", " << sigmaScalarKey << ' ' << (nHaveSigmas ? "and" : "or") << ' ' << sigmaTensorKey << " defined in dictionary " << dict.name() << exit(FatalIOError); } if (haveSigma || haveScalarSigma) { sigmaScalarPtr_.reset ( new FunctionalGeometricField ( sigmaKey, haveSigma ? sigmaKey : sigmaScalarKey, mesh(), dimensions::electricalConductivity, dict ) ); } else { sigmaTensorPtr_.reset ( new FunctionalGeometricField ( sigmaKey, sigmaTensorKey, mesh(), dimensions::electricalConductivity, dict ) ); } writeSigma_ = dict.lookupOrDefault("writeSigma", false); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fv::solidElectricalConduction::solidElectricalConduction ( const word& name, const word& modelType, const fvMesh& mesh, const dictionary& dict ) : fvModel(name, modelType, mesh, dict), phi_ ( IOobject ( "phi", mesh().time().name(), mesh(), IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh(), dimensions::electricPotential ), I_ ( IOobject ( "I", mesh().time().name(), mesh(), IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh(), dimensionedScalar(dimensions::current, scalar(0)) ), sigmaScalarPtr_(), sigmaTensorPtr_(), writeSigma_(false), meshChanged_(true) { readCoeffs(dict); mesh().schemes().setFluxRequired(phi_.name()); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::wordList Foam::fv::solidElectricalConduction::addSupFields() const { const basicThermo& thermo = mesh().lookupObject(physicalProperties::typeName); return wordList(1, thermo.he().name()); } void Foam::fv::solidElectricalConduction::addSup ( const volScalarField& rho, const volScalarField& he, fvMatrix& eqn ) const { eqn += fvi::div(I_*fvc::interpolate(phi_)); } void Foam::fv::solidElectricalConduction::correct() { const bool sigmaChanged = sigmaScalarPtr_.valid() ? sigmaScalarPtr_->update() : sigmaTensorPtr_->update(); if (sigmaChanged || meshChanged_) { const label nCorr = mesh() .solution() .solverDict(phi_.name()) .lookupOrDefault