Merge branch 'master' of /home/noisy3/OpenFOAM/OpenFOAM-dev

This commit is contained in:
mattijs
2011-02-22 12:17:28 +00:00
137 changed files with 232259 additions and 690 deletions

View File

@ -1,3 +0,0 @@
buoyantSimpleFoam.C
EXE = $(FOAM_APPBIN)/buoyantSimpleFoam

View File

@ -1,13 +0,0 @@
EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude \
-I$(LIB_SRC)/finiteVolume/cfdTools \
-I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \
-lmeshTools \
-lbasicThermophysicalModels \
-lspecie \
-lcompressibleRASModels \
-lfiniteVolume

View File

@ -1,24 +0,0 @@
// Solve the Momentum equation
tmp<fvVectorMatrix> UEqn
(
fvm::div(phi, U)
+ turbulence->divDevRhoReff(U)
);
UEqn().relax();
solve
(
UEqn()
==
rho*g
- fvc::grad(p)
/*
fvc::reconstruct
(
fvc::interpolate(rho)*(g & mesh.Sf())
- fvc::snGrad(p)*mesh.magSf()
)
*/
);

View File

@ -1,69 +0,0 @@
Info<< "Reading thermophysical properties\n" << endl;
autoPtr<basicPsiThermo> pThermo
(
basicPsiThermo::New(mesh)
);
basicPsiThermo& thermo = pThermo();
volScalarField rho
(
IOobject
(
"rho",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
thermo.rho()
);
volScalarField& p = thermo.p();
volScalarField& h = thermo.h();
const volScalarField& psi = thermo.psi();
Info<< "Reading field U\n" << endl;
volVectorField U
(
IOobject
(
"U",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh
);
#include "compressibleCreatePhi.H"
Info<< "Creating turbulence model\n" << endl;
autoPtr<compressible::RASModel> turbulence
(
compressible::RASModel::New
(
rho,
U,
phi,
thermo
)
);
thermo.correct();
label pRefCell = 0;
scalar pRefValue = 0.0;
setRefCell
(
p,
mesh.solutionDict().subDict("SIMPLE"),
pRefCell,
pRefValue
);
dimensionedScalar initialMass = fvc::domainIntegrate(rho);

View File

@ -1,17 +0,0 @@
{
fvScalarMatrix hEqn
(
fvm::div(phi, h)
- fvm::Sp(fvc::div(phi), h)
- fvm::laplacian(turbulence->alphaEff(), h)
==
fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p))
- p*fvc::div(phi/fvc::interpolate(rho))
);
hEqn.relax();
hEqn.solve();
thermo.correct();
}

View File

@ -1,59 +0,0 @@
{
rho = thermo.rho();
volScalarField rAU(1.0/UEqn().A());
surfaceScalarField rhorAUf("(rho*(1|A(U)))", fvc::interpolate(rho*rAU));
U = rAU*UEqn().H();
UEqn.clear();
phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf());
bool closedVolume = adjustPhi(phi, U, p);
surfaceScalarField buoyancyPhi
(
rhorAUf*fvc::interpolate(rho)*(g & mesh.Sf())
);
phi += buoyancyPhi;
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
{
fvScalarMatrix pEqn
(
fvm::laplacian(rhorAUf, p) == fvc::div(phi)
);
pEqn.setReference(pRefCell, pRefValue);
pEqn.solve();
if (nonOrth == nNonOrthCorr)
{
// For closed-volume cases adjust the pressure and density levels
// to obey overall mass continuity
if (closedVolume)
{
p += (initialMass - fvc::domainIntegrate(psi*p))
/fvc::domainIntegrate(psi);
}
// Calculate the conservative fluxes
phi -= pEqn.flux();
// Explicitly relax pressure for momentum corrector
p.relax();
// Correct the momentum source with the pressure gradient flux
// calculated from the relaxed pressure
U += rAU*(rho*g - fvc::grad(p));
//U += rAU*fvc::reconstruct((buoyancyPhi - pEqn.flux())/rhorAUf);
U.correctBoundaryConditions();
}
}
#include "continuityErrs.H"
rho = thermo.rho();
rho.relax();
Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value()
<< endl;
}

View File

@ -2,6 +2,7 @@
cd ${0%/*} || exit 1 # run from this directory
set -x
wclean libso coupledDerivedFvPatchFields
wclean
wclean chtMultiRegionSimpleFoam

View File

@ -2,6 +2,7 @@
cd ${0%/*} || exit 1 # run from this directory
set -x
wmake libso coupledDerivedFvPatchFields
wmake
wmake chtMultiRegionSimpleFoam

View File

@ -1,5 +1,3 @@
derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C
fluid/compressibleCourantNo.C
solid/solidRegionDiffNo.C

View File

@ -7,7 +7,8 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude
EXE_LIBS = \
-lbasicThermophysicalModels \
@ -17,4 +18,6 @@ EXE_LIBS = \
-lcompressibleRASModels \
-lcompressibleLESModels \
-lmeshTools \
-lfiniteVolume
-lfiniteVolume \
-lradiationModels \
-lcoupledDerivedFvPatchFields

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,6 +38,7 @@ Description
#include "compressibleCourantNo.H"
#include "solidRegionDiffNo.H"
#include "basicSolidThermo.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,7 +1,5 @@
EXE_INC = \
/* -DFULLDEBUG -O0 -g */ \
-I.. \
-I../derivedFvPatchFields \
-Ifluid \
-Isolid \
-I$(LIB_SRC)/finiteVolume/lnInclude \
@ -9,6 +7,7 @@ EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude
@ -20,4 +19,6 @@ EXE_LIBS = \
-lspecie \
-lcompressibleTurbulenceModel \
-lcompressibleRASModels \
-lcompressibleLESModels
-lcompressibleLESModels \
-lradiationModels \
-lcoupledDerivedFvPatchFields

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -35,6 +35,7 @@ Description
#include "fixedGradientFvPatchFields.H"
#include "regionProperties.H"
#include "basicSolidThermo.H"
#include "radiationModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -9,6 +9,7 @@
PtrList<volScalarField> p_rghFluid(fluidRegions.size());
PtrList<volScalarField> ghFluid(fluidRegions.size());
PtrList<surfaceScalarField> ghfFluid(fluidRegions.size());
PtrList<radiation::radiationModel> radiation(fluidRegions.size());
List<scalar> initialMassFluid(fluidRegions.size());
List<label> pRefCellFluid(fluidRegions.size(),0);
@ -168,6 +169,12 @@
// Force p_rgh to be consistent with p
p_rghFluid[i] = thermoFluid[i].p() - rhoFluid[i]*ghFluid[i];
radiation.set
(
i,
radiation::radiationModel::New(thermoFluid[i].T())
);
initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();
setRefCell

View File

@ -7,6 +7,7 @@
==
fvc::div(phi/fvc::interpolate(rho), rho/psi, "div(U,p)")
- (rho/psi)*fvc::div(phi/fvc::interpolate(rho))
+ rad.Sh(thermo)
);
hEqn.relax();
@ -15,6 +16,8 @@
thermo.correct();
rad.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}

View File

@ -19,6 +19,8 @@
initialMassFluid[i]
);
radiation::radiationModel& rad = radiation[i];
const label pRefCell = pRefCellFluid[i];
const scalar pRefValue = pRefValueFluid[i];

View File

@ -0,0 +1,4 @@
turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C
externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C
LIB = $(FOAM_LIBBIN)/libcoupledDerivedFvPatchFields

View File

@ -0,0 +1,12 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude
EXE_LIBS = \
-lmeshTools \
-lbasicThermophysicalModels \
-lfiniteVolume \
-lradiationModels

View File

@ -0,0 +1,271 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "externalWallHeatFluxTemperatureFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "directMappedPatchBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char*
NamedEnum
<externalWallHeatFluxTemperatureFvPatchScalarField::operationMode, 3>::names[]=
{
"fixed_heat_flux",
"fixed_heat_transfer_coefficient",
"unknown"
};
const NamedEnum
<
externalWallHeatFluxTemperatureFvPatchScalarField::operationMode, 3
>
externalWallHeatFluxTemperatureFvPatchScalarField::operationModeNames;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
externalWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined-K"),
oldMode_(unknown),
q_(p.size(), 0.0),
h_(p.size(), 0.0),
Ta_(p.size(), 0.0)
{
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 1.0;
}
Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
externalWallHeatFluxTemperatureFvPatchScalarField
(
const externalWallHeatFluxTemperatureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
temperatureCoupledBase(patch(), ptf.KMethod(), ptf.KName()),
oldMode_(unknown),
q_(ptf.q_, mapper),
h_(ptf.h_, mapper),
Ta_(ptf.Ta_, mapper)
{}
Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
externalWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), dict),
oldMode_(unknown),
q_(p.size(), 0.0),
h_(p.size(), 0.0),
Ta_(p.size(), 0.0)
{
if (dict.found("q") && !dict.found("h") && !dict.found("Ta"))
{
oldMode_ = fixedHeatFlux;
q_ = scalarField("q", dict, p.size());
}
else if(dict.found("h") && dict.found("Ta") && !dict.found("q"))
{
oldMode_ = fixedHeatTransferCoeff;
h_ = scalarField("h", dict, p.size());
Ta_ = scalarField("Ta", dict, p.size());
}
else
{
FatalErrorIn
(
"externalWallHeatFluxTemperatureFvPatchScalarField::"
"externalWallHeatFluxTemperatureFvPatchScalarField\n"
"(\n"
" const fvPatch& p,\n"
" const DimensionedField<scalar, volMesh>& iF,\n"
" const dictionary& dict\n"
")\n"
) << "\n patch type '" << p.type()
<< "' either q or h and Ta were not found '"
<< "\n for patch " << p.name()
<< " of field " << dimensionedInternalField().name()
<< " in file " << dimensionedInternalField().objectPath()
<< exit(FatalError);
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (dict.found("refValue"))
{
// Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
}
else
{
// Start from user entered data. Assume fixedValue.
refValue() = *this;
refGrad() = 0.0;
valueFraction() = 1.0;
}
}
Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
externalWallHeatFluxTemperatureFvPatchScalarField
(
const externalWallHeatFluxTemperatureFvPatchScalarField& tppsf
)
:
mixedFvPatchScalarField(tppsf),
temperatureCoupledBase(tppsf),
oldMode_(unknown),
q_(tppsf.q_),
h_(tppsf.h_),
Ta_(tppsf.Ta_)
{}
Foam::externalWallHeatFluxTemperatureFvPatchScalarField::
externalWallHeatFluxTemperatureFvPatchScalarField
(
const externalWallHeatFluxTemperatureFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(tppsf, iF),
temperatureCoupledBase(patch(), tppsf.KMethod(), tppsf.KName()),
oldMode_(tppsf.oldMode_),
q_(tppsf.q_),
h_(tppsf.h_),
Ta_(tppsf.Ta_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
if(oldMode_ == fixedHeatFlux)
{
this->refGrad() = q_/K(*this);
this->refValue() = 0.0;
this->valueFraction() = 0.0;
}
else if(oldMode_ == fixedHeatTransferCoeff)
{
this->refGrad() = (Ta_ - *this)*h_/K(*this);
this->refValue() = 0.0;
this->valueFraction() = 0.0;
}
else
{
FatalErrorIn
(
"externalWallHeatFluxTemperatureFvPatchScalarField"
"::updateCoeffs()"
) << "Illegal mode " << operationModeNames[oldMode_]
<< exit(FatalError);
}
mixedFvPatchScalarField::updateCoeffs();
if (debug)
{
scalar Q = gSum(K(*this)*patch().magSf()*snGrad());
Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':'
<< this->dimensionedInternalField().name() << " :"
<< " heatFlux:" << Q
<< " walltemperature "
<< " min:" << gMin(*this)
<< " max:" << gMax(*this)
<< " avg:" << gAverage(*this)
<< endl;
}
}
void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::write
(
Ostream& os
) const
{
mixedFvPatchScalarField::write(os);
temperatureCoupledBase::write(os);
q_.writeEntry("q", os);
h_.writeEntry("h", os);
Ta_.writeEntry("Ta", os);
this->writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
externalWallHeatFluxTemperatureFvPatchScalarField
);
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -22,31 +22,42 @@ License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
solidWallHeatFluxTemperatureFvPatchScalarField
externalWallHeatFluxTemperatureFvPatchScalarField
Description
Heat flux boundary condition for temperature on solid region
Heat flux boundary condition for temperature on external wall.
If h and Ta are specified then fixed_heat_transfer_coefficient mode is used
If q is specified then fixed_heat_flux is used.
Example usage:
myWallPatch
{
type solidWallHeatFluxTemperature;
K K; // Name of K field
q uniform 1000; // Heat flux / [W/m2]
value uniform 300.0; // Initial temperature / [K]
gradient uniform 0.0; // Initial gradient / [K/m]
type externalWallHeatFluxTemperature;
K solidThermo; // solidThermo or lookup
q uniform 1000; // Heat flux / [W/m2]
Ta uniform 300.0; // Tambient temperature /[K]
h uniform 10.0; // Heat transfer coeff /[W/Km2]
value uniform 300.0; // Initial temperature / [K]
KName none;
}
Note:
Only the pair h, Ta or q can be specified in the dictionary.
SourceFiles
solidWallHeatFluxTemperatureFvPatchScalarField.C
externalWallHeatFluxTemperatureFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef solidWallHeatFluxTemperatureFvPatchScalarField_H
#define solidWallHeatFluxTemperatureFvPatchScalarField_H
#include "fixedGradientFvPatchFields.H"
//#include "fixedGradientFvPatchFields.H"
#include "mixedFvPatchFields.H"
#include "temperatureCoupledBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -54,39 +65,55 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class solidWallHeatFluxTemperatureFvPatchScalarField Declaration
Class externalWallHeatFluxTemperatureFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class solidWallHeatFluxTemperatureFvPatchScalarField
class externalWallHeatFluxTemperatureFvPatchScalarField
:
public fixedGradientFvPatchScalarField
public mixedFvPatchScalarField,
public temperatureCoupledBase
{
// Private data
//- how to operate the BC
enum operationMode
{
fixedHeatFlux,
fixedHeatTransferCoeff,
unknown
};
static const NamedEnum<operationMode, 3> operationModeNames;
//- Operation mode
operationMode oldMode_;
//- Heat flux / [W/m2]
scalarField q_;
//- Name of thermal conductivity field
word KName_;
//- Heat transfer coefficient / [W/m2K]
scalarField h_;
//- Ambient temperature / [K]
scalarField Ta_;
public:
//- Runtime type information
TypeName("solidWallHeatFluxTemperature");
TypeName("externalWallHeatFluxTemperature");
// Constructors
//- Construct from patch and internal field
solidWallHeatFluxTemperatureFvPatchScalarField
externalWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
solidWallHeatFluxTemperatureFvPatchScalarField
externalWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
@ -94,20 +121,20 @@ public:
);
//- Construct by mapping given
// solidWallHeatFluxTemperatureFvPatchScalarField
// externalWallHeatFluxTemperatureFvPatchScalarField
// onto a new patch
solidWallHeatFluxTemperatureFvPatchScalarField
externalWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&,
const externalWallHeatFluxTemperatureFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
solidWallHeatFluxTemperatureFvPatchScalarField
externalWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&
const externalWallHeatFluxTemperatureFvPatchScalarField&
);
//- Construct and return a clone
@ -115,14 +142,14 @@ public:
{
return tmp<fvPatchScalarField>
(
new solidWallHeatFluxTemperatureFvPatchScalarField(*this)
new externalWallHeatFluxTemperatureFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
solidWallHeatFluxTemperatureFvPatchScalarField
externalWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField&,
const externalWallHeatFluxTemperatureFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
@ -134,40 +161,18 @@ public:
{
return tmp<fvPatchScalarField>
(
new solidWallHeatFluxTemperatureFvPatchScalarField(*this, iF)
new externalWallHeatFluxTemperatureFvPatchScalarField(*this, iF)
);
}
// Member functions
// Helper
//- Get K field on this patch
tmp<scalarField> K() const;
// 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

View File

@ -0,0 +1,234 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 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 "turbulentTemperatureRadCoupledMixedFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "directMappedPatchBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace compressible
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
turbulentTemperatureRadCoupledMixedFvPatchScalarField::
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined-K"),
TnbrName_("undefined-Tnbr"),
QrNbrName_("undefined-QrNbr"),
QrName_("undefined-Qr")
{
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 1.0;
}
turbulentTemperatureRadCoupledMixedFvPatchScalarField::
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const turbulentTemperatureRadCoupledMixedFvPatchScalarField& psf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(psf, p, iF, mapper),
temperatureCoupledBase(patch(), psf.KMethod(), psf.KName()),
TnbrName_(psf.TnbrName_),
QrNbrName_(psf.QrNbrName_),
QrName_(psf.QrName_)
{}
turbulentTemperatureRadCoupledMixedFvPatchScalarField::
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), dict),
TnbrName_(dict.lookup("Tnbr")),
QrNbrName_(dict.lookup("QrNbr")),
QrName_(dict.lookup("Qr"))
{
if (!isA<directMappedPatchBase>(this->patch().patch()))
{
FatalErrorIn
(
"turbulentTemperatureRadCoupledMixedFvPatchScalarField::"
"turbulentTemperatureRadCoupledMixedFvPatchScalarField\n"
"(\n"
" const fvPatch& p,\n"
" const DimensionedField<scalar, volMesh>& iF,\n"
" const dictionary& dict\n"
")\n"
) << "\n patch type '" << p.type()
<< "' not type '" << directMappedPatchBase::typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << dimensionedInternalField().name()
<< " in file " << dimensionedInternalField().objectPath()
<< exit(FatalError);
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (dict.found("refValue"))
{
// Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
}
else
{
// Start from user entered data. Assume fixedValue.
refValue() = *this;
refGrad() = 0.0;
valueFraction() = 1.0;
}
}
turbulentTemperatureRadCoupledMixedFvPatchScalarField::
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const turbulentTemperatureRadCoupledMixedFvPatchScalarField& psf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(psf, iF),
temperatureCoupledBase(patch(), psf.KMethod(), psf.KName()),
TnbrName_(psf.TnbrName_),
QrNbrName_(psf.QrNbrName_),
QrName_(psf.QrName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void turbulentTemperatureRadCoupledMixedFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
// Get the coupling information from the directMappedPatchBase
const directMappedPatchBase& mpp =
refCast<const directMappedPatchBase>(patch().patch());
const polyMesh& nbrMesh = mpp.sampleMesh();
const label samplePatchI = mpp.samplePolyPatch().index();
const fvPatch& nbrPatch =
refCast<const fvMesh>(nbrMesh).boundary()[samplePatchI];
scalarField Tc = patchInternalField();
scalarField& Tp = *this;
const turbulentTemperatureRadCoupledMixedFvPatchScalarField&
nbrField = refCast
<const turbulentTemperatureRadCoupledMixedFvPatchScalarField>
(
nbrPatch.lookupPatchField<volScalarField, scalar>(TnbrName_)
);
// Swap to obtain full local values of neighbour internal field
scalarField TcNbr = nbrField.patchInternalField();
mpp.map().distribute(TcNbr);
// Swap to obtain full local values of neighbour K*delta
scalarField KDeltaNbr = nbrField.K(TcNbr)*nbrPatch.deltaCoeffs();
mpp.map().distribute(KDeltaNbr);
scalarField KDelta = K(*this)*patch().deltaCoeffs();
scalarField Qr(Tp.size(), 0.0);
if (QrName_ != "none")
{
Qr = patch().lookupPatchField<volScalarField, scalar>(QrName_);
}
scalarField QrNbr(Tp.size(), 0.0);
if (QrNbrName_ != "none")
{
QrNbr = nbrPatch.lookupPatchField<volScalarField, scalar>(QrNbrName_);
}
scalarField alpha(KDeltaNbr - (Qr + QrNbr)/Tp);
valueFraction() = alpha/(alpha + KDelta);
refValue() = (KDeltaNbr*TcNbr)/alpha;
mixedFvPatchScalarField::updateCoeffs();
}
void turbulentTemperatureRadCoupledMixedFvPatchScalarField::write
(
Ostream& os
) const
{
mixedFvPatchScalarField::write(os);
os.writeKeyword("Tnbr")<< TnbrName_ << token::END_STATEMENT << nl;
os.writeKeyword("QrNbr")<< QrNbrName_ << token::END_STATEMENT << nl;
os.writeKeyword("Qr")<< QrName_ << token::END_STATEMENT << nl;
temperatureCoupledBase::write(os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchScalarField,
turbulentTemperatureRadCoupledMixedFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace compressible
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,186 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
Foam::
compressible::
turbulentTemperatureRadCoupledMixedFvPatchScalarField
Description
Mixed boundary condition for temperature and radiation heat transfer
to be used for in multiregion cases
Example usage:
myInterfacePatchName
{
type compressible::turbulentTemperatureRadCoupledMixed;
TNbr T; // name of T field on neighbour region
K lookup;
KName K;
QrNbr Qr; // or none. Name of Qr field on neighbour region
Qr Qr; // or none. Name of Qr field on local region
value uniform 300;
}
Needs to be on underlying directMapped(Wall)FvPatch.
Note: K : heat conduction at patch. Gets supplied how to lookup/calculate
K:
- 'lookup' : lookup volScalarField (or volSymmTensorField) with name
- 'basicThermo' : use basicThermo and compressible::RASmodel to calculate K
- 'solidThermo' : use basicSolidThermo K()
- 'directionalSolidThermo' directionalK()
Note: runs in parallel with arbitrary decomposition. Uses directMapped
functionality to calculate exchange.
SourceFiles
turbulentTemperatureRadCoupledMixedFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef turbulentTemperatureRadCoupledMixedFvPatchScalarField_H
#define turbulentTemperatureRadCoupledMixedFvPatchScalarField_H
#include "mixedFvPatchFields.H"
#include "temperatureCoupledBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace compressible
{
/*---------------------------------------------------------------------------*\
Class turbulentTemperatureRadCoupledMixedFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class turbulentTemperatureRadCoupledMixedFvPatchScalarField
:
public mixedFvPatchScalarField,
public temperatureCoupledBase
{
// Private data
//- Name of field on the neighbour region
const word TnbrName_;
//- Name of the radiative heat flux in the neighbout region
const word QrNbrName_;
//- Name of the radiative heat flux in local region
const word QrName_;
public:
//- Runtime type information
TypeName("compressible::turbulentTemperatureRadCoupledMixed");
// Constructors
//- Construct from patch and internal field
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// turbulentTemperatureCoupledBaffleMixedFvPatchScalarField onto a
// new patch
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const
turbulentTemperatureRadCoupledMixedFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
*this
)
);
}
//- Construct as copy setting internal field reference
turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
const turbulentTemperatureRadCoupledMixedFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new turbulentTemperatureRadCoupledMixedFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace compressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,213 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "solidWallHeatFluxTemperatureFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(p, iF),
q_(p.size(), 0.0),
KName_("undefined-K")
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
q_(ptf.q_, mapper),
KName_(ptf.KName_)
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchScalarField(p, iF, dict),
q_("q", dict, p.size()),
KName_(dict.lookup("K"))
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf
)
:
fixedGradientFvPatchScalarField(tppsf),
q_(tppsf.q_),
KName_(tppsf.KName_)
{}
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::
solidWallHeatFluxTemperatureFvPatchScalarField
(
const solidWallHeatFluxTemperatureFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(tppsf, iF),
q_(tppsf.q_),
KName_(tppsf.KName_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
fixedGradientFvPatchScalarField::autoMap(m);
q_.autoMap(m);
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
fixedGradientFvPatchScalarField::rmap(ptf, addr);
const solidWallHeatFluxTemperatureFvPatchScalarField& hfptf =
refCast<const solidWallHeatFluxTemperatureFvPatchScalarField>(ptf);
q_.rmap(hfptf.q_, addr);
}
Foam::tmp<Foam::scalarField>
Foam::solidWallHeatFluxTemperatureFvPatchScalarField::K() const
{
const fvMesh& mesh = patch().boundaryMesh().mesh();
if (mesh.objectRegistry::foundObject<volScalarField>(KName_))
{
return patch().lookupPatchField<volScalarField, scalar>(KName_);
}
else if (mesh.objectRegistry::foundObject<volSymmTensorField>(KName_))
{
const symmTensorField& KWall =
patch().lookupPatchField<volSymmTensorField, scalar>(KName_);
vectorField n(patch().nf());
return n & KWall & n;
}
else
{
FatalErrorIn
(
"solidWallHeatFluxTemperatureFvPatchScalarField::K()"
" const"
) << "Did not find field " << KName_
<< " on mesh " << mesh.name() << " patch " << patch().name()
<< endl
<< "Please set 'K' to a valid volScalarField"
<< " or a valid volSymmTensorField." << exit(FatalError);
return scalarField(0);
}
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
gradient() = q_/K();
fixedGradientFvPatchScalarField::updateCoeffs();
if (debug)
{
scalar Q = gSum(K()*patch().magSf()*snGrad());
Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':'
<< this->dimensionedInternalField().name() << " :"
<< " heatFlux:" << Q
<< " walltemperature "
<< " min:" << gMin(*this)
<< " max:" << gMax(*this)
<< " avg:" << gAverage(*this)
<< endl;
}
}
void Foam::solidWallHeatFluxTemperatureFvPatchScalarField::write
(
Ostream& os
) const
{
fixedGradientFvPatchScalarField::write(os);
q_.writeEntry("q", os);
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
this->writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
solidWallHeatFluxTemperatureFvPatchScalarField
);
}
// ************************************************************************* //

View File

@ -9,6 +9,7 @@
PtrList<volScalarField> p_rghFluid(fluidRegions.size());
PtrList<volScalarField> ghFluid(fluidRegions.size());
PtrList<surfaceScalarField> ghfFluid(fluidRegions.size());
PtrList<radiation::radiationModel> radiation(fluidRegions.size());
PtrList<volScalarField> DpDtFluid(fluidRegions.size());
List<scalar> initialMassFluid(fluidRegions.size());
@ -166,6 +167,12 @@
// Force p_rgh to be consistent with p
p_rghFluid[i] = thermoFluid[i].p() - rhoFluid[i]*ghFluid[i];
radiation.set
(
i,
radiation::radiationModel::New(thermoFluid[i].T())
);
initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value();
Info<< " Adding to DpDtFluid\n" << endl;

View File

@ -6,13 +6,16 @@
- fvm::laplacian(turb.alphaEff(), h)
==
DpDt
+ rad.Sh(thermo)
);
hEqn.relax();
hEqn.solve(mesh.solver(h.select(finalIter)));
thermo.correct();
rad.correct();
Info<< "Min/max T:" << min(thermo.T()).value() << ' '
<< max(thermo.T()).value() << endl;
}

View File

@ -17,6 +17,8 @@
const volScalarField& gh = ghFluid[i];
const surfaceScalarField& ghf = ghfFluid[i];
radiation::radiationModel& rad = radiation[i];
const dimensionedScalar initialMass
(
"initialMass",

View File

@ -27,7 +27,7 @@
(
fvc::ddt(rho) + psi*correction(fvm::ddt(p))
+ fvc::div(phi)
==
==
parcels.Srho()
+ massSource.SuTot()
);

View File

@ -116,7 +116,9 @@
&& runTime.timeIndex() > runTime.startTimeIndex() + 1
)
{
rDeltaT = rDeltaT0*max(rDeltaT/rDeltaT0, 1.0 - rDeltaTDampingCoeff);
rDeltaT =
rDeltaT0
*max(rDeltaT/rDeltaT0, scalar(1.0) - rDeltaTDampingCoeff);
Info<< "Damped flow time scale min/max = "
<< gMin(1/rDeltaT.internalField())

View File

@ -0,0 +1,3 @@
faceAgglomerate.C
EXE = $(FOAM_APPBIN)/faceAgglomerate

View File

@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/OpenFOAM/lnInclude \
-I$(LIB_SRC)/fvAgglomerationMethods/pairPatchAgglomeration/lnInclude
EXE_LIBS = \
-lOpenFOAM \
-lfiniteVolume \
-lpairPatchAgglomeration \
-ltriSurface \
-lmeshTools

View File

@ -0,0 +1,192 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Application
faceAgglomerate
Description
Agglomerate boundary faces using the pairPatchAgglomeration algorithm.
It writes a map from the fine to coarse grid.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fvMesh.H"
#include "Time.H"
#include "volFields.H"
#include "CompactListList.H"
#include "unitConversion.H"
#include "pairPatchAgglomeration.H"
#include "labelListIOList.H"
#include "syncTools.H"
using namespace Foam;
// Main program:
int main(int argc, char *argv[])
{
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedMesh.H"
const polyBoundaryMesh& patches = mesh.boundaryMesh();
labelListIOList finalAgglom
(
IOobject
(
"finalAgglom",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
patches.size()
);
// Read view factor dictionary
IOdictionary viewFactorDict
(
IOobject
(
"viewFactorsDict",
runTime.constant(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
bool writeAgglo =
readBool(viewFactorDict.lookup("writeFacesAgglomeration"));
const polyBoundaryMesh& boundary = mesh.boundaryMesh();
forAll(boundary, patchId)
{
const polyPatch& pp = boundary[patchId];
label patchI = pp.index();
finalAgglom[patchI].setSize(pp.size(), 0);
if (pp.size() > 0 && !pp.coupled())
{
if (viewFactorDict.found(pp.name()))
{
Info << "\nAgglomerating name : " << pp.name() << endl;
pairPatchAgglomeration agglomObject
(
pp,
viewFactorDict.subDict(pp.name())
);
agglomObject.agglomerate();
finalAgglom[patchI] =
agglomObject.restrictTopBottomAddressing();
}
else
{
FatalErrorIn
(
"main(int argc, char *argv[])"
) << pp.name()
<< " not found in dictionary : "
<< viewFactorDict.name()
<< exit(FatalError);
}
}
}
// Sync agglomeration across coupled patches
labelList nbrAgglom(mesh.nFaces()-mesh.nInternalFaces(), -1);
forAll(boundary, patchId)
{
const polyPatch& pp = boundary[patchId];
if (pp.coupled())
{
finalAgglom[patchId] = identity(pp.size());
forAll(pp, i)
{
nbrAgglom[pp.start()-mesh.nInternalFaces()+i] =
finalAgglom[patchId][i];
}
}
}
syncTools::swapBoundaryFaceList(mesh, nbrAgglom);
forAll(boundary, patchId)
{
const polyPatch& pp = boundary[patchId];
if (pp.coupled() && !refCast<const coupledPolyPatch>(pp).owner())
{
forAll(pp, i)
{
finalAgglom[patchId][i] =
nbrAgglom[pp.start()-mesh.nInternalFaces()+i];
}
}
}
finalAgglom.write();
if (writeAgglo)
{
volScalarField facesAgglomeration
(
IOobject
(
"facesAgglomeration",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("facesAgglomeration", dimless, 0)
);
forAll(boundary, patchId)
{
fvPatchScalarField& bFacesAgglomeration =
facesAgglomeration.boundaryField()[patchId];
forAll(bFacesAgglomeration, j)
{
bFacesAgglomeration[j] = finalAgglom[patchId][j];
}
}
Info << "\nWriting facesAgglomeration..." << endl;
facesAgglomeration.write();
}
Info<< "End\n" << endl;
return 0;
}

View File

@ -0,0 +1,3 @@
viewFactorsGen.C
EXE = $(FOAM_APPBIN)/viewFactorsGen

View File

@ -0,0 +1,16 @@
EXE_INC = \
-I$(LIB_SRC)/triSurface/lnInclude \
-I$(LIB_SRC)/parallel/distributed/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/OpenFOAM/lnInclude
EXE_LIBS = \
-lmeshTools \
-lfiniteVolume \
-lOpenFOAM \
-lmeshTools \
-ltriSurface \
-ldistributed \
-lradiationModels

View File

@ -0,0 +1,54 @@
Random rndGen(653213);
// Determine mesh bounding boxes:
List<treeBoundBox> meshBb
(
1,
treeBoundBox
(
boundBox(coarseMesh.points(), false)
).extend(rndGen, 1E-3)
);
// Dummy bounds dictionary
dictionary dict;
dict.add("bounds", meshBb);
dict.add
(
"distributionType",
distributedTriSurfaceMesh::distributionTypeNames_
[
distributedTriSurfaceMesh::FROZEN
]
);
dict.add("mergeDistance", SMALL);
labelHashSet includePatches;
forAll(patches, patchI) //
{
if (!isA<processorPolyPatch>(patches[patchI]))
{
includePatches.insert(patchI);
}
}
distributedTriSurfaceMesh surfacesMesh
(
IOobject
(
"wallSurface.stl",
runTime.constant(), // directory
"triSurface", // instance
runTime, // registry
IOobject::NO_READ,
IOobject::NO_WRITE
),
triSurfaceTools::triangulate
(
patches,
includePatches
),
dict
);
//surfacesMesh.searchableSurface::write();

View File

@ -0,0 +1,97 @@
// All rays expressed as start face (local) index end end face (global)
// Pre-size by assuming a certain percentage is visible.
// Maximum lenght for dynamicList
const label maxDynListLenght = 10000;
//label lenghtCount = 0;
for (label procI = 0; procI < Pstream::nProcs(); procI++)
{
// Shoot rays from me to procI. Note that even if processor has
// 0 faces we still need to call findLine to keep calls synced.
DynamicField<point> start(coarseMesh.nFaces());
DynamicField<point> end(start.size());
DynamicList<label> startIndex(start.size());
DynamicList<label> endIndex(start.size());
const pointField& myFc = remoteCoarseCf[Pstream::myProcNo()];
const vectorField& myArea = remoteCoarseSf[Pstream::myProcNo()];
const pointField& remoteArea = remoteCoarseSf[procI];
const pointField& remoteFc = remoteCoarseCf[procI];
if (myFc.size()*remoteFc.size() > 0)
{
forAll(myFc, i)
{
const point& fc = myFc[i];
const vector& fA = myArea[i];
forAll(remoteFc, j)
{
if (procI != Pstream::myProcNo() || i != j)
{
const point& remFc = remoteFc[j];
const vector& remA = remoteArea[j];
const vector& d = remFc-fc;
if (((d & fA) < 0.) && ((d & remA) > 0))
{
//lenghtCount ++;
start.append(fc + 0.0001*d);
startIndex.append(i);
end.append(fc + 0.9999*d);
label globalI = globalNumbering.toGlobal(procI, j);
endIndex.append(globalI);
if (startIndex.size() > maxDynListLenght)
{
List<pointIndexHit> hitInfo(startIndex.size());
surfacesMesh.findLine
(
start,
end,
hitInfo
);
surfacesMesh.findLine(start, end, hitInfo);
forAll (hitInfo, rayI)
{
if (!hitInfo[rayI].hit())
{
rayStartFace.append(startIndex[rayI]);
rayEndFace.append(endIndex[rayI]);
}
}
//lenghtCount = 0;
start.clear();
startIndex.clear();
end.clear();
endIndex.clear();
}
}
}
}
}
}
if (!start.empty())
{
List<pointIndexHit> hitInfo(startIndex.size());
surfacesMesh.findLine
(
start,
end,
hitInfo
);
surfacesMesh.findLine(start, end, hitInfo);
forAll (hitInfo, rayI)
{
if (!hitInfo[rayI].hit())
{
rayStartFace.append(startIndex[rayI]);
rayEndFace.append(endIndex[rayI]);
}
}
}
}

View File

@ -0,0 +1,861 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Application
viewFactorGenerator
Description
View factors are calculated based on a face agglomeration array
(finalAgglom generated by faceAgglomerate utility).
Each view factor between the agglomerated faces i and j (Fij) is calculated
using a double integral of the sub-areas composing the agglomaration.
The patches involved in the view factor calculation are taken from the Qr
volScalarField (radiative flux) when is greyDiffusiveRadiationViewFactor
otherwise they are not included.
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fvMesh.H"
#include "Time.H"
#include "volFields.H"
#include "surfaceFields.H"
#include "distributedTriSurfaceMesh.H"
#include "triSurfaceTools.H"
#include "mapDistribute.H"
#include "OFstream.H"
#include "meshTools.H"
#include "plane.H"
#include "uindirectPrimitivePatch.H"
#include "DynamicField.H"
#include "IFstream.H"
#include "unitConversion.H"
#include "mathematicalConstants.H"
#include "scalarMatrices.H"
#include "CompactListList.H"
#include "labelIOList.H"
#include "labelListIOList.H"
#include "scalarListIOList.H"
#include "singleCellFvMesh.H"
#include "IOdictionary.H"
#include "fixedValueFvPatchFields.H"
using namespace Foam;
void writeRays
(
const fileName& fName,
const pointField& compactCf,
const pointField& myFc,
const labelListList& visibleFaceFaces
)
{
OFstream str(fName);
label vertI = 0;
Pout<< "Dumping rays to " << str.name() << endl;
forAll(myFc, faceI)
{
const labelList visFaces = visibleFaceFaces[faceI];
forAll(visFaces, faceRemote)
{
label compactI = visFaces[faceRemote];
const point& remoteFc = compactCf[compactI];
meshTools::writeOBJ(str, myFc[faceI]);
vertI++;
meshTools::writeOBJ(str, remoteFc);
vertI++;
str << "l " << vertI-1 << ' ' << vertI << nl;
}
}
string cmd("objToVTK " + fName + " " + fName.lessExt() + ".vtk");
Pout<< "cmd:" << cmd << endl;
system(cmd);
}
scalar calculateViewFactorFij
(
const vector& i,
const vector& j,
const vector& dAi,
const vector& dAj
)
{
vector r = i - j;
scalar rMag = mag(r);
scalar dAiMag = mag(dAi);
scalar dAjMag = mag(dAj);
vector ni = dAi/dAiMag;
vector nj = dAj/dAjMag;
scalar cosThetaJ = mag(nj & r)/rMag;
scalar cosThetaI = mag(ni & r)/rMag;
return
(
(cosThetaI*cosThetaJ*dAjMag*dAiMag)
/(sqr(rMag)*constant::mathematical::pi)
);
}
void insertMatrixElements
(
const globalIndex& globalNumbering,
const label fromProcI,
const labelListList& globalFaceFaces,
const scalarListList& viewFactors,
scalarSquareMatrix& matrix
)
{
forAll(viewFactors, faceI)
{
const scalarList& vf = viewFactors[faceI];
const labelList& globalFaces = globalFaceFaces[faceI];
label globalI = globalNumbering.toGlobal(fromProcI, faceI);
forAll(globalFaces, i)
{
matrix[globalI][globalFaces[i]] = vf[i];
}
}
}
// Main program:
int main(int argc, char *argv[])
{
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedMesh.H"
// Read view factor dictionary
IOdictionary viewFactorDict
(
IOobject
(
"viewFactorsDict",
runTime.constant(),
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
const bool writeViewFactors =
viewFactorDict.lookupOrDefault<bool>("writeViewFactorMatrix", false);
const bool dumpRays =
viewFactorDict.lookupOrDefault<bool>("dumpRays", false);
// Debug
// ~~~~~
const label debug = viewFactorDict.lookupOrDefault<label>("debug", 0);
volScalarField Qr
(
IOobject
(
"Qr",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE
),
mesh
);
// Read agglomeration map
labelListIOList finalAgglom
(
IOobject
(
"finalAgglom",
mesh.facesInstance(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
// - Create the coarse mesh using agglomeration //
//-----------------------------------------------//
if (debug)
{
Info << "\nCreating single cell mesh..." << endl;
}
singleCellFvMesh coarseMesh
(
IOobject
(
mesh.name(),
runTime.timeName(),
runTime,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
finalAgglom
);
// - Calculate total number of fine and coarse faces //
//---------------------------------------------------//
label nCoarseFaces = 0; //total number of coarse faces
label nFineFaces = 0; //total number of fine faces
const polyBoundaryMesh& patches = mesh.boundaryMesh();
const polyBoundaryMesh& coarsePatches = coarseMesh.boundaryMesh();
labelList viewFactorsPatches(patches.size());
const volScalarField::GeometricBoundaryField& Qrb = Qr.boundaryField();
label count = 0;
forAll(Qrb, patchI)
{
const polyPatch& pp = patches[patchI];
const fvPatchScalarField& QrpI = Qrb[patchI];
if ((isA<fixedValueFvPatchScalarField>(QrpI)) && (pp.size() > 0))
{
viewFactorsPatches[count] = QrpI.patch().index();
nCoarseFaces += coarsePatches[patchI].size();
nFineFaces += patches[patchI].size();
count ++;
}
}
viewFactorsPatches.resize(count--);
//total number of coarse faces
label totalNCoarseFaces = nCoarseFaces;
reduce(totalNCoarseFaces, sumOp<label>());
if (Pstream::master())
{
Info << "\nTotal number of coarse faces: "<< totalNCoarseFaces << endl;
}
if (Pstream::master() && debug)
{
Pout << "\nView factor patches included in the calculation : "
<< viewFactorsPatches << endl;
}
// - Collect local Cf and Sf on coarse mesh //.
//------------------------------------------//
DynamicList<point> localCoarseCf(nCoarseFaces);
DynamicList<point> localCoarseSf(nCoarseFaces);
forAll (viewFactorsPatches, i)
{
const label patchID = viewFactorsPatches[i];
const polyPatch& pp = patches[patchID];
const labelList& agglom = finalAgglom[patchID];
label nAgglom = max(agglom)+1;
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
const pointField& coarseCf = coarseMesh.Cf().boundaryField()[patchID];
const pointField& coarseSf = coarseMesh.Sf().boundaryField()[patchID];
forAll(coarseCf, faceI)
{
point cf = coarseCf[faceI];
const label coarseFaceI = coarsePatchFace[faceI];
const labelList& fineFaces = coarseToFine[coarseFaceI];
// Construct single face
uindirectPrimitivePatch upp
(
UIndirectList<face>(pp, fineFaces),
pp.points()
);
List<point> availablePoints
(
upp.faceCentres().size()
+ upp.localPoints().size()
);
SubList<point>
(
availablePoints,
upp.faceCentres().size()
).assign(upp.faceCentres());
SubList<point>
(
availablePoints,
upp.localPoints().size(),
upp.faceCentres().size()
).assign(upp.localPoints());
point cfo = cf;
scalar dist = GREAT;
forAll(availablePoints, iPoint)
{
point cfFine = availablePoints[iPoint];
if(mag(cfFine-cfo) < dist)
{
dist = mag(cfFine-cfo);
cf = cfFine;
}
}
point sf = coarseSf[faceI];
localCoarseCf.append(cf);
localCoarseSf.append(sf);
}
}
// - Collect remote Cf and Sf on coarse mesh //.
//------------------------------------------//
List<pointField> remoteCoarseCf(Pstream::nProcs());
List<pointField> remoteCoarseSf(Pstream::nProcs());
remoteCoarseCf[Pstream::myProcNo()] = localCoarseCf;
remoteCoarseSf[Pstream::myProcNo()] = localCoarseSf;
// - Collect remote Cf and Sf on fine mesh //.
//------------------------------------------//
List<pointField> remoteFineCf(Pstream::nProcs());
List<pointField> remoteFineSf(Pstream::nProcs());
remoteCoarseCf[Pstream::myProcNo()] = localCoarseCf;
remoteCoarseSf[Pstream::myProcNo()] = localCoarseSf;
// Distribute local coarse Cf and Sf for shooting rays
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Pstream::gatherList(remoteCoarseCf);
Pstream::scatterList(remoteCoarseCf);
Pstream::gatherList(remoteCoarseSf);
Pstream::scatterList(remoteCoarseSf);
// Set up searching engine for obstacles
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# include "searchingEngine.H"
// Determine rays between coarse face centres
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DynamicList<label> rayStartFace
(
nCoarseFaces
+ 0.01*nCoarseFaces
);
DynamicList<label> rayEndFace(rayStartFace.size());
globalIndex globalNumbering(nCoarseFaces);
//- Return rayStartFace in local index andrayEndFace in global index //
// ------------------------------------------------------------------//
# include "shootRays.H"
// Calculate number of visible faces from local index
labelList nVisibleFaceFaces(nCoarseFaces, 0);
forAll(rayStartFace, i)
{
nVisibleFaceFaces[rayStartFace[i]]++;
}
labelListList visibleFaceFaces(nCoarseFaces);
label nViewFactors = 0;
forAll(nVisibleFaceFaces, faceI)
{
visibleFaceFaces[faceI].setSize(nVisibleFaceFaces[faceI]);
nViewFactors += nVisibleFaceFaces[faceI];
}
// - Construct compact numbering
// - return map from remote to compact indices
// (per processor (!= myProcNo) a map from remote index to compact index)
// - construct distribute map
// - renumber rayEndFace into compact addressing
List<Map<label> > compactMap(Pstream::nProcs());
mapDistribute map(globalNumbering, rayEndFace, compactMap);
labelListIOList IOsubMap
(
IOobject
(
"subMap",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
map.subMap()
);
IOsubMap.write();
labelListIOList IOconstructMap
(
IOobject
(
"constructMap",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
map.constructMap()
);
IOconstructMap.write();
IOList<label> consMapDim
(
IOobject
(
"constructMapDim",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
List<label>(1, map.constructSize())
);
consMapDim.write();
// visibleFaceFaces has:
// (local face, local viewed face) = compact viewed face
//------------------------------------------------------------//
nVisibleFaceFaces = 0;
forAll(rayStartFace, i)
{
label faceI = rayStartFace[i];
label compactI = rayEndFace[i];
visibleFaceFaces[faceI][nVisibleFaceFaces[faceI]++] = compactI;
}
// Construct data in compact addressing
// I need coarse Sf (Ai), fine Sf (dAi) and fine Cf(r) to calculate Fij
// --------------------------------------------------------------------//
pointField compactCoarseCf(map.constructSize(), pTraits<vector>::zero);
pointField compactCoarseSf(map.constructSize(), pTraits<vector>::zero);
List<List<point> > compactFineSf(map.constructSize());
List<List<point> > compactFineCf(map.constructSize());
DynamicList<label> compactPatchId(map.constructSize());
// Insert my coarse local values
SubList<point>(compactCoarseSf, nCoarseFaces).assign(localCoarseSf);
SubList<point>(compactCoarseCf, nCoarseFaces).assign(localCoarseCf);
// Insert my fine local values
label compactI = 0;
forAll(viewFactorsPatches, i)
{
label patchID = viewFactorsPatches[i];
const labelList& agglom = finalAgglom[patchID];
label nAgglom = max(agglom)+1;
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
const labelList& coarsePatchFace = coarseMesh.patchFaceMap()[patchID];
forAll(coarseToFine, coarseI)
{
compactPatchId.append(patchID);
List<point>& fineCf = compactFineCf[compactI];
List<point>& fineSf = compactFineSf[compactI++];
const label coarseFaceI = coarsePatchFace[coarseI];
const labelList& fineFaces = coarseToFine[coarseFaceI];
fineCf.setSize(fineFaces.size());
fineSf.setSize(fineFaces.size());
fineCf = UIndirectList<point>
(
mesh.Cf().boundaryField()[patchID],
coarseToFine[coarseFaceI]
);
fineSf = UIndirectList<point>
(
mesh.Sf().boundaryField()[patchID],
coarseToFine[coarseFaceI]
);
}
}
// Do all swapping
map.distribute(compactCoarseSf);
map.distribute(compactCoarseCf);
map.distribute(compactFineCf);
map.distribute(compactFineSf);
map.distribute(compactPatchId);
// Plot all rays between visible faces.
if (dumpRays)
{
writeRays
(
runTime.path()/"allVisibleFaces.obj",
compactCoarseCf,
remoteCoarseCf[Pstream::myProcNo()],
visibleFaceFaces
);
}
// Fill local view factor matrix
//-----------------------------
scalarListIOList F
(
IOobject
(
"F",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
nCoarseFaces
);
label totalPatches = coarsePatches.size();
reduce(totalPatches, maxOp<label>());
// Matrix sum in j(Fij) for each i (if enclosure sum = 1
scalarSquareMatrix sumViewFactorPatch
(
totalPatches,
totalPatches,
0.0
);
scalarList patchArea(totalPatches, 0.0);
if (Pstream::master())
{
Info << "\nCalculating view factors..." << endl;
}
if (mesh.nSolutionD() == 3)
{
forAll (localCoarseSf, coarseFaceI)
{
const List<point>& localFineSf = compactFineSf[coarseFaceI];
const vector Ai = sum(localFineSf);
const List<point>& localFineCf = compactFineCf[coarseFaceI];
const label fromPatchId = compactPatchId[coarseFaceI];
patchArea[fromPatchId] += mag(Ai);
const labelList& visCoarseFaces = visibleFaceFaces[coarseFaceI];
forAll (visCoarseFaces, visCoarseFaceI)
{
F[coarseFaceI].setSize(visCoarseFaces.size());
label compactJ = visCoarseFaces[visCoarseFaceI];
const List<point>& remoteFineSj = compactFineSf[compactJ];
const List<point>& remoteFineCj = compactFineCf[compactJ];
const label toPatchId = compactPatchId[compactJ];
scalar Fij = 0;
forAll (localFineSf, i)
{
const vector& dAi = localFineSf[i];
const vector& dCi = localFineCf[i];
forAll (remoteFineSj, j)
{
const vector& dAj = remoteFineSj[j];
const vector& dCj = remoteFineCj[j];
scalar dIntFij = calculateViewFactorFij
(
dCi,
dCj,
dAi,
dAj
);
Fij += dIntFij;
}
}
F[coarseFaceI][visCoarseFaceI] = Fij/mag(Ai);
sumViewFactorPatch[fromPatchId][toPatchId] += Fij;
}
}
}
else if (mesh.nSolutionD() == 2)
{
const boundBox& box = mesh.bounds();
const Vector<label>& dirs = mesh.geometricD();
vector emptyDir = vector::zero;
forAll (dirs, i)
{
if (dirs[i] == -1)
{
emptyDir[i] = 1.0;
}
}
scalar wideBy2 = (box.span() & emptyDir)*2.0;
forAll (localCoarseSf, coarseFaceI)
{
const vector& Ai = localCoarseSf[coarseFaceI];
const vector& Ci = localCoarseCf[coarseFaceI];
vector Ain = Ai/mag(Ai);
vector R1i = Ci + (mag(Ai)/wideBy2)*(Ain ^ emptyDir);
vector R2i = Ci - (mag(Ai)/wideBy2)*(Ain ^ emptyDir) ;
const label fromPatchId = compactPatchId[coarseFaceI];
patchArea[fromPatchId] += mag(Ai);
const labelList& visCoarseFaces = visibleFaceFaces[coarseFaceI];
forAll (visCoarseFaces, visCoarseFaceI)
{
F[coarseFaceI].setSize(visCoarseFaces.size());
label compactJ = visCoarseFaces[visCoarseFaceI];
const vector& Aj = compactCoarseSf[compactJ];
const vector& Cj = compactCoarseCf[compactJ];
const label toPatchId = compactPatchId[compactJ];
vector Ajn = Aj/mag(Aj);
vector R1j = Cj + (mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
vector R2j = Cj - (mag(Aj)/wideBy2)*(Ajn ^ emptyDir);
scalar d1 = mag(R1i - R2j);
scalar d2 = mag(R2i - R1j);
scalar s1 = mag(R1i - R1j);
scalar s2 = mag(R2i - R2j);
scalar Fij = mag((d1 + d2) - (s1 + s2))/(4.0*mag(Ai)/wideBy2);
F[coarseFaceI][visCoarseFaceI] = Fij;
sumViewFactorPatch[fromPatchId][toPatchId] += Fij*mag(Ai);
}
}
}
if (Pstream::master())
{
Info << "Writing view factor matrix..." << endl;
}
// Write view factors matrix in listlist form
F.write();
reduce(sumViewFactorPatch, sumOp<scalarSquareMatrix>());
reduce(patchArea, sumOp<scalarList>());
if (Pstream::master() && debug)
{
forAll (viewFactorsPatches, i)
{
label patchI = viewFactorsPatches[i];
forAll (viewFactorsPatches, i)
{
label patchJ = viewFactorsPatches[i];
Info << "F" << patchI << patchJ << ": "
<< sumViewFactorPatch[patchI][patchJ]/patchArea[patchI]
<< endl;
}
}
}
if (writeViewFactors)
{
volScalarField viewFactorField
(
IOobject
(
"viewFactorField",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionedScalar("viewFactorField", dimless, 0)
);
label compactI = 0;
forAll(viewFactorsPatches, i)
{
label patchID = viewFactorsPatches[i];
const labelList& agglom = finalAgglom[patchID];
label nAgglom = max(agglom)+1;
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
const labelList& coarsePatchFace =
coarseMesh.patchFaceMap()[patchID];
forAll (coarseToFine, coarseI)
{
const scalar Fij = sum(F[compactI]);
const label coarseFaceID = coarsePatchFace[coarseI];
const labelList& fineFaces = coarseToFine[coarseFaceID];
forAll (fineFaces, fineId)
{
const label faceID = fineFaces[fineId];
viewFactorField.boundaryField()[patchID][faceID] = Fij;
}
compactI++;
}
}
viewFactorField.write();
}
// Invert compactMap (from processor+localface to compact) to go
// from compact to processor+localface (expressed as a globalIndex)
// globalIndex globalCoarFaceNum(coarseMesh.nFaces());
labelList compactToGlobal(map.constructSize());
// Local indices first (note: are not in compactMap)
for (label i = 0; i < globalNumbering.localSize(); i++)
{
compactToGlobal[i] = globalNumbering.toGlobal(i);
}
forAll(compactMap, procI)
{
const Map<label>& localToCompactMap = compactMap[procI];
forAllConstIter(Map<label>, localToCompactMap, iter)
{
compactToGlobal[iter()] = globalNumbering.toGlobal
(
procI,
iter.key()
);
}
}
if (Pstream::master())
{
scalarSquareMatrix Fmatrix(totalNCoarseFaces, totalNCoarseFaces, 0.0);
labelListList globalFaceFaces(visibleFaceFaces.size());
// Create globalFaceFaces needed to insert view factors
// in F to the global matrix Fmatrix
forAll(globalFaceFaces, faceI)
{
globalFaceFaces[faceI] = renumber
(
compactToGlobal,
visibleFaceFaces[faceI]
);
}
labelListIOList IOglobalFaceFaces
(
IOobject
(
"globalFaceFaces",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
globalFaceFaces
);
IOglobalFaceFaces.write();
}
else
{
labelListList globalFaceFaces(visibleFaceFaces.size());
forAll(globalFaceFaces, faceI)
{
globalFaceFaces[faceI] = renumber
(
compactToGlobal,
visibleFaceFaces[faceI]
);
}
labelListIOList IOglobalFaceFaces
(
IOobject
(
"globalFaceFaces",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
globalFaceFaces
);
IOglobalFaceFaces.write();
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -53,6 +53,18 @@ inline scalar radToDeg(const scalar rad)
return (rad * 180.0/constant::mathematical::pi);
}
//- Conversion from atm to Pa
inline scalar atmToPa(const scalar atm)
{
return (atm * 101035.0);
}
//- Conversion from atm to Pa
inline scalar paToAtm(const scalar pa)
{
return (pa / 101035.0);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam

View File

@ -10,4 +10,6 @@ then
wmake $makeOption MGridGenGamgAgglomeration
fi
wmake libso pairPatchAgglomeration
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,3 @@
pairPatchAgglomeration.C
LIB = $(FOAM_LIBBIN)/libpairPatchAgglomeration

View File

@ -0,0 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/OpenFOAM/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lOpenFOAM \
-lmeshTools

View File

@ -0,0 +1,525 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "pairPatchAgglomeration.H"
#include "meshTools.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
void Foam::pairPatchAgglomeration::compactLevels(const label nCreatedLevels)
{
nFaces_.setSize(nCreatedLevels);
restrictAddressing_.setSize(nCreatedLevels);
patchLevels_.setSize(nCreatedLevels);
}
bool Foam::pairPatchAgglomeration::continueAgglomerating
(
const label nCoarseFaces
)
{
// Check the need for further agglomeration on all processors
bool contAgg = nCoarseFaces >= nFacesInCoarsestLevel_;
reduce(contAgg, andOp<bool>());
return contAgg;
}
void Foam::pairPatchAgglomeration::setBasedEdgeWeights()
{
const bPatch& coarsePatch = patchLevels_[0];
forAll(coarsePatch.edges(), i)
{
if(coarsePatch.isInternalEdge(i))
{
scalar edgeLength =
coarsePatch.edges()[i].mag(coarsePatch.localPoints());
const labelList& eFaces = coarsePatch.edgeFaces()[i];
if (eFaces.size() == 2)
{
scalar cosI =
coarsePatch.faceNormals()[eFaces[0]] &
coarsePatch.faceNormals()[eFaces[1]];
const edge edgeCommon = edge(eFaces[0], eFaces[1]);
if(facePairWeight_.found(edgeCommon))
{
facePairWeight_[edgeCommon] += edgeLength;
}
else
{
facePairWeight_.insert(edgeCommon, edgeLength);
}
if
(
cosI <
Foam::cos
(
featureAngle_*constant::mathematical::pi/180.0
)
)
{
facePairWeight_[edgeCommon] = -1.0;
}
}
else if (eFaces.size() == 3)
{
facePairWeight_.insert(edge(eFaces[1], eFaces[0]), -1.0);
facePairWeight_.insert(edge(eFaces[2], eFaces[0]), -1.0);
facePairWeight_.insert(edge(eFaces[1], eFaces[2]), -1.0);
}
}
}
}
void Foam::pairPatchAgglomeration::setEdgeWeights
(
const label fineLevelIndex
)
{
const bPatch& coarsePatch = patchLevels_[fineLevelIndex];
const labelList& fineToCoarse = restrictAddressing_[fineLevelIndex];
const label nCoarseI = max(fineToCoarse)+1;
labelListList coarseToFine
(
invertOneToMany(nCoarseI, fineToCoarse)
);
HashSet<edge, Hash<edge> > fineFeaturedFaces(coarsePatch.nEdges()/10);
// Map fine faces with featured edge into coarse faces
forAllConstIter(EdgeMap<scalar>, facePairWeight_, iter)
{
if (iter() == -1.0)
{
const edge e = iter.key();
const edge edgeFeatured
(
fineToCoarse[e[0]],
fineToCoarse[e[1]]
);
fineFeaturedFaces.insert(edgeFeatured);
}
}
// Clean old weitghs
facePairWeight_.clear();
facePairWeight_.resize(coarsePatch.nEdges());
forAll(coarsePatch.edges(), i)
{
if(coarsePatch.isInternalEdge(i))
{
scalar edgeLength =
coarsePatch.edges()[i].mag(coarsePatch.localPoints());
const labelList& eFaces = coarsePatch.edgeFaces()[i];
if (eFaces.size() == 2)
{
const edge edgeCommon = edge(eFaces[0], eFaces[1]);
if(facePairWeight_.found(edgeCommon))
{
facePairWeight_[edgeCommon] += edgeLength;
}
else
{
facePairWeight_.insert(edgeCommon, edgeLength);
}
// If the fine 'pair' faces was featured edge so it is
// the coarse 'pair'
if (fineFeaturedFaces.found(edgeCommon))
{
facePairWeight_[edgeCommon] = -1.0;
}
}
else if (eFaces.size() == 3)
{
facePairWeight_.insert(edge(eFaces[1], eFaces[0]), -1.0);
facePairWeight_.insert(edge(eFaces[2], eFaces[0]), -1.0);
facePairWeight_.insert(edge(eFaces[1], eFaces[2]), -1.0);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::pairPatchAgglomeration::pairPatchAgglomeration
(
const polyPatch& patch,
const dictionary& controlDict,
const bool additionalWeights
)
:
mergeLevels_
(
controlDict.lookupOrDefault<label>("mergeLevels", 2)
),
maxLevels_(50),
nFacesInCoarsestLevel_
(
readLabel(controlDict.lookup("nFacesInCoarsestLevel"))
),
featureAngle_
(
controlDict.lookupOrDefault<scalar>("featureAngle", 0)
),
nFaces_(maxLevels_),
restrictAddressing_(maxLevels_),
restrictTopBottomAddressing_(identity(patch.size())),
patchLevels_(maxLevels_),
facePairWeight_(patch.size())
{
// Set base fine patch
patchLevels_.set
(
0,
new bPatch
(
patch.localFaces(),
patch.localPoints()
)
);
// Set number of faces for the base patch
nFaces_[0] = patch.size();
// Set edge weights for level 0
setBasedEdgeWeights();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::pairPatchAgglomeration::~pairPatchAgglomeration()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::bPatch& Foam::pairPatchAgglomeration::patchLevel
(
const label i
) const
{
return patchLevels_[i];
}
void Foam::pairPatchAgglomeration::mapBaseToTopAgglom
(
const label fineLevelIndex
)
{
const labelList& fineToCoarse = restrictAddressing_[fineLevelIndex];
forAll (restrictTopBottomAddressing_, i)
{
restrictTopBottomAddressing_[i] =
fineToCoarse[restrictTopBottomAddressing_[i]];
}
}
bool Foam::pairPatchAgglomeration::agglomeratePatch
(
const bPatch& patch,
const labelList& fineToCoarse,
const label fineLevelIndex
)
{
if (min(fineToCoarse) == -1)
{
FatalErrorIn("pairPatchAgglomeration::agglomeratePatch")
<< "min(fineToCoarse) == -1" << exit(FatalError);
}
if (fineToCoarse.size() != patch.size())
{
FatalErrorIn
(
"pairPatchAgglomeration::agglomeratePatch"
"(const label fineLevelIndex)"
) << "restrict map does not correspond to fine level. " << endl
<< " Sizes: restrictMap: " << fineToCoarse.size()
<< " nEqns: " << patch.size()
<< abort(FatalError);
}
const label nCoarseI = max(fineToCoarse)+1;
List<face> patchFaces(nCoarseI);
// Patch faces per agglomeration
labelListList coarseToFine
(
invertOneToMany(nCoarseI, fineToCoarse)
);
for (label coarseI = 0; coarseI < nCoarseI; coarseI++)
{
const labelList& fineFaces = coarseToFine[coarseI];
// Construct single face
indirectPrimitivePatch upp
(
IndirectList<face>(patch, fineFaces),
patch.points()
);
if (upp.edgeLoops().size() != 1)
{
if (fineFaces.size() == 2)
{
const edge e(fineFaces[0], fineFaces[1]);
facePairWeight_[e] = -1.0;
}
else if (fineFaces.size() == 3)
{
const edge e(fineFaces[0], fineFaces[1]);
const edge e1(fineFaces[0], fineFaces[2]);
const edge e2(fineFaces[2], fineFaces[1]);
facePairWeight_[e] = -1.0;
facePairWeight_[e1] = -1.0;
facePairWeight_[e2] = -1.0;
}
return false;
}
patchFaces[coarseI] = face
(
renumber
(
upp.meshPoints(),
upp.edgeLoops()[0]
)
);
}
patchLevels_.set
(
fineLevelIndex,
new bPatch
(
SubList<face>(patchFaces, nCoarseI, 0),
patch.points()
)
);
return true;
}
void Foam::pairPatchAgglomeration:: agglomerate()
{
label nPairLevels = 0;
label nCreatedLevels = 1; //0 level is the base patch
while (nCreatedLevels < maxLevels_)
{
label nCoarseCells = -1;
const bPatch& patch = patchLevels_[nCreatedLevels - 1];
tmp<labelField> finalAgglomPtr(new labelField(patch.size()));
bool agglomOK = false;
while (!agglomOK)
{
finalAgglomPtr = agglomerateOneLevel
(
nCoarseCells,
patch
);
agglomOK = agglomeratePatch
(
patch,
finalAgglomPtr,
nCreatedLevels
);
}
nFaces_[nCreatedLevels] = nCoarseCells;
restrictAddressing_.set(nCreatedLevels, finalAgglomPtr);
mapBaseToTopAgglom(nCreatedLevels);
if(!continueAgglomerating(nCoarseCells))
{
break;
}
setEdgeWeights(nCreatedLevels);
if (nPairLevels % mergeLevels_)
{
combineLevels(nCreatedLevels);
}
else
{
nCreatedLevels++;
}
nPairLevels++;
}
}
Foam::tmp<Foam::labelField> Foam::pairPatchAgglomeration::agglomerateOneLevel
(
label& nCoarseCells,
const bPatch& patch
)
{
const label nFineFaces = patch.size();
tmp<labelField> tcoarseCellMap(new labelField(nFineFaces, -1));
labelField& coarseCellMap = tcoarseCellMap();
const labelListList& faceFaces = patch.faceFaces();
nCoarseCells = 0;
forAll (faceFaces, facei)
{
const labelList& fFaces = faceFaces[facei];
if (coarseCellMap[facei] < 0)
{
label matchFaceNo = -1;
label matchFaceNeibNo = -1;
scalar maxFaceWeight = -GREAT;
// check faces to find ungrouped neighbour with largest face weight
forAll(fFaces, i)
{
label faceNeig = fFaces[i];
const edge edgeCommon = edge(facei, faceNeig);
if
(
facePairWeight_[edgeCommon] > maxFaceWeight
&& coarseCellMap[faceNeig] < 0
&& facePairWeight_[edgeCommon] != -1.0
)
{
// Match found. Pick up all the necessary data
matchFaceNo = facei;
matchFaceNeibNo = faceNeig;
maxFaceWeight = facePairWeight_[edgeCommon];
}
}
if (matchFaceNo >= 0)
{
// Make a new group
coarseCellMap[matchFaceNo] = nCoarseCells;
coarseCellMap[matchFaceNeibNo] = nCoarseCells;
nCoarseCells++;
}
else
{
// No match. Find the best neighbouring cluster and
// put the cell there
label clusterMatchFaceNo = -1;
scalar clusterMaxFaceCoeff = -GREAT;
forAll(fFaces, i)
{
label faceNeig = fFaces[i];
const edge edgeCommon = edge(facei, faceNeig);
if
(
facePairWeight_[edgeCommon] > clusterMaxFaceCoeff
&& facePairWeight_[edgeCommon] != -1.0
&& coarseCellMap[faceNeig] > 0
)
{
clusterMatchFaceNo = faceNeig;
clusterMaxFaceCoeff = facePairWeight_[edgeCommon];
}
}
if (clusterMatchFaceNo >= 0)
{
// Add the cell to the best cluster
coarseCellMap[facei] = coarseCellMap[clusterMatchFaceNo];
}
else
{// if not create single-cell "clusters" for each
coarseCellMap[facei] = nCoarseCells;
nCoarseCells ++;
}
}
}
}
// Check that all faces are part of clusters,
for (label facei=0; facei<nFineFaces; facei++)
{
if (coarseCellMap[facei] < 0)
{
FatalErrorIn
(
"pairPatchAgglomeration::agglomerateOneLevel "
"(label&, const bPatch&) "
) << " face " << facei
<< " is not part of a cluster"
<< exit(FatalError);
}
}
return tcoarseCellMap;
}
void Foam::pairPatchAgglomeration::combineLevels(const label curLevel)
{
label prevLevel = curLevel - 1;
// Set the previous level nCells to the current
nFaces_[prevLevel] = nFaces_[curLevel];
// Map the restrictAddressing from the coarser level into the previous
// finer level
const labelList& curResAddr = restrictAddressing_[curLevel];
labelList& prevResAddr = restrictAddressing_[prevLevel];
forAll(prevResAddr, i)
{
prevResAddr[i] = curResAddr[prevResAddr[i]];
}
// Delete the restrictAddressing for the coarser level
restrictAddressing_.set(curLevel, NULL);
patchLevels_.set(prevLevel, patchLevels_.set(curLevel, NULL));
}
// ************************************************************************* //

View File

@ -0,0 +1,221 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
Foam::pairPatchAgglomeration
Description
Primitive patch pair agglomerate method.
SourceFiles
pairPatchAgglomeration.C
\*---------------------------------------------------------------------------*/
#ifndef pairPatchAgglomeration_H
#define pairPatchAgglomeration_H
#include "mathematicalConstants.H"
#include "polyPatch.H"
#include "indirectPrimitivePatch.H"
#include "List.H"
#include "EdgeMap.H"
namespace Foam
{
typedef PrimitivePatch<face, List, const pointField> bPatch;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class pairPatchAgglomeration Declaration
\*---------------------------------------------------------------------------*/
class pairPatchAgglomeration
{
protected:
// Protected data
//- Number of levels to merge, 1 = don't merge, 2 = merge pairs etc.
label mergeLevels_;
//- Max number of levels
label maxLevels_;
//- Number of faces in coarsest level
label nFacesInCoarsestLevel_;
//- Feature angle
scalar featureAngle_;
//- The number of faces in each level
labelList nFaces_;
//- Cell restriction addressing array.
// Maps from the finer to coarse level
PtrList<labelField> restrictAddressing_;
//- Maps from finest to coarsest
labelList restrictTopBottomAddressing_;
//- Hierarchy of patch addressing
PtrList<bPatch> patchLevels_;
//- Edge weights
EdgeMap<scalar> facePairWeight_;
private:
// Private Member Functions
//- Assemble coarse patch
bool agglomeratePatch
(
const bPatch& patch,
const labelList& fineToCoarse,
const label fineLevelIndex
);
//- Agglomerate one level
tmp<labelField> agglomerateOneLevel
(
label& nCoarseCells,
const bPatch& patchLevel
);
//- Combine leves
void combineLevels(const label curLevel);
//- Shrink the number of levels to that specified
void compactLevels(const label fineLevelIndex);
//- Check the need for further agglomeration
bool continueAgglomerating(const label fineLevelIndex);
//- Set edge weights
void setEdgeWeights(const label indexLevel);
//- Set base patch edge weights
void setBasedEdgeWeights();
//- Maps current level with base patch
void mapBaseToTopAgglom(const label fineLevelIndex);
//- Disallow default bitwise copy construct
pairPatchAgglomeration(const pairPatchAgglomeration&);
//- Disallow default bitwise assignment
void operator=(const pairPatchAgglomeration&);
public:
// Constructors
//- Construct given mesh and controls
pairPatchAgglomeration
(
const polyPatch& patch,
const dictionary& controlDict,
const bool additionalWeights = false
);
// Destructor
~pairPatchAgglomeration();
// Member Functions
//- Agglomerate patch
void agglomerate();
// Access
//- Return size
label size() const
{
return patchLevels_.size();
}
//- Return restriction from top level to bottom level
const labelList& restrictTopBottomAddressing() const
{
return restrictTopBottomAddressing_;
}
//- Return primitivePatch of given level
const bPatch& patchLevel(const label leveli) const;
//- Return cell restrict addressing of given level
const labelField& restrictAddressing(const label leveli) const
{
return restrictAddressing_[leveli];
}
// Restriction and prolongation
//- Restrict (integrate by summation) cell field
template<class Type>
void restrictField
(
Field<Type>& cf,
const Field<Type>& ff,
const label fineLevelIndex
) const;
//- Prolong (interpolate by injection) cell field
template<class Type>
void prolongField
(
Field<Type>& ff,
const Field<Type>& cf,
const label coarseLevelIndex
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "pairPatchAgglomerationTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -21,62 +21,58 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Application
buoyantSimpleFoam
Description
Steady-state solver for buoyant, turbulent flow of compressible fluids
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "basicPsiThermo.H"
#include "RASModel.H"
#include "fixedGradientFvPatchFields.H"
#include "pairPatchAgglomeration.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
template<class Type>
void Foam::pairPatchAgglomeration::restrictField
(
Field<Type>& cf,
const Field<Type>& ff,
const label fineLevelIndex
) const
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "readGravitationalAcceleration.H"
#include "createFields.H"
#include "initContinuityErrs.H"
const labelList& fineToCoarse = restrictAddressing_[fineLevelIndex];
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nStarting time loop\n" << endl;
while (runTime.loop())
if (ff.size() != fineToCoarse.size())
{
Info<< "Time = " << runTime.timeName() << nl << endl;
#include "readSIMPLEControls.H"
p.storePrevIter();
rho.storePrevIter();
// Pressure-velocity SIMPLE corrector
{
#include "UEqn.H"
#include "hEqn.H"
#include "pEqn.H"
}
turbulence->correct();
runTime.write();
Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"
<< nl << endl;
FatalErrorIn
(
"void pairPatchAgglomeration::restrictField"
"(Field<Type>& cf, const Field<Type>& ff, "
"const label fineLevelIndex) const"
) << "field does not correspond to level " << fineLevelIndex
<< " sizes: field = " << ff.size()
<< " level = " << fineToCoarse.size()
<< abort(FatalError);
}
Info<< "End\n" << endl;
cf = pTraits<Type>::zero;
return 0;
forAll(ff, i)
{
cf[fineToCoarse[i]] += ff[i];
}
}
template<class Type>
void Foam::pairPatchAgglomeration::prolongField
(
Field<Type>& ff,
const Field<Type>& cf,
const label coarseLevelIndex
) const
{
const labelList& fineToCoarse = restrictAddressing_[coarseLevelIndex];
forAll(fineToCoarse, i)
{
ff[i] = cf[fineToCoarse[i]];
}
}

View File

@ -49,7 +49,10 @@ Foam::label Foam::PatchInjection<CloudType>::parcelsToInject
if
(
nParcelsToInject > 0
&& (nParcels - scalar(nParcelsToInject) > rnd.position(0.0, 1.0))
&& (
nParcels - scalar(nParcelsToInject)
> rnd.position(scalar(0), scalar(1))
)
)
{
++nParcelsToInject;

View File

@ -7,6 +7,7 @@ radiationModel/fvDOM/fvDOM/fvDOM.C
radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C
radiationModel/fvDOM/blackBodyEmission/blackBodyEmission.C
radiationModel/fvDOM/absorptionCoeffs/absorptionCoeffs.C
radiationModel/viewFactor/viewFactor.C
/* Scatter model */
submodels/scatterModel/scatterModel/scatterModel.C
@ -29,5 +30,8 @@ derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C
derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C
derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C
derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C
derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C
derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
LIB = $(FOAM_LIBBIN)/libradiationModels

View File

@ -1,8 +1,27 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/SLGThermo/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/liquidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/properties/solidMixtureProperties/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude
LIB_LIBS = \
-lfiniteVolume \
-lbasicThermophysicalModels \
-lspecie
-lspecie \
-lbasicSolidThermo \
-lmeshTools \
-lSLGThermo \
-lsolidMixtureProperties \
-lliquidMixtureProperties \
-lsolidProperties \
-lliquidProperties

View File

@ -41,8 +41,8 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
TName_("undefined"),
emissivity_(0.0)
radiationCoupledBase(p, "undefined", scalarField::null()),
TName_("undefined")
{
refValue() = 0.0;
refGrad() = 0.0;
@ -59,8 +59,13 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
p,
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -72,8 +77,8 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
TName_(dict.lookup("T")),
emissivity_(readScalar(dict.lookup("emissivity")))
radiationCoupledBase(p, dict),
TName_(dict.lookup("T"))
{
if (dict.found("value"))
{
@ -99,8 +104,13 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -111,8 +121,13 @@ Foam::MarshakRadiationFvPatchScalarField::MarshakRadiationFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, iF),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -155,7 +170,7 @@ void Foam::MarshakRadiationFvPatchScalarField::updateCoeffs()
const scalarField& gamma =
patch().lookupPatchField<volScalarField, scalar>("gammaRad");
const scalar Ep = emissivity_/(2.0*(2.0 - emissivity_));
const scalarField Ep = emissivity()/(2.0*(2.0 - emissivity()));
// Set value fraction
valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep);
@ -167,8 +182,8 @@ void Foam::MarshakRadiationFvPatchScalarField::updateCoeffs()
void Foam::MarshakRadiationFvPatchScalarField::write(Ostream& os) const
{
mixedFvPatchScalarField::write(os);
radiationCoupledBase::write(os);
os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
}

View File

@ -37,6 +37,7 @@ SourceFiles
#define MarshakRadiationMixedFvPatchField_H
#include "mixedFvPatchFields.H"
#include "radiationCoupledBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +50,8 @@ namespace Foam
class MarshakRadiationFvPatchScalarField
:
public mixedFvPatchScalarField
public mixedFvPatchScalarField,
public radiationCoupledBase
{
// Private data
@ -57,9 +59,6 @@ class MarshakRadiationFvPatchScalarField
//- Name of temperature field
word TName_;
//- Emissivity
scalar emissivity_;
public:
@ -146,18 +145,6 @@ public:
return TName_;
}
//- Return the emissivity
scalar emissivity() const
{
return emissivity_;
}
//- Return reference to the emissivity to allow adjustment
scalar& emissivity()
{
return emissivity_;
}
// Mapping functions

View File

@ -42,8 +42,8 @@ MarshakRadiationFixedTMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
Trad_(p.size()),
emissivity_(0.0)
radiationCoupledBase(p, "undefined", scalarField::null()),
Trad_(p.size())
{
refValue() = 0.0;
refGrad() = 0.0;
@ -61,8 +61,13 @@ MarshakRadiationFixedTMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
Trad_(ptf.Trad_, mapper),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
p,
ptf.emissivityMethod(),
ptf.emissivity_
),
Trad_(ptf.Trad_, mapper)
{}
@ -75,8 +80,8 @@ MarshakRadiationFixedTMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
Trad_("Trad", dict, p.size()),
emissivity_(readScalar(dict.lookup("emissivity")))
radiationCoupledBase(p, dict),
Trad_("Trad", dict, p.size())
{
// refValue updated on each call to updateCoeffs()
refValue() = 4.0*constant::physicoChemical::sigma.value()*pow4(Trad_);
@ -97,8 +102,13 @@ MarshakRadiationFixedTMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf),
Trad_(ptf.Trad_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
Trad_(ptf.Trad_)
{}
@ -110,8 +120,13 @@ MarshakRadiationFixedTMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, iF),
Trad_(ptf.Trad_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
Trad_(ptf.Trad_)
{}
@ -156,7 +171,7 @@ void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::updateCoeffs()
const scalarField& gamma =
patch().lookupPatchField<volScalarField, scalar>("gammaRad");
const scalar Ep = emissivity_/(2.0*(2.0 - emissivity_));
const scalarField Ep = emissivity()/(2.0*(scalar(2.0) - emissivity()));
// Set value fraction
valueFraction() = 1.0/(1.0 + gamma*patch().deltaCoeffs()/Ep);
@ -171,8 +186,8 @@ void Foam::MarshakRadiationFixedTMixedFvPatchScalarField::write
) const
{
mixedFvPatchScalarField::write(os);
radiationCoupledBase::write(os);
Trad_.writeEntry("Trad", os);
os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
}

View File

@ -37,6 +37,7 @@ SourceFiles
#define MarshakRadiationFixedTMixedFvPatchField_H
#include "mixedFvPatchFields.H"
#include "radiationCoupledBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,7 +50,8 @@ namespace Foam
class MarshakRadiationFixedTMixedFvPatchScalarField
:
public mixedFvPatchScalarField
public mixedFvPatchScalarField,
public radiationCoupledBase
{
// Private data
@ -57,9 +59,6 @@ class MarshakRadiationFixedTMixedFvPatchScalarField
//- Radiation temperature field
scalarField Trad_;
//- Emissivity
scalar emissivity_;
public:
@ -146,18 +145,6 @@ public:
return Trad_;
}
//- Return the emissivity
scalar emissivity() const
{
return emissivity_;
}
//- Return reference to the emissivity to allow adjustment
scalar& emissivity()
{
return emissivity_;
}
// Mapping functions

View File

@ -44,8 +44,8 @@ greyDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
TName_("undefinedT"),
emissivity_(0.0)
radiationCoupledBase(p, "undefined", scalarField::null()),
TName_("undefinedT")
{
refValue() = 0.0;
refGrad() = 0.0;
@ -63,8 +63,13 @@ greyDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
p,
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -77,8 +82,8 @@ greyDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
TName_(dict.lookup("T")),
emissivity_(readScalar(dict.lookup("emissivity")))
radiationCoupledBase(p, dict),
TName_(dict.lookup("T"))
{
if (dict.found("refValue"))
{
@ -98,7 +103,7 @@ greyDiffusiveRadiationMixedFvPatchScalarField
patch().lookupPatchField<volScalarField, scalar>(TName_);
refValue() =
emissivity_*4.0*physicoChemical::sigma.value()*pow4(Tp)/pi;
4.0*physicoChemical::sigma.value()*pow4(Tp)*emissivity()/pi;
refGrad() = 0.0;
valueFraction() = 1.0;
@ -114,8 +119,13 @@ greyDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -127,8 +137,13 @@ greyDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, iF),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -202,8 +217,9 @@ updateCoeffs()
valueFraction()[faceI] = 1.0;
refValue()[faceI] =
(
Ir*(1.0 - emissivity_)
+ emissivity_*physicoChemical::sigma.value()*pow4(Tp[faceI])
Ir*(scalar(1.0) - emissivity()()[faceI])
+ emissivity()()[faceI]*physicoChemical::sigma.value()
* pow4(Tp[faceI])
)/pi;
}
else
@ -225,8 +241,8 @@ void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write
) const
{
mixedFvPatchScalarField::write(os);
radiationCoupledBase::write(os);
os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
}

View File

@ -36,6 +36,7 @@ SourceFiles
#define greyDiffusiveRadiationMixedFvPatchScalarField_H
#include "mixedFvPatchFields.H"
#include "radiationCoupledBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,16 +50,14 @@ namespace radiation
class greyDiffusiveRadiationMixedFvPatchScalarField
:
public mixedFvPatchScalarField
public mixedFvPatchScalarField,
public radiationCoupledBase
{
// Private data
//- Name of temperature field
word TName_;
//- Emissivity
scalar emissivity_;
public:
@ -145,18 +144,6 @@ public:
return TName_;
}
//- Return the emissivity
scalar emissivity() const
{
return emissivity_;
}
//- Return reference to the emissivity to allow adjustment
scalar& emissivity()
{
return emissivity_;
}
// Evaluation functions

View File

@ -0,0 +1,182 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "greyDiffusiveViewFactorFixedValueFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF),
radiationCoupledBase(patch(), "undefined", scalarField::null()),
Qro_(p.size(), 0.0)
{}
Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const greyDiffusiveViewFactorFixedValueFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper),
radiationCoupledBase
(
patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
Qro_(ptf.Qro_)
{}
Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF),
radiationCoupledBase(p, dict),
Qro_("Qro", dict, p.size())
{
if (dict.found("value"))
{
fvPatchScalarField::operator=
(
scalarField("value", dict, p.size())
);
}
else
{
fvPatchScalarField::operator=(0.0);
}
}
Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const greyDiffusiveViewFactorFixedValueFvPatchScalarField& ptf
)
:
fixedValueFvPatchScalarField(ptf),
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
Qro_(ptf.Qro_)
{}
Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const greyDiffusiveViewFactorFixedValueFvPatchScalarField& ptf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(ptf, iF),
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
Qro_(ptf.Qro_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
updateCoeffs()
{
//Do nothing
if (debug)
{
scalar Q = gSum((*this)*patch().magSf());
Info<< patch().boundaryMesh().mesh().name() << ':'
<< patch().name() << ':'
<< this->dimensionedInternalField().name() << " <- "
<< " heat[W]:" << Q
<< " wall radiative heat flux "
<< " min:" << gMin(*this)
<< " max:" << gMax(*this)
<< " avg:" << gAverage(*this)
<< endl;
}
}
void Foam::radiation::greyDiffusiveViewFactorFixedValueFvPatchScalarField::
write
(
Ostream& os
) const
{
fixedValueFvPatchScalarField::write(os);
radiationCoupledBase::write(os);
Qro_.writeEntry("Qro", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
makePatchTypeField
(
fvPatchScalarField,
greyDiffusiveViewFactorFixedValueFvPatchScalarField
);
}
}
// ************************************************************************* //

View File

@ -0,0 +1,167 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
Foam::greyDiffusiveViewFactorFixedValueFvPatchScalarField
Description
Radiation temperature specified
SourceFiles
greyDiffusiveViewFactorFixedValueFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef greyDiffusiveViewFactorFixedValueFvPatchScalarField_H
#define greyDiffusiveViewFactorFixedValueFvPatchScalarField_H
#include "radiationCoupledBase.H"
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class greyDiffusiveViewFactorFixedValueFvPatchScalarField declaration
\*---------------------------------------------------------------------------*/
class greyDiffusiveViewFactorFixedValueFvPatchScalarField
:
public fixedValueFvPatchScalarField,
public radiationCoupledBase
{
// Private data
//- External radiative heat flux
scalarField Qro_;
public:
//- Runtime type information
TypeName("greyDiffusiveRadiationViewFactor");
// Constructors
//- Construct from patch and internal field
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given a
// greyDiffusiveViewFactorFixedValueFvPatchScalarField onto a new patch
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const greyDiffusiveViewFactorFixedValueFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const greyDiffusiveViewFactorFixedValueFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new greyDiffusiveViewFactorFixedValueFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
const greyDiffusiveViewFactorFixedValueFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new greyDiffusiveViewFactorFixedValueFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
// Access
//- Return external radiative heat flux
const scalarList& Qro()
{
return Qro_;
}
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
// I-O
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,208 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "radiationCoupledBase.H"
#include "volFields.H"
#include "basicSolidThermo.H"
#include "directMappedPatchBase.H"
#include "fvPatchFieldMapper.H"
// * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum
<
Foam::radiationCoupledBase::emissivityMethodType,
2
>::names[] =
{
"solidThermo",
"lookup"
};
}
const Foam::NamedEnum<Foam::radiationCoupledBase::emissivityMethodType, 2>
Foam::radiationCoupledBase::emissivityMethodTypeNames_;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiationCoupledBase::radiationCoupledBase
(
const fvPatch& patch,
const word& calculationType,
const scalarField& emissivity
)
:
patch_(patch),
method_(emissivityMethodTypeNames_[calculationType]),
emissivity_(emissivity)
{}
Foam::radiationCoupledBase::radiationCoupledBase
(
const fvPatch& patch,
const dictionary& dict
)
:
patch_(patch),
method_(emissivityMethodTypeNames_.read(dict.lookup("emissivityMode")))
{
switch (method_)
{
case SOLIDTHERMO:
{
if (!isA<directMappedPatchBase>(patch_.patch()))
{
FatalErrorIn
(
"radiationCoupledBase::radiationCoupledBase\n"
"(\n"
" const fvPatch& p,\n"
" const dictionary& dict\n"
")\n"
) << "\n patch type '" << patch_.type()
<< "' not type '" << directMappedPatchBase::typeName << "'"
<< "\n for patch " << patch_.name()
<< exit(FatalError);
}
emissivity_ = scalarField(patch_.size(), 0.0);
}
break;
case LOOKUP:
{
if(!dict.found("emissivity"))
{
FatalErrorIn
(
"radiationCoupledBase::radiationCoupledBase\n"
"(\n"
" const fvPatch& p,\n"
" const dictionary& dict\n"
")\n"
) << "\n emissivity key does not exist for patch "
<< patch_.name()
<< exit(FatalError);
}
else
{
emissivity_ = scalarField("emissivity", dict, patch_.size());
}
}
break;
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::tmp<Foam::scalarField> Foam::radiationCoupledBase::emissivity() const
{
switch (method_)
{
case SOLIDTHERMO:
{
// Get the coupling information from the directMappedPatchBase
const directMappedPatchBase& mpp =
refCast<const directMappedPatchBase>
(
patch_.patch()
);
const polyMesh& nbrMesh = mpp.sampleMesh();
const fvPatch& nbrPatch = refCast<const fvMesh>
(
nbrMesh
).boundary()[mpp.samplePolyPatch().index()];
if (nbrMesh.foundObject<volScalarField>("emissivity"))
{
tmp<scalarField> temissivity
(
new scalarField
(
nbrPatch.lookupPatchField<volScalarField, scalar>
(
"emissivity"
)
)
);
scalarField& emissivity = temissivity();
// Use direct map mapping to exchange data
mpp.map().distribute(emissivity);
return temissivity;
}
else
{
return scalarField(0);
}
}
break;
case LOOKUP:
{
// return local value
return emissivity_;
}
default:
{
FatalErrorIn
(
"radiationCoupledBase::emissivity(const scalarField&)"
)
<< "Unimplemented method " << method_ << endl
<< "Please set 'emissivity' to one of "
<< emissivityMethodTypeNames_.toc()
<< " and 'emissivityName' to the name of the volScalar"
<< exit(FatalError);
}
break;
}
return scalarField(0);
}
void Foam::radiationCoupledBase::write(Ostream& os) const
{
os.writeKeyword("emissivityMode") << emissivityMethodTypeNames_[method_]
<< token::END_STATEMENT << nl;
emissivity_.writeEntry("emissivity", os);
}
// ************************************************************************* //

View File

@ -0,0 +1,132 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
radiationCoupledBase
Description
Common functions to emissivity. It gets supplied from lookup into a
dictionary or calculated by the solidThermo:
- 'lookup' : lookup volScalarField with name
- 'solidThermo' : use basicSolidThermo emissivity()
SourceFiles
radiationCoupledBase.C
\*---------------------------------------------------------------------------*/
#ifndef radiationCoupledBase_H
#define radiationCoupledBase_H
#include "scalarField.H"
#include "NamedEnum.H"
#include "fvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class radiationCoupledBase Declaration
\*---------------------------------------------------------------------------*/
class radiationCoupledBase
{
public:
//- Type of supplied emissivity
enum emissivityMethodType
{
SOLIDTHERMO,
LOOKUP
};
private:
// Private data
static const NamedEnum<emissivityMethodType, 2>
emissivityMethodTypeNames_;
//- Underlying patch
const fvPatch& patch_;
protected:
// Protected data
//- How to get emissivity
const emissivityMethodType method_;
//- Emissivity
// Cached locally when is read from dictionary (lookup mode)
scalarField emissivity_;
public:
// Constructors
//- Construct from patch, emissivity mode and emissivity
radiationCoupledBase
(
const fvPatch& patch,
const word& calculationMethod,
const scalarField& emissivity
);
//- Construct from patch and dictionary
radiationCoupledBase
(
const fvPatch& patch,
const dictionary& dict
);
// Member functions
//- Method to obtain emissivity
word emissivityMethod() const
{
return emissivityMethodTypeNames_[method_];
}
//- Calculate corresponding emissivity field
tmp<scalarField> emissivity() const;
//- Write
void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -45,8 +45,8 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
TName_("undefinedT"),
emissivity_(0.0)
radiationCoupledBase(p, "undefined", scalarField::null()),
TName_("undefinedT")
{
refValue() = 0.0;
refGrad() = 0.0;
@ -64,8 +64,13 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
p,
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -78,8 +83,8 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(p, iF),
TName_(dict.lookup("T")),
emissivity_(readScalar(dict.lookup("emissivity")))
radiationCoupledBase(p, dict),
TName_(dict.lookup("T"))
{
if (dict.found("value"))
{
@ -97,7 +102,7 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
patch().lookupPatchField<volScalarField, scalar>(TName_);
refValue() =
emissivity_*4.0*physicoChemical::sigma.value()*pow4(Tp)/pi;
4.0*physicoChemical::sigma.value()*pow4(Tp)*emissivity()/pi;
refGrad() = 0.0;
fvPatchScalarField::operator=(refValue());
@ -112,8 +117,13 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -125,8 +135,13 @@ wideBandDiffusiveRadiationMixedFvPatchScalarField
)
:
mixedFvPatchScalarField(ptf, iF),
TName_(ptf.TName_),
emissivity_(ptf.emissivity_)
radiationCoupledBase
(
ptf.patch(),
ptf.emissivityMethod(),
ptf.emissivity_
),
TName_(ptf.TName_)
{}
@ -200,8 +215,8 @@ updateCoeffs()
valueFraction()[faceI] = 1.0;
refValue()[faceI] =
(
Ir*(1.0 - emissivity_)
+ emissivity_*Eb[faceI]
Ir*(1.0 - emissivity()()[faceI])
+ emissivity()()[faceI]*Eb[faceI]
)/pi;
}
else
@ -223,8 +238,9 @@ void Foam::radiation::wideBandDiffusiveRadiationMixedFvPatchScalarField::write
) const
{
mixedFvPatchScalarField::write(os);
radiationCoupledBase::write(os);
os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl;
os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl;
}

View File

@ -36,6 +36,7 @@ SourceFiles
#define wideBandDiffusiveRadiationMixedFvPatchScalarField_H
#include "mixedFvPatchFields.H"
#include "radiationCoupledBase.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -49,16 +50,14 @@ namespace radiation
class wideBandDiffusiveRadiationMixedFvPatchScalarField
:
public mixedFvPatchScalarField
public mixedFvPatchScalarField,
public radiationCoupledBase
{
// Private data
//- Name of temperature field
word TName_;
//- Emissivity
scalar emissivity_;
public:
@ -145,18 +144,6 @@ public:
return TName_;
}
//- Return the emissivity
scalar emissivity() const
{
return emissivity_;
}
//- Return reference to the emissivity to allow adjustment
scalar& emissivity()
{
return emissivity_;
}
// Evaluation functions

View File

@ -89,7 +89,7 @@ Foam::radiation::P1::P1(const volScalarField& T)
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE
IOobject::AUTO_WRITE
),
mesh_,
dimensionedScalar("a", dimless/dimLength, 0.0)

View File

@ -157,7 +157,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
deltaTheta,
nLambda_,
absorptionEmission_,
blackBody_
blackBody_,
i
)
);
i++;
@ -190,7 +191,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
deltaTheta,
nLambda_,
absorptionEmission_,
blackBody_
blackBody_,
i
)
);
i++;
@ -220,7 +222,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T)
deltaTheta,
nLambda_,
absorptionEmission_,
blackBody_
blackBody_,
i
)
);
i++;

View File

@ -30,9 +30,6 @@ License
using namespace Foam::constant;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
Foam::label Foam::radiation::radiativeIntensityRay::rayId(0);
const Foam::word
Foam::radiation::radiativeIntensityRay::intensityPrefix("ILambda");
@ -50,7 +47,8 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
const scalar deltaTheta,
const label nLambda,
const absorptionEmissionModel& absorptionEmission,
const blackBodyEmission& blackBody
const blackBodyEmission& blackBody,
const label rayId
)
:
dom_(dom),
@ -167,7 +165,6 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
);
}
}
rayId++;
}
@ -182,7 +179,6 @@ Foam::radiation::radiativeIntensityRay::~radiativeIntensityRay()
Foam::scalar Foam::radiation::radiativeIntensityRay::correct()
{
// reset boundary heat flux to zero
//Qr_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0);
Qr_.boundaryField() = 0.0;
scalar maxResidual = -GREAT;

View File

@ -130,7 +130,8 @@ public:
const scalar deltaTheta,
const label lambda,
const absorptionEmissionModel& absEmmModel_,
const blackBodyEmission& blackBody
const blackBodyEmission& blackBody,
const label rayId
);

View File

@ -0,0 +1,641 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "viewFactor.H"
#include "addToRunTimeSelectionTable.H"
#include "constants.H"
#include "greyDiffusiveViewFactorFixedValueFvPatchScalarField.H"
#include "typeInfo.H"
using namespace Foam::constant;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
namespace radiation
{
defineTypeNameAndDebug(viewFactor, 0);
addToRunTimeSelectionTable
(
radiationModel,
viewFactor,
dictionary
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::radiation::viewFactor::viewFactor(const volScalarField& T)
:
radiationModel(typeName, T),
finalAgglom_
(
IOobject
(
"finalAgglom",
mesh_.facesInstance(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
),
map_(),
coarseMesh_
(
IOobject
(
mesh_.name(),
mesh_.polyMesh::instance(),
mesh_.time(),
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh_,
finalAgglom_
),
Qr_
(
IOobject
(
"Qr",
mesh_.time().timeName(),
mesh_,
IOobject::MUST_READ,
IOobject::AUTO_WRITE
),
mesh_
),
Fmatrix_(),
CLU_(),
selectedPatches_(mesh_.boundary().size(), -1),
totalNCoarseFaces_(0),
nLocalCoarseFaces_(0),
constEmissivity_(false),
iterCounter_(0),
pivotIndices_(0)
{
const polyBoundaryMesh& coarsePatches = coarseMesh_.boundaryMesh();
const volScalarField::GeometricBoundaryField& Qrp = Qr_.boundaryField();
label count = 0;
forAll(Qrp, patchI)
{
const polyPatch& pp = mesh_.boundaryMesh()[patchI];
const fvPatchScalarField& QrPatchI = Qrp[patchI];
if ((isA<fixedValueFvPatchScalarField>(QrPatchI)) && (pp.size() > 0))
{
selectedPatches_[count] = QrPatchI.patch().index();
nLocalCoarseFaces_ += coarsePatches[patchI].size();
count ++;
}
}
selectedPatches_.resize(count--);
if (debug)
{
Pout << "SelectedPatches:" << selectedPatches_ << endl;
Pout << "Number of coarse faces:" << nLocalCoarseFaces_ << endl;
}
totalNCoarseFaces_ = nLocalCoarseFaces_;
reduce(totalNCoarseFaces_, sumOp<label>());
if (Pstream::master())
{
Info << "Total number of clusters : " << totalNCoarseFaces_ << endl;
}
labelListIOList subMap
(
IOobject
(
"subMap",
mesh_.facesInstance(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
labelListIOList constructMap
(
IOobject
(
"constructMap",
mesh_.facesInstance(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
IOList<label> consMapDim
(
IOobject
(
"constructMapDim",
mesh_.facesInstance(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
map_.reset
(
new mapDistribute
(
consMapDim[0],
Xfer<labelListList>(subMap),
Xfer<labelListList>(constructMap)
)
);
scalarListIOList FmyProc
(
IOobject
(
"F",
mesh_.facesInstance(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
labelListIOList globalFaceFaces
(
IOobject
(
"globalFaceFaces",
mesh_.facesInstance(),
mesh_,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
List<labelListList> globalFaceFacesProc(Pstream::nProcs());
globalFaceFacesProc[Pstream::myProcNo()] = globalFaceFaces;
Pstream::gatherList(globalFaceFacesProc);
List<scalarListList> F(Pstream::nProcs());
F[Pstream::myProcNo()] = FmyProc;
Pstream::gatherList(F);
globalIndex globalNumbering(nLocalCoarseFaces_);
if (Pstream::master())
{
Fmatrix_.reset
(
new scalarSquareMatrix(totalNCoarseFaces_, totalNCoarseFaces_, 0.0)
);
Info << "Insert elemets in the matrix.." << endl;
for (label procI = 0; procI < Pstream::nProcs(); procI++)
{
insertMatrixElements
(
globalNumbering,
procI,
globalFaceFacesProc[procI],
F[procI],
Fmatrix_()
);
}
bool smoothing = readBool(coeffs_.lookup("smoothing"));
if(smoothing)
{
Info << "Smoothing the matrix..." << endl;
for(label i=0; i<totalNCoarseFaces_; i++)
{
scalar sumF = 0.0;
for(label j=0; j<totalNCoarseFaces_; j++)
{
sumF += Fmatrix_()[i][j];
}
scalar delta = 1.0 - sumF;
for(label j=0; j<totalNCoarseFaces_; j++)
{
Fmatrix_()[i][j] *= (1.0 - delta/(sumF + 0.001));
}
}
}
constEmissivity_ = readBool(coeffs_.lookup("constantEmissivity"));
if (constEmissivity_)
{
CLU_.reset
(
new scalarSquareMatrix
(
totalNCoarseFaces_,
totalNCoarseFaces_,
0.0
)
);
pivotIndices_.setSize(CLU_().n());
}
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::viewFactor::~viewFactor()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::radiation::viewFactor::read()
{
if (radiationModel::read())
{
return true;
}
else
{
return false;
}
}
void Foam::radiation::viewFactor::insertMatrixElements
(
const globalIndex& globalNumbering,
const label procI,
const labelListList& globalFaceFaces,
const scalarListList& viewFactors,
scalarSquareMatrix& Fmatrix
)
{
forAll(viewFactors, faceI)
{
const scalarList& vf = viewFactors[faceI];
const labelList& globalFaces = globalFaceFaces[faceI];
label globalI = globalNumbering.toGlobal(procI, faceI);
forAll(globalFaces, i)
{
Fmatrix[globalI][globalFaces[i]] = vf[i];
}
}
}
void Foam::radiation::viewFactor::calculate()
{
// Store previous iteration
Qr_.storePrevIter();
scalarField compactCoarseT(map_->constructSize(), 0.0);
scalarField compactCoarseE(map_->constructSize(), 0.0);
scalarField compactCoarseHo(map_->constructSize(), 0.0);
globalIndex globalNumbering(nLocalCoarseFaces_);
// Fill local averaged(T), emissivity(E) and external heatFlux(Ho)
DynamicList<scalar> localCoarseTave(nLocalCoarseFaces_);
DynamicList<scalar> localCoarseEave(nLocalCoarseFaces_);
DynamicList<scalar> localCoarseHoave(nLocalCoarseFaces_);
forAll (selectedPatches_, i)
{
label patchID = selectedPatches_[i];
const scalarField& Tp = T_.boundaryField()[patchID];
const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
fvPatchScalarField& QrPatch = Qr_.boundaryField()[patchID];
greyDiffusiveViewFactorFixedValueFvPatchScalarField& Qrp =
refCast
<
greyDiffusiveViewFactorFixedValueFvPatchScalarField
>(QrPatch);
const scalarList eb = Qrp.emissivity();
const scalarList& Hoi = Qrp.Qro();
const polyPatch& pp = coarseMesh_.boundaryMesh()[patchID];
const labelList& coarsePatchFace = coarseMesh_.patchFaceMap()[patchID];
const labelList& agglom = finalAgglom_[patchID];
label nAgglom = max(agglom)+1;
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
scalarList Tave(pp.size(), 0.0);
scalarList Eave(Tave.size(), 0.0);
scalarList Hoiave(Tave.size(), 0.0);
forAll(coarseToFine, coarseI)
{
const label coarseFaceID = coarsePatchFace[coarseI];
const labelList& fineFaces = coarseToFine[coarseFaceID];
UIndirectList<scalar> fineSf
(
sf,
fineFaces
);
scalar area = sum(fineSf());
// Temperature, emissivity and external flux area weighting
forAll(fineFaces, j)
{
label faceI = fineFaces[j];
Tave[coarseI] += (Tp[faceI]*sf[faceI])/area;
Eave[coarseI] += (eb[faceI]*sf[faceI])/area;
Hoiave[coarseI] += (Hoi[faceI]*sf[faceI])/area;
}
localCoarseTave.append(Tave[coarseI]);
localCoarseEave.append(Eave[coarseI]);
localCoarseHoave.append(Hoiave[coarseI]);
}
}
// Fill the local values to distribute
SubList<scalar>(compactCoarseT,nLocalCoarseFaces_).assign(localCoarseTave);
SubList<scalar>(compactCoarseE,nLocalCoarseFaces_).assign(localCoarseEave);
SubList<scalar>
(compactCoarseHo,nLocalCoarseFaces_).assign(localCoarseHoave);
// Distribute data
map_->distribute(compactCoarseT);
map_->distribute(compactCoarseE);
map_->distribute(compactCoarseHo);
// Distribute local global ID
labelList compactGlobalIds(map_->constructSize(), 0.0);
labelList localGlobalIds(nLocalCoarseFaces_);
for (label k = 0; k < nLocalCoarseFaces_; k++)
{
localGlobalIds[k] = globalNumbering.toGlobal(Pstream::myProcNo(), k);
}
SubList<label>
(
compactGlobalIds,
nLocalCoarseFaces_
).assign(localGlobalIds);
map_->distribute(compactGlobalIds);
// Create global size vectors
scalarField T(totalNCoarseFaces_, 0.0);
scalarField E(totalNCoarseFaces_, 0.0);
scalarField QrExt(totalNCoarseFaces_, 0.0);
// Fill lists from compact to global indexes.
forAll(compactCoarseT, i)
{
T[compactGlobalIds[i]] = compactCoarseT[i];
E[compactGlobalIds[i]] = compactCoarseE[i];
QrExt[compactGlobalIds[i]] = compactCoarseHo[i];
}
Pstream::listCombineGather(T, maxEqOp<scalar>());
Pstream::listCombineGather(E, maxEqOp<scalar>());
Pstream::listCombineGather(QrExt, maxEqOp<scalar>());
Pstream::listCombineScatter(T);
Pstream::listCombineScatter(E);
Pstream::listCombineScatter(QrExt);
// Net radiation
scalarField q(totalNCoarseFaces_, 0.0);
if (Pstream::master())
{
// Variable emissivity
if (!constEmissivity_)
{
scalarSquareMatrix C(totalNCoarseFaces_, totalNCoarseFaces_, 0.0);
for (label i=0; i<totalNCoarseFaces_; i++)
{
for (label j=0; j<totalNCoarseFaces_; j++)
{
scalar invEj = 1.0/E[j];
scalar sigmaT4 =
physicoChemical::sigma.value()*pow(T[j], 4.0);
if (i==j)
{
C[i][j] = invEj - (invEj - 1.0)*Fmatrix_()[i][j];
q[i] += (Fmatrix_()[i][j] - 1.0)*sigmaT4 - QrExt[j];
}
else
{
C[i][j] = (1.0 - invEj)*Fmatrix_()[i][j];
q[i] += Fmatrix_()[i][j]*sigmaT4 - QrExt[j];
}
}
}
Info<< "\nSolving view factor equations.." << endl;
// Negative coming into the fluid
LUsolve(C, q);
}
else //Constant emissivity
{
// Initial iter calculates CLU and chaches it
if(iterCounter_ == 0)
{
for (label i=0; i<totalNCoarseFaces_; i++)
{
for (label j=0; j<totalNCoarseFaces_; j++)
{
scalar invEj = 1.0/E[j];
if (i==j)
{
CLU_()[i][j] = invEj - (invEj-1.0)*Fmatrix_()[i][j];
}
else
{
CLU_()[i][j] = (1.0 - invEj)*Fmatrix_()[i][j];
}
}
}
Info<< "\nDecomposing C matrix.." << endl;
LUDecompose(CLU_(), pivotIndices_);
}
for (label i=0; i<totalNCoarseFaces_; i++)
{
for (label j=0; j<totalNCoarseFaces_; j++)
{
scalar sigmaT4 =
constant::physicoChemical::sigma.value()
*pow(T[j], 4.0);
if (i==j)
{
q[i] += (Fmatrix_()[i][j] - 1.0)*sigmaT4 - QrExt[j];
}
else
{
q[i] += Fmatrix_()[i][j]*sigmaT4 - QrExt[j];
}
}
}
Info<< "\nLU Back substitute C matrix.." << endl;
LUBacksubstitute(CLU_(), pivotIndices_, q);
iterCounter_ ++;
}
}
// Scatter q and fill Qr
Pstream::listCombineScatter(q);
Pstream::listCombineGather(q, maxEqOp<scalar>());
label globCoarseId = 0;
forAll (selectedPatches_, i)
{
const label patchID = selectedPatches_[i];
scalarField& Qrp = Qr_.boundaryField()[patchID];
const scalarField& sf = mesh_.magSf().boundaryField()[patchID];
const labelList& agglom = finalAgglom_[patchID];
label nAgglom = max(agglom)+1;
labelListList coarseToFine(invertOneToMany(nAgglom, agglom));
const labelList& coarsePatchFace = coarseMesh_.patchFaceMap()[patchID];
scalar heatFlux = 0.0;
forAll(coarseToFine, coarseI)
{
label globalCoarse =
globalNumbering.toGlobal(Pstream::myProcNo(), globCoarseId);
const label coarseFaceID = coarsePatchFace[coarseI];
const labelList& fineFaces = coarseToFine[coarseFaceID];
forAll(fineFaces, k)
{
label faceI = fineFaces[k];
Qrp[faceI] = q[globalCoarse];
heatFlux += Qrp[faceI]*sf[faceI];
}
globCoarseId ++;
}
}
if (debug)
{
forAll(Qr_.boundaryField(), patchID)
{
const scalarField& Qrp = Qr_.boundaryField()[patchID];
const scalarField& magSf = mesh_.magSf().boundaryField()[patchID];
scalar heatFlux = gSum(Qrp*magSf);
Info << "Total heat flux at patch: "
<< patchID << " "
<< heatFlux << " [W]" << endl;
}
}
// Relax Qr if necessary
Qr_.relax();
}
Foam::tmp<Foam::volScalarField> Foam::radiation::viewFactor::Rp() const
{
return tmp<volScalarField>
(
new volScalarField
(
IOobject
(
"Rp",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar
(
"zero",
dimMass/pow3(dimTime)/dimLength/pow4(dimTemperature),
0.0
)
)
);
}
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh> >
Foam::radiation::viewFactor::Ru() const
{
tmp<DimensionedField<scalar, volMesh> > tRu
(
new DimensionedField<scalar, volMesh>
(
IOobject
(
"tRu",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
mesh_,
dimensionedScalar("zero", dimMass/dimLength/pow3(dimTime), 0.0)
)
);
return tRu;
}
// ************************************************************************* //

View File

@ -0,0 +1,180 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>.
Class
Foam::radiation::viewFactor
Description
View factor radiation model. The system solved is: C q = b
where:
Cij = deltaij/Ej - (1/Ej - 1)Fij
q = heat flux
b = A eb - Ho
and:
eb = sigma*T^4
Ej = emissivity
Aij = deltaij - Fij
Fij = view factor matrix
SourceFiles
viewFactor.C
\*---------------------------------------------------------------------------*/
#ifndef radiationModelviewFactor_H
#define radiationModelviewFactor_H
#include "radiationModel.H"
#include "singleCellFvMesh.H"
#include "scalarMatrices.H"
#include "globalIndex.H"
#include "scalarListIOList.H"
#include "mapDistribute.H"
namespace Foam
{
namespace radiation
{
/*---------------------------------------------------------------------------*\
Class viewFactor Declaration
\*---------------------------------------------------------------------------*/
class viewFactor
:
public radiationModel
{
// Private data
//- Agglomeration List
labelListIOList finalAgglom_;
//- Map distributed
autoPtr<mapDistribute> map_;
//- Coarse mesh
singleCellFvMesh coarseMesh_;
//- Net radiative heat flux [W/m2]
volScalarField Qr_;
//- View factor matrix
autoPtr<scalarSquareMatrix> Fmatrix_;
//- Inverse of C matrix
autoPtr<scalarSquareMatrix> CLU_;
//- Selected patches
labelList selectedPatches_;
//- Total global coarse faces
label totalNCoarseFaces_;
//- Total local coarse faces
label nLocalCoarseFaces_;
//- Constant emissivity
bool constEmissivity_;
//- Iterations Counter
label iterCounter_;
//- Pivot Indices for LU decomposition
labelList pivotIndices_;
// Private Member Functions
//- Insert view factors into main matrix
void insertMatrixElements
(
const globalIndex& index,
const label fromProcI,
const labelListList& globalFaceFaces,
const scalarListList& viewFactors,
scalarSquareMatrix& matrix
);
//- Disallow default bitwise copy construct
viewFactor(const viewFactor&);
//- Disallow default bitwise assignment
void operator=(const viewFactor&);
public:
//- Runtime type information
TypeName("viewFactor");
// Constructors
//- Construct from components
viewFactor(const volScalarField& T);
//- Destructor
virtual ~viewFactor();
// Member functions
// Edit
//- Solve system of equation(s)
void calculate();
//- Read radiation properties dictionary
bool read();
//- Source term component (for power of T^4)
virtual tmp<volScalarField> Rp() const;
//- Source term component (constant)
virtual tmp<DimensionedField<scalar, volMesh> > Ru() const;
// Access
//- Const access to total radiative heat flux field
inline const volScalarField& Qr() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "viewFactorI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace radiation
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,34 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2008-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 <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
inline const Foam::volScalarField& Foam::radiation::viewFactor::Qr() const
{
return Qr_;
}
// ************************************************************************* //

View File

@ -25,6 +25,8 @@ License
#include "greyMeanAbsorptionEmission.H"
#include "addToRunTimeSelectionTable.H"
#include "unitConversion.H"
#include "zeroGradientFvPatchFields.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -56,13 +58,15 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
coeffsDict_((dict.subDict(typeName + "Coeffs"))),
speciesNames_(0),
specieIndex_(0),
lookUpTable_
lookUpTablePtr_(),
thermo_
(
fileName(coeffsDict_.lookup("lookUpTableFileName")),
mesh.time().constant(),
mesh
mesh,
const_cast<basicThermo&>
(
mesh.lookupObject<basicThermo>("thermophysicalProperties")
)
),
thermo_(mesh.lookupObject<basicThermo>("thermophysicalProperties")),
EhrrCoeff_(readScalar(coeffsDict_.lookup("EhrrCoeff"))),
Yj_(nSpecies_)
{
@ -83,17 +87,45 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
nFunc++;
}
if (coeffsDict_.found("lookUpTableFileName"))
{
const word name = coeffsDict_.lookup("lookUpTableFileName");
if (name != "none")
{
lookUpTablePtr_.set
(
new interpolationLookUpTable<scalar>
(
fileName(coeffsDict_.lookup("lookUpTableFileName")),
mesh.time().constant(),
mesh
)
);
if (!mesh.foundObject<volScalarField>("ft"))
{
FatalErrorIn
(
"Foam::radiation::greyMeanAbsorptionEmission(const"
"dictionary& dict, const fvMesh& mesh)"
) << "specie ft is not present to use with "
<< "lookUpTableFileName " << nl
<< exit(FatalError);
}
}
}
// Check that all the species on the dictionary are present in the
// look-up table and save the corresponding indices of the look-up table
label j = 0;
forAllConstIter(HashTable<label>, speciesNames_, iter)
{
if (mesh.foundObject<volScalarField>("ft"))
if (!lookUpTablePtr_.empty())
{
if (lookUpTable_.found(iter.key()))
if (lookUpTablePtr_().found(iter.key()))
{
label index = lookUpTable_.findFieldIndex(iter.key());
label index = lookUpTablePtr_().findFieldIndex(iter.key());
Info<< "specie: " << iter.key() << " found on look-up table "
<< " with index: " << index << endl;
@ -120,18 +152,32 @@ Foam::radiation::greyMeanAbsorptionEmission::greyMeanAbsorptionEmission
"dictionary& dict, const fvMesh& mesh)"
) << "specie: " << iter.key()
<< " is neither in look-up table: "
<< lookUpTable_.tableName()
<< lookUpTablePtr_().tableName()
<< " nor is being solved" << nl
<< exit(FatalError);
}
}
else if (mesh.foundObject<volScalarField>(iter.key()))
{
volScalarField& Y =
const_cast<volScalarField&>
(
mesh.lookupObject<volScalarField>(iter.key())
);
Yj_.set(j, &Y);
specieIndex_[iter()] = 0;
j++;
}
else
{
FatalErrorIn
(
"Foam::radiation::greyMeanAbsorptionEmission(const"
"dictionary& dict, const fvMesh& mesh)"
) << "specie ft is not present " << nl
) << " there is not lookup table and the specie" << nl
<< iter.key() << nl
<< " is not found " << nl
<< exit(FatalError);
}
@ -149,11 +195,10 @@ Foam::radiation::greyMeanAbsorptionEmission::~greyMeanAbsorptionEmission()
Foam::tmp<Foam::volScalarField>
Foam::radiation::greyMeanAbsorptionEmission::aCont(const label bandI) const
{
const volScalarField& T = thermo_.T();
const volScalarField& p = thermo_.p();
const volScalarField& ft = mesh_.lookupObject<volScalarField>("ft");
const volScalarField& T = thermo_.thermo().T();
const volScalarField& p = thermo_.thermo().p();
label nSpecies = speciesNames_.size();
const basicMultiComponentMixture& mixture = thermo_.carrier();
tmp<volScalarField> ta
(
@ -168,48 +213,60 @@ Foam::radiation::greyMeanAbsorptionEmission::aCont(const label bandI) const
IOobject::NO_WRITE
),
mesh(),
dimensionedScalar("a", dimless/dimLength, 0.0)
dimensionedScalar("a", dimless/dimLength, 0.0),
zeroGradientFvPatchVectorField::typeName
)
);
scalarField& a = ta().internalField();
forAll(a, i)
forAll(a, cellI)
{
const List<scalar>& species = lookUpTable_.lookUp(ft[i]);
for (label n=0; n<nSpecies; n++)
forAllConstIter(HashTable<label>, speciesNames_, iter)
{
label l = 0;
scalar Yipi = 0;
label n = iter();
scalar Xipi = 0.0;
if (specieIndex_[n] != 0)
{
//Specie found in the lookUpTable.
const volScalarField& ft =
mesh_.lookupObject<volScalarField>("ft");
const List<scalar>& Ynft = lookUpTablePtr_().lookUp(ft[cellI]);
//moles x pressure [atm]
Yipi = species[specieIndex_[n]]*p[i]*9.869231e-6;
Xipi = Ynft[specieIndex_[n]]*paToAtm(p[cellI]);
}
else
{
// mass fraction
Yipi = Yj_[l][i];
l++;
scalar invWt = 0.0;
forAll (mixture.Y(), s)
{
invWt += mixture.Y(s)[cellI]/mixture.W(s);
}
label index = mixture.species()[iter.key()];
scalar Xk = mixture.Y(index)[cellI]/(mixture.W(index)*invWt);
Xipi = Xk*paToAtm(p[cellI]);
}
const absorptionCoeffs::coeffArray& b = coeffs_[n].coeffs(T[i]);
const absorptionCoeffs::coeffArray& b = coeffs_[n].coeffs(T[cellI]);
scalar Ti = T[i];
scalar Ti = T[cellI];
// negative temperature exponents
if (coeffs_[n].invTemp())
{
Ti = 1./T[i];
Ti = 1.0/T[cellI];
}
a[i] +=
Yipi
a[cellI] +=
Xipi
*(
((((b[5]*Ti + b[4])*Ti + b[3])*Ti + b[2])*Ti + b[1])*Ti
+ b[0]
);
}
}
ta().correctBoundaryConditions();
return ta;
}

View File

@ -89,7 +89,8 @@ SourceFiles
#include "absorptionEmissionModel.H"
#include "HashTable.H"
#include "absorptionCoeffs.H"
#include "basicThermo.H"
#include "SLGThermo.H"
//#include "basicThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -110,10 +111,10 @@ public:
// Public data
// - Maximum number of species considered for absorptivity
// Maximum number of species considered for absorptivity
static const int nSpecies_ = 5;
// Absorption Coefficients
// Absorption Coefficients
absorptionCoeffs coeffs_[nSpecies_];
@ -127,14 +128,14 @@ private:
//- Hash table of species names
HashTable<label> speciesNames_;
// Indices of species in the look-up table
//- Indices of species in the look-up table
FixedList<label, nSpecies_> specieIndex_;
// Look-up table of species related to ft
mutable interpolationLookUpTable<scalar> lookUpTable_;
//- Look-up table of species related to ft
mutable autoPtr<interpolationLookUpTable<scalar> > lookUpTablePtr_;
// Thermo package
const basicThermo& thermo_;
//- SLG thermo package
SLGThermo thermo_;
//- Emission constant coefficient
const scalar EhrrCoeff_;

View File

@ -24,7 +24,8 @@ boundaryField
{
type MarshakRadiation;
T T;
emissivity 1;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
}

View File

@ -24,7 +24,8 @@ boundaryField
{
type greyDiffusiveRadiation;
T T;
emissivity 1.0;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
}

View File

@ -135,6 +135,62 @@ greyMeanAbsorptionEmissionCoeffs
);
}
N2
{
Tcommon 300;
invTemp false;
Tlow 200;
Thigh 2500;
loTcoeffs
(
0.01
0
0
0
0
0
);
hiTcoeffs
(
0.01
0
0
0
0
0
);
}
O2
{
Tcommon 300;
invTemp false;
Tlow 200;
Thigh 2500;
loTcoeffs
(
0.01
0
0
0
0
0
);
hiTcoeffs
(
0.01
0
0
0
0
0
);
}
}
scatterModel constantScatter;

View File

@ -24,7 +24,8 @@ boundaryField
{
type greyDiffusiveRadiation;
T T;
emissivity 1.0;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
}

View File

@ -135,6 +135,62 @@ greyMeanAbsorptionEmissionCoeffs
0
);
}
N2
{
Tcommon 300;
invTemp false;
Tlow 200;
Thigh 2500;
loTcoeffs
(
0.01
0
0
0
0
0
);
hiTcoeffs
(
0.01
0
0
0
0
0
);
}
O2
{
Tcommon 300;
invTemp false;
Tlow 200;
Thigh 2500;
loTcoeffs
(
0.01
0
0
0
0
0
);
hiTcoeffs
(
0.01
0
0
0
0
0
);
}
}

View File

@ -24,7 +24,8 @@ boundaryField
{
type MarshakRadiation;
T T;
emissivity 1;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
@ -32,7 +33,8 @@ boundaryField
{
type MarshakRadiation;
T T;
emissivity 1;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
@ -40,7 +42,8 @@ boundaryField
{
type MarshakRadiation;
T T;
emissivity 1;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
@ -48,7 +51,8 @@ boundaryField
{
type MarshakRadiation;
T T;
emissivity 1;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
}

View File

@ -24,7 +24,8 @@ boundaryField
{
type greyDiffusiveRadiation;
T T;
emissivity 1.0;
emissivityMode lookup;
emissivity uniform 1.0;
value uniform 0;
}
}

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object G;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 0 -3 0 0 0 0];
internalField uniform 0;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object IDefault;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 0 -3 0 0 0 0];
internalField uniform 0;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object Qr;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 0 -3 0 0 0 0];
internalField uniform 0;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 300;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (0.1 0 0);
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object Ychar;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0.5;
boundaryField
{
".*"
{
type calculated;
value uniform 0.5;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object Ypmma;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 0 0 0 0];
internalField uniform 0.5;
boundaryField
{
".*"
{
type calculated;
value uniform 0.5;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 0.01;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,30 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 0.1;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p_rgh;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 1e5;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,29 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object rho;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -3 0 0 0 0 0];
internalField uniform 8000;
boundaryField
{
".*"
{
type calculated;
}
}
// ************************************************************************* //

View File

@ -0,0 +1,35 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial clean functions
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
cleanCase
rm -rf VTK
rm -rf constant/cellToRegion constant/polyMesh/sets
rm -rf 0/bottomAir
rm -rf 0/topAir
rm -rf 0/heater
rm -rf 0/leftSolid
rm -rf 0/rightSolid
rm -f 0/cellToRegion
rm -rf constant/bottomAir/polyMesh
rm -rf constant/topAir/polyMesh
rm -rf constant/heater/polyMesh
rm -rf constant/leftSolid/polyMesh
rm -rf constant/rightSolid/polyMesh
rm -f constant/bottomAir/F
rm -f constant/bottomAir/constructMap*
rm -f constant/bottomAir/finalAgglom
rm -f constant/bottomAir/globalFaceFaces
rm -f constant/bottomAir/subMap
rm -f constant/topAir/F
rm -f constant/topAir/constructMap*
rm -f constant/topAir/finalAgglom
rm -f constant/topAir/globalFaceFaces
rm -f constant/topAir/subMap
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,69 @@
#!/bin/sh
cd ${0%/*} || exit 1 # run from this directory
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions
runApplication blockMesh
runApplication setSet -batch makeCellSets.setSet
runApplication splitMeshRegions -cellZones -overwrite
# remove fluid fields from solid regions (important for post-processing)
for i in heater leftSolid rightSolid
do
rm -f 0*/$i/{rho,mut,alphat,epsilon,k,p,U,p_rgh,Qr,G,IDefault}
done
## remove solid fields from fluid regions (important for post-processing)
for i in bottomAir topAir
do
rm -f 0*/$i/{Ypmma,Ychar}
done
for i in bottomAir topAir heater leftSolid rightSolid
do
changeDictionary -region $i > log.changeDictionary.$i 2>&1
done
for i in bottomAir topAir
do
faceAgglomerate -region $i > log.faceAgglomerate.$i 2>&1
done
for i in bottomAir topAir
do
viewFactorsGen -region $i > log.viewFactorsGen.$i 2>&1
done
#-- Run on single processor
runApplication chtMultiRegionSimpleFoam
## Decompose
#for i in bottomAir topAir heater leftSolid rightSolid
#do
# decomposePar -region $i > log.decomposePar.$i 2>&1
#done
#
## Run
#runParallel chtMultiRegionSimpleFoam 4
#
## Reconstruct
#for i in bottomAir topAir heater leftSolid rightSolid
#do
# reconstructPar -region $i > log.reconstructPar.$i 2>&1
#done
echo
echo "creating files for paraview post-processing"
echo
for i in bottomAir topAir heater leftSolid rightSolid
do
paraFoam -touch -region $i
done
# ----------------------------------------------------------------- end-of-file

View File

@ -0,0 +1,24 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object RASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
RASModel laminar;
turbulence on;
printCoeffs on;
// ************************************************************************* //

View File

@ -0,0 +1,20 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class uniformDimensionedVectorField;
object g;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -2 0 0 0 0];
value (0 -9.81 0);
// ************************************************************************* //

View File

@ -0,0 +1,156 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object radiationProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
radiation on;
radiationModel viewFactor;//fvDOM;//P1;
viewFactorCoeffs
{
smoothing true; //Smooth view factor matrix (use when in a close surface
//to force Sum(Fij = 1)
constantEmissivity true; //constant emissivity on surfaces.
}
noRadiation
{
}
P1Coeffs
{
}
fvDOMCoeffs
{
nPhi 3; // azimuthal angles in PI/2 on X-Y.(from Y to X)
nTheta 4; // polar angles in PI (from Z to X-Y plane)
convergence 1e-3; // convergence criteria for radiation iteration
maxIter 5; // maximum number of iterations
}
// Number of flow iterations per radiation iteration
solverFreq 3;
absorptionEmissionModel constantAbsorptionEmission;
constantAbsorptionEmissionCoeffs
{
a a [ 0 -1 0 0 0 0 0 ] 0.01;
e e [ 0 -1 0 0 0 0 0 ] 0.01;
E E [ 1 -1 -3 0 0 0 0 ] 0;
}
greyMeanAbsorptionEmissionCoeffs
{
lookUpTableFileName "SpeciesTable";
EhrrCoeff 0.0;
CO2
{
Tcommon 300; //Common Temp
invTemp true; //Is the polynomio using inverse temperature.
Tlow 200; //Low Temp
Thigh 2500; //High Temp
loTcoeffs //coefss for T < Tcommon
(
0 // a0 +
0 // a1*T +
0 // a2*T^(+/-)2 +
0 // a3*T^(+/-)3 +
0 // a4*T^(+/-)4 +
0 // a5*T^(+/-)5 +
);
hiTcoeffs //coefss for T > Tcommon
(
18.741
-121.31e3
273.5e6
-194.05e9
56.31e12
-5.8169e15
);
}
H2O
{
Tcommon 300;
invTemp true;
Tlow 200;
Thigh 2500;
loTcoeffs
(
0
0
0
0
0
0
);
hiTcoeffs
(
-0.23093
-1.12390e3
9.4153e6
-2.99885e9
0.51382e12
-1.868e10
);
}
CH4
{
Tcommon 300;
Tlow 200;
Thigh 2500;
invTemp false;
loTcoeffs
(
0
0
0
0
0
0
);
hiTcoeffs
(
6.6334
-0.0035686
1.6682e-8
2.5611e-10
-2.6558e-14
0
);
}
}
scatterModel constantScatter;
constantScatterCoeffs
{
sigma sigma [ 0 -1 0 0 0 0 0 ] 0;
C C [ 0 0 0 0 0 0 0 ] 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,31 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant/bottomAir";
object thermophysicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType hRhoThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>;
mixture
{
nMoles 1;
molWeight 28.9;
Cp 1000;
Hf 0;
mu 1.8e-05;
Pr 0.7;
}
// ************************************************************************* //

View File

@ -0,0 +1,19 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType laminar;
// ************************************************************************* //

View File

@ -0,0 +1,67 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object viewFactorsDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
writeViewFactorMatrix true;
writeFacesAgglomeration true;
bottomAir_to_heater
{
nFacesInCoarsestLevel 30;
featureAngle 10;
}
bottomAir_to_leftSolid
{
nFacesInCoarsestLevel 20;
featureAngle 10;
}
bottomAir_to_rightSolid
{
nFacesInCoarsestLevel 20;
featureAngle 10;
}
minX
{
nFacesInCoarsestLevel 10;
featureAngle 10;
}
minY
{
nFacesInCoarsestLevel 30;
featureAngle 10;
}
minZ
{
nFacesInCoarsestLevel 20;
featureAngle 10;
}
maxX
{
nFacesInCoarsestLevel 10;
featureAngle 10;
}
maxZ
{
nFacesInCoarsestLevel 20;
featureAngle 10;
}

View File

@ -0,0 +1,152 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object solidThermophysicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType constSolidThermo;
//thermoType isotropicKSolidThermo;
//thermoType directionalKSolidThermo;
//thermoType solidMixtureThermo<multiComponentSolidMixture<exponentialSolidTransport<constSolidRad<exponentialSolidThermo<constRho>>>>>;
constSolidThermoCoeffs
{
//- thermo properties
rho rho [1 -3 0 0 0 0 0] 8000;
Cp Cp [0 2 -2 -1 0 0 0] 450;
K K [1 1 -3 -1 0 0 0] 80;
//- radiative properties
kappa kappa [0 -1 0 0 0 0 0] 0;
sigmaS sigmaS [0 -1 0 0 0 0 0] 0;
emissivity emissivity [0 0 0 0 0 0 0] 0.5;
//- chemical properties
Hf Hf [0 2 -2 0 0 0 0] 0;
}
isotropicKSolidThermoCoeffs
{
//- thermo properties
TValues (100 1000);
rhoValues (1000 1700);
cpValues (1700 1700);
KValues (80 40);
//- radiative properties
emissivityValues (1 1);
kappaValues (0 0);
sigmaSValues (0 0);
//- chemical properties
HfValues (1 1);
}
directionalKSolidThermoCoeffs
{
//- does interpolation and directional K in coordinate system.
// Specify multiple values, one for each temperature. Properties are
// interpolated according to the local temperature.
//- thermo properties
TValues (100 1000);
rhoValues (1700 1700);
cpValues (1700 1700);
KValues ((10 10 10) (40 40 40));
coordinateSystem
{
origin (-0.000062 0.000019 0.000039);
coordinateRotation
{
type axes;
e1 (1 0 0);
e3 (-3.1807824e-6 -0.99813473 0.0610505);
}
}
//- chemical properties
HfValues (1 1);
//- radiative properties
emissivityValues (1 1);
kappaValues (1 1);
sigmaSValues (1 1);
}
solidComponents
(
pmma char
);
pmmaCoeffs
{
transportProperties
{
K0 0.152;
n0 1.3;
Tref 300; //K0*pow(T/Tref_, n0))
}
radiativeProperties
{
sigmaS 0.0;
kappa 0.0;
emissivity 0.1;
}
thermoProperties
{
Hf 0;
C0 1462; // Cp = C0*(T/Tref)^n0
Tref 300;
n0 1.31;
}
densityProperties
{
rho 1114.0;
}
}
charCoeffs
{
transportProperties
{
K0 0.4;
n0 1.3;
Tref 300; //K0*pow(T/Tref_, n0))
}
radiativeProperties
{
sigmaS 0.0;
kappa 0.0;
emissivity 0.0;
}
thermoProperties
{
Hf 0;
C0 611.0;; // Cp = C0*(T/Tref)^n0
Tref 300;
n0 1.31;
}
densityProperties
{
rho 11.5;
}
}
// ************************************************************************* //

View File

@ -0,0 +1 @@
../heater/solidThermophysicalProperties

View File

@ -0,0 +1,72 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object blockMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
convertToMeters 1;
vertices
(
(-0.1 -0.04 -0.05)
( 0.1 -0.04 -0.05)
( 0.1 0.04 -0.05)
(-0.1 0.04 -0.05)
(-0.1 -0.04 0.05)
( 0.1 -0.04 0.05)
( 0.1 0.04 0.05)
(-0.1 0.04 0.05)
);
blocks
(
hex (0 1 2 3 4 5 6 7) (30 10 10) simpleGrading (1 1 1)
);
edges
(
);
patches
(
wall maxY
(
(3 7 6 2)
)
patch minX
(
(0 4 7 3)
)
patch maxX
(
(2 6 5 1)
)
wall minY
(
(1 5 4 0)
)
wall minZ
(
(0 3 2 1)
)
wall maxZ
(
(4 5 6 7)
)
);
mergePatchPairs
(
);
// ************************************************************************* //

View File

@ -0,0 +1,58 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
6
(
maxY
{
type wall;
nFaces 300;
startFace 8300;
}
minX
{
type patch;
nFaces 100;
startFace 8600;
}
maxX
{
type patch;
nFaces 100;
startFace 8700;
}
minY
{
type wall;
nFaces 300;
startFace 8800;
}
minZ
{
type wall;
nFaces 300;
startFace 9100;
}
maxZ
{
type wall;
nFaces 300;
startFace 9400;
}
)
// ************************************************************************* //

View File

@ -0,0 +1,22 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object regionProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
fluidRegionNames ( bottomAir topAir );
solidRegionNames ( heater leftSolid rightSolid );
// ************************************************************************* //

Some files were not shown because too many files have changed in this diff Show More