Merge remote branch 'OpenCFD/master' into olesenm

Conflicts:
	bin/foamCleanPath
This commit is contained in:
Mark Olesen
2011-02-22 19:24:31 +01:00
156 changed files with 8498 additions and 919 deletions

View File

@ -35,43 +35,44 @@
*** Core library
+ Large number of code refinements and consistency improvements to support
other developments.
Parallel : using non-blocking communications wherever possible. This will
+ Parallel : using non-blocking communications wherever possible. This will
lead to lower requirements for MPI_BUFFER_SIZE and possibly better
start-up performance on larger numbers of processors.
*** Turbulence modelling
*** *Updated* thermophysical libraries
+ Now use the more descriptive dictionary input format, e.g. for a single
component mixture:
#+BEGIN_SRC c++
thermoType hPsiThermo<pureMixture<sutherlandTransport<specieThermo<hConstThermo<perfectGas>>>>>;
thermoType hPsiThermo<pureMixture<sutherlandTransport<specieThermo<hConstThermo<perfectGas>>>>>;
mixture
{
nMoles 1;
molWeight 28.9;
Cp 1007;
Hf 0;
As 1.4792e-06;
Ts 116;
}
mixture
{
nMoles 1;
molWeight 28.9;
Cp 1007;
Hf 0;
As 1.4792e-06;
Ts 116;
}
#+END_SRC
*** Lagrangian intermediate library
Extensively updated
*Updated* input format
Extended to include steady cloud tracking
*New* collision modelling
*Coupled* to new surface film modelling library
*New* sub-models
+ NonSphereDrag: drag model to account for non-spherical particles
+ ParticleTracks: post-processing model to generate track data, typically
during steady calculations
*Updated* sub-models
+ Devolatilisation models: now act on a per-specie basis
+ Extensively updated
+ *Updated* input format
+ Extended to include steady cloud tracking
+ *New* collision modelling
+ *Coupled* to new surface film modelling library
+ *New* sub-models
+ NonSphereDrag: drag model to account for non-spherical particles
+ ParticleTracks: post-processing model to generate track data, typically
during steady calculations
+ *Updated* sub-models
+ Devolatilisation models: now act on a per-specie basis
*** DSMC
*** Dynamic Mesh
*** Numerics
*** *Updated* command line help, e.g. `snappyHexMesh -help' now gives:
#+BEGIN_SRC c++
Usage: snappyHexMesh [OPTIONS]
options:
-case <dir> specify alternate case directory, default is the cwd
@ -80,12 +81,13 @@
-srcDoc display source code in browser
-doc display application documentation in browser
-help print the usage
#+END_SRC
*** *New* basicSolidThermo solids thermophysical library
+ Used in all conjugate heat transfer solvers
+ constant properties
+ temperature dependent properties
+ temperature and direction (in local coordinate system) dependent properties
+ temperature and direction (in local coordinate system) dependent
properties
*** *New* Surface film library
+ Creation of films by particle addition, or initial film distribution
+ Coupled with the lagrangian/intermediate cloud hierarchy library
@ -113,13 +115,16 @@
polyPatches holding data can map the data.
*** *Updated* particle tracking algorithm
+ uses non-blocking parallel transfers
+ does 'minimum-tet' decomposition of face to work with warped faces (snappyHexMesh!)
+ does 'minimum-tet' decomposition of face to work with warped faces
(snappyHexMesh!)
+ reuses tracking state in interpolation - improves consistency and speed
*** *Updated* split cyclics into two separate patches. See doc/changed/splitCyclics.txt
*** *Updated* split cyclics into two separate patches.
See [[./doc/changes/splitCyclic.txt]]
* *Updated* interpolation (volPointInterpolation) now works without the
globalPointPatch. Moving mesh cases can now be run non-parallel and
continued in parallel and reconstructed without any limitation.
*** *New* compact binary I/O for faces and cells. This speeds up reading/writing meshes in binary.
*** *New* compact binary I/O for faces and cells.
This speeds up reading/writing meshes in binary.
*** *Updated* runTimeModifiable
+ user selectable model to use for checking run-time modifiable
dictionaries (see also doc/changes/inotify.txt):
@ -129,32 +134,33 @@
contents from master.
+ inotifyMaster : only master checks and reads file. Slaves get file
contents from master.
+ on linux optionally uses inotify instead of time stamps - more efficient for large
numbers of monitored files. No more fileModificationSkew needed.
+ on linux optionally uses inotify instead of time stamps - more efficient
for large numbers of monitored files. No more fileModificationSkew needed.
+ single integer reduction instead of one reduction per monitored file.
+ only files that can be re-read are being checked. Drastic reduction of
number of files to check.
*** *New* #codeStream dictionary entry method. Uses on-the-fly compilation
of OpenFOAM C++ code to construct dictionary.
*** *New* #codeStream dictionary entry
Uses on-the-fly compilation of OpenFOAM C++ code to construct dictionary.
E.g. in blockMeshDict:
#+BEGIN_SRC c++
convertToMeters 0.001;
convertToMeters 0.001;
vertices #codeStream
{
code
#{
label nVerts =
readLabel(dict.lookup("nx"))
* readLabel(dict.lookup("ny"))
* readLabel(dict.lookup("nz"));
pointField verts(nVerts);
// Now fill verts here
// ..
os << verts;
#};
}
See also doc/changes/onTheFly.txt
vertices #codeStream
{
code
#{
label nVerts =
readLabel(dict.lookup("nx"))
*readLabel(dict.lookup("ny"))
*readLabel(dict.lookup("nz"));
pointField verts(nVerts);
// Now fill verts here
// ..
os << verts;
#};
}
#+END_SRC
See also ./[[doc/changes/codeStream.org]]
* Solvers
A number of new solvers have been developed for a range of engineering
@ -187,7 +193,7 @@
to e.g. sample fields just above wall (e.g. for streaklines)
+ *New* codedFixedValue: Uses the on-the-fly code compilation from #codeStream
to provide an in-line fixedValueFvPatchScalarField. E.g.
#+BEGIN_SRC c++
outlet
{
type codedFixedValue<scalar>;
@ -199,8 +205,8 @@
operator==(min(10, 0.1*this->db().time().value()));
#};
}
See doc/changes/onTheFly.txt
#+END_SRC
See also [[./doc/changes/codeStream.org]]
* Utilities
There have been some utilities added and updated in this release.
@ -221,23 +227,24 @@
+ =topoSet=: replacement of cellSet,faceSet,pointSet utilities.
Comparable to a dictionary driven =setSet= utility.
*** Updated utilities
+ =setFields=: optionally use faceSets to set patch values (see e.g. hotRoom tutorial).
+ =setFields=: optionally use faceSets to set patch values (see
e.g. =hotRoom= tutorial).
+ =blockMesh=: specify patches via dictionary instead of type only. This
makes rereading the boundary file superfluous. see
e.g. pitzDailyDirectMapped tutorial.
+ =setSet=: allows time range (e.g. 0:100) in combination with -batch argument
to execute the commands for multiple times.
+ =setSet=: allows time range (e.g. 0:100) in combination with -batch
argument to execute the commands for multiple times.
+ =extrudeMesh=:
- option to add extrusion to existing mesh.
- works in parallel
- option to add extrusion to existing mesh.
- works in parallel
+ =snappyHexMesh=:
+ extrude across multi-processor boundaries
+ preserve faceZones during layering
+ extrude across multi-processor boundaries
+ preserve faceZones during layering
* Post-processing
+ =paraFoam=, =foamToVTK=: full support for polyhedral cell type in recent
Paraview versions.
+ =foamToEnsight=: parallel continuous data. new =-nodeValues= option to generate and output nodal
field data.
+ =foamToEnsight=: parallel continuous data. new =-nodeValues= option to
generate and output nodal field data.
+ =singleCellMesh=: new utility to convert mesh and fields to a single cell
mesh. Great for postprocessing.
+ =steadyParticleTracks=: Generates VTK tracks from the output of the cloud
@ -271,3 +278,7 @@
+ multipleBoxes, hotBoxes, panel, evaporationTest
+ =interDyMFoam= tutorials:
+ testTubeMixer: showcases =solidBodyMotionFunction=
* Other
+ compilable with =clang=
In your prefs.sh set the WM_COMPILER to Clang

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,6 +6,7 @@
- fvm::laplacian(turb.alphaEff(), h)
==
DpDt
+ rad.Sh(thermo)
);
hEqn.relax();
@ -13,6 +14,8 @@
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

@ -60,6 +60,8 @@ Usage
\param -literalRE \n
Do not interpret regular expressions; treat them as any other keyword.
\param -enableFunctionEntries \n
By default all dictionary preprocessing of fields is disabled
\*---------------------------------------------------------------------------*/
@ -255,6 +257,11 @@ int main(int argc, char *argv[])
"literalRE",
"treat regular expressions literally (ie, as a keyword)"
);
argList::addBoolOption
(
"enableFunctionEntries",
"enable expansion of dictionary directives - #include, #codeStream etc"
);
#include "addRegionOption.H"
#include "setRootCase.H"
@ -271,6 +278,20 @@ int main(int argc, char *argv[])
<< " not present." << endl;
}
const bool enableEntries = args.optionFound("enableFunctionEntries");
if (enableEntries)
{
Info<< "Allowing dictionary preprocessing ('#include', '#codeStream')."
<< endl;
}
int oldFlag = entry::disableFunctionEntries;
if (!enableEntries)
{
// By default disable dictionary expansion for fields
entry::disableFunctionEntries = 1;
}
fileName regionPrefix = "";
if (regionName != fvMesh::defaultRegion)
@ -410,6 +431,7 @@ int main(int argc, char *argv[])
false
)
);
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Fake type back to what was in field
const_cast<word&>(fieldDict.type()) = fieldDict.headerClassName();
@ -429,6 +451,8 @@ int main(int argc, char *argv[])
}
}
entry::disableFunctionEntries = oldFlag;
Info<< endl;
Info<< "End\n" << endl;

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

@ -34,6 +34,9 @@ Usage
\param -test \n
Suppress writing the updated files with split cyclics
\param -enableFunctionEntries \n
By default all dictionary preprocessing of fields is disabled
\*---------------------------------------------------------------------------*/
#include "argList.H"
@ -391,7 +394,12 @@ int main(int argc, char *argv[])
{
timeSelector::addOptions();
argList::addBoolOption("test");
argList::addBoolOption("test", "test only; do not change any files");
argList::addBoolOption
(
"enableFunctionEntries",
"enable expansion of dictionary directives - #include, #codeStream etc"
);
# include "addRegionOption.H"
# include "setRootCase.H"
@ -404,6 +412,7 @@ int main(int argc, char *argv[])
{
Info<< "-test option: no changes made" << nl << endl;
}
const bool enableEntries = args.optionFound("enableFunctionEntries");
Foam::word regionName = polyMesh::defaultRegion;
@ -482,6 +491,13 @@ int main(int argc, char *argv[])
IOobjectList objects(runTime, runTime.timeName());
int oldFlag = entry::disableFunctionEntries;
if (!enableEntries)
{
// By default disable dictionary expansion for fields
entry::disableFunctionEntries = 1;
}
// volFields
// ~~~~~~~~~
@ -615,6 +631,8 @@ int main(int argc, char *argv[])
thisNames,
nbrNames
);
entry::disableFunctionEntries = oldFlag;
}
return 0;

View File

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

View File

@ -0,0 +1,15 @@
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

@ -97,10 +97,9 @@ do
wildcard=$1
shift
##DEBUG echo "remove>$wildcard<" 1>&2
if [ -n "$wildcard" ]
then
dirList=$(echo "$dirList" | sed -e "s@${wildcard}[^:]*:@@g")
dirList=$(echo "$dirList:" | sed -e "s@${wildcard}[^:]*:@@g")
fi
done

151
doc/changes/codeStream.org Normal file
View File

@ -0,0 +1,151 @@
# -*- mode: org; -*-
#
#+TITLE: =codeStream=: On-the-fly code compilation
#+AUTHOR: OpenCFD Ltd.
#+DATE: TBA
#+LINK: http://www.openfoam.com
#+OPTIONS: author:nil ^:{}
# Copyright (c) 2011 OpenCFD Ltd.
* Dictionary preprocessing directive: =#codeStream=
This is a dictionary preprocessing directive ('=functionEntry=') which
provides a snippet of OpenFOAM C++ code which gets compiled and executed to
provide the actual dictionary entry. The snippet gets provided as three
sections of C++ code which just gets inserted into a template:
- =code= section: the actual body of the code. It gets called with arguments
=const dictionary& dict, OStream& os= and the C++ code can do a
=dict.lookup= to find current dictionary values.
- optional =codeInclude= section: any #include statements to include OpenFOAM
files.
- optional 'codeOptions' section: any extra compilation flags to be added to
=EXE_INC= in =Make/options=
To ease inputting mulit-line code there is the =#{ #}= syntax. Anything in
between these two delimiters becomes a string with all newlines, quotes etc
preserved.
Example: Look up dictionary entries and do some calculation
#+BEGIN_SRC c++
startTime 0;
endTime 100;
..
writeInterval #codeStream
{
code
#{
scalar start = readScalar(dict["startTime"]);
scalar end = readScalar(dict["endTime"]);
label nDumps = 5;
label interval = end-start
os << ((start-end)/nDumps)
#}
};
#+END_SRC
* Implementation
- the =#codeStream= entry reads the dictionary following it, extracts the
=code=, =codeInclude=, =codeOptions= sections (these are just strings) and
calculates the SHA1 checksum of the contents.
- it copies a template file
=($FOAM_CODESTREAM_TEMPLATES/codeStreamTemplate.C)=, substituting all
occurences of =code=, =codeInclude=, =codeOptions=.
- it writes library source files to =constant/codeStream/<sha1>= and compiles
it using =wmake libso=.
- the resulting library gets loaded (=dlopen=, =dlsym=) and the function
executed
- the function will have written its output into the Ostream which then gets
used to construct the entry to replace the whole =#codeStream= section.
- using the sha1 means that same code will only be compiled and loaded once.
* Boundary condition: =codedFixedValue=
This uses the code from codeStream to have an in-line specialised
=fixedValueFvPatchScalarField=. For now only for scalars:
#+BEGIN_SRC c++
outlet
{
type codedFixedValue<scalar>;
value uniform 0;
redirectType fixedValue10;
code
#{
operator==(min(10, 0.1*this->db().time().value()));
#};
}
#+END_SRC
It by default always includes =fvCFD.H= and adds the =finiteVolume= library to
the include search path.
A special form is where the code is not supplied in-line but instead comes
from the =codeDict= dictionary in the =system= directory. It should contain
a =fixedValue10= entry:
#+BEGIN_SRC c++
fixedValue10
{
code
#{
operator==(min(10, 0.1*this->db().time().value()));
#};
}
#+END_SRC
The advantage of using this indirect way is that it supports
runTimeModifiable so any change of the code will be picked up next iteration.
* Security
Allowing the case to execute C++ code does introduce security risks. A
third-party case might have a =#codeStream{#code system("rm -rf .");};= hidden
somewhere in a dictionary. =#codeStream= is therefore not enabled by default
you have to enable it by setting in the system-wide =controlDict=
#+BEGIN_SRC c++
InfoSwitches
{
// Allow case-supplied c++ code (#codeStream, codedFixedValue)
allowSystemOperations 1;
}
#+END_SRC
* Field manipulation
Fields are read in as =IOdictionary= so can be upcast to provide access to the
mesh:
#+BEGIN_SRC c++
internalField #codeStream
{
codeInclude
#{
#include "fvCFD.H"
#};
code
#{
const IOdictionary& d = dynamicCast<const IOdictionary>(dict);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
scalarField fld(mesh.nCells(), 12.34);
fld.writeEntry("", os);
#};
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude
#};
};
#+END_SRC
* Exceptions
There are unfortunately some exceptions. Following applications read
the field as a dictionary, not as an =IOdictionary=:
- =foamFormatConvert=
- =changeDictionaryDict=
- =foamUpgradeCyclics=
These applications will usually switch off all '#' processing.
Note: above field initialisation has the problem that the boundary conditions
are not evaluated so e.g. processor boundaries will not hold the opposite cell
value.
* Other
- the implementation is still a bit raw - it compiles code overly much
- both =codeStream= and =codedFixedValue= take the contents of the dictionary
and extract values and re-assemble list of files and environment vars to
replace. Should just directly pass the dictionary into =codeStreamTools=.
- parallel running not tested a lot. What about distributed data parallel?

View File

@ -1,139 +0,0 @@
On-the-fly code compilation
---------------------------
1. #codeStream
This is a dictionary preprocessing directive ('functionEntry') which provides
a snippet of OpenFOAM
C++ code which gets compiled and executed to provide the actual dictionary
entry. The snippet gets provided as three sections of C++ code which just gets
inserted into a template:
- 'code' section: the actual body of the code. It gets called with
arguments
const dictionary& dict,
OStream& os
and the C++ code can do a dict.lookup to find current dictionary values.
- optional 'codeInclude' section: any #include statements to include
OpenFOAM files.
- optional 'codeOptions' section: any extra compilation flags to be added to
EXE_INC in Make/options
To ease inputting mulit-line code there is the #{ #} syntax. Anything
inbetween these two delimiters becomes a string with all newlines, quotes etc
preserved.
Example: Look up dictionary entries and do some calculation
startTime 0;
endTime 100;
..
writeInterval #codeStream
{
code
#{
scalar start = readScalar(dict["startTime"]);
scalar end = readScalar(dict["endTime"]);
label nDumps = 5;
label interval = end-start
os << ((start-end)/nDumps)
#}
};
2. Implementation
- the #codeStream entry reads the dictionary following it, extracts the
code, codeInclude, codeOptions sections (these are just strings) and
calculates the SHA1 checksum of the contents.
- it copies a template file
($FOAM_CODESTREAM_TEMPLATES/codeStreamTemplate.C), substituting all
occurences of code, codeInclude, codeOptions.
- it writes library source files to constant/codeStream/<sha1> and compiles it
using 'wmake libso'.
- the resulting library gets loaded (dlopen, dlsym) and the function
executed
- the function will have written its output into the Ostream which then
gets used to construct the entry to replace the whole #codeStream section.
- using the sha1 means that same code will only be compiled & loaded once.
3. codedFixedValue
This uses the code from codeStream to have an in-line specialised
fixedValueFvPatchScalarField. For now only for scalars:
outlet
{
type codedFixedValue<scalar>;
value uniform 0;
redirectType fixedValue10;
code
#{
operator==(min(10, 0.1*this->db().time().value()));
#};
}
It by default always includes fvCFD.H and adds the finiteVolume library
to the include search path.
4. Security
Allowing the case to execute C++ code does introduce security risks.
A thirdparty case might have a #codeStream{#code system("rm -rf .");};
hidden somewhere in a dictionary. #codeStream is therefore not enabled by
default - you have to enable it by setting in the system-wide controlDict
InfoSwitches
{
// Allow case-supplied c++ code (#codeStream, codedFixedValue)
allowSystemOperations 1;
}
5. Field manipulation.
Fields are read in as IOdictionary (*) so can be upcast to provide access
to the mesh:
internalField #codeStream
{
codeInclude
#{
#include "fvCFD.H"
#};
code
#{
const IOdictionary& d = dynamicCast<const IOdictionary>(dict);
const fvMesh& mesh = refCast<const fvMesh>(d.db());
scalarField fld(mesh.nCells(), 12.34);
fld.writeEntry("", os);
#};
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude
#};
};
* There are unfortunately some exceptions. Following applications read
the field as a dictionary, not as an IOdictionary:
- foamFormatConvert
- changeDictionaryDict
- foamUpgradeCyclics
- fieldToCell
Note: above field initialisation has the problem that the boundary
conditions are not evaluated so e.g. processor boundaries will
not hold the opposite cell value.
6. Other
- the implementation is still a bit raw - it compiles code overly much
- both codeStream and codedFixedValue take the contents of the dictionary
and extract values and re-assemble list of files and environment vars to
replace. Should just directly pass the dictionary into codeStreamTools.
- parallel running not tested a lot. What about distributed data parallel?

View File

@ -26,6 +26,10 @@ Description
\*---------------------------------------------------------------------------*/
#include "dictionary.H"
#include "Ostream.H"
#include "Pstream.H"
//{{{ begin codeInclude
${codeInclude}
//}}} end codeInclude

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
@ -162,11 +162,16 @@ Foam::Istream& Foam::UIPstream::read(token& t)
// String
case token::STRING :
case token::VERBATIMSTRING :
{
string* pval = new string;
if (read(*pval))
{
t = pval;
if (c == token::VERBATIMSTRING)
{
t.type() = token::VERBATIMSTRING;
}
}
else
{

View File

@ -203,7 +203,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
return *this;
}
// Verbatim string
// Possible verbatim string or dictionary functionEntry
case token::HASH :
{
char nextC;
@ -226,6 +226,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
else
{
t = sPtr;
t.type() = token::VERBATIMSTRING;
}
return *this;

View File

@ -78,6 +78,7 @@ public:
PUNCTUATION,
WORD,
STRING,
VERBATIMSTRING,
LABEL,
FLOAT_SCALAR,
DOUBLE_SCALAR,
@ -318,6 +319,7 @@ public:
// Access
inline tokenType type() const;
inline tokenType& type();
inline bool good() const;
inline bool undefined() const;

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
@ -39,7 +39,7 @@ inline void token::clear()
{
delete wordTokenPtr_;
}
else if (type_ == STRING)
else if (type_ == STRING || type_ == VERBATIMSTRING)
{
delete stringTokenPtr_;
}
@ -88,6 +88,7 @@ inline token::token(const token& t)
break;
case STRING:
case VERBATIMSTRING:
stringTokenPtr_ = new string(*t.stringTokenPtr_);
break;
@ -178,6 +179,11 @@ inline token::tokenType token::type() const
return type_;
}
inline token::tokenType& token::type()
{
return type_;
}
inline bool token::good() const
{
return (type_ != ERROR && type_ != UNDEFINED);
@ -231,12 +237,12 @@ inline const word& token::wordToken() const
inline bool token::isString() const
{
return (type_ == STRING);
return (type_ == STRING || type_ == VERBATIMSTRING);
}
inline const string& token::stringToken() const
{
if (type_ == STRING)
if (type_ == STRING || type_ == VERBATIMSTRING)
{
return *stringTokenPtr_;
}
@ -405,6 +411,7 @@ inline void token::operator=(const token& t)
break;
case STRING:
case VERBATIMSTRING:
stringTokenPtr_ = new string(*t.stringTokenPtr_);
break;
@ -511,6 +518,7 @@ inline bool token::operator==(const token& t) const
return *wordTokenPtr_ == *t.wordTokenPtr_;
case STRING:
case VERBATIMSTRING:
return *stringTokenPtr_ == *t.stringTokenPtr_;
case LABEL:
@ -544,7 +552,7 @@ inline bool token::operator==(const word& w) const
inline bool token::operator==(const string& s) const
{
return (type_ == STRING && stringToken() == s);
return ((type_ == STRING || type_ == VERBATIMSTRING) && stringToken() == s);
}
inline bool token::operator==(const label l) const

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
@ -70,6 +70,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& t)
break;
case token::STRING:
case token::VERBATIMSTRING:
os << *t.stringTokenPtr_;
break;
@ -156,6 +157,10 @@ ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
os << " the string " << t.stringToken();
break;
case token::VERBATIMSTRING:
os << " the verbatim string " << t.stringToken();
break;
case token::LABEL:
os << " the label " << t.labelToken();
break;
@ -226,6 +231,10 @@ Ostream& operator<<(Ostream& os, const InfoProxy<token>& ip)
os << " the string " << t.stringToken();
break;
case token::VERBATIMSTRING:
os << " the verbatim string " << t.stringToken();
break;
case token::LABEL:
os << " the label " << t.labelToken();
break;

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
@ -27,6 +27,14 @@ License
#include "dictionary.H"
#include "OStringStream.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
int Foam::entry::disableFunctionEntries
(
Foam::debug::infoSwitch("disableFunctionEntries", 0)
);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::entry::entry(const keyType& keyword)

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
@ -81,6 +81,9 @@ class entry
public:
static int disableFunctionEntries;
// Constructors
//- Construct from keyword

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
@ -98,21 +98,32 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
}
else // Keyword starts entry ...
{
if (keyword[0] == '#') // ... Function entry
if
(
!disableFunctionEntries
&& keyword[0] == '#'
) // ... Function entry
{
word functionName = keyword(1, keyword.size()-1);
return functionEntry::execute(functionName, parentDict, is);
}
else if (keyword[0] == '$') // ... Substitution entry
else if
(
!disableFunctionEntries
&& keyword[0] == '$') // ... Substitution entry
{
parentDict.substituteKeyword(keyword);
return true;
}
else if (keyword == "include") // ... For backward compatibility
else if
(
!disableFunctionEntries
&& keyword == "include"
) // ... For backward compatibility
{
return functionEntries::includeEntry::execute(parentDict, is);
}
else // ... Data entries
else // ... Data entries
{
token nextToken(is);
is.putBack(nextToken);

View File

@ -249,7 +249,7 @@ bool Foam::functionEntries::codeStream::execute
<< " in library " << lib << exit(FatalIOError);
}
OStringStream os;
OStringStream os(is.format());
(*function)(parentDict, os);
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);

View File

@ -224,8 +224,7 @@ bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const
<< "because of security issues. If you trust the code you can"
<< " enable this" << nl
<< "facility be adding to the InfoSwitches setting in the system"
<< " controlDict" << nl
<< nl
<< " controlDict:" << nl << nl
<< " allowSystemOperations 1" << nl << nl
<< "The system controlDict is either" << nl << nl
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << nl << nl

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
@ -44,7 +44,8 @@ void Foam::primitiveEntry::append
if
(
w.size() == 1
disableFunctionEntries
|| w.size() == 1
|| (
!(w[0] == '$' && expandVariable(w, dict))
&& !(w[0] == '#' && expandFunction(w, dict, is))
@ -215,7 +216,17 @@ void Foam::primitiveEntry::write(Ostream& os) const
for (label i=0; i<size(); ++i)
{
os << operator[](i);
const token& t = operator[](i);
if (t.type() == token::VERBATIMSTRING)
{
os << token::HASH << token::BEGIN_BLOCK;
os.writeQuoted(t.stringToken(), false);
os << token::HASH << token::END_BLOCK;
}
else
{
os << t;
}
if (i < size()-1)
{

View File

@ -32,6 +32,7 @@ License
#include "JobInfo.H"
#include "labelList.H"
#include "regIOobject.H"
#include "codeStreamTools.H"
#include <cctype>
@ -787,6 +788,16 @@ Foam::argList::argList
regIOobject::fileModificationChecking
]
<< endl;
Info<< "allowSystemOperations : ";
if (codeStreamTools::allowSystemOperations)
{
Info<< "Allowing user-supplied system call operations" << endl;
}
else
{
Info<< "Disallowing user-supplied system call operations" << endl;
}
}
if (Pstream::master() && bannerEnabled)

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,9 @@
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

@ -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
@ -24,8 +24,8 @@ License
\*---------------------------------------------------------------------------*/
#include "systemCall.H"
#include "dictionary.H"
#include "Time.H"
#include "codeStreamTools.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -71,6 +71,30 @@ void Foam::systemCall::read(const dictionary& dict)
<< "no executeCalls, endCalls or writeCalls defined."
<< endl;
}
else if (!codeStreamTools::allowSystemOperations)
{
FatalErrorIn
(
"systemCall::read(const dictionary&)"
) << "Executing user-supplied system calls is not"
<< " enabled by default" << endl
<< "because of security issues. If you trust the case you can"
<< " enable this" << endl
<< "facility be adding to the InfoSwitches setting in the system"
<< " controlDict:" << endl
<< endl
<< " allowSystemOperations 1" << endl
<< endl
<< "The system controlDict is either" << endl
<< endl
<< " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << endl
<< endl
<< "or" << endl
<< endl
<< " $WM_PROJECT_DIR/etc/controlDict" << endl
<< endl
<< exit(FatalError);
}
}
@ -78,7 +102,7 @@ void Foam::systemCall::execute()
{
forAll(executeCalls_, callI)
{
::system(executeCalls_[callI].c_str());
Foam::system(executeCalls_[callI].c_str());
}
}
@ -87,7 +111,7 @@ void Foam::systemCall::end()
{
forAll(endCalls_, callI)
{
::system(endCalls_[callI].c_str());
Foam::system(endCalls_[callI].c_str());
}
}
@ -96,7 +120,7 @@ void Foam::systemCall::write()
{
forAll(writeCalls_, callI)
{
::system(writeCalls_[callI].c_str());
Foam::system(writeCalls_[callI].c_str());
}
}

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,7 @@ 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,25 @@
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

@ -136,6 +136,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 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;
}
}
// ************************************************************************* //

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