diff --git a/src/fvOptions/Make/files b/src/fvOptions/Make/files index 889ddebabb8d09aecf0d3468a589e85f329665e7..9a8376a95cd20672f6f6037df3ced67776fc5cae 100644 --- a/src/fvOptions/Make/files +++ b/src/fvOptions/Make/files @@ -22,6 +22,8 @@ $(derivedSources)/directionalPressureGradientExplicitSource/directionalPressureG $(derivedSources)/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSourceIO.C $(derivedSources)/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C $(derivedSources)/explicitPorositySource/explicitPorositySource.C +$(derivedSources)/jouleHeatingSource/jouleHeatingSource.C +$(derivedSources)/jouleHeatingSource/jouleHeatingSourceIO.C $(derivedSources)/meanVelocityForce/meanVelocityForce.C $(derivedSources)/meanVelocityForce/meanVelocityForceIO.C $(derivedSources)/meanVelocityForce/patchMeanVelocityForce/patchMeanVelocityForce.C diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C new file mode 100644 index 0000000000000000000000000000000000000000..7a7a8ccde7db991d1bea27b65168f93b0cf3db3c --- /dev/null +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -0,0 +1,215 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "jouleHeatingSource.H" +#include "fvMatrices.H" +#include "fvmLaplacian.H" +#include "fvcGrad.H" +#include "zeroGradientFvPatchField.H" +#include "basicThermo.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + defineTypeNameAndDebug(jouleHeatingSource, 0); + + addToRunTimeSelectionTable + ( + option, + jouleHeatingSource, + dictionary + ); +} +} + + +const Foam::word Foam::fv::jouleHeatingSource::sigmaName(typeName + ":sigma"); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +const Foam::coordinateSystem& Foam::fv::jouleHeatingSource::coordSys() const +{ + if (!coordSysPtr_.valid()) + { + FatalErrorInFunction + << "Co-ordinate system invalid" + << abort(FatalError); + } + + return coordSysPtr_(); +} + + +Foam::tmp<Foam::volSymmTensorField> +Foam::fv::jouleHeatingSource::transformSigma +( + const volVectorField& sigmaLocal +) const +{ + tmp<volSymmTensorField> tsigma + ( + new volSymmTensorField + ( + IOobject + ( + sigmaName, + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh_, + dimensionedSymmTensor("0", sigmaLocal.dimensions(), Zero), + zeroGradientFvPatchField<symmTensor>::typeName + ) + ); + + volSymmTensorField& sigma = tsigma.ref(); + sigma.primitiveFieldRef() = coordSys().R().transformVector(sigmaLocal); + + sigma.correctBoundaryConditions(); + + return tsigma; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fv::jouleHeatingSource::jouleHeatingSource +( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh +) +: + option(sourceName, modelType, dict, mesh), + TName_("T"), + V_ + ( + IOobject + ( + typeName + ":V", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ), + anisotropicElectricalConductivity_(false), + scalarSigmaVsTPtr_(nullptr), + vectorSigmaVsTPtr_(nullptr), + coordSysPtr_(nullptr), + curTimeIndex_(-1) +{ + // Set the field name to that of the energy field from which the temperature + // is obtained + + const basicThermo& thermo = + mesh_.lookupObject<basicThermo>(basicThermo::dictName); + + fieldNames_.setSize(1, thermo.he().name()); + + applied_.setSize(fieldNames_.size(), false); + + read(dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fv::jouleHeatingSource::~jouleHeatingSource() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +void Foam::fv::jouleHeatingSource::addSup +( + const volScalarField& rho, + fvMatrix<scalar>& eqn, + const label fieldi +) +{ + DebugInfo<< name() << ": applying source to " << eqn.psi().name() << endl; + + if (curTimeIndex_ != mesh_.time().timeIndex()) + { + if (anisotropicElectricalConductivity_) + { + // Update sigma as a function of T if required + const volVectorField& sigmaLocal = updateSigma(vectorSigmaVsTPtr_); + + tmp<volSymmTensorField> sigma = transformSigma(sigmaLocal); + + // Solve the electrical potential equation + fvScalarMatrix VEqn(fvm::laplacian(sigma, V_)); + VEqn.relax(); + VEqn.solve(); + } + else + { + // Update sigma as a function of T if required + const volScalarField& sigma = updateSigma(scalarSigmaVsTPtr_); + + // Solve the electrical potential equation + fvScalarMatrix VEqn(fvm::laplacian(sigma, V_)); + VEqn.relax(); + VEqn.solve(); + } + + curTimeIndex_ = mesh_.time().timeIndex(); + } + + // Add the Joule heating contribution + + const volVectorField gradV(fvc::grad(V_)); + if (anisotropicElectricalConductivity_) + { + const volVectorField& sigmaLocal = + mesh_.lookupObject<volVectorField>(sigmaName); + + tmp<volSymmTensorField> sigma = transformSigma(sigmaLocal); + + eqn += (sigma & gradV) & gradV; + } + else + { + const volScalarField& sigma = + mesh_.lookupObject<volScalarField>(sigmaName); + + eqn += (sigma*gradV) & gradV; + } +} + + +// ************************************************************************* // diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H new file mode 100644 index 0000000000000000000000000000000000000000..58565647393f01904d4fc9e8e25be88cc09b99ce --- /dev/null +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.H @@ -0,0 +1,278 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ 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 <http://www.gnu.org/licenses/>. + +Class + Foam::fv::jouleHeatingSource + +Group + grpFvOptionsSources + +Description + Evolves an electrical potential equation + + \f[ + \grad \left( \sigma \grad V \right) + \f] + + where \f$ V \f$ is electrical potential and \f$\sigma\f$ is the + electrical current + + To provide a Joule heating contribution according to: + + Differential form of Joule heating - power per unit volume: + + \f[ + \frac{d(P)}{d(V)} = J \cdot E + \f] + + where \f$ J \f$ is the current density and \f$ E \f$ the electric field. + If no magnetic field is present: + + \f[ + J = \sigma E + \f] + + The electric field given by + + \f[ + E = \grad V + \f] + + Therefore: + + \f[ + \frac{d(P)}{d(V)} = J \cdot E + = (sigma E) \cdot E + = (sigma \grad V) \cdot \grad V + \f] + + +Usage + Isotropic (scalar) electrical conductivity + \verbatim + jouleHeatingSourceCoeffs + { + anisotropicElectricalConductivity no; + + // Optionally specify the conductivity as a function of temperature + // Note: if not supplied, this will be read from the time directory + sigma table + ( + (273 1e5) + (1000 1e5) + ); + } + \endverbatim + + Anisotropic (vectorial) electrical conductivity + jouleHeatingSourceCoeffs + { + anisotropicElectricalConductivity yes; + + coordinateSystem + { + type cartesian; + origin (0 0 0); + + coordinateRotation + { + type axesRotation; + e1 (1 0 0); + e3 (0 0 1); + } + } + + // Optionally specify sigma as a function of temperature + //sigma (31900 63800 127600); + // + //sigma table + //( + // (0 (0 0 0)) + // (1000 (127600 127600 127600)) + //); + } + + + Where: + \table + Property | Description | Required | Default value + T | Name of temperature field | no | T + sigma | Electrical conductivity as a function of temperature |no| + anisotropicElectricalConductivity | Anisotropic flag | yes | + \endtable + + The electrical conductivity can be specified using either: + - If the \c sigma entry is present the electrical conductivity is specified + as a function of temperature using a Function1 type + - If not present the sigma field will be read from file + - If the anisotropicElectricalConductivity flag is set to 'true', sigma + should be specified as a vector quantity + +SourceFiles + jouleHeatingSource.C + +SeeAlso + Foam::Function1 + +\*---------------------------------------------------------------------------*/ + +#ifndef fv_jouleHeatingSource_H +#define fv_jouleHeatingSource_H + +#include "fvOption.H" +#include "Function1.H" +#include "coordinateSystem.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace fv +{ + +/*---------------------------------------------------------------------------*\ + Class jouleHeatingSource Declaration +\*---------------------------------------------------------------------------*/ + +class jouleHeatingSource +: + public option +{ + // Private data + + //- Name of electrical conductivity field + static const word sigmaName; + + //- Name of temperature field - default = "T" (optional) + word TName_; + + //- Electrical potential field / [V] + volScalarField V_; + + //- Flag to indicate that the electrical conductivity is anisotropic + bool anisotropicElectricalConductivity_; + + //- Electrical conductivity as a scalar function of temperature + autoPtr<Function1<scalar>> scalarSigmaVsTPtr_; + + //- Electrical conductivity as a vector function of temperature + autoPtr<Function1<vector>> vectorSigmaVsTPtr_; + + //- Co-ordinate system - used for vectorial electrical conductivity + autoPtr<coordinateSystem> coordSysPtr_; + + //- Current time index (used for updating) + label curTimeIndex_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + jouleHeatingSource(const jouleHeatingSource&); + + //- Disallow default bitwise assignment + void operator=(const jouleHeatingSource&); + + //- Return the co-ordinate system for anisotropic electrical + // conductivity + const coordinateSystem& coordSys() const; + + //- Transform the anisotropic electrical conductivity into global system + tmp<volSymmTensorField> transformSigma + ( + const volVectorField& sigmaLocal + ) const; + + //- Initialise the electrical conductivity field + template<class Type> + void initialiseSigma + ( + const dictionary& dict, + autoPtr<Function1<Type>>& sigmaVsTPtr + ); + + //- Update the electrical conductivity field + template<class Type> + const GeometricField<Type, fvPatchField, volMesh>& + updateSigma(const autoPtr<Function1<Type>>& sigmaVsTPtr) const; + + +public: + + //- Runtime type information + TypeName("jouleHeatingSource"); + + + // Constructors + + //- Construct from explicit source name and mesh + jouleHeatingSource + ( + const word& sourceName, + const word& modelType, + const dictionary& dict, + const fvMesh& mesh + ); + + + //- Destructor + virtual ~jouleHeatingSource(); + + + // Member Functions + + // Evaluate + + //- Add explicit contribution to compressible momentum equation + virtual void addSup + ( + const volScalarField& rho, + fvMatrix<scalar>& eqn, + const label fieldi + ); + + + // IO + + //- Read source dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace fv +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "jouleHeatingSourceTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceIO.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceIO.C new file mode 100644 index 0000000000000000000000000000000000000000..ce4dde6f95ee0c2b9fd5cc807e0ce638b5639f38 --- /dev/null +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceIO.C @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "jouleHeatingSource.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::fv::jouleHeatingSource::read(const dictionary& dict) +{ + if (option::read(dict)) + { + coeffs_.readIfPresent("T", TName_); + coeffs_.lookup("anisotropicElectricalConductivity") + >> anisotropicElectricalConductivity_; + + if (anisotropicElectricalConductivity_) + { + Info<< " Using vector electrical conductivity" << endl; + + initialiseSigma(coeffs_, vectorSigmaVsTPtr_); + coordSysPtr_ = coordinateSystem::New(mesh_, coeffs_); + } + else + { + Info<< " Using scalar electrical conductivity" << endl; + + initialiseSigma(coeffs_, scalarSigmaVsTPtr_); + } + + return true; + } + + return false; +} + + +// ************************************************************************* // diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..11d7eed98c6ef912f4422511220ff3208686ec42 --- /dev/null +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "emptyFvPatchField.H" + +template<class Type> +void Foam::fv::jouleHeatingSource::initialiseSigma +( + const dictionary& dict, + autoPtr<Function1<Type>>& sigmaVsTPtr +) +{ + typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; + + if (dict.found("sigma")) + { + // Sigma to be defined using a Funcion1 type + sigmaVsTPtr = Function1<Type>::New("sigma", dict); + + tmp<VolFieldType> tsigma + ( + new VolFieldType + ( + IOobject + ( + typeName + ":sigma", + mesh_.time().timeName(), + mesh_, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh_, + dimensioned<Type> + ( + "0", + sqr(dimCurrent)/dimPower/dimLength, + Zero + ) + ) + ); + + mesh_.objectRegistry::store(tsigma.ptr()); + + Info<< " Conductivity 'sigma' read from dictionary as f(T)" + << nl << endl; + } + else + { + // Sigma to be defined by user input + tmp<VolFieldType> tsigma + ( + new VolFieldType + ( + IOobject + ( + typeName + ":sigma", + mesh_.time().timeName(), + mesh_, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh_ + ) + ); + + mesh_.objectRegistry::store(tsigma.ptr()); + + Info<< " Conductivity 'sigma' read from file" << nl << endl; + } +} + + +template<class Type> +const Foam::GeometricField<Type, Foam::fvPatchField, Foam::volMesh>& +Foam::fv::jouleHeatingSource::updateSigma +( + const autoPtr<Function1<Type>>& sigmaVsTPtr +) const +{ + typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType; + + VolFieldType& sigma = + const_cast<VolFieldType&> + ( + mesh_.lookupObject<VolFieldType>(typeName + ":sigma") + ); + + if (!sigmaVsTPtr.valid()) + { + // Electrical conductivity field, sigma, was specified by the user + return sigma; + } + + const volScalarField& T = mesh_.lookupObject<volScalarField>(TName_); + + // Internal field + forAll(sigma, i) + { + sigma[i] = sigmaVsTPtr->value(T[i]); + } + + + // Boundary field + typename VolFieldType::Boundary& bf = sigma.boundaryFieldRef(); + forAll(bf, patchi) + { + fvPatchField<Type>& pf = bf[patchi]; + if (!isA<emptyFvPatchField<Type>>(pf)) + { + const scalarField& Tbf = T.boundaryField()[patchi]; + forAll(pf, facei) + { + pf[facei] = sigmaVsTPtr->value(Tbf[facei]); + } + } + } + + // Update processor patches + sigma.correctBoundaryConditions(); + + return sigma; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/T b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/T new file mode 100644 index 0000000000000000000000000000000000000000..302392cd2cb9d078fd840f16e39aba279492d901 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/T @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1612+ | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0/solid"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 0 0 1 0 0 0 ]; + +internalField uniform 500; + +boundaryField +{ + left + { + type fixedValue; + value uniform 500; + } + right + { + type fixedValue; + value uniform 500; + } + top + { + type zeroGradient; + } + bottom + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/jouleHeatingSource:V b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/jouleHeatingSource:V new file mode 100644 index 0000000000000000000000000000000000000000..407005dbd410f993be2fa147e144f63d8e00281b --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/jouleHeatingSource:V @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1612+ | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0/heater"; + object jouleHeatingSource:V; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 1 2 -3 0 0 -1 0 ]; + +internalField uniform 0; + +boundaryField +{ + left + { + type fixedValue; + value uniform 1.5; + } + right + { + type fixedValue; + value uniform 0; + } + top + { + type zeroGradient; + } + bottom + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/jouleHeatingSource:sigma b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/jouleHeatingSource:sigma new file mode 100644 index 0000000000000000000000000000000000000000..b3acde6b3665c798eb5bd0aabecb0df601553d39 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/jouleHeatingSource:sigma @@ -0,0 +1,47 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1612+ | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0/heater"; + object jouleHeatingSource:sigma; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ -1 -3 3 0 0 2 0 ]; + +internalField uniform 127599.8469; + +boundaryField +{ + left + { + type zeroGradient; + } + right + { + type zeroGradient; + } + top + { + type zeroGradient; + } + bottom + { + type zeroGradient; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/p b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/p new file mode 100644 index 0000000000000000000000000000000000000000..d0b8fa4f65eaa44367c142cbf6c7894c0090a632 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid/p @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1612+ | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0/solid"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 100000; + +boundaryField +{ + ".*" + { + type calculated; + value uniform 100000; + } + frontAndBack + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..31c0b764b5a135ceb1891ba7d5dda8123cb51ded --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allclean @@ -0,0 +1,14 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase +rm -rf 0 + +foamCleanPolyMesh -region solid + +rm -f *.OpenFOAM OF_vs_ANALYTICAL.eps + +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..98857416a91cbba898dc7c53731e2306b08af098 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun @@ -0,0 +1,13 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +./Allrun.pre + +runApplication $(getApplication) + +./createGraphs + +# ----------------------------------------------------------------------------- diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel new file mode 100755 index 0000000000000000000000000000000000000000..b48e4c119d991666fbaa5898f239939af8a88f90 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun-parallel @@ -0,0 +1,17 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +./Allrun.pre + +runApplication -s solid decomposePar -region solid + +runParallel $(getApplication) + +runApplication -s solid reconstructPar -latestTime -region solid + +./createGraphs + +# ----------------------------------------------------------------------------- diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre new file mode 100755 index 0000000000000000000000000000000000000000..c8198f9848a5385a6251bd757cbee53fa0ed6398 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/Allrun.pre @@ -0,0 +1,15 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # Run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +# Create meshe +runApplication -s solid blockMesh -region solid + +# create dummy files for post-processing +paraFoam -touch -region solid + +restore0Dir + +# ----------------------------------------------------------------------------- diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/constant/regionProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/constant/regionProperties new file mode 100644 index 0000000000000000000000000000000000000000..4b0d4cf1d548510b21558fdebebb15562da22a53 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/constant/regionProperties @@ -0,0 +1,24 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object regionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +regions +( + fluid () + solid (solid) +); + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/constant/solid/thermophysicalProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/constant/solid/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..a24fa3e3ab72e2e13fccba9fb102b26c43802341 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/constant/solid/thermophysicalProperties @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------* \ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type heSolidThermo; + mixture pureMixture; + transport constIso; + thermo hConst; + equationOfState rhoConst; + specie specie; + energy sensibleEnthalpy; +} + +mixture +{ + specie + { + nMoles 1; + molWeight 12; + } + + transport + { + kappa 200; + } + + thermodynamics + { + Hf 0; + Cp 700; + } + + equationOfState + { + rho 8000; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs new file mode 100755 index 0000000000000000000000000000000000000000..04bbc57ea0a4109b12822ba42e3cac767d0ef9ea --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/createGraphs @@ -0,0 +1,87 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox +# \\ / O peration | +# \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. +# \\/ 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 <http://www.gnu.org/licenses/>. +# +# Script +# createGraphs +# +# Description +# Creates .eps graph of OpenFOAM results vs analytical solution for the +# Joule heating case +# +#------------------------------------------------------------------------------ + +cd ${0%/*} || exit 1 # Run from this directory + +# Stop on first error +set -e + +# test if gnuplot exists on the system +if ! which gnuplot > /dev/null 2>&1 +then + echo "FOAM FATAL ERROR: gnuplot not found - skipping graph creation" >&2 + exit 1 +fi + + +echo "Creating graph" +OFDATA='postProcessing/sample1/solid/20000/centreLine_T_jouleHeatingSource:V_jouleHeatingSource:sigma.xy' + +if [ ! -f "$OFDATA" ] +then + echo "FOAM FATAL ERROR: OpenFOAM results not available in $OFDATA" >&2 + exit 1 +fi + +gnuplot<<EOF +set terminal postscript eps color enhanced +set output "OF_vs_ANALYTICAL.eps" +set xlabel "Length, x / [m]" +set ylabel "Temperature / [K]" +set grid +set key left top +rho = 7.837e-6 +sigma = 1/rho +kappa = 200 +L = 2.5 +D = 0.1 +H = 0.1 +vol = 2.0*L*D*H +V = 1.5 +R = rho*2*L/(D*H) +I = V/R +P = I*V +Q = P/vol +Ts = 500 +T(x) = Q*L*L/(2*kappa)*(1-(x/L)*(x/L)) + Ts + + +plot \ + "$OFDATA" u 1:2 w lines title "OpenFOAM", \ + T(x) w linespoints lt 0 pt 6 pi 15 title "Analytical" +EOF + + +echo "End" + +#------------------------------------------------------------------------------ diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/controlDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..a07195d4fe62c70e9959cc1590c0ebc6fb533317 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/controlDict @@ -0,0 +1,75 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application chtMultiRegionSimpleFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 20000; + +deltaT 1; + +writeControl timeStep; + +writeInterval 50; + +purgeWrite 2; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +functions +{ + sample1 + { + type sets; + libs ("libsampling.so"); + writeControl outputTime; + region solid; + fields (T jouleHeatingSource:V jouleHeatingSource:sigma); + interpolationScheme cellPoint; + setFormat raw; + + sets + ( + centreLine + { + type uniform; + axis x; + start (-2.5 0.05 0.05); + end ( 2.5 0.05 0.05); + nPoints 20; + } + ); + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..5448946b393246ebd70ba0b83352f9c4d257c619 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/decomposeParDict @@ -0,0 +1,23 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method scotch; + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/blockMeshDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..aad40c34c05f32dc3e2a59a878501abeadb2ef7c --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/blockMeshDict @@ -0,0 +1,89 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (-2.5 0 0) + ( 2.5 0 0) + ( 2.5 0.1 0) + (-2.5 0.1 0) + (-2.5 0 0.1) + ( 2.5 0 0.1) + ( 2.5 0.1 0.1) + (-2.5 0.1 0.1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (500 20 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + top + { + type patch; + faces + ( + (3 7 6 2) + ); + } + bottom + { + type patch; + faces + ( + (1 5 4 0) + ); + } + left + { + type patch; + faces + ( + (0 4 7 3) + ); + } + right + { + type patch; + faces + ( + (2 6 5 1) + ); + } + frontAndBack + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/decomposeParDict new file mode 120000 index 0000000000000000000000000000000000000000..46638e60f61f453fde97c51772ad6111792db0f6 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/decomposeParDict @@ -0,0 +1 @@ +../decomposeParDict \ No newline at end of file diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvOptions b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvOptions new file mode 100644 index 0000000000000000000000000000000000000000..114d7e7736edc6ac2c79cda92d90c1c9056b8f98 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvOptions @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvOptions; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +heating +{ + type jouleHeatingSource; + active true; + + jouleHeatingSourceCoeffs + { + anisotropicElectricalConductivity no; + + // Optionally specify sigma as a function of temperature + //sigma 127599.8469; + // + //sigma table + //( + // (0 127599.8469) + // (1000 127599.8469) + //); + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..3ae1552969519ccbadf1bdce0a105a55cf0db8c8 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvSchemes @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; +} + +laplacianSchemes +{ + default none; + laplacian(alpha,h) Gauss linear uncorrected; + laplacian(jouleHeatingSource:sigma,jouleHeatingSource:V) Gauss linear uncorrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default uncorrected; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..b155dcedefa184000b2319c6daf5e5d4abcd398d --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/system/solid/fvSolution @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + h + { + solver PCG; + preconditioner DIC; + tolerance 0; + relTol 0.1; + } + + jouleHeatingSource:V + { + solver PCG; + preconditioner DIC; + tolerance 0; + relTol 0.1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + equations + { + h 0.99; + } +} + +// ************************************************************************* //