diff --git a/ThirdParty/rpmBuild/SOURCES/ParaView-3.14.1.patch_2 b/ThirdParty/rpmBuild/SOURCES/ParaView-3.14.1.patch_2 new file mode 100644 index 000000000..e47ee6e17 --- /dev/null +++ b/ThirdParty/rpmBuild/SOURCES/ParaView-3.14.1.patch_2 @@ -0,0 +1,41 @@ +From 1d6745888bcc34b260410a3cdbba49ecf0084ba2 Mon Sep 17 00:00:00 2001 +From: Utkarsh Ayachit +Date: Tue, 17 Apr 2012 14:54:05 -0400 +Subject: [PATCH] BUG #13101. STL ascii reader was report failures prematurely. + +STL ascii reader was reporting error when eof was reached at an expected +location. This was causing the reader to fail for the STL file attached with the +bug report. + +Change-Id: I734d2c8d8c85854df3d2a63bae6ba23bccf7a9c2 +--- + IO/vtkSTLReader.cxx | 13 ++++++++----- + 1 files changed, 8 insertions(+), 5 deletions(-) + +diff --git a/IO/vtkSTLReader.cxx b/IO/vtkSTLReader.cxx +index 189ea1b..34ee3e0 100644 +--- a/VTK/IO/vtkSTLReader.cxx ++++ b/VTK/IO/vtkSTLReader.cxx +@@ -442,12 +442,15 @@ int vtkSTLReader::ReadASCIISTL(FILE *fp, vtkPoints *newPts, + { + if (!fgets(line, 255, fp)) + { +- vtkErrorMacro ("STLReader error reading file: " << this->FileName +- << " Premature EOF while reading end solid."); +- fclose(fp); +- return 0; ++ done = feof(fp); ++ if (!done) ++ { ++ vtkErrorMacro ("STLReader error reading file: " << this->FileName ++ << " Premature EOF while reading end solid."); ++ fclose(fp); ++ return 0; ++ } + } +- + done = feof(fp); + } + +-- +1.7.4.1 diff --git a/ThirdParty/rpmBuild/SOURCES/scotch-5.1.10b_patch_0 b/ThirdParty/rpmBuild/SOURCES/scotch-5.1.10b_patch_0 index 29d09cbdc..8686a86e5 100644 --- a/ThirdParty/rpmBuild/SOURCES/scotch-5.1.10b_patch_0 +++ b/ThirdParty/rpmBuild/SOURCES/scotch-5.1.10b_patch_0 @@ -25,9 +25,9 @@ diff -ruN scotch_5.1.10b_orig/src/Make.inc/Makefile.inc.i686_mac_darwin10.shlib +RANLIB = ranlib +YACC = bison -y diff -ruN scotch_5.1.10b_orig/src/Make.inc/Makefile.inc.i686_pc_linux2.shlib scotch_5.1.10b/src/Make.inc/Makefile.inc.i686_pc_linux2.shlib ---- scotch_5.1.10b_orig/src/Make.inc/Makefile.inc.i686_pc_linux2.shlib 2010-08-07 03:02:42.000000000 -0400 -+++ scotch_5.1.10b/src/Make.inc/Makefile.inc.i686_pc_linux2.shlib 2010-10-31 15:50:53.000000000 -0400 -@@ -4,13 +4,13 @@ +--- scotch_5.1.10b_orig/src/Make.inc/Makefile.inc.i686_pc_linux2.shlib 2010-08-07 00:02:42.000000000 -0700 ++++ scotch_5.1.10b/src/Make.inc/Makefile.inc.i686_pc_linux2.shlib 2013-07-19 17:15:56.638402200 -0700 +@@ -4,14 +4,14 @@ MAKE = make AR = gcc @@ -39,9 +39,11 @@ diff -ruN scotch_5.1.10b_orig/src/Make.inc/Makefile.inc.i686_pc_linux2.shlib sco -CCD = gcc -CFLAGS = -O3 -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -DSCOTCH_RENAME_PARSER -DSCOTCH_PTHREAD -Drestrict=__restrict -CLIBFLAGS = -shared -fPIC +-LDFLAGS = -lz -lm -lrt +CCD = mpicc -I$(MPI_HOME)/include +CFLAGS = -O3 -fPIC -DCOMMON_FILE_COMPRESS_GZ -DCOMMON_PTHREAD -DCOMMON_RANDOM_FIXED_SEED -DSCOTCH_RENAME -DSCOTCH_RENAME_PARSER -DSCOTCH_PTHREAD -Drestrict=__restrict +CLIBFLAGS = -shared - LDFLAGS = -lz -lm -lrt ++LDFLAGS = -lpthread -lz -lm -lrt CP = cp LEX = flex -Pscotchyy -olex.yy.c + LN = ln diff --git a/ThirdParty/rpmBuild/SPECS/ParaView-3.14.1.spec b/ThirdParty/rpmBuild/SPECS/ParaView-3.14.1.spec index 34d58d329..00b5f52f7 100644 --- a/ThirdParty/rpmBuild/SPECS/ParaView-3.14.1.spec +++ b/ThirdParty/rpmBuild/SPECS/ParaView-3.14.1.spec @@ -79,7 +79,8 @@ Prefix: %{_prefix} Group: Development/Tools Patch0: ParaView-3.14.1.patch_0_ParaView.git_0f43430 Patch1: ParaView-3.14.1.patch_1 -Patch2: ParaView-3.14.1.patch_darwin +Patch2: ParaView-3.14.1.patch_2 +Patch3: ParaView-3.14.1.patch_darwin %define _installPrefix %{_prefix}/packages/%{name}-%{version}/platforms/%{_WM_OPTIONS} @@ -114,9 +115,12 @@ Patch2: ParaView-3.14.1.patch_darwin # Correction to BUG #13065. %patch1 -p1 +# Correction to BUG #13101. +%patch2 -p1 + %ifos darwin # Patch for proper install of paraview binary under Mac OS X -%patch2 -p1 +%patch3 -p1 %endif %build diff --git a/applications/solvers/coupled/conjugateHeatFoam/Allwmake b/applications/solvers/coupled/conjugateHeatFoam/Allwmake new file mode 100755 index 000000000..c416ec239 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/Allwmake @@ -0,0 +1,8 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +wmake libso conjugateHeatTransfer +wmake + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/solvers/coupled/conjugateHeatFoam/Make/options b/applications/solvers/coupled/conjugateHeatFoam/Make/options index fa25c2dca..75fefc0ed 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/Make/options +++ b/applications/solvers/coupled/conjugateHeatFoam/Make/options @@ -1,9 +1,22 @@ EXE_INC = \ + -IconjugateHeatTransfer/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ -I$(LIB_SRC)/coupledMatrix/lnInclude \ - -I$(LIB_SRC)/finiteVolume/lnInclude - + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude EXE_LIBS = \ + -lincompressibleTurbulenceModel \ + -lincompressibleRASModels \ + -lincompressibleTransportModels \ -lcoupledLduMatrix \ -lfiniteVolume \ - -llduSolvers + -lradiation \ + -lbasicThermophysicalModels \ + -lspecie \ + -lconjugateHeatTransfer diff --git a/applications/solvers/coupled/conjugateHeatFoam/UEqn.H b/applications/solvers/coupled/conjugateHeatFoam/UEqn.H new file mode 100644 index 000000000..df6f90ac0 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/UEqn.H @@ -0,0 +1,26 @@ + // Solve the momentum equation + + fvVectorMatrix UEqn + ( + fvm::ddt(U) + + fvm::div(phi, U) + + turbulence->divDevReff(U) + ); + + UEqn.relax(); + + if (momentumPredictor) + { + solve + ( + UEqn + == + fvc::reconstruct + ( + ( + - ghf*fvc::snGrad(rhok) + - fvc::snGrad(p_rgh) + )*mesh.magSf() + ) + ); + } diff --git a/applications/solvers/coupled/conjugateHeatFoam/attachPatches.H b/applications/solvers/coupled/conjugateHeatFoam/attachPatches.H index 225f570e0..3a2f62f06 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/attachPatches.H +++ b/applications/solvers/coupled/conjugateHeatFoam/attachPatches.H @@ -14,5 +14,5 @@ } // Force recalculation of weights - mesh.surfaceInterpolation::movePoints(); + mesh.surfaceInterpolation::movePoints(); } diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C index 29f0c9fa3..3c3721e3b 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatFoam.C @@ -2,8 +2,8 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright held by original author - \\/ M anipulation | + \\ / A nd | Copyright (C) 2008-2011 H. Jasak & H. Rusche + \\/ M anipulation | All rights reserved ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -25,45 +25,92 @@ License Application conjugateHeatFoam -Author - Hrvoje Jasak, Wikki Ltd. All rights reserved. - Description - Transient solver for incompressible, laminar flow of Newtonian fluids - with conjugate heat transfer + Transient solver for buoyancy-driven turbulent flow of incompressible + Newtonian fluids with conjugate heat transfer, complex heat conduction + and radiation \*---------------------------------------------------------------------------*/ #include "fvCFD.H" #include "coupledFvMatrices.H" #include "regionCouplePolyPatch.H" +#include "radiationModel.H" +#include "thermalModel.H" +#include "singlePhaseTransportModel.H" +#include "RASModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // int main(int argc, char *argv[]) { # include "setRootCase.H" - # include "createTime.H" # include "createFluidMesh.H" -# include "attachPatches.H" # include "createSolidMesh.H" +# include "readGravitationalAcceleration.H" # include "createFields.H" # include "createSolidFields.H" - # include "initContinuityErrs.H" +# include "readTimeControls.H" +# include "CourantNo.H" +# include "setInitialDeltaT.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; - for (runTime++; !runTime.end(); runTime++) + while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "solveFluid.H" +# include "readTimeControls.H" +# include "readPISOControls.H" +# include "CourantNo.H" +# include "setDeltaT.H" + + // Detach patches +# include "detachPatches.H" + +# include "UEqn.H" + + p_rgh.storePrevIter(); + + for (int corr = 0; corr < nCorr; corr++) + { +# include "pEqn.H" + } + + // Update turbulent quantities + turbulence->correct(); + + radiation->correct(); + + // Update thermal conductivity in the fluid + kappaEff = rho*Cp*(turbulence->nu()/Pr + turbulence->nut()/Prt); + + // Update thermal conductivity in the solid + solidThermo.correct(); + ksolid = solidThermo.k(); + + rhoCpsolid.oldTime(); + rhoCpsolid = solidThermo.rho()*solidThermo.C(); + + // Coupled patches +# include "attachPatches.H" + + kappaEff.correctBoundaryConditions(); + ksolid.correctBoundaryConditions(); + + // Interpolate to the faces and add thermal resistance + surfaceScalarField ksolidf = fvc::interpolate(ksolid); + solidThermo.modifyResistance(ksolidf); + # include "solveEnergy.H" + // Update density according to Boussinesq approximation + rhok = 1.0 - beta*(T - TRef); + runTime.write(); Info<< "ExecutionTime = " diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/Make/files b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/Make/files new file mode 100644 index 000000000..83341cec2 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/Make/files @@ -0,0 +1,49 @@ +thermalModel/thermalModel.C +thermalLaws = thermalModel/thermalLaws + +$(thermalLaws)/thermalLaw/thermalLaw.C +$(thermalLaws)/thermalLaw/newThermalLaw.C +$(thermalLaws)/constantThermal/constantThermal.C +$(thermalLaws)/multiMaterialThermal/multiMaterialThermal.C +$(thermalLaws)/multiMaterialZonesThermal/multiMaterialZonesThermal.C + +thermalGaps = thermalModel/thermalGaps + +$(thermalGaps)/thermalGap/thermalGap.C +$(thermalGaps)/thermalGap/newThermalGap.C +$(thermalGaps)/constantThermalGap/constantThermalGap.C +$(thermalGaps)/constantResistanceThermalGap/constantResistanceThermalGap.C + +thermalSource = thermalModel/thermalSource + +$(thermalSource)/thermalSource/thermalSource.C +$(thermalSource)/thermalSource/newThermalSource.C +$(thermalSource)/constantThermalSource/constantThermalSource.C + +BCs = fvPatchFields + +$(BCs)/controlledParabolicVelocity/controlledParabolicVelocityFvPatchVectorField.C + +$(BCs)/chtRegionCoupleBase/chtRegionCoupleBase.C +$(BCs)/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C +$(BCs)/chtRcTemperature/chtRcTemperatureFvPatchScalarField.C +$(BCs)/chtRcThermalDiffusivityResistance/chtRcThermalDiffusivityResistanceFvPatchScalarField.C +$(BCs)/chtRcThermalDiffusivitySlave/chtRcThermalDiffusivitySlaveFvPatchScalarField.C + +$(BCs)/extendedWallHeatTransfer/extendedWallHeatTransferFvPatchScalarField.C + +$(BCs)/externalRadiation/externalRadiationSource/externalRadiationSource.C +$(BCs)/externalRadiation/externalRadiationSource/newExternalRadiationSource.C +$(BCs)/externalRadiation/ersConstantFlux/ersConstantFlux.C +$(BCs)/externalRadiation/ersViewFactor/ersViewFactor.C +$(BCs)/externalRadiation/ersPlaneToCylinder/ersPlaneToCylinder.C +$(BCs)/externalRadiation/ersPointSource/ersPointSource.C +$(BCs)/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C +$(BCs)/adiabatic/adiabaticFvPatchScalarField.C + +FOs = functionObjects + +$(FOs)/heatFlux/heatFlux/heatFlux.C +$(FOs)/heatFlux/heatFluxFunctionObject/heatFluxFunctionObject.C + +LIB = $(FOAM_LIBBIN)/libconjugateHeatTransfer diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/Make/options b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/Make/options new file mode 100644 index 000000000..721166578 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/Make/options @@ -0,0 +1,13 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/VectorN/lnInclude + +LIB_LIBS = \ + -lfiniteVolume \ + -lspecie \ + -lbasicThermophysicalModels \ + -lradiation \ + -lVectorN + diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItem.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItem.C new file mode 100644 index 000000000..61c0e7595 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItem.C @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "fieldAverageItem.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + template<> + const char* Foam::NamedEnum + < + Foam::fieldAverageItem::baseType, + 2 + >::names[] = + { + "iteration", + "time" + }; +} + + +const Foam::NamedEnum + Foam::fieldAverageItem::baseTypeNames_; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldAverageItem::fieldAverageItem() +: + fieldName_("unknown"), + mean_(0), + prime2Mean_(0), + base_(ITER) +{} + + +Foam::fieldAverageItem::fieldAverageItem(const fieldAverageItem& faItem) +: + fieldName_(faItem.fieldName_), + mean_(faItem.mean_), + prime2Mean_(faItem.prime2Mean_), + base_(faItem.base_) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::fieldAverageItem::~fieldAverageItem() +{} + + +// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // + +void Foam::fieldAverageItem::operator=(const fieldAverageItem& rhs) +{ + // Check for assignment to self + if (this == &rhs) + { + FatalErrorIn + ( + "Foam::fieldAverageItem::operator=(const Foam::fieldAverageItem&)" + ) << "Attempted assignment to self" << nl + << abort(FatalError); + } + + // Set updated values + fieldName_ = rhs.fieldName_; + mean_ = rhs.mean_; + prime2Mean_ = rhs.prime2Mean_; + base_ = rhs.base_; +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItem.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItem.H new file mode 100644 index 000000000..0c4aee6cf --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItem.H @@ -0,0 +1,208 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +Class + Foam::fieldAverageItem + +Description + Helper class to describe what form of averaging to apply. A set will be + applied to each base field in Foam::fieldAverage, of the form: + + \verbatim + { + mean on; + prime2Mean on; + base time; // iteration + } + \endverbatim + +SourceFiles + fieldAverageItem.C + fieldAverageItemIO.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fieldAverageItem_H +#define fieldAverageItem_H + +#include "NamedEnum.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class Istream; +class Ostream; + +// Forward declaration of friend functions and operators +class fieldAverageItem; +Istream& operator>>(Istream&, fieldAverageItem&); +Ostream& operator<<(Ostream&, const fieldAverageItem&); + + +/*---------------------------------------------------------------------------*\ + Class fieldAverageItem Declaration +\*---------------------------------------------------------------------------*/ + +class fieldAverageItem +{ +public: + + // Public data + + //- Enumeration defining the averaging base type + enum baseType + { + ITER, + TIME + }; + + +private: + + // Private data + + //- Field name + word fieldName_; + + //- Compute mean flag + Switch mean_; + + //- Compute prime-squared mean flag + Switch prime2Mean_; + + //- Averaging base type names + static const NamedEnum baseTypeNames_; + + //- Averaging base type + baseType base_; + + +public: + + // Constructors + + //- Construct null + fieldAverageItem(); + + //- Construct from Istream + fieldAverageItem(Istream&); + + //- Construct as copy + fieldAverageItem(const fieldAverageItem&); + + + //- Destructor + ~fieldAverageItem(); + + + // Member Functions + + // Access + + //- Return const access to the field name + const word& fieldName() const + { + return fieldName_; + } + + //- Return const access to the mean flag + const Switch& mean() const + { + return mean_; + } + + //- Return const access to the prime-squared mean flag + const Switch& prime2Mean() const + { + return prime2Mean_; + } + + //- Return averaging base type name + const word base() const + { + return baseTypeNames_[base_]; + } + + //- Return true if base is ITER + Switch ITERBase() const + { + return base_ == ITER; + } + + //- Return true if base is time + Switch timeBase() const + { + return base_ == TIME; + } + + + // Member Operators + + void operator=(const fieldAverageItem&); + + + // Friend Operators + + friend bool operator== + ( + const fieldAverageItem& a, + const fieldAverageItem& b + ) + { + return + a.fieldName_ == b.fieldName_ + && a.mean_ == b.mean_ + && a.prime2Mean_ == b.prime2Mean_ + && a.base_ == b.base_; + } + + friend bool operator!= + ( + const fieldAverageItem& a, + const fieldAverageItem& b + ) + { + return !(a == b); + } + + + // IOstream Operators + + friend Istream& operator>>(Istream&, fieldAverageItem&); + friend Ostream& operator<<(Ostream&, const fieldAverageItem&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItemIO.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItemIO.C new file mode 100644 index 000000000..30f4d8702 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/fieldAverageItem/fieldAverageItemIO.C @@ -0,0 +1,95 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "fieldAverageItem.H" +#include "IOstreams.H" +#include "dictionaryEntry.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::fieldAverageItem::fieldAverageItem(Istream& is) +: + fieldName_("unknown"), + mean_(0), + prime2Mean_(0) +{ + is.check("Foam::fieldAverageItem::fieldAverageItem(Foam::Istream&)"); + + const dictionaryEntry entry(dictionary::null, is); + + fieldName_ = entry.keyword(); + entry.lookup("mean") >> mean_; + entry.lookup("prime2Mean") >> prime2Mean_; + base_ = baseTypeNames_[entry.lookup("base")]; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>>(Istream& is, fieldAverageItem& faItem) +{ + is.check + ( + "Foam::Istream& Foam::operator>>" + "(Foam::Istream&, Foam::fieldAverageItem&)" + ); + + const dictionaryEntry entry(dictionary::null, is); + + faItem.fieldName_ = entry.keyword(); + entry.lookup("mean") >> faItem.mean_; + entry.lookup("prime2Mean") >> faItem.prime2Mean_; + faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")]; + + return is; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem) +{ + os.check + ( + "Foam::Ostream& Foam::operator<<" + "(Foam::Ostream&, const Foam::fieldAverageItem&)" + ); + + os << faItem.fieldName_ << nl << token::BEGIN_BLOCK << nl; + os.writeKeyword("mean") << faItem.mean_ << token::END_STATEMENT << nl; + os.writeKeyword("prime2Mean") << faItem.mean_ + << token::END_STATEMENT << nl; + os.writeKeyword("base") << faItem.baseTypeNames_[faItem.base_] + << token::END_STATEMENT << nl << token::END_BLOCK << nl; + + os.check + ( + "Foam::Ostream& Foam::operator<<" + "(Foam::Ostream&, const Foam::fieldAverageItem&)" + ); + + return os; +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/IOFieldAverage.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/IOFieldAverage.H new file mode 100644 index 000000000..e252ce589 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/IOFieldAverage.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +Typedef + Foam::IOfieldAverage + +Description + Instance of the generic IOOutputFilter for fieldAverage. + +\*---------------------------------------------------------------------------*/ + +#ifndef IOfieldAverage_H +#define IOfieldAverage_H + +#include "fieldAverage.H" +#include "IOOutputFilter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef IOOutputFilter IOFieldAverage; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/detachPatches.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/detachPatches.H new file mode 100644 index 000000000..30e3ebe30 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/detachPatches.H @@ -0,0 +1,18 @@ +{ + const polyPatchList& patches = mesh.boundaryMesh(); + + forAll (patches, patchI) + { + if (isType(patches[patchI])) + { + const regionCouplePolyPatch& rcp = + refCast(patches[patchI]); + + // Detach it here + rcp.detach(); + } + } + + // Force recalculation of weights + mesh.surfaceInterpolation::movePoints(); +} diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFlux.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFlux.C new file mode 100644 index 000000000..a48fcfbf6 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFlux.C @@ -0,0 +1,241 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "heatFlux.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "fvc.H" +#include "chtRcTemperatureFvPatchScalarField.H" +#include "processorFvPatchFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::heatFlux, 0); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::heatFlux::heatFlux +( + const word& name, + const objectRegistry& obr, + const dictionary& dict, + const bool loadFromFiles +) +: + name_(name), + Kfluid_(dict.lookup("K")), + obr_(obr), + active_(true) +{ + // Only active if a fvMesh is available + if (isA(obr_)) + { + read(dict); + } + else + { + active_ = false; + WarningIn + ( + "heatFlux::heatFlux\n" + "(\n" + "const word&,\n" + "const objectRegistry&,\n" + "const dictionary&,\n" + "const bool\n" + ")" + ) << "No fvMesh available, deactivating." + << nl << endl; + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::heatFlux::~heatFlux() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::heatFlux::calcAndPrint() +{ + const volScalarField& T = + obr_.lookupObject("T"); + const volScalarField& kappaEff = + obr_.lookupObject(Kfluid_); + //const surfaceScalarField& kappaEff = + // obr_.lookupObject(Kfluid_); + + scalar rho = 1.2; + scalar Cp = 1000; + + const fvMesh& mesh = T.mesh(); + + surfaceScalarField heatFluxD = + -fvc::interpolate(kappaEff)*fvc::snGrad(T); + // -kappaEff*fvc::snGrad(T); + + const surfaceScalarField::GeometricBoundaryField& patchHeatFluxD = + heatFluxD.boundaryField(); + //const surfaceScalarField::GeometricBoundaryField& patchHeatFluxD = + // heatFluxC.boundaryField(); + + //surfaceScalarField::GeometricBoundaryField patchHeatFluxC = + + scalar sumConduction = 0.0; + scalar sumConvection = 0.0; + scalar sumRadiation = 0.0; + + Info<< "\nWall heat fluxes [W]" << endl; + forAll(patchHeatFluxD, patchi) + { + if(isA(T.boundaryField()[patchi])) + { + continue; + } + + scalar conduction = gSum + ( + mesh.magSf().boundaryField()[patchi] + *heatFluxD.boundaryField()[patchi] + ); + + // Account for heat sources at region couple BCs + if(isA(T.boundaryField()[patchi])) + { + const chtRcTemperatureFvPatchScalarField& pT = + dynamic_cast + ( + T.boundaryField()[patchi] + ); + + conduction -= gSum + ( + pT.source()*mesh.magSf().boundaryField()[patchi] + ); + } + + scalar convection = 0.0; + scalar radiation = 0.0; + + if(obr_.foundObject("phi")) + { + const surfaceScalarField& phi = + obr_.lookupObject("phi"); + + convection = gSum + ( + rho*Cp*T.boundaryField()[patchi] + *phi.boundaryField()[patchi] + ); + } + + if(obr_.foundObject("Qr")) + { + const volScalarField& Qr = + obr_.lookupObject("Qr"); + + radiation = gSum + ( + Qr.boundaryField()[patchi] + *mesh.magSf().boundaryField()[patchi] + ); + } + + Info<< mesh.boundary()[patchi].name() + << " " + << conduction + << " " + << convection + << " " + << radiation + << " " + << conduction + convection + radiation + << endl; + + sumConduction += conduction; + sumConvection += convection; + sumRadiation += radiation; + } + + Info<< "sum " + << sumConduction + << " " + << sumConvection + << " " + << sumRadiation + << " " + << sumConduction + sumConvection + sumRadiation + << nl << endl; +} + +void Foam::heatFlux::read(const dictionary& dict) +{ + if (active_) + { + } +} + + +void Foam::heatFlux::execute() +{ + if (active_) + { + calcAndPrint(); + } +} + + +void Foam::heatFlux::end() +{ + if (active_) + { + calcAndPrint(); + } +} + + +void Foam::heatFlux::write() +{ + if (active_) + { + } +} + + +void Foam::heatFlux::updateMesh(const mapPolyMesh&) +{ + // Do nothing +} + + +void Foam::heatFlux::movePoints(const pointField&) +{ + // Do nothing +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFlux.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFlux.H new file mode 100644 index 000000000..81f7e128d --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFlux.H @@ -0,0 +1,154 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +Class + Foam::heatFlux + +Description + +SourceFiles + heatFlux.C + heatFluxTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef heatFlux_H +#define heatFlux_H + +#include "volFieldsFwd.H" +#include "pointFieldFwd.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class objectRegistry; +class dictionary; +class heatFluxItem; +class OFstream; +template +class List; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class heatFlux Declaration +\*---------------------------------------------------------------------------*/ + +class heatFlux +{ +protected: + + // Private data + + //- Name of this set of heat flux check + word name_; + + //- name of fluid thermal diffusivity + word Kfluid_; + + //- Database this class is registered to + const objectRegistry& obr_; + + //- On/off switch + bool active_; + + // Private Member Functions + + // Calculation functions + + //- Write + virtual void calcAndPrint(); + + // Functions to be over-ridden from IOoutputFilter class + + //- Update mesh + virtual void updateMesh(const mapPolyMesh&); + + //- Move points + virtual void movePoints(const Field&); + + + //- Disallow default bitwise copy construct + heatFlux(const heatFlux&); + + //- Disallow default bitwise assignment + void operator=(const heatFlux&); + + +public: + + //- Runtime type information + TypeName("heatFlux"); + + + // Constructors + + //- Construct for given objectRegistry and dictionary. + // Allow the possibility to load fields from files + heatFlux + ( + const word& name, + const objectRegistry&, + const dictionary&, + const bool loadFromFiles = false + ); + + + //- Destructor + virtual ~heatFlux(); + + + // Member Functions + + //- Return name of the set of field averages + virtual const word& name() const + { + return name_; + } + + //- Read the field average data + virtual void read(const dictionary&); + + //- Execute the averaging + virtual void execute(); + + //- Execute the averaging at the final time-loop, currently does nothing + virtual void end(); + + //- Calculate the field average data and write + virtual void write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFluxTemplates.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFluxTemplates.C new file mode 100644 index 000000000..29fb05666 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFlux/heatFluxTemplates.C @@ -0,0 +1,286 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "heatFluxItem.H" +#include "volFields.H" +#include "OFstream.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +void Foam::heatFlux::addMeanField +( + const label fieldI, + wordList& meanFieldList +) const +{ + if (faItems_[fieldI].mean()) + { + typedef GeometricField fieldType; + + const word& fieldName = faItems_[fieldI].fieldName(); + + const word meanFieldName = fieldName + EXT_MEAN; + + Info<< "Reading/calculating field " << meanFieldName << nl << endl; + + if (obr_.foundObject(meanFieldName)) + { + meanFieldList[fieldI] = meanFieldName; + } + else if (obr_.found(meanFieldName)) + { + Info<< "Cannot allocate average field " << meanFieldName + << " since an object with that name already exists." + << " Disabling averaging." << nl << endl; + meanFieldList[fieldI] = word::null; + } + else + { + const fieldType& baseField = + obr_.lookupObject(fieldName); + + // Store on registry + obr_.store + ( + new fieldType + ( + IOobject + ( + meanFieldName, + obr_.time().timeName(), + obr_, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + 1*baseField + ) + ); + + meanFieldList[fieldI] = meanFieldName; + } + } +} + + +template +void Foam::heatFlux::addPrime2MeanField +( + const label fieldI, + const wordList& meanFieldList, + wordList& prime2MeanFieldList +) const +{ + if (faItems_[fieldI].mean() && meanFieldList[fieldI].size()) + { + typedef GeometricField fieldType1; + typedef GeometricField fieldType2; + + const word& fieldName = faItems_[fieldI].fieldName(); + + const word meanFieldName = fieldName + EXT_PRIME2MEAN; + Info<< "Reading/calculating field " << meanFieldName << nl << endl; + + if (obr_.foundObject(meanFieldName)) + { + prime2MeanFieldList[fieldI] = meanFieldName; + } + else if (obr_.found(meanFieldName)) + { + Info<< "Cannot allocate average field " << meanFieldName + << " since an object with that name already exists." + << " Disabling averaging." << nl << endl; + prime2MeanFieldList[fieldI] = word::null; + } + else + { + const fieldType1& baseField = + obr_.lookupObject(fieldName); + const fieldType1& meanField = + obr_.lookupObject(meanFieldList[fieldI]); + + obr_.store + ( + new fieldType2 + ( + IOobject + ( + meanFieldName, + obr_.time().timeName(), + obr_, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + sqr(baseField) - sqr(meanField) + ) + ); + + prime2MeanFieldList[fieldI] = meanFieldName; + } + } +} + + +template +void Foam::heatFlux::calculateMeanFields(const wordList& meanFieldList) +const +{ + typedef GeometricField fieldType; + + const scalar dt = obr_.time().deltaTValue(); + + forAll(faItems_, i) + { + if (faItems_[i].mean() && meanFieldList[i].size()) + { + const word& fieldName = faItems_[i].fieldName(); + const fieldType& baseField = + obr_.lookupObject(fieldName); + fieldType& meanField = const_cast + ( + obr_.lookupObject(meanFieldList[i]) + ); + + scalar alpha = 0.0; + scalar beta = 0.0; + if (faItems_[i].timeBase()) + { + alpha = (totalTime_[i] - dt)/totalTime_[i]; + beta = dt/totalTime_[i]; + } + else + { + alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]); + beta = 1.0/scalar(totalIter_[i]); + } + + meanField = alpha*meanField + beta*baseField; + } + } +} + + +template +void Foam::heatFlux::calculatePrime2MeanFields +( + const wordList& meanFieldList, + const wordList& prime2MeanFieldList +) const +{ + typedef GeometricField fieldType1; + typedef GeometricField fieldType2; + + const scalar dt = obr_.time().deltaTValue(); + + forAll(faItems_, i) + { + if + ( + faItems_[i].prime2Mean() + && meanFieldList[i].size() + && prime2MeanFieldList[i].size() + ) + { + const word& fieldName = faItems_[i].fieldName(); + const fieldType1& baseField = + obr_.lookupObject(fieldName); + const fieldType1& meanField = + obr_.lookupObject(meanFieldList[i]); + fieldType2& prime2MeanField = const_cast + ( + obr_.lookupObject(prime2MeanFieldList[i]) + ); + + scalar alpha = 0.0; + scalar beta = 0.0; + if (faItems_[i].timeBase()) + { + alpha = (totalTime_[i] - dt)/totalTime_[i]; + beta = dt/totalTime_[i]; + } + else + { + alpha = scalar(totalIter_[i] - 1)/scalar(totalIter_[i]); + beta = 1.0/scalar(totalIter_[i]); + } + + prime2MeanField = + alpha*prime2MeanField + + beta*sqr(baseField) + - sqr(meanField); + } + } +} + + +template +void Foam::heatFlux::addMeanSqrToPrime2Mean +( + const wordList& meanFieldList, + const wordList& prime2MeanFieldList +) const +{ + typedef GeometricField fieldType1; + typedef GeometricField fieldType2; + + forAll(faItems_, i) + { + if + ( + faItems_[i].prime2Mean() + && meanFieldList[i].size() + && prime2MeanFieldList[i].size() + ) + { + const fieldType1& meanField = + obr_.lookupObject(meanFieldList[i]); + fieldType2& prime2MeanField = const_cast + ( + obr_.lookupObject(prime2MeanFieldList[i]) + ); + + prime2MeanField += sqr(meanField); + } + } +} + + +template +void Foam::heatFlux::writeFieldList(const wordList& fieldList) const +{ + typedef GeometricField fieldType; + + forAll(fieldList, i) + { + if (fieldList[i].size()) + { + const fieldType& f = obr_.lookupObject(fieldList[i]); + f.write(); + } + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFluxFunctionObject/heatFluxFunctionObject.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFluxFunctionObject/heatFluxFunctionObject.C new file mode 100644 index 000000000..9a14decf3 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFluxFunctionObject/heatFluxFunctionObject.C @@ -0,0 +1,42 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +\*---------------------------------------------------------------------------*/ + +#include "heatFluxFunctionObject.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineNamedTemplateTypeNameAndDebug(heatFluxFunctionObject, 0); + + addToRunTimeSelectionTable + ( + functionObject, + heatFluxFunctionObject, + dictionary + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFluxFunctionObject/heatFluxFunctionObject.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFluxFunctionObject/heatFluxFunctionObject.H new file mode 100644 index 000000000..d445bbdd2 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/functionObjects/heatFlux/heatFluxFunctionObject/heatFluxFunctionObject.H @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2011 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 . + +Typedef + Foam::heatFluxFunctionObject + +Description + FunctionObject wrapper around fieldAverage to allow them to be created + via the functions entry within controlDict. + +SourceFiles + heatFluxFunctionObject.C + +\*---------------------------------------------------------------------------*/ + +#ifndef heatFluxFunctionObject_H +#define heatFluxFunctionObject_H + +#include "heatFlux.H" +#include "OutputFilterFunctionObject.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef OutputFilterFunctionObject + heatFluxFunctionObject; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/adiabatic/adiabaticFvPatchScalarField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/adiabatic/adiabaticFvPatchScalarField.C new file mode 100644 index 000000000..5503a4c9b --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/adiabatic/adiabaticFvPatchScalarField.C @@ -0,0 +1,161 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "adiabaticFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "radiationConstants.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::adiabaticFvPatchScalarField:: +adiabaticFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + KName_("undefined-K") +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 0.0; +} + + +Foam::adiabaticFvPatchScalarField:: +adiabaticFvPatchScalarField +( + const adiabaticFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + KName_(ptf.KName_) +{} + + +Foam::adiabaticFvPatchScalarField:: +adiabaticFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + KName_(dict.lookup("K")) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 0.0; + + if (dict.found("value")) + { + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); + } +} + + +Foam::adiabaticFvPatchScalarField:: +adiabaticFvPatchScalarField +( + const adiabaticFvPatchScalarField& tppsf +) +: + mixedFvPatchScalarField(tppsf), + KName_(tppsf.KName_) +{} + + +Foam::adiabaticFvPatchScalarField:: +adiabaticFvPatchScalarField +( + const adiabaticFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(tppsf, iF), + KName_(tppsf.KName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::adiabaticFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const scalarField& Tp = *this; + + const scalarField& Kw = + patch().lookupPatchField(KName_); + + const scalarField& Qr = + patch().lookupPatchField("Qr"); + + scalarField fourQro = 4.0*radiation::sigmaSB.value()*pow4(Tp); + + refGrad() = (Qr + fourQro)/Kw; + valueFraction() = fourQro/(fourQro + Kw*patch().deltaCoeffs()*Tp); + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::adiabaticFvPatchScalarField::write +( + Ostream& os +) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + adiabaticFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/adiabatic/adiabaticFvPatchScalarField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/adiabatic/adiabaticFvPatchScalarField.H new file mode 100644 index 000000000..237278a46 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/adiabatic/adiabaticFvPatchScalarField.H @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + adiabaticFvPatchScalarField + +Description + adiabatic boundary (with radiation) + + Example usage: + myWallPatch + { + type adiabatic; + K K; // Name of K field + value 300.0; // Initial temperature / [K] + } + + +SourceFiles + adiabaticFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef adiabaticFvPatchScalarField_H +#define adiabaticFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class adiabaticFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class adiabaticFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Name of thermal conductivity field + word KName_; + + +public: + + //- Runtime type information + TypeName("adiabatic"); + + + // Constructors + + //- Construct from patch and internal field + adiabaticFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + adiabaticFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // adiabaticFvPatchScalarField + // onto a new patch + adiabaticFvPatchScalarField + ( + const adiabaticFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + adiabaticFvPatchScalarField + ( + const adiabaticFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new adiabaticFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + adiabaticFvPatchScalarField + ( + const adiabaticFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new adiabaticFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // Mapping functions + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcTemperature/chtRcTemperatureFvPatchScalarField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcTemperature/chtRcTemperatureFvPatchScalarField.C new file mode 100644 index 000000000..29dd67953 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcTemperature/chtRcTemperatureFvPatchScalarField.C @@ -0,0 +1,215 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#include "chtRcTemperatureFvPatchScalarField.H" +#include "chtRegionCoupleBase.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "fvMatrices.H" +#include "magLongDelta.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +chtRcTemperatureFvPatchScalarField::chtRcTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + regionCouplingFvPatchScalarField(p, iF), + kName_("none"), + radiation_(false) +{} + + +chtRcTemperatureFvPatchScalarField::chtRcTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + regionCouplingFvPatchScalarField(p, iF, dict), + kName_(dict.lookup("K")), + radiation_(readBool(dict.lookup("radiation"))) +{} + + +chtRcTemperatureFvPatchScalarField::chtRcTemperatureFvPatchScalarField +( + const chtRcTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + regionCouplingFvPatchScalarField(ptf, p, iF, mapper), + kName_(ptf.kName_), + radiation_(ptf.radiation_) +{} + + +chtRcTemperatureFvPatchScalarField::chtRcTemperatureFvPatchScalarField +( + const chtRcTemperatureFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + regionCouplingFvPatchScalarField(ptf, iF), + kName_(ptf.kName_), + radiation_(ptf.radiation_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +// Return a named shadow patch field +const chtRcTemperatureFvPatchScalarField& +chtRcTemperatureFvPatchScalarField::shadowPatchField() const +{ + return dynamic_cast + < + const chtRcTemperatureFvPatchScalarField& + > + ( + regionCouplingFvPatchScalarField::shadowPatchField() + ); +} + + +void chtRcTemperatureFvPatchScalarField::initEvaluate +( + const Pstream::commsTypes commsType +) +{ + const chtRegionCoupleBase& K = + dynamic_cast + ( + patch().lookupPatchField(kName_) + ); + + K.calcTemperature(*this, shadowPatchField(), K); +} + + +void chtRcTemperatureFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + fvPatchScalarField::evaluate(); +} + + +void chtRcTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + fvPatchScalarField::updateCoeffs(); +} + + +tmp chtRcTemperatureFvPatchScalarField::source() const +{ + const fvPatch& p = patch(); + const magLongDelta& mld = magLongDelta::New(p.boundaryMesh().mesh()); + + const scalarField TcOwn = patchInternalField(); + const scalarField TcNei = patchNeighbourField(); + const scalarField& Tw = *this; + + const chtRegionCoupleBase& K = + dynamic_cast + ( + p.lookupPatchField(kName_) + ); + + const scalarField k = K*p.deltaCoeffs(); + + const scalarField kOwn = + K.originalPatchField()/(1 - p.weights())/mld.magDelta(p.index()); + + return kOwn*(Tw - TcOwn) - k*(TcNei - TcOwn); +} + + +void chtRcTemperatureFvPatchScalarField::manipulateMatrix +( + fvScalarMatrix& matrix +) +{ + const fvPatch& p = patch(); + const scalarField& magSf = p.magSf(); + const labelList& cellLabels = p.faceCells(); + scalarField& source = matrix.source(); + + scalarField s = this->source(); + + //Info << "s = " << s << " Sum s = " << sum(s*p.magSf()) << endl; + //Info << "Sum s = " << sum(s*p.magSf()) << endl; + + forAll(cellLabels, i) + { + source[cellLabels[i]] += s[i]*magSf[i]; + } +} + + +void chtRcTemperatureFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("K") << kName_ << token::END_STATEMENT << nl; + os.writeKeyword("radiation") << radiation_ << token::END_STATEMENT << nl; + os.writeKeyword("remoteField") + << remoteFieldName() << token::END_STATEMENT << nl; + this->writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + chtRcTemperatureFvPatchScalarField +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcTemperature/chtRcTemperatureFvPatchScalarField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcTemperature/chtRcTemperatureFvPatchScalarField.H new file mode 100644 index 000000000..a6249ea5b --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcTemperature/chtRcTemperatureFvPatchScalarField.H @@ -0,0 +1,174 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + chtRcTemperatureFvPatchScalarField + +Description + Region couple patch field taking radiation into account + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +SourceFiles + chtRcTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef chtRcTemperatureFvPatchScalarField_H +#define chtRcTemperatureFvPatchScalarField_H + +#include "regionCouplingFvPatchFields.H" +#include "fvMatricesFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class chtRcTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class chtRcTemperatureFvPatchScalarField +: + public regionCouplingFvPatchScalarField +{ + // Private data + + //- Name of thermal diffusivity field + word kName_; + + //- Take radiation into account for this patch + bool radiation_; + + +public: + + //- Runtime type information + TypeName("chtRcTemperature"); + + + // Constructors + + //- Construct from patch and internal field + chtRcTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + chtRcTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given chtRcTemperatureFvPatchScalarField onto a new patch + chtRcTemperatureFvPatchScalarField + ( + const chtRcTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy setting internal field reference + chtRcTemperatureFvPatchScalarField + ( + const chtRcTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new chtRcTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new chtRcTemperatureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access functions + + //- Return radiation + bool radiation() const + { + return radiation_; + } + + //- Return shadow patch field + virtual const chtRcTemperatureFvPatchScalarField& + shadowPatchField() const; + + + // Evaluation functions + + //- Initialise the evaluation of the patch field + virtual void initEvaluate(const Pstream::commsTypes commsType); + + //- Evaluate the patch field + virtual void evaluate(const Pstream::commsTypes commsType); + + //- Evaluate the patch field + virtual void updateCoeffs(); + + //- Calculate source term + virtual tmp source() const; + + //- Manipulate matrix + virtual void manipulateMatrix(fvScalarMatrix& matrix); + + //- Write + virtual void write(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C new file mode 100644 index 000000000..8280f2ec4 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.C @@ -0,0 +1,364 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#include "chtRcThermalDiffusivityFvPatchScalarField.H" +#include "chtRcThermalDiffusivitySlaveFvPatchScalarField.H" +#include "chtRcTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "harmonic.H" +#include "radiationConstants.H" +#include "VectorN.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +chtRcThermalDiffusivityFvPatchScalarField::chtRcThermalDiffusivityFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + chtRegionCoupleBase(p, iF) +{} + + +chtRcThermalDiffusivityFvPatchScalarField::chtRcThermalDiffusivityFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + chtRegionCoupleBase(p, iF, dict) +{} + + +chtRcThermalDiffusivityFvPatchScalarField::chtRcThermalDiffusivityFvPatchScalarField +( + const chtRcThermalDiffusivityFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + chtRegionCoupleBase(ptf, p, iF, mapper) +{} + + +chtRcThermalDiffusivityFvPatchScalarField::chtRcThermalDiffusivityFvPatchScalarField +( + const chtRcThermalDiffusivityFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + chtRegionCoupleBase(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void chtRcThermalDiffusivityFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + fvPatchScalarField::evaluate(); +} + + +void chtRcThermalDiffusivityFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + calcThermalDiffusivity(*this, shadowPatchField()); +} + + +void +chtRcThermalDiffusivityFvPatchScalarField::calcThermalDiffusivity +( + chtRegionCoupleBase& owner, + const chtRegionCoupleBase& neighbour +) const +{ + if(debug) + { + Info << "In chtRcThermalDiffusivityFvPatchScalarField::calcThermalDiffusivity on " + << this->dimensionedInternalField().name() + << " in " << this->patch().boundaryMesh().mesh().name() + << endl; + } + + const fvPatch& p = owner.patch(); + const fvMesh& mesh = p.boundaryMesh().mesh(); + const magLongDelta& mld = magLongDelta::New(mesh); + + const chtRcTemperatureFvPatchScalarField& TwOwn = + dynamic_cast + ( + p.lookupPatchField("T") + ); + scalarField& k = owner; + const scalarField& fOwn = owner.originalPatchField(); + const scalarField TcOwn = TwOwn.patchInternalField(); + + scalarField fNei(p.size()); + scalarField TcNei(p.size()); + + scalarField Qr(p.size(), 0.0); + scalarField fourQro(p.size(), 0.0); + + if (TwOwn.radiation()) + { + Qr += p.lookupPatchField("Qr"); + fourQro += 4.0*radiation::sigmaSB.value()*pow4(TwOwn); + } + + { + Field > lData(neighbour.size()); + + const scalarField& lfNei = neighbour.originalPatchField(); + scalarField lTcNei = TwOwn.shadowPatchField().patchInternalField(); + + forAll(lData, facei) + { + lData[facei][0] = lTcNei[facei]; + lData[facei][1] = lfNei[facei]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + const scalarField& lQrNei = + owner.lookupShadowPatchField("Qr"); + const scalarField& lTwNei = TwOwn.shadowPatchField(); + + forAll(lData, facei) + { + lData[facei][2] = lTwNei[facei]; + lData[facei][3] = lQrNei[facei]; + } + } + + const Field > iData = + owner.regionCouplePatch().interpolate(lData); + + forAll(iData, facei) + { + TcNei[facei] = iData[facei][0]; + fNei[facei] = iData[facei][1]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + forAll(iData, facei) + { + Qr[facei] += iData[facei][3]; + fourQro[facei] += + 4.0*radiation::sigmaSB.value()*pow4(iData[facei][2]); + } + } + } + + // Do interpolation + harmonic interp(mesh); + const scalarField weights = interp.weights(fOwn, fNei, p); + const scalarField kHarm = weights*fOwn + (1.0 - weights)*fNei; + + const scalarField kOwn = fOwn/(1.0 - p.weights())/mld.magDelta(p.index()); + const scalarField kNei = fNei/p.weights()/mld.magDelta(p.index()); + + //Info << "kOwn = " << kOwn << endl; + //Info << "kNei = " << kNei << endl; + //Info << "TcOwn = " << TcOwn << endl; + //Info << "TcNei = " << TcNei << endl; + //Info << "DeltaT = " << TcNei - TcOwn << endl; + + //Info << "Qr = " << Qr << endl; + //Info << "kOwn + kNei = " << (kOwn + kNei) << endl; + + //Info << "k = " << k << endl; + + k = kOwn*(TwOwn*(kNei*(TcNei - TcOwn) + Qr + fourQro) - TcOwn*fourQro); + k /= stabilise((fourQro + TwOwn*(kOwn + kNei))*(TcNei - TcOwn), SMALL); + k /= p.deltaCoeffs(); + + //Info << "k = " << k << endl; + + forAll(k, facei) + { + k[facei] = max(min(k[facei], 100*kHarm[facei]), 0.01*kHarm[facei]); + } + + //Info << "k = " << k << endl; + + owner.fvPatchScalarField::updateCoeffs(); +} + + +void +chtRcThermalDiffusivityFvPatchScalarField::calcTemperature +( + chtRcTemperatureFvPatchScalarField& TwOwn, + const chtRcTemperatureFvPatchScalarField& neighbour, + const chtRegionCoupleBase& ownerK +) const +{ + if(debug) + { + Info << "In chtRcThermalDiffusivityFvPatchScalarField::calcTemperature on " + << this->dimensionedInternalField().name() + << " in " << this->patch().boundaryMesh().mesh().name() + << endl; + } + + const fvPatch& p = TwOwn.patch(); + const fvMesh& mesh = p.boundaryMesh().mesh(); + const magLongDelta& mld = magLongDelta::New(mesh); + + const scalarField& fOwn = ownerK.originalPatchField(); + const scalarField TcOwn = TwOwn.patchInternalField(); + + scalarField fNei(p.size()); + scalarField TcNei(p.size()); + + scalarField Qr(p.size(), 0.0); + scalarField fourQro(p.size(), 0.0); + + if (TwOwn.radiation()) + { + Qr += p.lookupPatchField("Qr"); + fourQro += 4.0*radiation::sigmaSB.value()*pow4(TwOwn); + } + + { + Field > lData(neighbour.size()); + + const scalarField& lfNei = + ownerK.shadowPatchField().originalPatchField(); + scalarField lTcNei = + TwOwn.shadowPatchField().patchInternalField(); + + forAll(lData, facei) + { + lData[facei][0] = lTcNei[facei]; + lData[facei][1] = lfNei[facei]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + const scalarField& lTwNei = TwOwn.shadowPatchField(); + const scalarField& lQrNei = + TwOwn.lookupShadowPatchField("Qr"); + + forAll(lData, facei) + { + lData[facei][2] = lTwNei[facei]; + lData[facei][3] = lQrNei[facei]; + } + } + + const Field > iData = + TwOwn.regionCouplePatch().interpolate(lData); + + forAll(iData, facei) + { + TcNei[facei] = iData[facei][0]; + fNei[facei] = iData[facei][1]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + forAll(iData, facei) + { + fourQro[facei] += + 4.0*radiation::sigmaSB.value()*pow4(iData[facei][2]); + Qr[facei] += iData[facei][3]; + } + } + } + + const scalarField kOwn = fOwn/(1.0 - p.weights())/mld.magDelta(p.index()); + const scalarField kNei = fNei/p.weights()/mld.magDelta(p.index()); + + //Info << "kOwn = " << kOwn << endl; + //Info << "kNei = " << kNei << endl; + //Info << "TcOwn = " << TcOwn << endl; + //Info << "TcNei = " << TcNei << endl; + //Info << "Qr = " << Qr << " Sum = " << sum(Qr*p.magSf()) << endl; + + TwOwn *= + (fourQro + Qr + kOwn*TcOwn + kNei*TcNei) + /(TwOwn*(kOwn + kNei) + fourQro); + + //Info << "TwOwn = " << TwOwn << endl; + + //scalarField q1 = (TwOwn - TcOwn)*kOwn; + //Info << "q1 = " << q1 << " Sum = " << sum(q1*p.magSf()) << endl; + + //scalarField q2 = (TcNei - TcOwn)*ownerK*p.deltaCoeffs(); + //Info << "q2 = " << q2 << " Sum = " << sum(q2*p.magSf()) << endl; + + TwOwn.fvPatchScalarField::updateCoeffs(); +} + + +void chtRcThermalDiffusivityFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("remoteField") + << remoteFieldName() << token::END_STATEMENT << nl; + this->writeEntry("value", os); +} + + +//- Specify data associated with VectorN type is contiguous +template<> +inline bool contiguous >() {return true;} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + chtRcThermalDiffusivityFvPatchScalarField +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.H new file mode 100644 index 000000000..eba968a8c --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivity/chtRcThermalDiffusivityFvPatchScalarField.H @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + chtRcThermalDiffusivityFvPatchScalarField + +Description + Region couple patch field taking radiation into account + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +SourceFiles + chtRcThermalDiffusivityFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef chtRcThermalDiffusivityFvPatchScalarField_H +#define chtRcThermalDiffusivityFvPatchScalarField_H + +#include "chtRegionCoupleBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class chtRcThermalDiffusivityFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class chtRcThermalDiffusivityFvPatchScalarField +: + public chtRegionCoupleBase +{ + // Private data + + +public: + + //- Runtime type information + TypeName("chtRcThermalDiffusivity"); + + + // Constructors + + //- Construct from patch and internal field + chtRcThermalDiffusivityFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + chtRcThermalDiffusivityFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given chtRcThermalDiffusivityFvPatchScalarField onto a new patch + chtRcThermalDiffusivityFvPatchScalarField + ( + const chtRcThermalDiffusivityFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy setting internal field reference + chtRcThermalDiffusivityFvPatchScalarField + ( + const chtRcThermalDiffusivityFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new chtRcThermalDiffusivityFvPatchScalarField(*this) + ); + } + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new chtRcThermalDiffusivityFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + + // Evaluation functions + + //- Evaluate the patch field + virtual void updateCoeffs(); + + //- Evaluate the patch field + virtual void evaluate(const Pstream::commsTypes commsType); + + //- Calculate the thermal diffusivity + virtual void calcThermalDiffusivity + ( + chtRegionCoupleBase& owner, + const chtRegionCoupleBase& neighbour + ) const; + + //- Calculate the temperature + virtual void calcTemperature + ( + chtRcTemperatureFvPatchScalarField& owner, + const chtRcTemperatureFvPatchScalarField& neighbour, + const chtRegionCoupleBase& ownerK + ) const; + + + //- Write + virtual void write(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivityResistance/chtRcThermalDiffusivityResistanceFvPatchScalarField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivityResistance/chtRcThermalDiffusivityResistanceFvPatchScalarField.C new file mode 100644 index 000000000..6d985f88c --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivityResistance/chtRcThermalDiffusivityResistanceFvPatchScalarField.C @@ -0,0 +1,479 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#include "chtRcThermalDiffusivityResistanceFvPatchScalarField.H" +#include "chtRcThermalDiffusivitySlaveFvPatchScalarField.H" +#include "chtRcTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "harmonic.H" +#include "radiationConstants.H" +#include "VectorN.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +chtRcThermalDiffusivityResistanceFvPatchScalarField:: +chtRcThermalDiffusivityResistanceFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + chtRegionCoupleBase(p, iF), + conductivity_(p.size(), 0) +{} + + +chtRcThermalDiffusivityResistanceFvPatchScalarField:: +chtRcThermalDiffusivityResistanceFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + chtRegionCoupleBase(p, iF, dict), + conductivity_("conductivity", dict, p.size()) +{} + + +chtRcThermalDiffusivityResistanceFvPatchScalarField:: +chtRcThermalDiffusivityResistanceFvPatchScalarField +( + const chtRcThermalDiffusivityResistanceFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + chtRegionCoupleBase(ptf, p, iF, mapper), + conductivity_(ptf.conductivity_) +{} + + +chtRcThermalDiffusivityResistanceFvPatchScalarField:: +chtRcThermalDiffusivityResistanceFvPatchScalarField +( + const chtRcThermalDiffusivityResistanceFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + chtRegionCoupleBase(ptf, iF), + conductivity_(ptf.conductivity_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void chtRcThermalDiffusivityResistanceFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + fvPatchScalarField::evaluate(); +} + + +void chtRcThermalDiffusivityResistanceFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + calcThermalDiffusivity(*this, shadowPatchField()); +} + + +void +chtRcThermalDiffusivityResistanceFvPatchScalarField::calcThermalDiffusivity +( + chtRegionCoupleBase& owner, + const chtRegionCoupleBase& neighbour +) const +{ + const fvPatch& p = owner.patch(); + const fvMesh& mesh = p.boundaryMesh().mesh(); + const magLongDelta& mld = magLongDelta::New(mesh); + + const chtRcTemperatureFvPatchScalarField& TwOwn = + dynamic_cast + ( + p.lookupPatchField("T") + ); + scalarField& k = owner; + const scalarField& fOwn = owner.originalPatchField(); + const scalarField TcOwn = TwOwn.patchInternalField(); + + scalarField fNei(p.size()); + scalarField TcNei(p.size()); + scalarField TwNei(p.size()); + + scalarField QrOwn(p.size(), 0.0); + scalarField fourQroOwn(p.size(), 0.0); + scalarField fourQroNei(p.size(), 0.0); + + if (TwOwn.radiation()) + { + QrOwn += p.lookupPatchField("Qr"); + fourQroOwn += 4.0*radiation::sigmaSB.value()*pow4(TwOwn); + } + + scalarField Qr = QrOwn; + scalarField cond(p.size()); + + { + Field > lData(neighbour.size()); + + const scalarField& lfNei = neighbour.originalPatchField(); + scalarField lTcNei = TwOwn.shadowPatchField().patchInternalField(); + const scalarField& lTwNei = TwOwn.shadowPatchField(); + + forAll(lData, facei) + { + lData[facei][0] = lTcNei[facei]; + lData[facei][1] = lfNei[facei]; + lData[facei][2] = lTwNei[facei]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + const scalarField& lQrNei = + owner.lookupShadowPatchField("Qr"); + + forAll(lData, facei) + { + lData[facei][3] = lQrNei[facei]; + } + } + + if(isA(owner)) + { + forAll(lData, facei) + { + lData[facei][4] = conductivity_[facei]; + } + } + + const Field > iData = + owner.regionCouplePatch().interpolate(lData); + + forAll(iData, facei) + { + TcNei[facei] = iData[facei][0]; + fNei[facei] = iData[facei][1]; + TwNei[facei] = iData[facei][2]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + forAll(iData, facei) + { + fourQroNei[facei] += + 4.0*radiation::sigmaSB.value()*pow4(iData[facei][2]); + Qr[facei] += iData[facei][3]; + } + } + + if(isA(owner)) + { + forAll(lData, facei) + { + cond[facei] = iData[facei][4]; + } + } + else + { + cond = conductivity_; + } + } + + // Do interpolation + harmonic interp(mesh); + const scalarField weights = interp.weights(fOwn, fNei, p); + scalarField kHarm = weights*fOwn + (1.0 - weights)*fNei; + kHarm *= cond/(kHarm*p.deltaCoeffs() + cond); + + const scalarField kOwn = fOwn/(1.0 - p.weights())/mld.magDelta(p.index()); + const scalarField kNei = fNei/p.weights()/mld.magDelta(p.index()); + + //Info << "kOwn = " << kOwn << endl; + //Info << "kNei = " << kNei << endl; + //Info << "TcOwn = " << TcOwn << endl; + //Info << "TcNei = " << TcNei << endl; + //Info << "DeltaT = " << TcNei - TcOwn << endl; + //Info << "TwOwn = " << TwOwn << endl; + //Info << "TwNei = " << TwNei << endl; + + //Info << "QrOwn = " << QrOwn << endl; + //Info << "Qr = " << Qr << endl; + //Info << "kOwn + kNei = " << (kOwn + kNei) << endl; + //Info << "f1 = " << fourQroOwn << endl; + //Info << "f2 = " << fourQroNei << endl; + + scalarField temp = TwNei*(cond + kNei) + fourQroNei; + +/* + k = -TwOwn* + ( + kOwn* + ( + TwNei*(cond*(kNei*TcNei + fourQroOwn + fourQroNei + Qr) + kNei*(fourQroOwn + QrOwn)) + + fourQroNei*(fourQroOwn + QrOwn) + ) + + kOwn*kOwn*TcOwn*temp + ); + + k /= stabilise(TwOwn*(kOwn*temp + cond*(TwNei*kNei + fourQroNei)) + fourQroOwn*temp, SMALL); + k += kOwn*TcOwn; + k /= stabilise(TcOwn - TcNei, SMALL)*p.deltaCoeffs(); +*/ + + // Expression is equivalent to the one above + k = kOwn* + ( + TwOwn* + ( + TwNei* + ( + cond*(kNei*(TcOwn - TcNei) - fourQroOwn - fourQroNei - Qr) + - kNei*(fourQroOwn + QrOwn) + ) + + fourQroNei*(TcOwn*cond - fourQroOwn - QrOwn) + ) + + (TcOwn*fourQroOwn*temp) + ); + + k /= stabilise + ( + (TcOwn - TcNei)* + ( + TwOwn* + ( + kOwn*temp + cond*(TwNei*kNei + fourQroNei) + ) + + fourQroOwn*temp + ), + SMALL + ); + + k /= p.deltaCoeffs(); + + //Info << "k = " << k << endl; + + forAll(k, facei) + { + k[facei] = max(min(k[facei], 100*kHarm[facei]), 0.01*kHarm[facei]); + } + + //Info << "k = " << k << endl; + + owner.fvPatchScalarField::updateCoeffs(); +} + + +void +chtRcThermalDiffusivityResistanceFvPatchScalarField::calcTemperature +( + chtRcTemperatureFvPatchScalarField& TwOwn, + const chtRcTemperatureFvPatchScalarField& neighbour, + const chtRegionCoupleBase& ownerK +) const +{ + const fvPatch& p = TwOwn.patch(); + const fvMesh& mesh = p.boundaryMesh().mesh(); + const magLongDelta& mld = magLongDelta::New(mesh); + + const scalarField& fOwn = ownerK.originalPatchField(); + const scalarField TcOwn = TwOwn.patchInternalField(); + + scalarField fNei(p.size()); + scalarField TcNei(p.size()); + scalarField TwNei(p.size()); + + scalarField QrOwn(p.size(), 0.0); + scalarField fourQroOwn(p.size(), 0.0); + scalarField fourQroNei(p.size(), 0.0); + + if (TwOwn.radiation()) + { + QrOwn += p.lookupPatchField("Qr"); + fourQroOwn += 4.0*radiation::sigmaSB.value()*pow4(TwOwn); + } + + scalarField Qr = QrOwn; + scalarField cond(p.size()); + + { + Field > lData(neighbour.size()); + + const scalarField& lfNei = + ownerK.shadowPatchField().originalPatchField(); + scalarField lTcNei = + TwOwn.shadowPatchField().patchInternalField(); + const scalarField& lTwNei = + TwOwn.shadowPatchField(); + + forAll(lData, facei) + { + lData[facei][0] = lTcNei[facei]; + lData[facei][1] = lfNei[facei]; + lData[facei][2] = lTwNei[facei]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + const scalarField& lQrNei = + TwOwn.lookupShadowPatchField("Qr"); + + forAll(lData, facei) + { + lData[facei][3] = lQrNei[facei]; + } + } + + if(isA(ownerK)) + { + forAll(lData, facei) + { + lData[facei][4] = conductivity_[facei]; + } + } + + const Field > iData = + TwOwn.regionCouplePatch().interpolate(lData); + + forAll(iData, facei) + { + TcNei[facei] = iData[facei][0]; + fNei[facei] = iData[facei][1]; + TwNei[facei] = iData[facei][2]; + } + + if(TwOwn.shadowPatchField().radiation()) + { + forAll(iData, facei) + { + Qr[facei] += iData[facei][3]; + fourQroNei[facei] += + 4.0*radiation::sigmaSB.value()*pow4(iData[facei][2]); + } + } + + if(isA(ownerK)) + { + forAll(lData, facei) + { + cond[facei] = iData[facei][4]; + } + } + else + { + cond = conductivity_; + } + } + + const scalarField kOwn = fOwn/(1.0 - p.weights())/mld.magDelta(p.index()); + const scalarField kNei = fNei/p.weights()/mld.magDelta(p.index()); + + //Info << "kOwn = " << kOwn << endl; + //Info << "kNei = " << kNei << endl; + //Info << "TcOwn = " << TcOwn << endl; + //Info << "TcNei = " << TcNei << endl; + //Info << "QrOwn = " << QrOwn << " Sum = " << sum(QrOwn*p.magSf()) << endl; + //Info << "Qr = " << Qr << " Sum = " << sum(Qr*p.magSf()) << endl; + + scalarField temp = fourQroOwn + QrOwn + kOwn*TcOwn; + + TwOwn *= + ( + TwNei* + ( + cond* + ( + kNei*TcNei + fourQroOwn + fourQroNei + Qr + kOwn*TcOwn + ) + + kNei*temp + ) + + fourQroNei*temp + ) + / + ( + TwOwn* + ( + TwNei*(cond*(kOwn + kNei) + kOwn*kNei) + + fourQroNei*(kOwn + cond) + ) + + fourQroOwn*(TwNei*(cond + kNei) + fourQroNei) + ); + + //Info << "TwOwn = " << TwOwn << endl; + + //scalarField q1 = (TwOwn - TcOwn)*kOwn; + //Info << "q1 = " << q1 << " Sum = " << sum(q1*p.magSf()) << endl; + + //scalarField q2 = (TcNei - TcOwn)*ownerK*p.deltaCoeffs(); + //Info << "q2 = " << q2 << " Sum = " << sum(q2*p.magSf()) << endl; + + TwOwn.fvPatchScalarField::updateCoeffs(); +} + + +void chtRcThermalDiffusivityResistanceFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + conductivity_.writeEntry("conductivity", os); + os.writeKeyword("remoteField") + << remoteFieldName() << token::END_STATEMENT << nl; + this->writeEntry("value", os); +} + + +//- Specify data associated with VectorN type is contiguous +template<> +inline bool contiguous >() {return true;} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + chtRcThermalDiffusivityResistanceFvPatchScalarField +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivityResistance/chtRcThermalDiffusivityResistanceFvPatchScalarField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivityResistance/chtRcThermalDiffusivityResistanceFvPatchScalarField.H new file mode 100644 index 000000000..b814acb50 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivityResistance/chtRcThermalDiffusivityResistanceFvPatchScalarField.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + regionCouplingResistanceFvPatchField + +Description + Region couple patch field jump resistance on the surface taking + radiation into account + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +SourceFiles + regionCouplingResistanceFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef regionCouplingResistanceFvPatchField_H +#define regionCouplingResistanceFvPatchField_H + +#include "chtRegionCoupleBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class regionCouplingResistanceFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +class chtRcThermalDiffusivityResistanceFvPatchScalarField +: + public chtRegionCoupleBase +{ + // Private data + + //- Conductivity + scalarField conductivity_; + + +public: + + //- Runtime type information + TypeName("chtRcThermalDiffusivityResistance"); + + + // Constructors + + //- Construct from patch and internal field + chtRcThermalDiffusivityResistanceFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + chtRcThermalDiffusivityResistanceFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given regionCouplingResistanceFvPatchField + // onto a new patch + chtRcThermalDiffusivityResistanceFvPatchScalarField + ( + const chtRcThermalDiffusivityResistanceFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy setting internal field reference + chtRcThermalDiffusivityResistanceFvPatchScalarField + ( + const chtRcThermalDiffusivityResistanceFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new chtRcThermalDiffusivityResistanceFvPatchScalarField(*this) + ); + } + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new chtRcThermalDiffusivityResistanceFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return conductivity + const scalarField& conductivity() const + { + return conductivity_; + } + + //- Return Access to conductivity + scalarField& conductivity() + { + return conductivity_; + } + + + // Evaluation functions + + //- Evaluate the patch field + virtual void updateCoeffs(); + + //- Evaluate the patch field + virtual void evaluate(const Pstream::commsTypes commsType); + + //- Calculate the thermal diffusivity + virtual void calcThermalDiffusivity + ( + chtRegionCoupleBase& owner, + const chtRegionCoupleBase& neighbour + ) const; + + //- Calculate the temperature + virtual void calcTemperature + ( + chtRcTemperatureFvPatchScalarField& owner, + const chtRcTemperatureFvPatchScalarField& neighbour, + const chtRegionCoupleBase& ownerK + ) const; + + + //- Write + virtual void write(Ostream&) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivitySlave/chtRcThermalDiffusivitySlaveFvPatchScalarField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivitySlave/chtRcThermalDiffusivitySlaveFvPatchScalarField.C new file mode 100644 index 000000000..8243859d9 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivitySlave/chtRcThermalDiffusivitySlaveFvPatchScalarField.C @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#include "chtRcThermalDiffusivitySlaveFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +chtRcThermalDiffusivitySlaveFvPatchScalarField::chtRcThermalDiffusivitySlaveFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + chtRegionCoupleBase(p, iF) +{} + + +chtRcThermalDiffusivitySlaveFvPatchScalarField::chtRcThermalDiffusivitySlaveFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + chtRegionCoupleBase(p, iF, dict) +{} + + +chtRcThermalDiffusivitySlaveFvPatchScalarField::chtRcThermalDiffusivitySlaveFvPatchScalarField +( + const chtRcThermalDiffusivitySlaveFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + chtRegionCoupleBase(ptf, p, iF, mapper) +{} + + +chtRcThermalDiffusivitySlaveFvPatchScalarField::chtRcThermalDiffusivitySlaveFvPatchScalarField +( + const chtRcThermalDiffusivitySlaveFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + chtRegionCoupleBase(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const chtRegionCoupleBase& +chtRcThermalDiffusivitySlaveFvPatchScalarField::shadowPatchField() const +{ + return dynamic_cast + ( + regionCouplingFvPatchScalarField::shadowPatchField() + ); +} + + +void chtRcThermalDiffusivitySlaveFvPatchScalarField::evaluate +( + const Pstream::commsTypes +) +{ + fvPatchScalarField::evaluate(); +} + + +void chtRcThermalDiffusivitySlaveFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + shadowPatchField().calcThermalDiffusivity(*this, shadowPatchField()); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + chtRcThermalDiffusivitySlaveFvPatchScalarField +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivitySlave/chtRcThermalDiffusivitySlaveFvPatchScalarField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivitySlave/chtRcThermalDiffusivitySlaveFvPatchScalarField.H new file mode 100644 index 000000000..42fda45e2 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRcThermalDiffusivitySlave/chtRcThermalDiffusivitySlaveFvPatchScalarField.H @@ -0,0 +1,149 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + chtRcThermalDiffusivitySlaveFvPatchScalarField + +Description + Region couple patch field taking radiation into account + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +SourceFiles + chtRcThermalDiffusivitySlaveFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef chtRcThermalDiffusivitySlaveFvPatchScalarField_H +#define chtRcThermalDiffusivitySlaveFvPatchScalarField_H + +#include "chtRegionCoupleBase.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class chtThermalDiffusivityRegionCoupleFvPatchScalarField; +class chtTemperatureRegionCoupleFvPatchScalarField; + +/*---------------------------------------------------------------------------*\ + Class chtRcThermalDiffusivitySlaveFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class chtRcThermalDiffusivitySlaveFvPatchScalarField +: + public chtRegionCoupleBase +{ + // Private data + +public: + + //- Runtime type information + TypeName("chtRcThermalDiffusivitySlave"); + + + // Constructors + + //- Construct from patch and internal field + chtRcThermalDiffusivitySlaveFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + chtRcThermalDiffusivitySlaveFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given chtRcThermalDiffusivitySlaveFvPatchScalarField onto a new patch + chtRcThermalDiffusivitySlaveFvPatchScalarField + ( + const chtRcThermalDiffusivitySlaveFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy setting internal field reference + chtRcThermalDiffusivitySlaveFvPatchScalarField + ( + const chtRcThermalDiffusivitySlaveFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new chtRcThermalDiffusivitySlaveFvPatchScalarField(*this) + ); + } + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new chtRcThermalDiffusivitySlaveFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return shadow patch field + virtual const chtRegionCoupleBase& shadowPatchField() const; + + + // Evaluation functions + + //- Evaluate the patch field + virtual void updateCoeffs(); + + //- Evaluate the patch field + virtual void evaluate(const Pstream::commsTypes commsType); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRegionCoupleBase/chtRegionCoupleBase.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRegionCoupleBase/chtRegionCoupleBase.C new file mode 100644 index 000000000..eb7a3d84f --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRegionCoupleBase/chtRegionCoupleBase.C @@ -0,0 +1,178 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#include "chtRcTemperatureFvPatchScalarField.H" +#include "chtRegionCoupleBase.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "fvMatrices.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +chtRegionCoupleBase::chtRegionCoupleBase +( + const fvPatch& p, + const DimensionedField& iF +) +: + regionCouplingFvPatchScalarField(p, iF) +{} + + +chtRegionCoupleBase::chtRegionCoupleBase +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + regionCouplingFvPatchScalarField(p, iF, dict) +{} + + +chtRegionCoupleBase::chtRegionCoupleBase +( + const chtRegionCoupleBase& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + regionCouplingFvPatchScalarField(ptf, p, iF, mapper) +{} + + +chtRegionCoupleBase::chtRegionCoupleBase +( + const chtRegionCoupleBase& ptf, + const DimensionedField& iF +) +: + regionCouplingFvPatchScalarField(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// Return a named shadow patch field +const chtRegionCoupleBase& +chtRegionCoupleBase::shadowPatchField() const +{ + return dynamic_cast + ( + regionCouplingFvPatchScalarField::shadowPatchField() + ); +} + + +void chtRegionCoupleBase::initEvaluate +( + const Pstream::commsTypes commsType +) +{ + updateCoeffs(); +} + + +void +Foam::chtRegionCoupleBase::calcThermalDiffusivity +( + chtRegionCoupleBase& owner, + const chtRegionCoupleBase& neighbour +) const +{ + shadowPatchField().calcThermalDiffusivity(owner, neighbour); +} + + +void +Foam::chtRegionCoupleBase::calcTemperature +( + chtRcTemperatureFvPatchScalarField& owner, + const chtRcTemperatureFvPatchScalarField& neighbour, + const chtRegionCoupleBase& ownerK +) const +{ + shadowPatchField().calcTemperature(owner, neighbour, ownerK); +} + + +void +Foam::chtRegionCoupleBase::initInterfaceMatrixUpdate +( + const scalarField&, + scalarField&, + const lduMatrix&, + const scalarField&, + const direction, + const Pstream::commsTypes +) const +{ + FatalErrorIn + ( + "chtRegionCoupleBase::initInterfaceMatrixUpdate" + ) << abort(FatalError); +} + + +void +Foam::chtRegionCoupleBase::updateInterfaceMatrix +( + const scalarField&, + scalarField&, + const lduMatrix&, + const scalarField&, + const direction, + const Pstream::commsTypes +) const +{ + FatalErrorIn + ( + "chtRegionCoupleBase::updateInterfaceMatrix" + ) << abort(FatalError); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + chtRegionCoupleBase +); + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRegionCoupleBase/chtRegionCoupleBase.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRegionCoupleBase/chtRegionCoupleBase.H new file mode 100644 index 000000000..d95c40e53 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/chtRegionCoupleBase/chtRegionCoupleBase.H @@ -0,0 +1,197 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + chtRegionCoupleBase + +Description + Region couple patch field taking radiation into account + +Author + Henrik Rusche, Wikki GmbH. All rights reserved + +SourceFiles + chtRegionCoupleBase.C + +\*---------------------------------------------------------------------------*/ + +#ifndef chtRegionCoupleBase_H +#define chtRegionCoupleBase_H + +#include "regionCouplingFvPatchFields.H" +#include "fvMatricesFwd.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class chtRcTemperatureFvPatchScalarField; + +/*---------------------------------------------------------------------------*\ + Class chtRegionCoupleBase Declaration +\*---------------------------------------------------------------------------*/ + +class chtRegionCoupleBase +: + public regionCouplingFvPatchScalarField +{ + // Private data + + +public: + + //- Runtime type information + TypeName("chtRegionCoupleBase"); + + + // Constructors + + //- Construct from patch and internal field + chtRegionCoupleBase + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + chtRegionCoupleBase + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given chtRegionCoupleBase onto a new patch + chtRegionCoupleBase + ( + const chtRegionCoupleBase&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy setting internal field reference + chtRegionCoupleBase + ( + const chtRegionCoupleBase&, + const DimensionedField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new chtRegionCoupleBase(*this) + ); + } + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new chtRegionCoupleBase(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return false to disable interpolation on this patch + virtual bool coupled() const + { + return false; + } + + //- Return shadow patch field + const chtRegionCoupleBase& shadowPatchField() const; + + //- Return original patch field + const scalarField& originalPatchField() const + { + return regionCouplingFvPatchScalarField::originalPatchField(); + } + + + // Evaluation functions + + //- Initialise the evaluation of the patch field + virtual void initEvaluate(const Pstream::commsTypes commsType); + + //- Calculate the thermal diffusivity + virtual void calcThermalDiffusivity + ( + chtRegionCoupleBase& owner, + const chtRegionCoupleBase& neighbour + ) const; + + //- Calculate the temperature + virtual void calcTemperature + ( + chtRcTemperatureFvPatchScalarField& owner, + const chtRcTemperatureFvPatchScalarField& neighbour, + const chtRegionCoupleBase& ownerK + ) const; + + //- Initialise neighbour matrix update + virtual void initInterfaceMatrixUpdate + ( + const scalarField& psiInternal, + scalarField& result, + const lduMatrix& m, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + const scalarField& psiInternal, + scalarField& result, + const lduMatrix&, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/controlledParabolicVelocity/controlledParabolicVelocityFvPatchVectorField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/controlledParabolicVelocity/controlledParabolicVelocityFvPatchVectorField.C new file mode 100644 index 000000000..4912cf6b7 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/controlledParabolicVelocity/controlledParabolicVelocityFvPatchVectorField.C @@ -0,0 +1,214 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "controlledParabolicVelocityFvPatchVectorField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +controlledParabolicVelocityFvPatchVectorField::controlledParabolicVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(p, iF), + Umean_(0), + n_(0, 1, 0), + y_(1, 0, 0), + target_(0), + obsFieldName_("undef"), + obsPatchName_("undef"), + obsPatchID_(-1), + gain_(0), + curTimeIndex_(-1) +{} + + +controlledParabolicVelocityFvPatchVectorField::controlledParabolicVelocityFvPatchVectorField +( + const controlledParabolicVelocityFvPatchVectorField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchVectorField(ptf, p, iF, mapper), + Umean_(ptf.Umean_), + n_(ptf.n_), + y_(ptf.y_), + target_(ptf.target_), + obsFieldName_(ptf.obsFieldName_), + obsPatchName_(ptf.obsPatchName_), + obsPatchID_(ptf.obsPatchID_), + gain_(ptf.gain_), + curTimeIndex_(-1) +{} + + +controlledParabolicVelocityFvPatchVectorField::controlledParabolicVelocityFvPatchVectorField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchVectorField(p, iF), + Umean_(readScalar(dict.lookup("Umean"))), + n_(dict.lookup("n")), + y_(dict.lookup("y")), + target_(readScalar(dict.lookup("target"))), + obsFieldName_(dict.lookup("obsFieldName")), + obsPatchName_(dict.lookup("obsPatchName")), + obsPatchID_(patch().patch().boundaryMesh().findPatchID(obsPatchName_)), + gain_(readScalar(dict.lookup("gain"))), + curTimeIndex_(-1) +{ + if (obsPatchID_ < 0) + { + FatalErrorIn + ( + "controlledParabolicVelocityFvPatchVectorField" + ) << "patch " << dict.lookup("obsPatchName") + << "not found" + << nl << exit(FatalError); + } + + n_ /= mag(n_); + y_ /= mag(y_); + + fvPatchField::operator= + ( + vectorField("value", dict, p.size()) + ); +} + + +controlledParabolicVelocityFvPatchVectorField::controlledParabolicVelocityFvPatchVectorField +( + const controlledParabolicVelocityFvPatchVectorField& fcvpvf, + const DimensionedField& iF +) +: + fixedValueFvPatchVectorField(fcvpvf, iF), + Umean_(fcvpvf.Umean_), + n_(fcvpvf.n_), + y_(fcvpvf.y_), + target_(fcvpvf.target_), + obsFieldName_(fcvpvf.obsFieldName_), + obsPatchName_(fcvpvf.obsPatchName_), + obsPatchID_(fcvpvf.obsPatchID_), + gain_(fcvpvf.gain_), + curTimeIndex_(-1) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void controlledParabolicVelocityFvPatchVectorField::updateCoeffs() +{ + if (updated()) + { + return; + } + + if (curTimeIndex_ != this->db().time().timeIndex()) + { + const volScalarField& field = + db().lookupObject(obsFieldName_); + + scalar obsPatchAverage = gAverage(field.boundaryField()[obsPatchID_]); + + + Info<< "Average of " << obsFieldName_ + << " on patch " << patch().name() + << " = " << obsPatchAverage + << " Difference to target = " + << obsPatchAverage - target_ + << " Umean = " << Umean_ + << endl; + + Umean_ += gain_*(obsPatchAverage - target_); + + // Get range and orientation + boundBox bb(patch().patch().localPoints(), true); + + vector ctr = 0.5*(bb.max() + bb.min()); + + const vectorField& c = patch().Cf(); + + // Calculate local 1-D coordinate for the parabolic profile + scalarField coord = + 0.5 - ((c - ctr) & y_)/((bb.max() - bb.min()) & y_); + + operator==(n_*3/2*Umean_*(1.0 - sqr(coord))); + + curTimeIndex_ = this->db().time().timeIndex(); + } + + fixedValueFvPatchVectorField::updateCoeffs(); +} + + +// Write +void controlledParabolicVelocityFvPatchVectorField::write(Ostream& os) const +{ + fvPatchVectorField::write(os); + os.writeKeyword("Umean") + << Umean_ << token::END_STATEMENT << nl; + os.writeKeyword("n") + << n_ << token::END_STATEMENT << nl; + os.writeKeyword("y") + << y_ << token::END_STATEMENT << nl; + os.writeKeyword("target") + << target_ << token::END_STATEMENT << nl; + os.writeKeyword("obsPatchName") + << obsPatchName_ << token::END_STATEMENT << nl; + os.writeKeyword("obsFieldName") + << obsFieldName_ << token::END_STATEMENT << nl; + os.writeKeyword("gain") + << gain_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField(fvPatchVectorField, controlledParabolicVelocityFvPatchVectorField); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/controlledParabolicVelocity/controlledParabolicVelocityFvPatchVectorField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/controlledParabolicVelocity/controlledParabolicVelocityFvPatchVectorField.H new file mode 100644 index 000000000..c9c422d97 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/controlledParabolicVelocity/controlledParabolicVelocityFvPatchVectorField.H @@ -0,0 +1,170 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + controlledParabolicVelocityFvPatchVectorField + +Description + Boundary condition specifies a velocity inlet profile + (fixed value), given the volumetric flow rate + flow direction n and direction of the parabolic coordinate y + +SourceFiles + controlledParabolicVelocityFvPatchVectorField.C + +Author + Wikki Ltd. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#ifndef controlledParabolicVelocityFvPatchVectorField_H +#define controlledParabolicVelocityFvPatchVectorField_H + +#include "fvPatchFields.H" +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class parabolicVelocityFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +class controlledParabolicVelocityFvPatchVectorField +: + public fixedValueFvPatchVectorField +{ + // Private data + + //- Volumetric flow rate + scalar Umean_; + + //- Flow direction + vector n_; + + //- 1D coordinate direction + vector y_; + + //- target value + scalar target_; + + //- field to observe + word obsFieldName_; + + //- patch ID to observe + word obsPatchName_; + + //- patch ID to observe + label obsPatchID_; + + //- proportionality factor + scalar gain_; + + //- Current time index + label curTimeIndex_; + + +public: + + //- Runtime type information + TypeName("controlledParabolicVelocity"); + + + // Constructors + + //- Construct from patch and internal field + controlledParabolicVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + controlledParabolicVelocityFvPatchVectorField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given controlledParabolicVelocityFvPatchVectorField + // onto a new patch + controlledParabolicVelocityFvPatchVectorField + ( + const controlledParabolicVelocityFvPatchVectorField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new controlledParabolicVelocityFvPatchVectorField(*this) + ); + } + + //- Construct as copy setting internal field reference + controlledParabolicVelocityFvPatchVectorField + ( + const controlledParabolicVelocityFvPatchVectorField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new controlledParabolicVelocityFvPatchVectorField(*this, iF) + ); + } + + + // Member functions + + //- Update coefficients + virtual void updateCoeffs(); + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/extendedWallHeatTransferFvPatchScalarField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/extendedWallHeatTransferFvPatchScalarField.C new file mode 100644 index 000000000..ee2cfa692 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/extendedWallHeatTransferFvPatchScalarField.C @@ -0,0 +1,235 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "extendedWallHeatTransferFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "radiationConstants.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::extendedWallHeatTransferFvPatchScalarField::extendedWallHeatTransferFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + Tinf_(0.0), + hc_(0.0), + alpha_(0.0), + KName_("undefined-K"), + radiation_(false) +{} + + +Foam::extendedWallHeatTransferFvPatchScalarField::extendedWallHeatTransferFvPatchScalarField +( + const extendedWallHeatTransferFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(p, iF), + Tinf_(ptf.Tinf_), + hc_(ptf.hc_), + alpha_(ptf.alpha_), + radSources_(ptf.radSources_), + KName_(ptf.KName_), + radiation_(ptf.radiation_) +{} + + +Foam::extendedWallHeatTransferFvPatchScalarField::extendedWallHeatTransferFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + Tinf_(readScalar(dict.lookup("Tinf"))), + hc_(readScalar(dict.lookup("hc"))), + alpha_(readScalar(dict.lookup("alpha"))), + KName_(dict.lookup("K")), + radiation_(readBool(dict.lookup("radiation"))) +{ + refValue() = Tinf_; + refGrad() = 0.0; + valueFraction() = 0.0; + + // Construct radiation sources + PtrList entries(dict.lookup("radiationSources")); + radSources_.setSize(entries.size()); + + forAll(entries, entryI) + { + radSources_.set + ( + entryI, + externalRadiationSource::New + ( + entries[entryI].keyword(), + entries[entryI].dict(), + p + ) + ); + } + + fvPatchField::operator= + ( + scalarField("value", dict, p.size()) + ); +} + + +Foam::extendedWallHeatTransferFvPatchScalarField::extendedWallHeatTransferFvPatchScalarField +( + const extendedWallHeatTransferFvPatchScalarField& tppsf +) +: + mixedFvPatchScalarField(tppsf), + Tinf_(tppsf.Tinf_), + hc_(tppsf.hc_), + alpha_(tppsf.alpha_), + radSources_(tppsf.radSources_), + KName_(tppsf.KName_), + radiation_(tppsf.radiation_) +{} + + +Foam::extendedWallHeatTransferFvPatchScalarField::extendedWallHeatTransferFvPatchScalarField +( + const extendedWallHeatTransferFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(tppsf, iF), + Tinf_(tppsf.Tinf_), + hc_(tppsf.hc_), + alpha_(tppsf.alpha_), + radSources_(tppsf.radSources_), + KName_(tppsf.KName_), + radiation_(tppsf.radiation_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::extendedWallHeatTransferFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvPatch& p = patch(); + + scalarField Tc = patchInternalField(); + const scalarField& Tb = *this; + + const scalarField& kappaEff = + p.lookupPatchField(KName_); + + scalarField term = kappaEff*patch().deltaCoeffs(); + + scalarField Qri(p.size(), 0); + if (radiation()) + { + Qri = p.lookupPatchField("Qr"); + } + + scalarField Qrio = 4.0*radiation::sigmaSB.value()*pow4(Tb); + + scalarField Two = Tb - (term*(patchInternalField() - Tb) + Qri)/hc_; + + scalarField Qro(p.size(), 0.0); + forAll(radSources_, rsI) + { + Qro += radSources_[rsI].q(Two); + } + + scalarField term2 = Tb*hc_*alpha_ + hc_*Qrio + alpha_*Qrio; + + //Info << "Tc = " << Tc << endl; + //Info << "Tb = "<< (scalarField) *this << endl; + //Info << "Two = "<< Two << endl; + //Info << "Qri = "<< Qri << endl; + //Info << "q = "<< q << endl; + + //Info << "q1 = " << hc_*(*this - Two) << endl; + //Info << "q2 = " << Qro + alpha_*(Two - Tinf_) << endl; + //Info << "q3 = "<< term*(Tc - *this) + Qri << endl; + + valueFraction() = 1.0 / (1.0 + Tb*term*(hc_ + alpha_)/term2); + refValue() = + Tb*(hc_*alpha_*Tinf_ - hc_*Qro + (hc_ + alpha_)*(Qri + Qrio))/term2; + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::extendedWallHeatTransferFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; + os.writeKeyword("radiation") << radiation_ << token::END_STATEMENT << nl; + os.writeKeyword("Tinf") << Tinf_ << token::END_STATEMENT << nl; + os.writeKeyword("hc") << hc_ << token::END_STATEMENT << nl; + os.writeKeyword("alpha") << alpha_ << token::END_STATEMENT << nl; + + os << nl << indent << "radiationSources" << nl + << indent << token::BEGIN_LIST << incrIndent << nl; + + forAll(radSources_, rsI) + { + os << indent << radSources_[rsI].name() << nl + << indent << token::BEGIN_BLOCK << nl << incrIndent; + radSources_[rsI].write(os); + os << decrIndent << indent << token::END_BLOCK << endl; + } + + os << decrIndent << indent + << token::END_LIST << token::END_STATEMENT << nl << nl; + + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + extendedWallHeatTransferFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/extendedWallHeatTransferFvPatchScalarField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/extendedWallHeatTransferFvPatchScalarField.H new file mode 100644 index 000000000..fdb828447 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/extendedWallHeatTransferFvPatchScalarField.H @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::extendedWallHeatTransferFvPatchScalarField + +Description + wall heat transfer boundary condition taking into account + + - heat resistance through a solid planar wall + + q = hc*(Tb - Two) + + - heat convection + + q = alpha*(Two - Tinf) + + - grey body radiation to infinite medium + + q = epsilon*sigma*(Two^4 - Tinf^4) + +SourceFiles + extendedWallHeatTransferFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef extendedWallHeatTransferFvPatchScalarField_H +#define extendedWallHeatTransferFvPatchScalarField_H + +#include "mixedFvPatchFields.H" +#include "externalRadiationSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class extendedWallHeatTransferFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Tinf [K] + scalar Tinf_; + + //- thermal conductance [W/m^2/K] + scalar hc_; + + //- heat transfer coefficient [W/m^2/K] + scalar alpha_; + + //- list of radiative sources + PtrList radSources_; + + //- Name of thermal conductivity field + word KName_; + + //- Take radiation into account for this patch + bool radiation_; + + +public: + + //- Runtime type information + TypeName("extendedWallHeatTransfer"); + + + // Constructors + + //- Construct from patch and internal field + extendedWallHeatTransferFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + extendedWallHeatTransferFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given extendedWallHeatTransferFvPatchScalarField + // onto a new patch + extendedWallHeatTransferFvPatchScalarField + ( + const extendedWallHeatTransferFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + extendedWallHeatTransferFvPatchScalarField + ( + const extendedWallHeatTransferFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new extendedWallHeatTransferFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + extendedWallHeatTransferFvPatchScalarField + ( + const extendedWallHeatTransferFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new extendedWallHeatTransferFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return radiation + bool radiation() const + { + return radiation_; + } + + // Mapping functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/viewFactorRadiation.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/viewFactorRadiation.C new file mode 100644 index 000000000..fc76e3554 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/viewFactorRadiation.C @@ -0,0 +1,66 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "viewFactorRadiation.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::viewFactorRadiation::viewFactorRadiation +( + const word& name, + const dictionary& dict, + const label size +) +: + name_(name), + Tinf_(readScalar(dict.lookup("Tinf"))), + F_("F", dict, size), + epsilon_(readScalar(dict.lookup("epsilon"))) +{} + + +void Foam::viewFactorRadiation::write(Ostream& os) const +{ + os << indent << name_ << nl + << indent << token::BEGIN_BLOCK << incrIndent << nl; + + os.writeKeyword("Tinf") << Tinf_ << token::END_STATEMENT << nl; + F_.writeEntry("F", os); + os.writeKeyword("epsilon") << epsilon_ << token::END_STATEMENT << nl; + + os << decrIndent << indent << token::END_BLOCK << endl; +} + + +Foam::Ostream& Foam::operator<<(Ostream& os, const viewFactorRadiation& r) +{ + r.write(os); + os.check("Ostream& operator<<(Ostream&, const viewFactorRadiation&)"); + return os; +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/viewFactorRadiation.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/viewFactorRadiation.H new file mode 100644 index 000000000..11d32b42e --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/extendedWallHeatTransfer/viewFactorRadiation.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::viewFactorRadiation + +Description + helper class to sum up external radiation sources + + +SourceFiles + viewFactorRadiation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef viewFactorRadiation_H +#define viewFactorRadiation_H + +#include "scalarField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators +class viewFactorRadiation; +Ostream& operator<<(Ostream&, const viewFactorRadiation&); + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class viewFactorRadiation +{ + // Private data + + //- name + word name_; + + //- Tinf [K] + scalar Tinf_; + + //- view factor [-] + scalarField F_; + + //- emissivity [-] + scalar epsilon_; + + +public: + + // Selectors + + //- Return a reference to the selected thermal model + static autoPtr New + ( + const word& name, + const dictionary& dict, + const label size + ) + { + return autoPtr + ( + new viewFactorRadiation(name, dict, size) + ); + }; + + // Constructors + + //- Construct from components + explicit viewFactorRadiation + ( + const word& name, + const dictionary& dict, + const label size + ); + + + //- Construct and return a clone + Foam::autoPtr clone() const + { + return autoPtr + ( + new viewFactorRadiation(*this) + ); + } + + + // Member functions + + // Access + + // Mapping functions + + // Evaluation functions + + //- Return Tinf + scalar Tinf() const + { + return Tinf_; + }; + + //- Return F + const scalarField& F() const + { + return F_; + }; + + //- Return epsilon + scalar epsilon() const + { + return epsilon_; + }; + + + //- Write + void write(Ostream&) const; + + // IOstream operators + + friend Ostream& operator<<(Ostream&, const viewFactorRadiation&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersConstantFlux/ersConstantFlux.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersConstantFlux/ersConstantFlux.C new file mode 100644 index 000000000..a9571bd18 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersConstantFlux/ersConstantFlux.C @@ -0,0 +1,72 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "ersConstantFlux.H" +#include "addToRunTimeSelectionTable.H" + +namespace Foam +{ + +defineTypeNameAndDebug(ersConstantFlux, 0); +addToRunTimeSelectionTable(externalRadiationSource, ersConstantFlux, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +ersConstantFlux::ersConstantFlux +( + const word& name, + const dictionary& dict, + const fvPatch& p +) +: + externalRadiationSource(name), + q_("q", dict, p.size()) +{} + +ersConstantFlux::ersConstantFlux +( + const word& name +) +: + externalRadiationSource(name) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void ersConstantFlux::write(Ostream& os) const +{ + externalRadiationSource::write(os); + + q_.writeEntry("q", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersConstantFlux/ersConstantFlux.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersConstantFlux/ersConstantFlux.H new file mode 100644 index 000000000..edc7c7da4 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersConstantFlux/ersConstantFlux.H @@ -0,0 +1,136 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::ersConstantFlux + +Description + helper class to sum up external radiation sources + + +SourceFiles + ersConstantFlux.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ersConstantFlux_H +#define ersConstantFlux_H + +#include "externalRadiationSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class ersConstantFlux +: + public externalRadiationSource +{ + // Private data + + //- heat flux + scalarField q_; + + +public: + + //- Runtime type information + TypeName("constantFlux"); + + + // Constructors + + //- Construct from components + explicit ersConstantFlux + ( + const word& name, + const dictionary& dict, + const fvPatch& p + ); + + explicit ersConstantFlux + ( + const word& name + ); + + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new ersConstantFlux(*this) + ); + } + + // Destructor + + virtual ~ersConstantFlux() + {}; + + + // Member functions + + // Access + + const scalarField& q() const + { + return q_; + }; + + scalarField& q() + { + return q_; + }; + + + // Mapping functions + + // Evaluation functions + + //- Return heat flux + virtual tmp q(const scalarField&) const + { + return q_; + } + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPlaneToCylinder/ersPlaneToCylinder.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPlaneToCylinder/ersPlaneToCylinder.C new file mode 100644 index 000000000..b795291e1 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPlaneToCylinder/ersPlaneToCylinder.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "ersPlaneToCylinder.H" +#include "addToRunTimeSelectionTable.H" + +namespace Foam +{ + +defineTypeNameAndDebug(ersPlaneToCylinder, 0); +addToRunTimeSelectionTable(externalRadiationSource, ersPlaneToCylinder, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +ersPlaneToCylinder::ersPlaneToCylinder +( + const word& name, + const dictionary& dict, + const fvPatch& p +) +: + ersViewFactor(name, dict), + direction_(dict.lookup("direction")) +{ + scalarField cosBeta = (direction_ & p.Sf()/p.magSf()); + + F() = 0.5 - 0.5*cosBeta; +} + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void ersPlaneToCylinder::write(Ostream& os) const +{ + ersViewFactor::write(os); + os.writeKeyword("direction") << direction_ << token::END_STATEMENT << nl; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPlaneToCylinder/ersPlaneToCylinder.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPlaneToCylinder/ersPlaneToCylinder.H new file mode 100644 index 000000000..146d9feef --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPlaneToCylinder/ersPlaneToCylinder.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::ersPlaneToCylinder + +Description + helper class to sum up external radiation sources + + +SourceFiles + ersPlaneToCylinder.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ersPlaneToCylinder_H +#define ersPlaneToCylinder_H + +#include "ersViewFactor.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class ersPlaneToCylinder +: + public ersViewFactor +{ + // Private data + + //- Direction of infinite plane + vector direction_; + + +public: + + //- Runtime type information + TypeName("planeToCylinder"); + + + // Constructors + + //- Construct from components + explicit ersPlaneToCylinder + ( + const word& name, + const dictionary& dict, + const fvPatch& p + ); + + + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new ersPlaneToCylinder(*this) + ); + } + + // Destructor + + virtual ~ersPlaneToCylinder() + {}; + + + // Member functions + + // Access + + // Mapping functions + + // Evaluation functions + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPointSource/ersPointSource.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPointSource/ersPointSource.C new file mode 100644 index 000000000..5290e14d0 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPointSource/ersPointSource.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "ersPointSource.H" +#include "addToRunTimeSelectionTable.H" + +namespace Foam +{ + +defineTypeNameAndDebug(ersPointSource, 0); +addToRunTimeSelectionTable(externalRadiationSource, ersPointSource, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +ersPointSource::ersPointSource +( + const word& name, + const dictionary& dict, + const fvPatch& p +) +: + ersConstantFlux(name), + qmax_(readScalar(dict.lookup("qmax"))), + alpha_(readScalar(dict.lookup("alpha"))), + direction_(dict.lookup("direction")) +{ + q() = -alpha_*qmax_*min(direction_ & p.Sf()/p.magSf(), 0.0); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void ersPointSource::write(Ostream& os) const +{ + ersConstantFlux::write(os); + os.writeKeyword("qmax") << qmax_ << token::END_STATEMENT << nl; + os.writeKeyword("alpha") << alpha_ << token::END_STATEMENT << nl; + os.writeKeyword("direction") << direction_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPointSource/ersPointSource.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPointSource/ersPointSource.H new file mode 100644 index 000000000..654e34880 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersPointSource/ersPointSource.H @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::ersPointSource + +Description + helper class to sum up external radiation sources + + +SourceFiles + ersPointSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ersPointSource_H +#define ersPointSource_H + +#include "ersConstantFlux.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class ersPointSource +: + public ersConstantFlux +{ + // Private data + + //- Strenght of the point source + scalar qmax_; + + //- radiation absorptivity + scalar alpha_; + + //- Direction of the ersPointSource + vector direction_; + +public: + + //- Runtime type information + TypeName("pointSource"); + + + // Constructors + + //- Construct from components + explicit ersPointSource + ( + const word& name, + const dictionary& dict, + const fvPatch& p + ); + + + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new ersPointSource(*this) + ); + } + + // Destructor + + virtual ~ersPointSource() + {}; + + + // Member functions + + // Access + + // Mapping functions + + // Evaluation functions + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersViewFactor/ersViewFactor.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersViewFactor/ersViewFactor.C new file mode 100644 index 000000000..66d4ef3b2 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersViewFactor/ersViewFactor.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "ersViewFactor.H" +#include "addToRunTimeSelectionTable.H" +#include "radiationConstants.H" + +namespace Foam +{ + +defineTypeNameAndDebug(ersViewFactor, 0); +addToRunTimeSelectionTable(externalRadiationSource, ersViewFactor, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +ersViewFactor::ersViewFactor +( + const word& name, + const dictionary& dict, + const fvPatch& p +) +: + externalRadiationSource(name), + Tinf_(readScalar(dict.lookup("Tinf"))), + F_("F", dict, p.size()), + epsilon_(readScalar(dict.lookup("epsilon"))) +{} + +ersViewFactor::ersViewFactor +( + const word& name, + const dictionary& dict +) +: + externalRadiationSource(name), + Tinf_(readScalar(dict.lookup("Tinf"))), + epsilon_(readScalar(dict.lookup("epsilon"))) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp ersViewFactor::q +( + const scalarField& Tw +) const +{ + return epsilon_*F_*radiation::sigmaSB.value()*(pow4(Tw) - pow4(Tinf_)); +} + + +void ersViewFactor::write(Ostream& os) const +{ + externalRadiationSource::write(os); + + os.writeKeyword("Tinf") << Tinf_ << token::END_STATEMENT << nl; + F_.writeEntry("F", os); + os.writeKeyword("epsilon") << epsilon_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersViewFactor/ersViewFactor.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersViewFactor/ersViewFactor.H new file mode 100644 index 000000000..537492424 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/ersViewFactor/ersViewFactor.H @@ -0,0 +1,152 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::ersViewFactor + +Description + helper class to sum up external radiation sources + + +SourceFiles + ersViewFactor.C + +\*---------------------------------------------------------------------------*/ + +#ifndef ersViewFactor_H +#define ersViewFactor_H + +#include "externalRadiationSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class ersViewFactor +: + public externalRadiationSource +{ + // Private data + + //- temperature at infinity + scalar Tinf_; + + //- view factor + scalarField F_; + + //- espison + scalar epsilon_; + +public: + + //- Runtime type information + TypeName("viewFactor"); + + + // Constructors + + //- Construct from components + explicit ersViewFactor + ( + const word& name, + const dictionary& dict, + const fvPatch& p + ); + + + //- Construct from components + explicit ersViewFactor + ( + const word& name, + const dictionary& dict + ); + + + //- Construct and return a clone + virtual autoPtr clone() const + { + return autoPtr + ( + new ersViewFactor(*this) + ); + } + + // Destructor + + virtual ~ersViewFactor() + {}; + + + // Member functions + + // Access + + const scalarField& F() const + { + return F_; + }; + + scalarField& F() + { + return F_; + }; + + const scalar& epsilon() const + { + return epsilon_; + }; + + scalar& epsilson() + { + return epsilon_; + }; + + + // Mapping functions + + // Evaluation functions + + //- Return heat flux + virtual tmp q(const scalarField& Tw) const; + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/externalRadiationSource.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/externalRadiationSource.C new file mode 100644 index 000000000..7684aa2c7 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/externalRadiationSource.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "externalRadiationSource.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(externalRadiationSource, 0); +defineRunTimeSelectionTable(externalRadiationSource, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +externalRadiationSource::externalRadiationSource +( + const word& name +) +: + name_(name) +{ + Info << "externalRadiationSource::externalRadiationSource" << endl; +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void externalRadiationSource::write(Ostream& os) const +{ + os.writeKeyword("type") << type() << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/externalRadiationSource.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/externalRadiationSource.H new file mode 100644 index 000000000..7537b0a62 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/externalRadiationSource.H @@ -0,0 +1,158 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::externalRadiationSource + +Description + Virtual base class for external radiation sources + + +SourceFiles + externalRadiationSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef externalRadiationSource_H +#define externalRadiationSource_H + +#include "scalarField.H" +#include "tmp.H" +#include "fvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class externalRadiationSource +{ + // Private data + + //- name + word name_; + + +public: + + //- Runtime type information + TypeName("externalRadiationSource"); + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + externalRadiationSource, + dictionary, + ( + const word& name, + const dictionary& dict, + const fvPatch& p + ), + (name, dict, p) + ); + + + // Destructor + + virtual ~externalRadiationSource() + {}; + + // Selectors + + //- Return a reference to the selected thermal model + static autoPtr New + ( + const word& name, + const dictionary& dict, + const fvPatch& p + ); + + + //- Construct and return a clone + virtual autoPtr clone() const + { + notImplemented("autoPt clone() const"); + return autoPtr(NULL); + + return autoPtr + ( + new externalRadiationSource(*this) + ); + }; + + // Constructors + + //- Construct from components + explicit externalRadiationSource + ( + const word& name + ); + + + // Member functions + + // Access + + const word& name() const + { + return name_; + } + + // Mapping functions + + // Evaluation functions + + //- Return heat flux + virtual tmp q(const scalarField& Tw) const + { + notImplemented + ( + type() +"::q(const scalarField& Tw) const" + ); + + return tmp(NULL); + }; + + + //- Write + + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/newExternalRadiationSource.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/newExternalRadiationSource.C new file mode 100644 index 000000000..58f1adb2f --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/externalRadiation/externalRadiationSource/newExternalRadiationSource.C @@ -0,0 +1,74 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "externalRadiationSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +autoPtr externalRadiationSource::New +( + const word& name, + const dictionary& dict, + const fvPatch& p +) +{ + word ersTypeName = dict.lookup("type"); + + Info<< "Selecting external radiation source " << ersTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(ersTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "externalRadiationSource::New(\n" + " const word& name,\n" + " const dictionary& dict,\n" + " const fvPatch& p\n" + ")", + dict + ) << "Unknown externalRadiationSource type " + << ersTypeName << endl << endl + << "Valid externalRadiationSource are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + Info << "Here 2" << endl; + + return cstrIter()(name, dict, p); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/fieldStorage/fieldStorage.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/fieldStorage/fieldStorage.C new file mode 100644 index 000000000..787a58641 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/fieldStorage/fieldStorage.C @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved + +\*---------------------------------------------------------------------------*/ + +#include "fieldStorage.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +fieldStorage::fieldStorage() +: + storedField_(), + curTimeIndex_(-1) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +template +void fieldStorage::store() +{ + if (curTimeIndex_ != time_.timeIndex()) + { + storedField_ = *this; + curTimeIndex_ = time_.timeIndex(); + } +} + + +template +const Field& originalPatchField::store() const +{ + if (curTimeIndex_ == time_.timeIndex()) + { + return storedField_; + } + else + { + return *this; + } +}; + + +template +void originalPatchField::autoMap +( + const fvPatchFieldMapper& m +) +{ + storedField_::autoMap(m); +} + + +template +void clear() const +{ + originalPatchField_.setSize(0); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/fieldStorage/fieldStorage.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/fieldStorage/fieldStorage.H new file mode 100644 index 000000000..4843ee41f --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/fieldStorage/fieldStorage.H @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + fieldStorage + +Description + Region couple patch field + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved + +SourceFiles + fieldStorage.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fieldStorage_H +#define fieldStorage_H + +#include "coupledFvPatchField.H" +#include "fvPatchFieldMapper.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fieldStorage Declaration +\*---------------------------------------------------------------------------*/ + +template +class fieldStorage +{ + // Private data + + // Reference to time + const runTime& time_; + + //- original patch field + Field storedField_; + + //- Current time index used to store originalPatchField_ + label curTimeIndex_; + + +public: + + // Constructors + + //- Construct from patch and internal field + fieldStorage(); + + // Member functions + + //- Store field + void store(const Field&) const; + + //- Return stored field + const Field& originalPatchField() const; + + //- Map (and resize as needed) from self given a mapping object + void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + void rmap + ( + const fvPatchField&, + const labelList& + ); + + //- Clear storage + void clear() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "fieldStorage.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 000000000..610a1b9eb --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "solidWallHeatFluxTemperatureFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF), + q_(p.size(), 0.0), + KName_("undefined-K") +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const solidWallHeatFluxTemperatureFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper), + q_(ptf.q_, mapper), + KName_(ptf.KName_) +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict), + q_("q", dict, p.size()), + KName_(dict.lookup("K")) +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf +) +: + fixedValueFvPatchScalarField(tppsf), + q_(tppsf.q_), + KName_(tppsf.KName_) +{} + + +Foam::solidWallHeatFluxTemperatureFvPatchScalarField:: +solidWallHeatFluxTemperatureFvPatchScalarField +( + const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(tppsf, iF), + q_(tppsf.q_), + KName_(tppsf.KName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + fixedValueFvPatchScalarField::autoMap(m); + q_.autoMap(m); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + fixedValueFvPatchScalarField::rmap(ptf, addr); + + const solidWallHeatFluxTemperatureFvPatchScalarField& hfptf = + refCast(ptf); + + q_.rmap(hfptf.q_, addr); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const scalarField& Kw = + patch().lookupPatchField(KName_); + + const fvPatchScalarField& Tw = *this; + + operator==(q_/(patch().deltaCoeffs()*Kw) + Tw.patchInternalField()); + + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::write +( + Ostream& os +) const +{ + fixedValueFvPatchScalarField::write(os); + q_.writeEntry("q", os); + os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField + ( + fvPatchScalarField, + solidWallHeatFluxTemperatureFvPatchScalarField + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H new file mode 100644 index 000000000..31a27c4f1 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/fvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright held by original author + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + solidWallHeatFluxTemperatureFvPatchScalarField + +Description + Heat flux boundary condition for temperature on solid region + + Example usage: + myWallPatch + { + type solidWallHeatFluxTemperature; + K K; // Name of K field + q uniform 1000; // Heat flux / [W/m2] + value 300.0; // Initial temperature / [K] + } + + +SourceFiles + solidWallHeatFluxTemperatureFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solidWallHeatFluxTemperatureFvPatchScalarField_H +#define solidWallHeatFluxTemperatureFvPatchScalarField_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class solidWallHeatFluxTemperatureFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class solidWallHeatFluxTemperatureFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + // Private data + + //- Heat flux / [W/m2] + scalarField q_; + + //- Name of thermal conductivity field + word KName_; + + +public: + + //- Runtime type information + TypeName("solidWallHeatFluxTemperature"); + + + // Constructors + + //- Construct from patch and internal field + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // solidWallHeatFluxTemperatureFvPatchScalarField + // onto a new patch + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const solidWallHeatFluxTemperatureFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const solidWallHeatFluxTemperatureFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new solidWallHeatFluxTemperatureFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + solidWallHeatFluxTemperatureFvPatchScalarField + ( + const solidWallHeatFluxTemperatureFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new solidWallHeatFluxTemperatureFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + // I-O + + //- Write + void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantResistanceThermalGap/constantResistanceThermalGap.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantResistanceThermalGap/constantResistanceThermalGap.C new file mode 100644 index 000000000..984923577 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantResistanceThermalGap/constantResistanceThermalGap.C @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +\*---------------------------------------------------------------------------*/ + +#include "constantResistanceThermalGap.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(constantResistanceThermalGap, 0); + addToRunTimeSelectionTable(thermalGap, constantResistanceThermalGap, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from dictionary +Foam::constantResistanceThermalGap::constantResistanceThermalGap +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + thermalGap(name, T, dict), + R_(dict.lookup("R")), + zones_(dict.lookup("zones")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::constantResistanceThermalGap::~constantResistanceThermalGap() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::constantResistanceThermalGap::modifyResistance +( + surfaceScalarField& DT +) const +{ + forAll(zones_, zoneI) + { + const label zoneID = mesh().faceZones().findZoneID(zones_[zoneI]); + + if ( zoneID < 0 ) + { + FatalErrorIn + ( + "constantResistanceThermalGap::modifyResistance()\n" + ) << "Zone " << zones_[zoneI] + << " specified in gap " << name() + << " does not exist" + << abort(FatalError); + } + + const labelList& faces = mesh().faceZones()[zoneID]; + const surfaceScalarField& deltaCoeffs = mesh().deltaCoeffs(); + + forAll(faces, faceI) + { + DT[faces[faceI]] = 1.0/deltaCoeffs[faceI]/R_.value(); + } + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantResistanceThermalGap/constantResistanceThermalGap.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantResistanceThermalGap/constantResistanceThermalGap.H new file mode 100644 index 000000000..9bc667df6 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantResistanceThermalGap/constantResistanceThermalGap.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + constantResistanceThermalGap + +Description + Constant thermal properties + +Author + Henrik Rusche, Wikki GmbH, All rights reserved. + +SourceFiles + constantResistanceThermalGap.C + +\*---------------------------------------------------------------------------*/ + +#ifndef constantResistanceThermalGap_H +#define constantResistanceThermalGap_H + +#include "thermalGap.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class constantResistanceThermalGap Declaration +\*---------------------------------------------------------------------------*/ + +class constantResistanceThermalGap +: + public thermalGap +{ + // Private data + + //- thermal resistance of the gap + dimensionedScalar R_; + + //- list of face zones + const wordList zones_; + + // Private Member Functions + + //- Disallow default bitwise copy construct + constantResistanceThermalGap(const constantResistanceThermalGap&); + + //- Disallow default bitwise assignment + void operator=(const constantResistanceThermalGap&); + + +public: + + //- Runtime type information + TypeName("constantResistance"); + + // Static data members + + + // Constructors + + //- Construct from dictionary + constantResistanceThermalGap + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~constantResistanceThermalGap(); + + + // Member Functions + + //- Return density + virtual void modifyResistance(surfaceScalarField&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantThermalGap/constantThermalGap.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantThermalGap/constantThermalGap.C new file mode 100644 index 000000000..9d3a8dc3f --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantThermalGap/constantThermalGap.C @@ -0,0 +1,100 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +\*---------------------------------------------------------------------------*/ + +#include "constantThermalGap.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(constantThermalGap, 0); + addToRunTimeSelectionTable(thermalGap, constantThermalGap, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from dictionary +Foam::constantThermalGap::constantThermalGap +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + thermalGap(name, T, dict), + beta_(dict.lookup("beta")), + zones_(dict.lookup("zones")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::constantThermalGap::~constantThermalGap() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::constantThermalGap::modifyResistance(surfaceScalarField& DT) const +{ + forAll(zones_, zoneI) + { + const label zoneID = mesh().faceZones().findZoneID(zones_[zoneI]); + + if ( zoneID < 0 ) + { + FatalErrorIn + ( + "constantThermalGap::modifyResistance()\n" + ) << "Zone " << zones_[zoneI] + << " specified in gap " << name() + << " does not exist" + << abort(FatalError); + } + + const labelList& faces = mesh().faceZones()[zoneID]; + + forAll(faces, faceI) + { + label fI = faces[faceI]; + if(fI < mesh().nInternalFaces()) + { + DT[fI] = beta_.value(); + } + else + { + const label patchI = mesh().boundaryMesh().whichPatch(fI); + fI -= mesh().boundaryMesh()[patchI].start(); + DT.boundaryField()[patchI][fI] = beta_.value(); + } + } + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantThermalGap/constantThermalGap.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantThermalGap/constantThermalGap.H new file mode 100644 index 000000000..0ca45aa80 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/constantThermalGap/constantThermalGap.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + constantThermalGap + +Description + Constant thermal properties + +Author + Henrik Rusche, Wikki GmbH, All rights reserved. + +SourceFiles + constantThermalGap.C + +\*---------------------------------------------------------------------------*/ + +#ifndef constantThermalGap_H +#define constantThermalGap_H + +#include "thermalGap.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class constantThermalGap Declaration +\*---------------------------------------------------------------------------*/ + +class constantThermalGap +: + public thermalGap +{ + // Private data + + //- thermal resistance of the gap + dimensionedScalar beta_; + + //- list of face zones + const wordList zones_; + + // Private Member Functions + + //- Disallow default bitwise copy construct + constantThermalGap(const constantThermalGap&); + + //- Disallow default bitwise assignment + void operator=(const constantThermalGap&); + + +public: + + //- Runtime type information + TypeName("constant"); + + // Static data members + + + // Constructors + + //- Construct from dictionary + constantThermalGap + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~constantThermalGap(); + + + // Member Functions + + //- Return density + virtual void modifyResistance(surfaceScalarField&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/newThermalGap.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/newThermalGap.C new file mode 100644 index 000000000..a0d7a0bbe --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/newThermalGap.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalGap + +\*---------------------------------------------------------------------------*/ + +#include "thermalGap.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +autoPtr thermalGap::New +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +{ + word tgTypeName = dict.lookup("type"); + + Info<< "Selecting thermal gap model " << tgTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(tgTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "thermalGap::New(\n" + " const word& name,\n" + " const volScalarField& T,\n" + " const dictionary& dict\n" + ")", + dict + ) << "Unknown thermalGap type " + << tgTypeName << endl << endl + << "Valid thermalGaps are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr(cstrIter()(name, T, dict)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/thermalGap.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/thermalGap.C new file mode 100644 index 000000000..975e7c73f --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/thermalGap.C @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalGap + +\*---------------------------------------------------------------------------*/ + +#include "thermalGap.H" +#include "volFields.H" +#include "fvc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(thermalGap, 0); +defineRunTimeSelectionTable(thermalGap, dictionary); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermalGap::thermalGap +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + name_(name), + T_(T) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/thermalGap.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/thermalGap.H new file mode 100644 index 000000000..efb69af77 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalGaps/thermalGap/thermalGap.H @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalGap + +Description + Thermal properties of a gap. + +Author + Henrik Rusche, Wikki GmbH, All rights reserved. + +SourceFiles + thermalGap.C + newThermalLaw.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalGap_H +#define thermalGap_H + +#include "IOdictionary.H" +#include "typeInfo.H" +#include "runTimeSelectionTables.H" +#include "volFields.H" +#include "tmp.H" +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class thermalGap Declaration +\*---------------------------------------------------------------------------*/ + +class thermalGap +{ + // Private data + + //- Name + const word name_; + + //- Reference to temperature field + const volScalarField& T_; + + + // Private Member Functions + + //- Disallow copy construct + thermalGap(const thermalGap&); + + //- Disallow default bitwise assignment + void operator=(const thermalGap&); + + +protected: + + //- Return reference to mesh + const fvMesh& mesh() const + { + return T_.mesh(); + } + +public: + + //- Runtime type information + TypeName("thermalGap"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + thermalGap, + dictionary, + ( + const word name, + const volScalarField& T, + const dictionary& dict + ), + (name, T, dict) + ); + + + // Selectors + + //- Return a reference to the selected thermal model + static autoPtr New + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Constructors + + //- Construct from dictionary + thermalGap + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~thermalGap() + {} + + + // Member Functions + + //- Return name + const word& name() const + { + return name_; + } + + //- Return temperture + const volScalarField& T() const + { + return T_; + }; + + //- Modify the resistance + virtual void modifyResistance(surfaceScalarField&) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/constantThermal/constantThermal.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/constantThermal/constantThermal.C new file mode 100644 index 000000000..5349b94c5 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/constantThermal/constantThermal.C @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +\*---------------------------------------------------------------------------*/ + +#include "constantThermal.H" +#include "addToRunTimeSelectionTable.H" +#include "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(constantThermal, 0); + addToRunTimeSelectionTable(thermalLaw, constantThermal, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from dictionary +Foam::constantThermal::constantThermal +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + thermalLaw(name, T, dict), + rho_(dict.lookup("rho")), + C_(dict.lookup("C")), + k_(dict.lookup("k")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::constantThermal::~constantThermal() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp Foam::constantThermal::rho() const +{ + tmp tresult + ( + new volScalarField + ( + IOobject + ( + "rho", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + rho_, + zeroGradientFvPatchScalarField::typeName + ) + ); + + tresult().correctBoundaryConditions(); + + return tresult; +} + +Foam::tmp Foam::constantThermal::C() const +{ + tmp tresult + ( + new volScalarField + ( + IOobject + ( + "C", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + C_, + zeroGradientFvPatchScalarField::typeName + ) + ); + + tresult().correctBoundaryConditions(); + + return tresult; +} + + +Foam::tmp Foam::constantThermal::k() const +{ + tmp tresult + ( + new volScalarField + ( + IOobject + ( + "kTmp", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + k_, + zeroGradientFvPatchScalarField::typeName + ) + ); + + tresult().correctBoundaryConditions(); + + return tresult; +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/constantThermal/constantThermal.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/constantThermal/constantThermal.H new file mode 100644 index 000000000..c2a7ec8d5 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/constantThermal/constantThermal.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + constantThermal + +Description + Constant thermal properties + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved. + +SourceFiles + constantThermal.C + +\*---------------------------------------------------------------------------*/ + +#ifndef constantThermal_H +#define constantThermal_H + +#include "thermalLaw.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class constantThermal Declaration +\*---------------------------------------------------------------------------*/ + +class constantThermal +: + public thermalLaw +{ + // Private data + + //- Specific heat capacity + dimensionedScalar rho_; + + //- Specific heat capacity + dimensionedScalar C_; + + //- Thermal conductivity + dimensionedScalar k_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + constantThermal(const constantThermal&); + + //- Disallow default bitwise assignment + void operator=(const constantThermal&); + + +public: + + //- Runtime type information + TypeName("constant"); + + // Static data members + + + // Constructors + + //- Construct from dictionary + constantThermal + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~constantThermal(); + + + // Member Functions + + //- Return density + virtual tmp rho() const; + + //- Return specific heat capacity + virtual tmp C() const; + + //- Return thermal conductivity + virtual tmp k() const; + + virtual void correct() + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.C new file mode 100644 index 000000000..3822a8801 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.C @@ -0,0 +1,325 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +\*---------------------------------------------------------------------------*/ + +#include "multiMaterialThermal.H" +#include "addToRunTimeSelectionTable.H" +#include "zeroGradientFvPatchFields.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(multiMaterialThermal, 0); + addToRunTimeSelectionTable(thermalLaw, multiMaterialThermal, dictionary); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::tmp Foam::multiMaterialThermal::indicator +( + const label i +) const +{ + const scalarField& mat = materials_.internalField(); + + tmp tresult + ( + new volScalarField + ( + IOobject + ( + "indicator", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + dimless, + zeroGradientFvPatchScalarField::typeName + ) + ); + + volScalarField& result = tresult(); + + forAll (mat, matI) + { + if (mat[matI] > i - SMALL && mat[matI] < i + SMALL) + { + result[matI] = 1.0; + } + else + { + result[matI] = 0.0; + } + } + + result.correctBoundaryConditions(); + + return tresult; +} + + +void Foam::multiMaterialThermal::readLaws +( + const volScalarField& T, + const dictionary& dict +) +{ + PtrList& laws = *this; + + PtrList lawEntries(dict.lookup("laws")); + laws.setSize(lawEntries.size()); + + forAll (laws, lawI) + { + laws.set + ( + lawI, + thermalLaw::New + ( + lawEntries[lawI].keyword(), + T, + lawEntries[lawI].dict() + ) + ); + } +} + +void Foam::multiMaterialThermal::checkLaws() const +{ + const PtrList& laws = *this; + + if + ( + max(materials_).value() > laws.size() + SMALL + ) + { + FatalErrorIn + ( + "multiMaterialThermal::checkLaws()\n" + ) << "Invalid definition of material indicator field. " + << "Number of materials: " << laws.size() + << " max index: " << max(materials_) + << ". Should be " << laws.size() - 1 + << abort(FatalError); + } + + if + ( + min(materials_).value() < 0 + ) + { + FatalErrorIn + ( + "multiMaterialThermal::checkLaws()\n" + ) << "Invalid definition of material indicator field. " + << "Number of materials: " << laws.size() + << " min index: " << min(materials_) + << ". Should be 0" + << abort(FatalError); + } +} + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from dictionary +Foam::multiMaterialThermal::multiMaterialThermal +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + thermalLaw(name, T, dict), + PtrList(), + materials_ + ( + IOobject + ( + "materials", + mesh().time().timeName(), + mesh(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh() + ) +{ + readLaws(T, dict); + checkLaws(); +} + +// Construct from dictionary and create default material field +Foam::multiMaterialThermal::multiMaterialThermal +( + const word& name, + const volScalarField& T, + const dictionary& dict, + const scalar defaultMaterial +) +: + thermalLaw(name, T, dict), + PtrList(), + materials_ + ( + IOobject + ( + "materials", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh(), + defaultMaterial, + zeroGradientFvPatchScalarField::typeName + ) +{ + readLaws(T, dict); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + + +Foam::multiMaterialThermal::~multiMaterialThermal() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp Foam::multiMaterialThermal::rho() const +{ + tmp tresult + ( + new volScalarField + ( + IOobject + ( + "rhoTmp", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + dimensionedScalar("zeroRho", dimDensity, 0), + calculatedFvPatchScalarField::typeName + ) + ); + volScalarField& result = tresult(); + + // Accumulate data for all fields + const PtrList& laws = *this; + + forAll (laws, lawI) + { + result += indicator(lawI)*laws[lawI].rho()(); + } + + return tresult; +} + +Foam::tmp Foam::multiMaterialThermal::C() const +{ + tmp tresult + ( + new volScalarField + ( + IOobject + ( + "CTmp", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + dimensionedScalar("zeroC", dimSpecificHeatCapacity, 0), + calculatedFvPatchScalarField::typeName + ) + ); + volScalarField& result = tresult(); + + // Accumulate data for all fields + const PtrList& laws = *this; + + forAll (laws, lawI) + { + result += indicator(lawI)*laws[lawI].C()(); + } + + return tresult; +} + + +Foam::tmp Foam::multiMaterialThermal::k() const +{ + tmp tresult + ( + new volScalarField + ( + IOobject + ( + "kTmp", + mesh().time().timeName(), + mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh(), + dimensionedScalar("zerok", dimensionSet(1, 1, -3, -1, 0), 0), + calculatedFvPatchScalarField::typeName + ) + ); + volScalarField& result = tresult(); + + // Accumulate data for all fields + const PtrList& laws = *this; + + forAll (laws, lawI) + { + result += indicator(lawI)*laws[lawI].k(); + } + + return tresult; +} + + +void Foam::multiMaterialThermal::correct() +{ + PtrList& laws = *this; + + forAll (laws, lawI) + { + laws[lawI].correct(); + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.H new file mode 100644 index 000000000..7e565552c --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialThermal/multiMaterialThermal.H @@ -0,0 +1,146 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + multiMaterialThermal + +Description + Zoned multi-material thermal model controlled by an indicator field. + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved. + +SourceFiles + multiMaterialThermal.C + +\*---------------------------------------------------------------------------*/ + +#ifndef multiMaterialThermal_H +#define multiMaterialThermal_H + +#include "thermalLaw.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class multiMaterialThermal Declaration +\*---------------------------------------------------------------------------*/ + +class multiMaterialThermal +: + public thermalLaw, + public PtrList +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + multiMaterialThermal(const multiMaterialThermal&); + + //- Disallow default bitwise assignment + void operator=(const multiMaterialThermal&); + + + //- Calculate indicator field given index + tmp indicator(const label index) const; + +protected: + + // Protected data + + //- Material indicator field + volScalarField materials_; + + // Protected member functions + + //- Check that the laws and the material field are okay + void readLaws + ( + const volScalarField& T, + const dictionary& dict + ); + + //- Check that the laws and the material field are okay + void checkLaws() const; + + +public: + + //- Runtime type information + TypeName("multiMaterial"); + + // Static data members + + + // Constructors + + //- Construct from dictionary + multiMaterialThermal + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + //- Construct from dictionary and create default material field + multiMaterialThermal + ( + const word& name, + const volScalarField& T, + const dictionary& dict, + const scalar defaultMaterial + ); + + // Destructor + + virtual ~multiMaterialThermal(); + + + // Member Functions + + //- Return density + virtual tmp rho() const; + + //- Return specific heat capacity + virtual tmp C() const; + + //- Return thermal conductivity + virtual tmp k() const; + + //- Correct the rheological model + virtual void correct(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.C new file mode 100644 index 000000000..c31255690 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.C @@ -0,0 +1,96 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +\*---------------------------------------------------------------------------*/ + +#include "multiMaterialZonesThermal.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(multiMaterialZonesThermal, 0); + addToRunTimeSelectionTable(thermalLaw, multiMaterialZonesThermal, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from dictionary +Foam::multiMaterialZonesThermal::multiMaterialZonesThermal +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + multiMaterialThermal(name, T, dict, -1) +{ + readLaws(T, dict); + + PtrList lawEntries(dict.lookup("laws")); + + PtrList& laws = *this; + forAll (laws, lawI) + { + wordList zones (lawEntries[lawI].dict().lookup("zones")); + + forAll(zones, zoneI) + { + const label zoneID = mesh().cellZones().findZoneID(zones[zoneI]); + + if ( zoneID < 0 ) + { + FatalErrorIn + ( + "multiMaterialZonesThermal::multiMaterialZonesThermal()\n" + ) << "Zone " << zones[zoneI] + << " specified in material " << lawEntries[lawI].keyword() + << " does not exist" + << abort(FatalError); + } + + const labelList& cells = mesh().cellZones()[zoneID]; + + forAll(cells, cellI) + { + materials_[cells[cellI]] = lawI; + } + } + } + + materials_.correctBoundaryConditions(); + materials_.write(); + + checkLaws(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::multiMaterialZonesThermal::~multiMaterialZonesThermal() +{} + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.H new file mode 100644 index 000000000..2ba403d6f --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/multiMaterialZonesThermal/multiMaterialZonesThermal.H @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + multiMaterialZonesThermal + +Description + Zoned multi-material thermal model constructed from zones + +Author + Henrik Rusche, Wikki GmbH, All rights reserved. + +SourceFiles + multiMaterialZonesThermal.C + +\*---------------------------------------------------------------------------*/ + +#ifndef multiMaterialZonesThermal_H +#define multiMaterialZonesThermal_H + +#include "multiMaterialThermal.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class multiMaterialZonesThermal Declaration +\*---------------------------------------------------------------------------*/ + +class multiMaterialZonesThermal +: + public multiMaterialThermal +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + multiMaterialZonesThermal(const multiMaterialZonesThermal&); + + //- Disallow default bitwise assignment + void operator=(const multiMaterialZonesThermal&); + +public: + + //- Runtime type information + TypeName("multiMaterialZones"); + + // Static data members + + + // Constructors + + //- Construct from dictionary + multiMaterialZonesThermal + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~multiMaterialZonesThermal(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/newThermalLaw.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/newThermalLaw.C new file mode 100644 index 000000000..3ed0c2fbb --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/newThermalLaw.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalLaw + +\*---------------------------------------------------------------------------*/ + +#include "thermalLaw.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +autoPtr thermalLaw::New +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +{ + word rheoTypeName = dict.lookup("type"); + + Info<< "Selecting thermal model " << rheoTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(rheoTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "thermalLaw::New(\n" + " const word& name,\n" + " const volScalarField& T,\n" + " const dictionary& dict\n" + ")", + dict + ) << "Unknown thermalLaw type " + << rheoTypeName << endl << endl + << "Valid thermalLaws are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr(cstrIter()(name, T, dict)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/thermalLaw.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/thermalLaw.C new file mode 100644 index 000000000..ac9e5f28c --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/thermalLaw.C @@ -0,0 +1,62 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalLaw + +\*---------------------------------------------------------------------------*/ + +#include "thermalLaw.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(thermalLaw, 0); +defineRunTimeSelectionTable(thermalLaw, dictionary); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermalLaw::thermalLaw +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + name_(name), + T_(T) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/thermalLaw.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/thermalLaw.H new file mode 100644 index 000000000..b952111a9 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalLaws/thermalLaw/thermalLaw.H @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalLaw + +Description + Thermal material properties for solids. + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved. + +SourceFiles + thermalLaw.C + newThermalLaw.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalLaw_H +#define thermalLaw_H + +#include "IOdictionary.H" +#include "typeInfo.H" +#include "runTimeSelectionTables.H" +#include "volFields.H" +#include "tmp.H" +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class thermalLaw Declaration +\*---------------------------------------------------------------------------*/ + +class thermalLaw +{ + // Private data + + //- Name + const word name_; + + //- Reference to temperature field + const volScalarField& T_; + + + // Private Member Functions + + //- Disallow copy construct + thermalLaw(const thermalLaw&); + + //- Disallow default bitwise assignment + void operator=(const thermalLaw&); + + +protected: + + //- Return reference to mesh + const fvMesh& mesh() const + { + return T_.mesh(); + } + +public: + + //- Runtime type information + TypeName("thermalLaw"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + thermalLaw, + dictionary, + ( + const word name, + const volScalarField& T, + const dictionary& dict + ), + (name, T, dict) + ); + + + // Selectors + + //- Return a reference to the selected thermal model + static autoPtr New + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Constructors + + //- Construct from dictionary + thermalLaw + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~thermalLaw() + {} + + + // Member Functions + + //- Return name + const word& name() const + { + return name_; + } + + //- Return temperture + const volScalarField& T() const + { + return T_; + }; + + //- Return specific density + virtual tmp rho() const = 0; + + //- Return specific heat capacity + virtual tmp C() const = 0; + + //- Return thermal conductivity + virtual tmp k() const = 0; + + //- Correct the thermal model + virtual void correct() = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalModel.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalModel.C new file mode 100644 index 000000000..38f85b7fa --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalModel.C @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalModel + +Description + Thermal material properties for solids. + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved. + +\*---------------------------------------------------------------------------*/ + +#include "thermalModel.H" +#include "volFields.H" +#include "fvc.H" +#include "fvm.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(thermalModel, 0); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermalModel::thermalModel(const volScalarField& T) +: + IOdictionary + ( + IOobject + ( + "thermalProperties", + T.time().constant(), + T.db(), + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + T_(T), + lawPtr_(thermalLaw::New("law", T_, subDict("thermal"))) +{ + { + PtrList entries(subDict("thermal").lookup("gaps")); + gapPtr_.setSize(entries.size()); + + forAll (gapPtr_, gapI) + { + gapPtr_.set + ( + gapI, + thermalGap::New + ( + entries[gapI].keyword(), + T, + entries[gapI].dict() + ) + ); + } + } + + { + PtrList entries(subDict("thermal").lookup("sources")); + sourcePtr_.setSize(entries.size()); + + forAll (sourcePtr_, sourceI) + { + sourcePtr_.set + ( + sourceI, + thermalSource::New + ( + entries[sourceI].keyword(), + T, + entries[sourceI].dict() + ) + ); + } + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void thermalModel::modifyResistance +( + surfaceScalarField& kf +) const +{ + forAll(gapPtr_, gapI) + { + gapPtr_[gapI].modifyResistance(kf); + } +} + +tmp thermalModel::laplacian(volScalarField& T) +{ + word kScheme ("laplacian(k,T)"); + + surfaceScalarField kf = fvc::interpolate(lawPtr_->k()); + + modifyResistance(kf); + + return tmp + ( + new fvScalarMatrix( fvm::laplacian(kf, T, kScheme) ) + ); +} + +tmp thermalModel::S() const +{ + tmp tsource + ( + new volScalarField + ( + IOobject + ( + "heatSource", + T_.time().timeName(), + T_.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + T_.mesh(), + dimensionedScalar + ( + "zero", + dimEnergy/dimTime/dimVolume, + scalar(0.0) + ) + ) + ); + + forAll(sourcePtr_, sourceI) + { + sourcePtr_[sourceI].addSource(tsource()); + } + + return tsource; +} + +bool thermalModel::read() +{ + if (regIOobject::read()) + { + lawPtr_ = thermalLaw::New("law", T_, subDict("thermal")); + + return true; + } + else + { + return false; + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalModel.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalModel.H new file mode 100644 index 000000000..422b2d86c --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalModel.H @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-2011 Hrvoje Jasak + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalModel + +Description + Thermal material properties for solids. + +Author + Hrvoje Jasak, Wikki Ltd. All rights reserved. + +SourceFiles + thermalModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalModel_H +#define thermalModel_H + +#include "IOdictionary.H" +#include "typeInfo.H" +#include "runTimeSelectionTables.H" +#include "volFields.H" +#include "fvMatrices.H" +#include "tmp.H" +#include "thermalLaw.H" +#include "thermalGap.H" +#include "thermalSource.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class thermalModel Declaration +\*---------------------------------------------------------------------------*/ + +class thermalModel +: + public IOdictionary +{ + // Private data + + //- Reference to temperature field + const volScalarField& T_; + + //- Thermal law + autoPtr lawPtr_; + + //- Contact resistance + PtrList gapPtr_; + + //- Thermal Source + PtrList sourcePtr_; + + // Private Member Functions + + //- Disallow copy construct + thermalModel(const thermalModel&); + + //- Disallow default bitwise assignment + void operator=(const thermalModel&); + + +public: + + //- Runtime type information + TypeName("thermalModel"); + + // Constructors + + //- Construct from dictionary + thermalModel(const volScalarField& T); + + + // Destructor + + virtual ~thermalModel() + {} + + + // Member Functions + + //- Return thermal law + const thermalLaw& law() const + { + return lawPtr_(); + } + + //- Return density + tmp rho() const + { + return lawPtr_->rho(); + } + + //- Return specific heat capacity + tmp C() const + { + return lawPtr_->C(); + } + + //- Return thermal conductivity + tmp k() const + { + return lawPtr_->k(); + } + + //- Add resistance for gaps + void modifyResistance(surfaceScalarField&) const; + + //- Return the laplacian and incorporate resistance for gaps + tmp laplacian(volScalarField&); + + //- Return the aggregated source + tmp S() const; + + //- Correct the thermal model + void correct() + { + lawPtr_->correct(); + } + + //- Read thermalProperties dictionary + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/constantThermalSource/constantThermalSource.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/constantThermalSource/constantThermalSource.C new file mode 100644 index 000000000..a2e6addc2 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/constantThermalSource/constantThermalSource.C @@ -0,0 +1,90 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +\*---------------------------------------------------------------------------*/ + +#include "constantThermalSource.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(constantThermalSource, 0); + addToRunTimeSelectionTable(thermalSource, constantThermalSource, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from dictionary +Foam::constantThermalSource::constantThermalSource +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + thermalSource(name, T, dict), + S_(dict.lookup("S")), + zones_(dict.lookup("zones")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::constantThermalSource::~constantThermalSource() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::constantThermalSource::addSource(volScalarField& source) const +{ + forAll(zones_, zoneI) + { + const label zoneID = mesh().cellZones().findZoneID(zones_[zoneI]); + + if ( zoneID < 0 ) + { + FatalErrorIn + ( + "constantThermalSource::addSourcex()\n" + ) << "Zone " << zones_[zoneI] + << " specified in source " << name() + << " does not exist" + << abort(FatalError); + } + + const labelList& cells = mesh().cellZones()[zoneID]; + + forAll(cells, cellI) + { + source[cells[cellI]] = S_.value(); + } + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/constantThermalSource/constantThermalSource.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/constantThermalSource/constantThermalSource.H new file mode 100644 index 000000000..202343182 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/constantThermalSource/constantThermalSource.H @@ -0,0 +1,113 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + constantThermalSource + +Description + Constant thermal properties + +Author + Henrik Rusche, Wikki GmbH. All rights reserved. + +SourceFiles + constantThermalSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef constantThermalSource_H +#define constantThermalSource_H + +#include "thermalSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class constantThermalSource Declaration +\*---------------------------------------------------------------------------*/ + +class constantThermalSource +: + public thermalSource +{ + // Private data + + //- Strengh of the source + dimensionedScalar S_; + + //- list of cell zones + const wordList zones_; + + // Private Member Functions + + //- Disallow default bitwise copy construct + constantThermalSource(const constantThermalSource&); + + //- Disallow default bitwise assignment + void operator=(const constantThermalSource&); + + +public: + + //- Runtime type information + TypeName("constant"); + + // Static data members + + + // Constructors + + //- Construct from dictionary + constantThermalSource + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~constantThermalSource(); + + + // Member Functions + + //- Add source term + virtual void addSource(volScalarField& source) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/newThermalSource.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/newThermalSource.C new file mode 100644 index 000000000..94aa2b855 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/newThermalSource.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalSource + +\*---------------------------------------------------------------------------*/ + +#include "thermalSource.H" +#include "volFields.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +autoPtr thermalSource::New +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +{ + word rheoTypeName = dict.lookup("type"); + + Info<< "Selecting thermal model " << rheoTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(rheoTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "thermalSource::New(\n" + " const word& name,\n" + " const volScalarField& T,\n" + " const dictionary& dict\n" + ")", + dict + ) << "Unknown thermalSource type " + << rheoTypeName << endl << endl + << "Valid thermalSources are : " << endl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr(cstrIter()(name, T, dict)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/thermalSource.C b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/thermalSource.C new file mode 100644 index 000000000..47d0c8c41 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/thermalSource.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalSource + +\*---------------------------------------------------------------------------*/ + +#include "thermalSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(thermalSource, 0); +defineRunTimeSelectionTable(thermalSource, dictionary); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +thermalSource::thermalSource +( + const word& name, + const volScalarField& T, + const dictionary& dict +) +: + name_(name), + T_(T) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/thermalSource.H b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/thermalSource.H new file mode 100644 index 000000000..1abe9db91 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/conjugateHeatTransfer/thermalModel/thermalSource/thermalSource/thermalSource.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Rusche + \\/ 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 2 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, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + thermalSource + +Description + A thermal source. + +Author + Henrik Rusche, Wikki GmbH. All rights reserved. + +SourceFiles + thermalSource.C + newThermalSource.C + +\*---------------------------------------------------------------------------*/ + +#ifndef thermalSource_H +#define thermalSource_H + +#include "IOdictionary.H" +#include "typeInfo.H" +#include "runTimeSelectionTables.H" +#include "volFields.H" +#include "autoPtr.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class thermalSource Declaration +\*---------------------------------------------------------------------------*/ + +class thermalSource +{ + // Private data + + //- Name + const word name_; + + //- Reference to temperature field + const volScalarField& T_; + + + // Private Member Functions + + //- Disallow copy construct + thermalSource(const thermalSource&); + + //- Disallow default bitwise assignment + void operator=(const thermalSource&); + + +protected: + + //- Return reference to mesh + const fvMesh& mesh() const + { + return T_.mesh(); + } + +public: + + //- Runtime type information + TypeName("thermalSource"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + thermalSource, + dictionary, + ( + const word name, + const volScalarField& T, + const dictionary& dict + ), + (name, T, dict) + ); + + + // Selectors + + //- Return a reference to the selected thermal model + static autoPtr New + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Constructors + + //- Construct from dictionary + thermalSource + ( + const word& name, + const volScalarField& T, + const dictionary& dict + ); + + + // Destructor + + virtual ~thermalSource() + {} + + + // Member Functions + + //- Return name + const word& name() const + { + return name_; + } + + //- Add source term + virtual void addSource(volScalarField& source) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatFoam/createFields.H b/applications/solvers/coupled/conjugateHeatFoam/createFields.H index 83b8544b9..720ef6deb 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/createFields.H +++ b/applications/solvers/coupled/conjugateHeatFoam/createFields.H @@ -12,19 +12,16 @@ ) ); + Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); + surfaceScalarField ghf("ghf", g & mesh.Cf()); - dimensionedScalar nu - ( - transportProperties.lookup("nu") - ); - - - Info<< "Reading field p\n" << endl; - volScalarField p + Info<< "Reading field p_rgh\n" << endl; + volScalarField p_rgh ( IOobject ( - "p", + "p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -48,7 +45,6 @@ ); Info<< "Reading field T\n" << endl; - volScalarField T ( IOobject @@ -64,16 +60,31 @@ # include "createPhi.H" +# include "readTransportProperties.H" + label pRefCell = 0; scalar pRefValue = 0.0; - setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + setRefCell + ( + p_rgh, + mesh.solutionDict().subDict("PISO"), + pRefCell, + pRefValue + ); - Info<< "Reading field DT\n" << endl; - volScalarField DT + autoPtr turbulence + ( + incompressible::RASModel::New(U, phi, laminarTransport) + ); + +# include "attachPatches.H" + + Info<< "Reading field kappaEff\n" << endl; + volScalarField kappaEff ( IOobject ( - "DT", + "kappaEff", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -81,3 +92,21 @@ ), mesh ); + + // Kinematic density for buoyancy force + volScalarField rhok + ( + IOobject + ( + "rhok", + runTime.timeName(), + mesh + ), + 1.0 - beta*(T - TRef) + ); + + Info<< "Creating radiation model\n" << endl; + autoPtr radiation + ( + radiation::radiationModel::New(T) + ); diff --git a/applications/solvers/coupled/conjugateHeatFoam/createFluidMesh.H b/applications/solvers/coupled/conjugateHeatFoam/createFluidMesh.H index f0321c9c7..32edb8f54 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/createFluidMesh.H +++ b/applications/solvers/coupled/conjugateHeatFoam/createFluidMesh.H @@ -1,8 +1,6 @@ Info<< "Create mesh for time = " << runTime.timeName() << nl << endl; -Info << "f1" << endl; - fvMesh mesh ( IOobject @@ -13,6 +11,3 @@ Info << "f1" << endl; IOobject::MUST_READ ) ); - -Info << "f2" << endl; - diff --git a/applications/solvers/coupled/conjugateHeatFoam/createSolidFields.H b/applications/solvers/coupled/conjugateHeatFoam/createSolidFields.H index 84f06b5c2..aaa829c37 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/createSolidFields.H +++ b/applications/solvers/coupled/conjugateHeatFoam/createSolidFields.H @@ -12,13 +12,15 @@ solidMesh ); - Info<< "Reading solid diffusivity DT\n" << endl; + Info<< "Reading solid thermal properties" << endl; + thermalModel solidThermo(Tsolid); - volScalarField DTsolid + Info<< "Reading solid diffusivity k\n" << endl; + volScalarField ksolid ( IOobject ( - "DT", + "k", runTime.timeName(), solidMesh, IOobject::MUST_READ, @@ -27,6 +29,17 @@ solidMesh ); - // On creation of both diffusivities, couple the sides - DT.correctBoundaryConditions(); - DTsolid.correctBoundaryConditions(); + Info<< "Constructing rhoCp\n" << endl; + volScalarField rhoCpsolid + ( + IOobject + ( + "rhoCpsolid", + runTime.timeName(), + solidMesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + solidThermo.rho()*solidThermo.C() + ); + rhoCpsolid.oldTime(); diff --git a/applications/solvers/coupled/conjugateHeatFoam/createSolidMesh.H b/applications/solvers/coupled/conjugateHeatFoam/createSolidMesh.H index 2d23d07b5..94e9a4eea 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/createSolidMesh.H +++ b/applications/solvers/coupled/conjugateHeatFoam/createSolidMesh.H @@ -1,5 +1,3 @@ -Info << "s1" << endl; - fvMesh solidMesh ( IOobject @@ -11,5 +9,22 @@ Info << "s1" << endl; ) ); -Info << "s2" << endl; +{ + const polyPatchList& patches = solidMesh.boundaryMesh(); + + forAll (patches, patchI) + { + if (isType(patches[patchI])) + { + const regionCouplePolyPatch& rcp = + refCast(patches[patchI]); + + // Attach it here + rcp.attach(); + } + } + + // Force recalculation of weights + solidMesh.surfaceInterpolation::movePoints(); +} diff --git a/applications/solvers/coupled/conjugateHeatFoam/detachPatches.H b/applications/solvers/coupled/conjugateHeatFoam/detachPatches.H index 3171a5173..30e3ebe30 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/detachPatches.H +++ b/applications/solvers/coupled/conjugateHeatFoam/detachPatches.H @@ -14,5 +14,5 @@ } // Force recalculation of weights - mesh.surfaceInterpolation::movePoints(); + mesh.surfaceInterpolation::movePoints(); } diff --git a/applications/solvers/coupled/conjugateHeatFoam/initConvergenceCheck.H b/applications/solvers/coupled/conjugateHeatFoam/initConvergenceCheck.H new file mode 100644 index 000000000..b56197f22 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/initConvergenceCheck.H @@ -0,0 +1,7 @@ +// initialize values for convergence checks + + scalar eqnResidual = 1, maxResidual = 0; + scalar convergenceCriterion = 0; + + simple.readIfPresent("convergence", convergenceCriterion); + diff --git a/applications/solvers/coupled/conjugateHeatFoam/pEqn.H b/applications/solvers/coupled/conjugateHeatFoam/pEqn.H new file mode 100644 index 000000000..57e9a156d --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/pEqn.H @@ -0,0 +1,47 @@ +{ + volScalarField rUA("rUA", 1.0/UEqn.A()); + surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); + + U = rUA*UEqn.H(); + + phi = (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, U, phi); + + surfaceScalarField buoyancyPhi(rUAf*ghf*fvc::snGrad(rhok)*mesh.magSf()); + phi -= buoyancyPhi; + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix p_rghEqn + ( + fvm::laplacian(rUAf, p_rgh) == fvc::div(phi) + ); + + p_rghEqn.setReference(pRefCell, pRefValue); + + if (corr == nCorr-1 && nonOrth == nNonOrthCorr) + { + p_rghEqn.solve(mesh.solutionDict().solver(p_rgh.name() + "Final")); + } + else + { + p_rghEqn.solve(mesh.solutionDict().solver(p_rgh.name())); + } + + if (nonOrth == nNonOrthCorr) + { + // Calculate the conservative fluxes + phi -= p_rghEqn.flux(); + + // Explicitly relax pressure for momentum corrector + p_rgh.relax(); + + // Correct the momentum source with the pressure gradient flux + // calculated from the relaxed pressure + U -= rUA*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rUAf); + U.correctBoundaryConditions(); + } + } + + #include "continuityErrs.H" +} diff --git a/applications/solvers/coupled/conjugateHeatFoam/readTransportProperties.H b/applications/solvers/coupled/conjugateHeatFoam/readTransportProperties.H new file mode 100644 index 000000000..297641a43 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatFoam/readTransportProperties.H @@ -0,0 +1,19 @@ + singlePhaseTransportModel laminarTransport(U, phi); + + // Density [kg/m^3] + dimensionedScalar rho(laminarTransport.lookup("rho")); + + // Heat capacity [J/kgK] + dimensionedScalar Cp(laminarTransport.lookup("Cp")); + + // Thermal expansion coefficient [1/K] + dimensionedScalar beta(laminarTransport.lookup("beta")); + + // Reference temperature [K] + dimensionedScalar TRef(laminarTransport.lookup("TRef")); + + // Laminar Prandtl number + dimensionedScalar Pr(laminarTransport.lookup("Pr")); + + // Turbulent Prandtl number + dimensionedScalar Prt(laminarTransport.lookup("Prt")); diff --git a/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H b/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H index 7e83801a4..e7f3c809c 100644 --- a/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H +++ b/applications/solvers/coupled/conjugateHeatFoam/solveEnergy.H @@ -1,7 +1,4 @@ { - // Decoupled patches -# include "attachPatches.H" - // Solid side # include "readSolidControls.H" @@ -9,28 +6,40 @@ { coupledFvScalarMatrix TEqns(2); - // Add fluid equation - TEqns.set + fvScalarMatrix* TFluidEqn = new fvScalarMatrix ( - 0, - new fvScalarMatrix + rho*Cp* ( fvm::ddt(T) + fvm::div(phi, T) - - fvm::laplacian(DT, T) ) + - fvm::laplacian(kappaEff, T) + == + radiation->Ru() + - fvm::Sp(4.0*radiation->Rp()*pow3(T), T) + + 3.0*radiation->Rp()*pow4(T) ); - // Add solid equation - TEqns.set + //Done automatically in 1.6.1-ext + //TFluidEqn->boundaryManipulate(T.boundaryField()); + + fvScalarMatrix* TSolidEqn = new fvScalarMatrix ( - 1, - new fvScalarMatrix - ( - fvm::ddt(Tsolid) - fvm::laplacian(DTsolid, Tsolid) - ) + fvm::ddt(rhoCpsolid, Tsolid) + - fvm::laplacian(ksolidf, Tsolid, "laplacian(k,T)") + + fvm::SuSp(-solidThermo.S()/Tsolid, Tsolid) ); + //Done automatically in 1.6.1-ext + //TSolidEqn->boundaryManipulate(Tsolid.boundaryField()); + + + // Add fluid equation + TEqns.set(0, TFluidEqn); + + // Add solid equation + TEqns.set(1, TSolidEqn); + TEqns.solve(); } } diff --git a/applications/solvers/coupled/conjugateHeatFoam/solveFluid.H b/applications/solvers/coupled/conjugateHeatFoam/solveFluid.H deleted file mode 100644 index 5a8ffa1e1..000000000 --- a/applications/solvers/coupled/conjugateHeatFoam/solveFluid.H +++ /dev/null @@ -1,47 +0,0 @@ -{ - // Detach patches -# include "detachPatches.H" - -# include "readPISOControls.H" -# include "CourantNo.H" - - fvVectorMatrix UEqn - ( - fvm::ddt(U) - + fvm::div(phi, U) - - fvm::laplacian(nu, U) - ); - - solve(UEqn == -fvc::grad(p)); - - // --- PISO loop - - for (int corr = 0; corr < nCorr; corr++) - { - U = UEqn.H()/UEqn.A(); - U.correctBoundaryConditions(); - - phi = fvc::interpolate(U) & mesh.Sf(); - - for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) - { - fvScalarMatrix pEqn - ( - fvm::laplacian(1.0/UEqn.A(), p) == fvc::div(phi) - ); - - pEqn.setReference(pRefCell, pRefValue); - pEqn.solve(); - - if (nonOrth == nNonOrthCorr) - { - phi -= pEqn.flux(); - } - } - -# include "continuityErrs.H" - - U -= fvc::grad(p)/UEqn.A(); - U.correctBoundaryConditions(); - } -} diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/Make/files b/applications/solvers/coupled/conjugateHeatSimpleFoam/Make/files new file mode 100644 index 000000000..aabca7fed --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/Make/files @@ -0,0 +1,3 @@ +conjugateHeatSimpleFoam.C + +EXE = $(FOAM_APPBIN)/conjugateHeatSimpleFoam diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/Make/options b/applications/solvers/coupled/conjugateHeatSimpleFoam/Make/options new file mode 100644 index 000000000..9c1fa7a2f --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/Make/options @@ -0,0 +1,22 @@ +EXE_INC = \ + -I../conjugateHeatFoam/conjugateHeatTransfer/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/coupledMatrix/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude + +EXE_LIBS = \ + -lincompressibleTurbulenceModel \ + -lincompressibleRASModels \ + -lincompressibleTransportModels \ + -lcoupledLduMatrix \ + -lfiniteVolume \ + -lradiation \ + -lbasicThermophysicalModels \ + -lspecie \ + -lconjugateHeatTransfer diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/UEqn.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/UEqn.H new file mode 100644 index 000000000..59633497a --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/UEqn.H @@ -0,0 +1,27 @@ + // Solve the momentum equation + + tmp UEqn + ( + fvm::div(phi, U) + + turbulence->divDevReff(U) + + fvm::SuSp(-fvc::div(phi), U) + ); + + UEqn().relax(); + + eqnResidual = solve + ( + UEqn() + == + fvc::reconstruct + ( + ( + ( + - ghf*fvc::snGrad(rhok) + - fvc::snGrad(p_rgh) + )*mesh.magSf() + ) + ) + ).initialResidual(); + + maxResidual = max(eqnResidual, maxResidual); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/attachPatches.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/attachPatches.H new file mode 100644 index 000000000..3a2f62f06 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/attachPatches.H @@ -0,0 +1,18 @@ +{ + const polyPatchList& patches = mesh.boundaryMesh(); + + forAll (patches, patchI) + { + if (isType(patches[patchI])) + { + const regionCouplePolyPatch& rcp = + refCast(patches[patchI]); + + // Attach it here + rcp.attach(); + } + } + + // Force recalculation of weights + mesh.surfaceInterpolation::movePoints(); +} diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/conjugateHeatSimpleFoam.C b/applications/solvers/coupled/conjugateHeatSimpleFoam/conjugateHeatSimpleFoam.C new file mode 100644 index 000000000..7c07815c5 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/conjugateHeatSimpleFoam.C @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 H. Jasak & H. Rusche + \\/ M anipulation | All rights reserved +------------------------------------------------------------------------------- +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 2 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + conjugateHeatSimpleFoam + +Description + Steady-State solver for buoyancy-driven turbulent flow of incompressible + Newtonian fluids with conjugate heat transfer, complex heat conduction + and radiation + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "coupledFvMatrices.H" +#include "regionCouplePolyPatch.H" +#include "radiationModel.H" +#include "thermalModel.H" +#include "singlePhaseTransportModel.H" +#include "RASModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ +# include "setRootCase.H" +# include "createTime.H" +# include "createFluidMesh.H" +# include "createSolidMesh.H" +# include "readGravitationalAcceleration.H" +# include "createFields.H" +# include "createSolidFields.H" +# include "initContinuityErrs.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.loop()) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + +# include "readSIMPLEControls.H" +# include "initConvergenceCheck.H" + + // Detach patches +# include "detachPatches.H" + + p_rgh.storePrevIter(); + +# include "UEqn.H" +# include "pEqn.H" + + // Update turbulent quantities + turbulence->correct(); + + radiation->correct(); + + // Update thermal conductivity in the fluid + kappaEff = rho*Cp*(turbulence->nu()/Pr + turbulence->nut()/Prt); + + // Update thermal conductivity in the solid + solidThermo.correct(); + ksolid = solidThermo.k(); + + // Coupled patches +# include "attachPatches.H" + + kappaEff.correctBoundaryConditions(); + ksolid.correctBoundaryConditions(); + + // Interpolate to the faces and add thermal resistance + surfaceScalarField ksolidf = fvc::interpolate(ksolid); + solidThermo.modifyResistance(ksolidf); + +# include "solveEnergy.H" + + // Update density according to Boussinesq approximation + rhok = 1.0 - beta*(T - TRef); + + runTime.write(); + + Info<< "ExecutionTime = " + << runTime.elapsedCpuTime() + << " s\n\n" << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/createFields.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/createFields.H new file mode 100644 index 000000000..159d180cc --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/createFields.H @@ -0,0 +1,112 @@ + Info<< "Reading transportProperties\n" << endl; + + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + + Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); + surfaceScalarField ghf("ghf", g & mesh.Cf()); + + Info<< "Reading field p_rgh\n" << endl; + volScalarField p_rgh + ( + IOobject + ( + "p_rgh", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Reading field T\n" << endl; + volScalarField T + ( + IOobject + ( + "T", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "createPhi.H" + +# include "readTransportProperties.H" + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell + ( + p_rgh, + mesh.solutionDict().subDict("SIMPLE"), + pRefCell, + pRefValue + ); + + autoPtr turbulence + ( + incompressible::RASModel::New(U, phi, laminarTransport) + ); + +# include "attachPatches.H" + + Info<< "Reading field kappaEff\n" << endl; + volScalarField kappaEff + ( + IOobject + ( + "kappaEff", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + // Kinematic density for buoyancy force + volScalarField rhok + ( + IOobject + ( + "rhok", + runTime.timeName(), + mesh + ), + 1.0 - beta*(T - TRef) + ); + + Info<< "Creating radiation model\n" << endl; + autoPtr radiation + ( + radiation::radiationModel::New(T) + ); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/createFluidMesh.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/createFluidMesh.H new file mode 100644 index 000000000..32edb8f54 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/createFluidMesh.H @@ -0,0 +1,13 @@ + Info<< "Create mesh for time = " + << runTime.timeName() << nl << endl; + + fvMesh mesh + ( + IOobject + ( + fvMesh::defaultRegion, + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/createSolidFields.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/createSolidFields.H new file mode 100644 index 000000000..26e1cd843 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/createSolidFields.H @@ -0,0 +1,30 @@ + Info<< "Reading field Tsolid\n" << endl; + volScalarField Tsolid + ( + IOobject + ( + "T", + runTime.timeName(), + solidMesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidMesh + ); + + Info<< "Reading solid thermal properties" << endl; + thermalModel solidThermo(Tsolid); + + Info<< "Reading solid diffusivity k\n" << endl; + volScalarField ksolid + ( + IOobject + ( + "k", + runTime.timeName(), + solidMesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + solidMesh + ); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/createSolidMesh.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/createSolidMesh.H new file mode 100644 index 000000000..94e9a4eea --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/createSolidMesh.H @@ -0,0 +1,30 @@ + fvMesh solidMesh + ( + IOobject + ( + "solid", + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ); + +{ + const polyPatchList& patches = solidMesh.boundaryMesh(); + + forAll (patches, patchI) + { + if (isType(patches[patchI])) + { + const regionCouplePolyPatch& rcp = + refCast(patches[patchI]); + + // Attach it here + rcp.attach(); + } + } + + // Force recalculation of weights + solidMesh.surfaceInterpolation::movePoints(); +} + diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/detachPatches.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/detachPatches.H new file mode 100644 index 000000000..99ddc8e35 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/detachPatches.H @@ -0,0 +1,38 @@ +{ + const polyPatchList& patches = mesh.boundaryMesh(); + + forAll (patches, patchI) + { + if (isType(patches[patchI])) + { + const regionCouplePolyPatch& rcp = + refCast(patches[patchI]); + + // Detach it here + rcp.detach(); + } + } + + // Force recalculation of weights + mesh.surfaceInterpolation::movePoints(); +} +/* +{ + const polyPatchList& patches = solidMesh.boundaryMesh(); + + forAll (patches, patchI) + { + if (isType(patches[patchI])) + { + const regionCouplePolyPatch& rcp = + refCast(patches[patchI]); + + // Detach it here + rcp.detach(); + } + } + + // Force recalculation of weights + solidMesh.surfaceInterpolation::movePoints(); +} +*/ diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/initConvergenceCheck.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/initConvergenceCheck.H new file mode 100644 index 000000000..b56197f22 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/initConvergenceCheck.H @@ -0,0 +1,7 @@ +// initialize values for convergence checks + + scalar eqnResidual = 1, maxResidual = 0; + scalar convergenceCriterion = 0; + + simple.readIfPresent("convergence", convergenceCriterion); + diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/pEqn.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/pEqn.H new file mode 100644 index 000000000..559b052c6 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/pEqn.H @@ -0,0 +1,50 @@ +{ + volScalarField rUA("rUA", 1.0/UEqn().A()); + surfaceScalarField rUAf("(1|A(U))", fvc::interpolate(rUA)); + + U = rUA*UEqn().H(); + UEqn.clear(); + + phi = fvc::interpolate(U) & mesh.Sf(); + adjustPhi(phi, U, p_rgh); + + surfaceScalarField buoyancyPhi(rUAf*ghf*fvc::snGrad(rhok)*mesh.magSf()); + phi -= buoyancyPhi; + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix p_rghEqn + ( + fvm::laplacian(rUAf, p_rgh) == fvc::div(phi) + ); + + p_rghEqn.setReference(pRefCell, pRefValue); + + // retain the residual from the first iteration + if (nonOrth == 0) + { + eqnResidual = p_rghEqn.solve().initialResidual(); + maxResidual = max(eqnResidual, maxResidual); + } + else + { + p_rghEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + // Calculate the conservative fluxes + phi -= p_rghEqn.flux(); + + // Explicitly relax pressure for momentum corrector + p_rgh.relax(); + + // Correct the momentum source with the pressure gradient flux + // calculated from the relaxed pressure + U -= rUA*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rUAf); + U.correctBoundaryConditions(); + } + } + + #include "continuityErrs.H" +} diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/readSolidControls.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/readSolidControls.H new file mode 100644 index 000000000..c2b6f17f5 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/readSolidControls.H @@ -0,0 +1,7 @@ + const dictionary& simple = solidMesh.solutionDict().subDict("SIMPLE"); + + int nNonOrthCorr = 0; + if (simple.found("nNonOrthogonalCorrectors")) + { + nNonOrthCorr = readInt(simple.lookup("nNonOrthogonalCorrectors")); + } diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/readTransportProperties.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/readTransportProperties.H new file mode 100644 index 000000000..297641a43 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/readTransportProperties.H @@ -0,0 +1,19 @@ + singlePhaseTransportModel laminarTransport(U, phi); + + // Density [kg/m^3] + dimensionedScalar rho(laminarTransport.lookup("rho")); + + // Heat capacity [J/kgK] + dimensionedScalar Cp(laminarTransport.lookup("Cp")); + + // Thermal expansion coefficient [1/K] + dimensionedScalar beta(laminarTransport.lookup("beta")); + + // Reference temperature [K] + dimensionedScalar TRef(laminarTransport.lookup("TRef")); + + // Laminar Prandtl number + dimensionedScalar Pr(laminarTransport.lookup("Pr")); + + // Turbulent Prandtl number + dimensionedScalar Prt(laminarTransport.lookup("Prt")); diff --git a/applications/solvers/coupled/conjugateHeatSimpleFoam/solveEnergy.H b/applications/solvers/coupled/conjugateHeatSimpleFoam/solveEnergy.H new file mode 100644 index 000000000..a6549e8b5 --- /dev/null +++ b/applications/solvers/coupled/conjugateHeatSimpleFoam/solveEnergy.H @@ -0,0 +1,46 @@ +{ + // Solid side +# include "readSolidControls.H" + + for (int nonOrth = 0; nonOrth <= nNonOrthCorr; nonOrth++) + { + coupledFvScalarMatrix TEqns(2); + + fvScalarMatrix* TFluidEqn = new fvScalarMatrix + ( + rho*Cp* + ( + fvm::div(phi, T) + + fvm::SuSp(-fvc::div(phi), T) + ) + - fvm::laplacian(kappaEff, T) + == + radiation->Ru() + - fvm::Sp(4.0*radiation->Rp()*pow3(T), T) + + 3.0*radiation->Rp()*pow4(T) + ); + + //Called automatically in 1.6.1-ext + //TFluidEqn->boundaryManipulate(T.boundaryField()); + TFluidEqn->relax(); + + fvScalarMatrix* TSolidEqn = new fvScalarMatrix + ( + - fvm::laplacian(ksolidf, Tsolid, "laplacian(k,T)") + + fvm::SuSp(-solidThermo.S()/Tsolid, Tsolid) + ); + + //Called automatically in 1.6.1-ext + //TSolidEqn->boundaryManipulate(Tsolid.boundaryField()); + TSolidEqn->relax(); + + + // Add fluid equation + TEqns.set(0, TFluidEqn); + + // Add solid equation + TEqns.set(1, TSolidEqn); + + TEqns.solve(); + } +} diff --git a/applications/utilities/mesh/conversion/gmshToFoam/piece-extr-rec.msh.gz b/applications/utilities/mesh/conversion/gmshToFoam/piece-extr-rec.msh.gz index bebf32f5a..00240c2d4 100644 Binary files a/applications/utilities/mesh/conversion/gmshToFoam/piece-extr-rec.msh.gz and b/applications/utilities/mesh/conversion/gmshToFoam/piece-extr-rec.msh.gz differ diff --git a/applications/utilities/mesh/conversion/kivaToFoam/kiva3v-valves.pdf b/applications/utilities/mesh/conversion/kivaToFoam/kiva3v-valves.pdf index 0249c10e4..7a7f8bec5 100644 Binary files a/applications/utilities/mesh/conversion/kivaToFoam/kiva3v-valves.pdf and b/applications/utilities/mesh/conversion/kivaToFoam/kiva3v-valves.pdf differ diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio2009.zip b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio2009.zip index f78519fe5..cf5c035ce 100644 Binary files a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio2009.zip and b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecio2009.zip differ diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 618dfcabc..a98adceab 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -681,6 +681,8 @@ matrices/blockLduMatrix/BlockLduSmoothers/BlockLduSmoother/blockLduSmoothers.C matrices/blockLduMatrix/BlockLduSmoothers/BlockGaussSeidelSmoother/blockGaussSeidelSmoothers.C matrices/blockLduMatrix/BlockLduSmoothers/BlockILUSmoother/blockILUSmoothers.C +/* compile blockVectorNSolvers earlier to exploit parallelismn */ +matrices/blockLduMatrix/BlockLduSolvers/blockVectorNSolvers.C matrices/blockLduMatrix/BlockLduSolvers/BlockLduSolver/blockLduSolvers.C matrices/blockLduMatrix/BlockLduSolvers/BlockDiagonal/blockDiagonalSolvers.C matrices/blockLduMatrix/BlockLduSolvers/BlockGaussSeidel/blockGaussSeidelSolvers.C @@ -690,6 +692,4 @@ matrices/blockLduMatrix/BlockLduSolvers/BlockGMRES/blockGMRESSolvers.C matrices/blockLduMatrix/BlockLduSolvers/BlockAmgSolver/blockAmgSolvers.C matrices/blockLduMatrix/BlockLduSolvers/Segregated/segregatedSolvers.C -matrices/blockLduMatrix/BlockLduSolvers/blockVectorNSolvers.C - LIB = $(FOAM_LIBBIN)/libOpenFOAM diff --git a/src/OpenFOAM/interpolations/MixingPlaneInterpolation/MixingPlaneInterpolationAddressing.C b/src/OpenFOAM/interpolations/MixingPlaneInterpolation/MixingPlaneInterpolationAddressing.C index 76c25fad1..731650685 100644 --- a/src/OpenFOAM/interpolations/MixingPlaneInterpolation/MixingPlaneInterpolationAddressing.C +++ b/src/OpenFOAM/interpolations/MixingPlaneInterpolation/MixingPlaneInterpolationAddressing.C @@ -356,7 +356,7 @@ MixingPlaneInterpolation::calcTransforms() const InfoIn ( "MixingPlaneInterpolation" - "::calcTransforms()" + "::calcTransforms() const" ) << "slave face centre transformation check: " << "(should be zero!) mag = " << mag(transformedFaceCentre2 - slaveFaceCntr) << nl diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C index 2e49458d9..802fb64d0 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.C @@ -85,7 +85,7 @@ Foam::label Foam::cyclicPolyPatch::findMaxArea } -void Foam::cyclicPolyPatch::calcTransforms() +void Foam::cyclicPolyPatch::calcTransforms() const { if (size()) { @@ -243,7 +243,7 @@ void Foam::cyclicPolyPatch::calcTransforms() { SeriousErrorIn ( - "void cyclicPolyPatch::calcTransforms()" + "void cyclicPolyPatch::calcTransforms() const" ) << "Transformation tensor is not constant for the cyclic " << "patch " << name() << ". Please reconsider your setup and definition of " diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H index 8eafb7dd8..df1801f83 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/cyclic/cyclicPolyPatch.H @@ -125,7 +125,7 @@ private: static label findMaxArea(const pointField&, const faceList&); //- Force calculation of transformation tensors - virtual void calcTransforms(); + virtual void calcTransforms() const; // Face ordering diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C index 563549be8..10a116a76 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/ggi/ggiPolyPatchTemplates.C @@ -82,6 +82,15 @@ Foam::tmp > Foam::ggiPolyPatch::fastExpand << abort(FatalError); } + // HR, 10/Jul/2013 + // This function requires send-receive-addressing, but usage is not + // symmetric across processors. Hence trigger re-calculate at this point + if (Pstream::parRun() && !localParallel()) + { + receiveAddr(); + shadow().receiveAddr(); + } + // Expand the field to zone size tmp > texpandField ( diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.C index 17776ed56..b081bf73a 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.C @@ -904,7 +904,7 @@ void Foam::mixingPlanePolyPatch::updateMesh() } -void Foam::mixingPlanePolyPatch::calcTransforms() +void Foam::mixingPlanePolyPatch::calcTransforms() const { forwardT_.setSize(0); reverseT_.setSize(0); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.H index 1712f751d..bd9ea0942 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/mixingPlane/mixingPlanePolyPatch.H @@ -130,7 +130,7 @@ class mixingPlanePolyPatch void calcReconFaceCellCentres() const; //- Force calculation of transformation tensors - virtual void calcTransforms(); + virtual void calcTransforms() const; // Parallel communication optimisation, stored on master processor diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatch.H index a09989d1e..043d61dec 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatch.H @@ -131,7 +131,7 @@ class overlapGgiPolyPatch void calcReconFaceCellCentres() const; //- Force calculation of transformation tensors - void calcTransforms(); + void calcTransforms() const; //- Check definition: angles and offsets void checkDefinition() const; diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatchGeometry.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatchGeometry.C index 404313442..87d872d50 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatchGeometry.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/overlapGgi/overlapGgiPolyPatchGeometry.C @@ -414,7 +414,7 @@ void Foam::overlapGgiPolyPatch::updateMesh() } -void Foam::overlapGgiPolyPatch::calcTransforms() +void Foam::overlapGgiPolyPatch::calcTransforms() const { forwardT_.setSize(0); reverseT_.setSize(0); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C index e4b7904ae..d3156a4f5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.C @@ -318,13 +318,13 @@ void Foam::regionCouplePolyPatch::calcLocalParallel() const localParallelPtr_ = new bool(false); bool& emptyOrComplete = *localParallelPtr_; - // If running in serial, all GGIs are expanded to zone size. + // If running in parallel, all GGIs are expanded to zone size. // This happens on decomposition and reconstruction where // size and shadow size may be zero, but zone size may not // HJ, 1/Jun/2011 if (!Pstream::parRun()) { - emptyOrComplete = false; + emptyOrComplete = true; } else { @@ -346,7 +346,7 @@ void Foam::regionCouplePolyPatch::calcLocalParallel() const if (emptyOrComplete) { - Info<< "local parallel" << endl; + Info<< "local parallel" << endl; } else { @@ -468,9 +468,15 @@ Foam::regionCouplePolyPatch& Foam::regionCouplePolyPatch::shadow() } -void Foam::regionCouplePolyPatch::clearGeom() const +void Foam::regionCouplePolyPatch::clearDeltas() const { deleteDemandDrivenData(reconFaceCellCentresPtr_); +} + + +void Foam::regionCouplePolyPatch::clearGeom() const +{ + clearDeltas(); // Remote addressing and send-receive maps depend on the local // position. Therefore, it needs to be recalculated at mesh motion. @@ -480,16 +486,19 @@ void Foam::regionCouplePolyPatch::clearGeom() const deleteDemandDrivenData(receiveAddrPtr_); deleteDemandDrivenData(sendAddrPtr_); + + // localParallel depends on geometry - must be cleared! + // HR, 11/Jul/2013 + deleteDemandDrivenData(localParallelPtr_); } -void Foam::regionCouplePolyPatch::clearOut() +void Foam::regionCouplePolyPatch::clearOut() const { clearGeom(); deleteDemandDrivenData(zoneAddressingPtr_); deleteDemandDrivenData(patchToPatchPtr_); - deleteDemandDrivenData(localParallelPtr_); } @@ -800,7 +809,11 @@ void Foam::regionCouplePolyPatch::attach() const // Patch-to-patch interpolation does not need to be cleared, // only face/cell centres and interpolation factors // HJ, 6/Jun/2011 - clearGeom(); + //clearGeom() + + // Clear delta coefficients, but keep the rest. + // HR, 10/Jul/2013 + clearDeltas(); } } @@ -815,7 +828,11 @@ void Foam::regionCouplePolyPatch::detach() const // Patch-to-patch interpolation does not need to be cleared, // only face/cell centres and interpolation factors // HJ, 6/Jun/2011 - clearGeom(); + //clearGeom() + + // Clear delta coefficients, but keep the rest. + // HR, 10/Jul/2013 + clearDeltas(); } } @@ -1015,7 +1032,7 @@ void Foam::regionCouplePolyPatch::updateMesh() } -void Foam::regionCouplePolyPatch::calcTransforms() +void Foam::regionCouplePolyPatch::calcTransforms() const { // No transform or separation forwardT_.setSize(0); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H index 970295cd9..32eaa4bc5 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatch.H @@ -134,7 +134,7 @@ class regionCouplePolyPatch void calcReconFaceCellCentres() const; //- Force calculation of transformation tensors - virtual void calcTransforms(); + virtual void calcTransforms() const; // Parallel communication optimisation, stored on master processor @@ -155,11 +155,14 @@ class regionCouplePolyPatch // Memory management + //- Clear delta coefficients + void clearDeltas() const; + //- Clear geometry - void clearGeom() const; + void clearGeom() const; //- Clear out - void clearOut(); + void clearOut() const; protected: diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatchTemplates.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatchTemplates.C index 617af8cf0..0106df1e1 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatchTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/regionCouple/regionCouplePolyPatchTemplates.C @@ -51,7 +51,7 @@ Foam::tmp > Foam::regionCouplePolyPatch::fastExpand // Notes: // A) If the size of zone addressing is zero, data is not sent // B) Communicated data on each processor has the size of live faces - // C) Expanded data will be equal to actual data fronm other processors + // C) Expanded data will be equal to actual data from other processors // only for the faces marked in remote; for other faces, it will be // equal to zero // D) On processor zero, complete data is available @@ -81,6 +81,15 @@ Foam::tmp > Foam::regionCouplePolyPatch::fastExpand << abort(FatalError); } + // This function requires send-receive-addressing, but usage is not + // symmetric across processors. Hence trigger re-calculate at this point + // HR, 10/Jul/2013 + if (Pstream::parRun() && !localParallel()) + { + receiveAddr(); + shadow().receiveAddr(); + } + // Expand the field to zone size tmp > texpandField ( diff --git a/applications/utilities/surface/surfaceToPatch/uindirectPrimitivePatch.H b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H similarity index 100% rename from applications/utilities/surface/surfaceToPatch/uindirectPrimitivePatch.H rename to src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H diff --git a/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C b/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C index fbcbbcb8d..af2e349e8 100644 --- a/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C +++ b/src/coupledMatrix/coupledFvMatrices/coupledFvMatrix/coupledFvMatrix.C @@ -204,7 +204,7 @@ Foam::coupledFvMatrix::solve(const dictionary& solverControls) } } - // Correct boundart conditions + // Correct boundary conditions forAll (matrices, rowI) { fvMatrix& curMatrix = diff --git a/src/coupledMatrix/coupledFvMatrices/coupledFvScalarMatrix/coupledFvScalarMatrix.C b/src/coupledMatrix/coupledFvMatrices/coupledFvScalarMatrix/coupledFvScalarMatrix.C index 01796187a..28422cac4 100644 --- a/src/coupledMatrix/coupledFvMatrices/coupledFvScalarMatrix/coupledFvScalarMatrix.C +++ b/src/coupledMatrix/coupledFvMatrices/coupledFvScalarMatrix/coupledFvScalarMatrix.C @@ -70,7 +70,10 @@ coupledSolverPerformance coupledFvMatrix::solve static_cast(matrices[rowI]); saveDiag.set(rowI, new scalarField(curMatrix.diag())); - psi.set(rowI, new scalarField(curMatrix.psi())); + // HR 17/Feb/2013 + // Need to be able to compare references to support hacks such as in jumpCyclic + // psi.set(rowI, new scalarField(curMatrix.psi())); + psi.set(rowI, &curMatrix.psi()); source.set(rowI, new scalarField(curMatrix.source())); curMatrix.addBoundarySource(source[rowI], 0); @@ -111,16 +114,18 @@ coupledSolverPerformance coupledFvMatrix::solve solverPerf.print(); + // HR 17/Feb/2013 + // Not needed since reference is used // Update solution - forAll (matrices, rowI) - { - fvScalarMatrix& curMatrix = - static_cast(matrices[rowI]); + //forAll (matrices, rowI) + //{ + // fvScalarMatrix& curMatrix = + // static_cast(matrices[rowI]); + // + // curMatrix.psi().internalField() = psi[rowI]; + //} - curMatrix.psi().internalField() = psi[rowI]; - } - - // Correct boundart conditions + // Correct boundary conditions forAll (matrices, rowI) { fvScalarMatrix& curMatrix = @@ -129,6 +134,12 @@ coupledSolverPerformance coupledFvMatrix::solve curMatrix.psi().correctBoundaryConditions(); } + //HR 17.2.2013: Clear references to internal field without deleting the objects + forAll (matrices, rowI) + { + psi.set(rowI, NULL).ptr(); + } + return solverPerf; } diff --git a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C index 3bf149363..2c2733242 100644 --- a/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C +++ b/src/dynamicMesh/dynamicMesh/polyMeshModifiers/layerAdditionRemoval/setLayerPairing.C @@ -45,7 +45,7 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const // be cleared. HJ, 2/Oct/2002 // Algorithm for point collapse - // 1) Go through the master cell layer and for every face of + // Go through the master cell layer and for every face of // the face zone find the opposite face in the master cell. // Check the direction of the opposite face and adjust as // necessary. Check other faces to find an edge defining @@ -144,11 +144,11 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const // Point mapped from some other face. Check the label if (ptc[clp] != lidFace[pointI]) { - // HR 01.05.2011: // We may be dealing with a layer that is wrapped around // a cell. Check second point neighbours for common point. // This is most probably not a general solution for // arbitray polyhedra! + // HR, 1/May/2011 label curPoint = faces[mf[faceI]][pointI]; @@ -184,12 +184,12 @@ bool Foam::layerAdditionRemoval::setLayerPairing() const { nPointErrors++; // Pout<< "Topological error in cell layer pairing. " -// << "This mesh is either topologically incorrect " -// << "or the master face layer is not defined " -// << "consistently. Please check the " -// << "face zone flip map." << nl -// << "First index: " << ptc[clp] -// << " new index: " << lidFace[pointI] << endl; +// << "This mesh is either topologically incorrect " +// << "or the master afce layer is not defined " +// << "consistently. Please check the " +// << "face zone flip map." << nl +// << "First index: " << ptc[clp] +// << " new index: " << lidFace[pointI] << endl; } } } diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index c25566720..98d5caa68 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -1,6 +1,7 @@ fvMesh/fvMeshGeometry.C fvMesh/fvMesh.C +fvMesh/singleCellFvMesh/singleCellFvMesh.C fvMesh/fvMeshSubset/fvMeshSubset.C fvBoundaryMesh = fvMesh/fvBoundaryMesh diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.C index 1ee72e8bc..af0cfc2b2 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.C @@ -410,7 +410,6 @@ void regionCouplingFvPatchField::initInterfaceMatrixUpdate "regionCouplingFvPatchField::initInterfaceMatrixUpdate" ) << "init matrix update called in detached state" << abort(FatalError); - } } @@ -461,7 +460,6 @@ void regionCouplingFvPatchField::updateInterfaceMatrix "regionCouplingFvPatchField::updateInterfaceMatrix" ) << "Matrix update called in detached state" << abort(FatalError); - } } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.H index fb129265e..00bfd538d 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/regionCoupling/regionCouplingFvPatchField.H @@ -79,15 +79,21 @@ class regionCouplingFvPatchField protected: + //- Set remote field name + void setRemoteFieldName(const word& name) + { + remoteFieldName_ = name; + } + + //- Return non-const access to matrixUpdateBuffer + void setMatrixUpdateBuffer(const scalarField& field) const + { + matrixUpdateBuffer_ = field; + } + //- Return original patch field const Field& originalPatchField() const; - //- Return contents of a matrix update buffer - const scalarField& matrixUpdateBuffer() const - { - return matrixUpdateBuffer_; - } - public: @@ -161,6 +167,12 @@ public: return remoteFieldName_; } + //- Return contents of a matrix update buffer + const scalarField& matrixUpdateBuffer() const + { + return matrixUpdateBuffer_; + } + //- Return a named shadow patch field template const typename LookupField::PatchFieldType& @@ -171,7 +183,7 @@ public: const LookupType* = NULL ) const; - + //- Return a shadow patch const regionCoupleFvPatch& regionCouplePatch() const { return regionCouplePatch_; @@ -186,7 +198,7 @@ public: //- Return neighbour field given internal cell data virtual tmp > patchNeighbourField() const; - //- Return neighbour field given internal cell data + //- Return named neighbour field given internal cell data virtual tmp > patchNeighbourField ( const word& name diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.C b/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.C index ebb73d11b..7ca345904 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.C +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.C @@ -34,6 +34,24 @@ Author namespace Foam { +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template +const Foam::Field& regionCouplingFvsPatchField::originalPatchField() const +{ + if (curTimeIndex_ != this->db().time().timeIndex()) + { + // Store original field for symmetric evaluation + // Henrik Rusche, Aug/2011 + + originalPatchField_ = *this; + curTimeIndex_ = this->db().time().timeIndex(); + } + + return originalPatchField_; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template @@ -131,21 +149,37 @@ regionCouplingFvsPatchField::regionCouplingFvsPatchField // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Return neighbour field +// Return a named shadow patch field +template +template +const typename LookupField::PatchFieldType& +regionCouplingFvsPatchField::lookupShadowPatchField +( + const word& name, + const LookupField*, + const LookupType* +) const +{ + // Lookup neighbour field + const LookupField& shadowField = + regionCouplePatch_.shadowRegion(). + objectRegistry::lookupObject(name); + + return shadowField.boundaryField()[regionCouplePatch_.shadowIndex()]; +} + + +// Return shadow patch field template const regionCouplingFvsPatchField& regionCouplingFvsPatchField::shadowPatchField() const { // Lookup neighbour field - typedef GeometricField GeoField; - - const GeoField& coupleField = - regionCouplePatch_.shadowRegion(). - objectRegistry::lookupObject(remoteFieldName_); + typedef GeometricField GeoField; return refCast > ( - coupleField.boundaryField()[regionCouplePatch_.shadowIndex()] + lookupShadowPatchField(remoteFieldName_) ); } diff --git a/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.H b/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.H index ea329ae72..9c211d2cb 100644 --- a/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.H +++ b/src/finiteVolume/fields/fvsPatchFields/constraint/regionCoupling/regionCouplingFvsPatchField.H @@ -72,15 +72,31 @@ class regionCouplingFvsPatchField //- Matrix update buffer mutable scalarField matrixUpdateBuffer_; + //- Original patch field. Required for correct evaluation + // in harmonic averaging + mutable Field originalPatchField_; + + //- Current time index used to store originalPatchField_ + mutable label curTimeIndex_; + protected: - //- Return contents of a matrix update buffer - const scalarField& matrixUpdateBuffer() const + //- Set remote field name + void setRemoteFieldName(const word& name) { - return matrixUpdateBuffer_; + remoteFieldName_ = name; } + //- Return non-const access to matrixUpdateBuffer + void setMatrixUpdateBuffer(const scalarField& field) const + { + matrixUpdateBuffer_ = field; + } + + //- Return original patch field + const Field& originalPatchField() const; + public: @@ -146,7 +162,7 @@ public: // Member functions - // Evaluation functions + // Access functions //- Return remote field name const word& remoteFieldName() const @@ -154,10 +170,35 @@ public: return remoteFieldName_; } + //- Return contents of a matrix update buffer + const scalarField& matrixUpdateBuffer() const + { + return matrixUpdateBuffer_; + } + + //- Return a named shadow patch field + template + const typename LookupField::PatchFieldType& + lookupShadowPatchField + ( + const word& name, + const LookupField* = NULL, + const LookupType* = NULL + ) const; + + //- Return a shadow patch + const regionCoupleFvPatch& regionCouplePatch() const + { + return regionCouplePatch_; + } + //- Return shadow patch field const regionCouplingFvsPatchField& shadowPatchField() const; + // Evaluation functions + + //- Write virtual void write(Ostream&) const; diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index ec135b3ff..8c44fb1cd 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -519,35 +519,38 @@ void Foam::fvMatrix::setReference const bool forceReference ) { - if (celli >= 0 && (psi_.needReference() || forceReference)) + if ((forceReference || psi_.needReference()) && celli >= 0) { - // Bug fix: force reference only on master for parallel runs - // HJ, 12/Feb/2010 - if (Pstream::parRun()) - { - // Parallel run: - // - only set reference on master processor: one place is enough - // - make sure that cellI is not out of range - if (Pstream::master()) - { - label parCelli = celli; + // HR, 9/Jul/2013 + // Very early versions could produce memory violations if celli is read + // from dictionary, however, the proposed fix produced unpredictable + // results in parallel. Keeping in mind that topologically changing + // meshes will complicate the matter to level that cannot possibly be + // dealt with at this point, we will simply raise an error if celli + // is out of bound. - while (parCelli >= diag().size()) - { - // Out of range, pick a local cell - parCelli /= Pstream::nProcs(); - } + // In essence: The user of this function needs to make sure that celli + // is set only on one processor and that it is updated if the mesh + // changes. We should be doing better than this! Consider mesh object + // to hold reference cell and associated data. - source()[parCelli] += diag()[parCelli]*value; - diag()[parCelli] += diag()[parCelli]; - } - } - else + if (celli >= diag().size()) { - // Serial run, standard practice - source()[celli] += diag()[celli]*value; - diag()[celli] += diag()[celli]; + FatalErrorIn + ( + "fvMatrix::setReference" + "(" + "const label celli, " + "const Type& value, " + "const bool forceReference" + ")" + ) + << "celli out of bound" + << abort(FatalError); } + + source()[celli] += diag()[celli]*value; + diag()[celli] += diag()[celli]; } } diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C new file mode 100644 index 000000000..474ad9f00 --- /dev/null +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C @@ -0,0 +1,646 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 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 "singleCellFvMesh.H" +#include "syncTools.H" +#include "uindirectPrimitivePatch.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// Conversion is a two step process: +// - from original (fine) patch faces to agglomerations (aggloms might not +// be in correct patch order) +// - from agglomerations to coarse patch faces +void Foam::singleCellFvMesh::agglomerateMesh +( + const fvMesh& mesh, + const labelListList& agglom +) +{ + const polyBoundaryMesh& oldPatches = mesh.boundaryMesh(); + + // Check agglomeration within patch face range and continuous + labelList nAgglom(oldPatches.size(), 0); + + forAll(oldPatches, patchI) + { + const polyPatch& pp = oldPatches[patchI]; + if (pp.size() > 0) + { + nAgglom[patchI] = max(agglom[patchI])+1; + + forAll(pp, i) + { + if (agglom[patchI][i] < 0 || agglom[patchI][i] >= pp.size()) + { + FatalErrorIn + ( + "singleCellFvMesh::agglomerateMesh(..)" + ) << "agglomeration on patch " << patchI + << " is out of range 0.." << pp.size()-1 + << exit(FatalError); + } + } + } + } + + // Check agglomeration is sync + { + // Get neighbouring agglomeration + labelList nbrAgglom(mesh.nFaces()-mesh.nInternalFaces()); + forAll(oldPatches, patchI) + { + const polyPatch& pp = oldPatches[patchI]; + + if (pp.coupled()) + { + label offset = pp.start()-mesh.nInternalFaces(); + forAll(pp, i) + { + nbrAgglom[offset+i] = agglom[patchI][i]; + } + } + } + syncTools::swapBoundaryFaceList(mesh, nbrAgglom, false); + + + // Get correspondence between this agglomeration and remote one + Map