diff --git a/ReleaseNotes-dev b/ReleaseNotes-dev index 57fc61743df54d843ac740b18cfad12a1534290c..cb57f5cf9f41f0fe22655f94ba7fe7513cbf7285 100644 --- a/ReleaseNotes-dev +++ b/ReleaseNotes-dev @@ -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 diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/Make/files b/applications/solvers/heatTransfer/buoyantSimpleFoam_old/Make/files deleted file mode 100644 index 25c10cc98f75684c718201b973fbcaf989c57a97..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -buoyantSimpleFoam.C - -EXE = $(FOAM_APPBIN)/buoyantSimpleFoam diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/Make/options b/applications/solvers/heatTransfer/buoyantSimpleFoam_old/Make/options deleted file mode 100644 index ec604cf28cd4c9d764e745b5947a08c0b47449bf..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/Make/options +++ /dev/null @@ -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 diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/UEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam_old/UEqn.H deleted file mode 100644 index e51dfcdfcbd4dced772545407931b76412a48e78..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/UEqn.H +++ /dev/null @@ -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() - ) - */ - ); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleFoam_old/createFields.H deleted file mode 100644 index b304ace1046bbb82fff0318762b17848835cce1d..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/createFields.H +++ /dev/null @@ -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); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/hEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam_old/hEqn.H deleted file mode 100644 index b91a17ee7cb36244b1a7694d6ed345b3d990d1ca..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/hEqn.H +++ /dev/null @@ -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(); -} diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam_old/pEqn.H deleted file mode 100644 index a90dd23ebcefa831598ea8b4fa3b711ae802f648..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/pEqn.H +++ /dev/null @@ -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; -} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean index c583a8de0a566e26aac9c9ea863e7d07c49d3536..a4096c3fbef0f5ebce40518b3ca31d41cdc61887 100755 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwclean @@ -2,6 +2,7 @@ cd ${0%/*} || exit 1 # run from this directory set -x +wclean libso coupledDerivedFvPatchFields wclean wclean chtMultiRegionSimpleFoam diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake index f65ba1181b27328e733c732a1defa724bce87f30..be40e0c4f4bfa7c261f2f501c5506eaa2b3523a0 100755 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Allwmake @@ -2,6 +2,7 @@ cd ${0%/*} || exit 1 # run from this directory set -x +wmake libso coupledDerivedFvPatchFields wmake wmake chtMultiRegionSimpleFoam diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files index c62898c31f5de1989ceb9977ea572c045cd3d6f1..9ae609083204fe327c51be981e57d862b3a169a9 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files @@ -1,5 +1,3 @@ -derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C - fluid/compressibleCourantNo.C solid/solidRegionDiffNo.C diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options index 636fc5d8bb8cf3a807d7a9aa83c9e471de28baf8..84d0633333fe473fc4ff3da76e588e68d8722de1 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options @@ -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 diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C index eab496d11b5b0dab91f1b13a77438c8f2363ad0e..e126b4656d224f2d7c3c37a7a5f6c1aa1f99b6dd 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options index 599e1e7502ef5b5a0df30e23944f9b8f70f4d876..0459735470352de2b8effde0449400838d1ad8cc 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/Make/options @@ -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 diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C index 4f0d5fc25b43cd64a21fc5b226da09e0a6a6a360..1cb756541a8418779bf0784eb9d7b547b58a94ee 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C @@ -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" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidFields.H index 75191acff962bafb660652cb41830e9c074eeaae..3d8531e1bb6bb98ac532724d71f3a62337950744 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/createFluidFields.H @@ -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 diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H index 7869046fa0213e4b92d30119fa40f2149489095b..2fde518a6c10a6c55addf6d5bba10c22bf72d532 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H @@ -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; } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H index 754f67c52cf9a980b2231c78846816c572f04e57..1b6a22db0da022cf756921210b2c59d3abcbb00c 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H @@ -19,6 +19,8 @@ initialMassFluid[i] ); + radiation::radiationModel& rad = radiation[i]; + const label pRefCell = pRefCellFluid[i]; const scalar pRefValue = pRefValueFluid[i]; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..7e253a8b32fcced91764a31c83fd8c2d832b4642 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/Make/files @@ -0,0 +1,4 @@ +turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C + +LIB = $(FOAM_LIBBIN)/libcoupledDerivedFvPatchFields diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..a178c0d55d50cfb058feaee3a1a6a458481c1dcb --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/Make/options @@ -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 diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..03d932975f3b21a6082ad9c293fc3d0da3b0538c --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.C @@ -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 + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H similarity index 59% rename from applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H rename to applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H index 5d91b8daa1d8a80b40b6789d23712bfd03f5055a..e98c940f128863096fccb5f78651f4112ce9c4ba 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/externalWallHeatFluxTemperature/externalWallHeatFluxTemperatureFvPatchScalarField.H @@ -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 diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..47dd57d86397d9631efb09a3588f3ba5dfabeb99 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -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 + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..0140cdd199117cef8bc6dd5df5a549cc1d246a3f --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupledDerivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H @@ -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 + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C deleted file mode 100644 index 0d73c89cd6b518de6ef9b4a9e54bcf4a298d1a91..0000000000000000000000000000000000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C +++ /dev/null @@ -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 - ); -} - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index 012426af6a7b22a0feaa0ff53f6f7db14319bd3f..f6788d26eb3ecccb2bea1484949a781e7f3010a3 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -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; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H index 16ba36f7dc71513a6204dde059fb1cfe8868062d..0bb3c8b47c61f70aedd822071aab0a6753957055 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H @@ -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; } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H index 9cb2450952acdf9531a94bc60e1eac5615657238..81c6d25bb0ccc68597a0b154e0b7c3baa98552ba 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H @@ -17,6 +17,8 @@ const volScalarField& gh = ghFluid[i]; const surfaceScalarField& ghf = ghfFluid[i]; + radiation::radiationModel& rad = radiation[i]; + const dimensionedScalar initialMass ( "initialMass", diff --git a/applications/solvers/lagrangian/steadyReactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/steadyReactingParcelFoam/pEqn.H index fb6c4f76d9bf373bc6e7faf0361f5c628eb00d8a..c9c4890b01cccee6a02ae70fefaa1ac206d20a31 100644 --- a/applications/solvers/lagrangian/steadyReactingParcelFoam/pEqn.H +++ b/applications/solvers/lagrangian/steadyReactingParcelFoam/pEqn.H @@ -27,7 +27,7 @@ ( fvc::ddt(rho) + psi*correction(fvm::ddt(p)) + fvc::div(phi) - == + == parcels.Srho() + massSource.SuTot() ); diff --git a/applications/solvers/multiphase/interFoam/LTSInterFoam/setrDeltaT.H b/applications/solvers/multiphase/interFoam/LTSInterFoam/setrDeltaT.H index e84eef10237224fe5c89b9d5cd1390a4f02d31e6..7dc077996939c7b2d87c9b155dca421de926cf1a 100644 --- a/applications/solvers/multiphase/interFoam/LTSInterFoam/setrDeltaT.H +++ b/applications/solvers/multiphase/interFoam/LTSInterFoam/setrDeltaT.H @@ -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()) diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index 083107efb941126c93d447101baf8c057d60804a..c5df6ef79f2a88db3605186cbfc879c8fc5f6ae1 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -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; diff --git a/applications/utilities/preProcessing/faceAgglomerate/Make/files b/applications/utilities/preProcessing/faceAgglomerate/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..34bd95a842526d76a964c2d160ea69d04b3873bc --- /dev/null +++ b/applications/utilities/preProcessing/faceAgglomerate/Make/files @@ -0,0 +1,3 @@ +faceAgglomerate.C + +EXE = $(FOAM_APPBIN)/faceAgglomerate diff --git a/applications/utilities/preProcessing/faceAgglomerate/Make/options b/applications/utilities/preProcessing/faceAgglomerate/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..c2b07c70247b621c7c6b968856a751fe4bdd8c4d --- /dev/null +++ b/applications/utilities/preProcessing/faceAgglomerate/Make/options @@ -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 diff --git a/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C new file mode 100644 index 0000000000000000000000000000000000000000..f71df8c6f3f19f85e7398039df3f09572f155eef --- /dev/null +++ b/applications/utilities/preProcessing/faceAgglomerate/faceAgglomerate.C @@ -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; +} diff --git a/applications/utilities/preProcessing/foamUpgradeCyclics/foamUpgradeCyclics.C b/applications/utilities/preProcessing/foamUpgradeCyclics/foamUpgradeCyclics.C index dd44b492809ce6d09a3cef1e004d24a17d030ee0..f1a7ab5301a2ed90260a227fc12891eebbd69f63 100644 --- a/applications/utilities/preProcessing/foamUpgradeCyclics/foamUpgradeCyclics.C +++ b/applications/utilities/preProcessing/foamUpgradeCyclics/foamUpgradeCyclics.C @@ -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; diff --git a/applications/utilities/preProcessing/viewFactorGen/Make/files b/applications/utilities/preProcessing/viewFactorGen/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..aa0bc4481e115c0f278dc12b32bceba280daeb4f --- /dev/null +++ b/applications/utilities/preProcessing/viewFactorGen/Make/files @@ -0,0 +1,3 @@ +viewFactorsGen.C + +EXE = $(FOAM_APPBIN)/viewFactorsGen diff --git a/applications/utilities/preProcessing/viewFactorGen/Make/options b/applications/utilities/preProcessing/viewFactorGen/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..b0dbd4000feaee878d6483436595eccfa52bcdb2 --- /dev/null +++ b/applications/utilities/preProcessing/viewFactorGen/Make/options @@ -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 diff --git a/applications/utilities/preProcessing/viewFactorGen/searchingEngine.H b/applications/utilities/preProcessing/viewFactorGen/searchingEngine.H new file mode 100644 index 0000000000000000000000000000000000000000..17de4fbf6cf10261608166d93f9e2de07a850243 --- /dev/null +++ b/applications/utilities/preProcessing/viewFactorGen/searchingEngine.H @@ -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(); diff --git a/applications/utilities/preProcessing/viewFactorGen/shootRays.H b/applications/utilities/preProcessing/viewFactorGen/shootRays.H new file mode 100644 index 0000000000000000000000000000000000000000..75eca8bc280ad9364fe6c2cf267474661dc34d18 --- /dev/null +++ b/applications/utilities/preProcessing/viewFactorGen/shootRays.H @@ -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]); + } + } + } +} diff --git a/applications/utilities/preProcessing/viewFactorGen/viewFactorsGen.C b/applications/utilities/preProcessing/viewFactorGen/viewFactorsGen.C new file mode 100644 index 0000000000000000000000000000000000000000..cd852f59c3a721556068e4b468b4de130539462f --- /dev/null +++ b/applications/utilities/preProcessing/viewFactorGen/viewFactorsGen.C @@ -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; +} + +// ************************************************************************* // diff --git a/bin/foamCleanPath b/bin/foamCleanPath index 0485c76dd10d9b427c02db5c29dad5ca006e7558..7eae89bc3433e64849e0b5aac441922e6862447b 100755 --- a/bin/foamCleanPath +++ b/bin/foamCleanPath @@ -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 diff --git a/doc/changes/codeStream.org b/doc/changes/codeStream.org new file mode 100644 index 0000000000000000000000000000000000000000..bcef4c166bb5803cabb1d1ccd8828b2d0d4aa859 --- /dev/null +++ b/doc/changes/codeStream.org @@ -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? diff --git a/doc/changes/onTheFly.txt b/doc/changes/onTheFly.txt deleted file mode 100644 index 2dc3f5edfaf99bb39b6bd0f80c84254a62cae228..0000000000000000000000000000000000000000 --- a/doc/changes/onTheFly.txt +++ /dev/null @@ -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? diff --git a/etc/codeTemplates/codeStream/codeStreamTemplate.C b/etc/codeTemplates/codeStream/codeStreamTemplate.C index f6aa7501ccebe08a4e5ddbb928b82e7d1809fae1..50a47e1b1ae4acd35024f4a3fab147d59bfd75ab 100644 --- a/etc/codeTemplates/codeStream/codeStreamTemplate.C +++ b/etc/codeTemplates/codeStream/codeStreamTemplate.C @@ -26,6 +26,10 @@ Description \*---------------------------------------------------------------------------*/ +#include "dictionary.H" +#include "Ostream.H" +#include "Pstream.H" + //{{{ begin codeInclude ${codeInclude} //}}} end codeInclude diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C index f0026c2ff09e230b21c229b7eb2152f728e123c9..50728c425ccba43a2f960d4b8d00d102089dcbb7 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -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 { diff --git a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C index 135f61823afe9c3e8f6ba2f54840a6242f160f0b..90e2a46c829155bf39056901cff9544fefd2b6bc 100644 --- a/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C +++ b/src/OpenFOAM/db/IOstreams/Sstreams/ISstream.C @@ -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; diff --git a/src/OpenFOAM/db/IOstreams/token/token.H b/src/OpenFOAM/db/IOstreams/token/token.H index 7c91758c1a528011db70e6564b6876935c93f380..c48c22b5c3e067ce2d3e6b3bd5affe04e24279fd 100644 --- a/src/OpenFOAM/db/IOstreams/token/token.H +++ b/src/OpenFOAM/db/IOstreams/token/token.H @@ -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; diff --git a/src/OpenFOAM/db/IOstreams/token/tokenI.H b/src/OpenFOAM/db/IOstreams/token/tokenI.H index 6c3434deadd3a8eaa779a4975cabb6dab2564ba2..11124e9e2aea899bae69eb4459703e52d51890f4 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenI.H +++ b/src/OpenFOAM/db/IOstreams/token/tokenI.H @@ -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 diff --git a/src/OpenFOAM/db/IOstreams/token/tokenIO.C b/src/OpenFOAM/db/IOstreams/token/tokenIO.C index bf7cdd081d0451fddca9149665e0ec7244f85aef..23c17e75e582899d711315820d294246dc5783a9 100644 --- a/src/OpenFOAM/db/IOstreams/token/tokenIO.C +++ b/src/OpenFOAM/db/IOstreams/token/tokenIO.C @@ -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; diff --git a/src/OpenFOAM/db/dictionary/entry/entry.C b/src/OpenFOAM/db/dictionary/entry/entry.C index de62c861a48a164b3a88fabb66e21eade3b6a93b..3bba611deeb574cde58d921f6d4fc02b7012f8d7 100644 --- a/src/OpenFOAM/db/dictionary/entry/entry.C +++ b/src/OpenFOAM/db/dictionary/entry/entry.C @@ -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) diff --git a/src/OpenFOAM/db/dictionary/entry/entry.H b/src/OpenFOAM/db/dictionary/entry/entry.H index 21f56347282f4ebcd05ddc8afd7b7b1f0e144250..93b5a143a213b8fcba54632d54db9682cf35a304 100644 --- a/src/OpenFOAM/db/dictionary/entry/entry.H +++ b/src/OpenFOAM/db/dictionary/entry/entry.H @@ -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 diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index c61a97e7c58f71f2a02e7268ac078c72c3a46921..1f3172f0e50af5a4ce13043bd8cd61822e66d087 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.C @@ -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); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 02b5ec77f2ef3b1bcc8b0a05510edaeec17b5757..af3904759dfb1e3f95ad212e55a2e4376bb4fcec 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -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); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C index cf9f1a324ae6f9deaf078e0618bc25c335b53d4d..fc1c6f0ffb79b7de0cbcb92044b249b7f6d49f40 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C @@ -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 diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index a7fcb0c64dab12157c7538694ca8fdb5f9b1e9a5..fa9a50efdb15b6dc603d17abfdb4295f5e6a51ac 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -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) { diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 1d23a86c9cb72cd37deb8cc75e205b965ae678d3..08cc78f762ef74687329e2f05b82acffb976a31f 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -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) diff --git a/src/OpenFOAM/global/unitConversion/unitConversion.H b/src/OpenFOAM/global/unitConversion/unitConversion.H index 3255a4d805d6db5ab1a9e8f0fcdce521bf3824d5..b9a84dcf395fdad068defd1619cd5ba2d856e296 100644 --- a/src/OpenFOAM/global/unitConversion/unitConversion.H +++ b/src/OpenFOAM/global/unitConversion/unitConversion.H @@ -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 diff --git a/src/fvAgglomerationMethods/Allwmake b/src/fvAgglomerationMethods/Allwmake index 61d951c8c6f76481968aebcdc58dc977031103b6..8328d915fc671b1561795a490c5470167e86a10f 100755 --- a/src/fvAgglomerationMethods/Allwmake +++ b/src/fvAgglomerationMethods/Allwmake @@ -10,4 +10,6 @@ then wmake $makeOption MGridGenGamgAgglomeration fi +wmake libso pairPatchAgglomeration + # ----------------------------------------------------------------- end-of-file diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/files b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..275c4795f3b7d271330350feb0d87f1b919a89f8 --- /dev/null +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/files @@ -0,0 +1,3 @@ +pairPatchAgglomeration.C + +LIB = $(FOAM_LIBBIN)/libpairPatchAgglomeration diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/options b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..93a7e01542e3a516c7ed5370f0f7b4b77b8e9544 --- /dev/null +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/Make/options @@ -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 diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C new file mode 100644 index 0000000000000000000000000000000000000000..12946afadfd2e812456daa24734687b149479fbe --- /dev/null +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.C @@ -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)); +} +// ************************************************************************* // diff --git a/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H new file mode 100644 index 0000000000000000000000000000000000000000..ed66673bd7b95124e9d41c4be1754999094215c5 --- /dev/null +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomeration.H @@ -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 + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/buoyantSimpleFoam.C b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomerationTemplates.C similarity index 50% rename from applications/solvers/heatTransfer/buoyantSimpleFoam_old/buoyantSimpleFoam.C rename to src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomerationTemplates.C index b78c36ed86e07726e68fb7f8aaf59db80836e017..0ac62aa3adf9b7f9ff4315fa686d4b4e22e85007 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam_old/buoyantSimpleFoam.C +++ b/src/fvAgglomerationMethods/pairPatchAgglomeration/pairPatchAgglomerationTemplates.C @@ -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" - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - - Info<< "\nStarting time loop\n" << endl; + const labelList& fineToCoarse = restrictAddressing_[fineLevelIndex]; - while (runTime.loop()) + if (ff.size() != fineToCoarse.size()) { - Info<< "Time = " << runTime.timeName() << nl << endl; - - #include "readSIMPLEControls.H" + 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); + } - p.storePrevIter(); - rho.storePrevIter(); + cf = pTraits<Type>::zero; - // Pressure-velocity SIMPLE corrector - { - #include "UEqn.H" - #include "hEqn.H" - #include "pEqn.H" - } + forAll(ff, i) + { + cf[fineToCoarse[i]] += ff[i]; + } +} - turbulence->correct(); - runTime.write(); +template<class Type> +void Foam::pairPatchAgglomeration::prolongField +( + Field<Type>& ff, + const Field<Type>& cf, + const label coarseLevelIndex +) const +{ + const labelList& fineToCoarse = restrictAddressing_[coarseLevelIndex]; - Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" - << " ClockTime = " << runTime.elapsedClockTime() << " s" - << nl << endl; + forAll(fineToCoarse, i) + { + ff[i] = cf[fineToCoarse[i]]; } - - Info<< "End\n" << endl; - - return 0; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C index 1f6a2750272fd8b0ce91328ae78524acf592a99f..38517d00a72a3cec389fdb7768e49b80c7ab05a6 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C @@ -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; diff --git a/src/postProcessing/functionObjects/systemCall/systemCall.C b/src/postProcessing/functionObjects/systemCall/systemCall.C index 5f12e9689ce0a16ba879f08472e9abc3b9081a4f..664589750cf6665fe77ea6f12ec3440e4d4f81b4 100644 --- a/src/postProcessing/functionObjects/systemCall/systemCall.C +++ b/src/postProcessing/functionObjects/systemCall/systemCall.C @@ -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()); } } diff --git a/src/thermophysicalModels/radiationModels/Make/files b/src/thermophysicalModels/radiationModels/Make/files index 2a8b05a84d1fb267321fad19742240b3b2b76604..c86d8aa8d321f33659d709a87fd51afb032cb5ca 100644 --- a/src/thermophysicalModels/radiationModels/Make/files +++ b/src/thermophysicalModels/radiationModels/Make/files @@ -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 diff --git a/src/thermophysicalModels/radiationModels/Make/options b/src/thermophysicalModels/radiationModels/Make/options index 2e150f2bf995816237915d12a8ce6b0cf4633fc2..5b54f537f810ea3f5c1226ad17c9585f10deb0af 100644 --- a/src/thermophysicalModels/radiationModels/Make/options +++ b/src/thermophysicalModels/radiationModels/Make/options @@ -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 diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C index 5ef5f62f864ef7a9bedb4dd1288b576ea9a6a600..ff6337ebc106076281dbfd67c4f3ef28eb966dc1 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.C @@ -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; } diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H index 9a5f880042f71c3ace771c8f5a9cc40879ec03de..35ed979edb899f1ac305bfb415db992022e3c75f 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H @@ -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 diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C index d5bc52360a73d0b1e222d90559542aca396f1512..120e699b939e1f1110bae18c336372a771330716 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.C @@ -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; } diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H index 5a77b6f246e7d021dfc38a24ad56f4385daea6f5..3306420baa2c79475eefe7e338915b3da9faecb1 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H @@ -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 diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C index 850ea09543e04d1570ccf911b8f18138feb03e42..dd2fc5700740049a1fb70acb152b991f4f866834 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -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; } diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H index 1cf290ec79993c20001c9dd93b17cf81483ca646..129e69f2b51947eec991a0350a661dde53bfafbd 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H @@ -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 diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..4a062f3b90e98ddddea07561e16a27a07c456de9 --- /dev/null +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.C @@ -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 + ); +} +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..c1e45318736303409e01603c1019155776dba54b --- /dev/null +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveViewFactor/greyDiffusiveViewFactorFixedValueFvPatchScalarField.H @@ -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 + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C new file mode 100644 index 0000000000000000000000000000000000000000..eab4624c295b675920d3537e24a91d4f05109b1c --- /dev/null +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C @@ -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); +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H new file mode 100644 index 0000000000000000000000000000000000000000..405d0f75a54ef6723d169f997bf1cdaaadf9d706 --- /dev/null +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H @@ -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 + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C index efe439d69bb4a186737470463bbfa72b009ef251..45ab196b5c0780f5bae069d5aa06d97e2e2393dc 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.C @@ -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; + } diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H index 87048d767ad6ebc43e349cb141e7c5eb7d96b1c8..403d5b8960c1660d021536512dc3f1137f63dbca 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H @@ -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 diff --git a/src/thermophysicalModels/radiationModels/radiationModel/P1/P1.C b/src/thermophysicalModels/radiationModels/radiationModel/P1/P1.C index f59b5632f4468fc80e8b9db8e475efe7563ec8e5..907ffc4566361f92b43a2a605a58bf6cdbf44653 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/P1/P1.C +++ b/src/thermophysicalModels/radiationModels/radiationModel/P1/P1.C @@ -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) diff --git a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C index 17cdab82b4989411eb9cd57728251068c7ff895c..cda5e495a0a38ddf454d520f08227b7942511191 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -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++; diff --git a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C index 8da1d9a7ae2508cfdf75be9cca6b7ae7e67dcfa1..4edf09663f7d7105f0920c1094c216ecabc46a73 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +++ b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C @@ -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; diff --git a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H index d2b928dbf2bde4b31c988ff8f23fb08a0c0fb2dd..a7a95648d49a70f63bcf18e682c4548ce9cdc17b 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H +++ b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H @@ -130,7 +130,8 @@ public: const scalar deltaTheta, const label lambda, const absorptionEmissionModel& absEmmModel_, - const blackBodyEmission& blackBody + const blackBodyEmission& blackBody, + const label rayId ); diff --git a/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactor.C b/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactor.C new file mode 100644 index 0000000000000000000000000000000000000000..a8d736e4c44c97719f68bfcfc9cd29e806743b53 --- /dev/null +++ b/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactor.C @@ -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; +} + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactor.H b/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactor.H new file mode 100644 index 0000000000000000000000000000000000000000..714c908e19da97bb0e47169794254c25849c38ea --- /dev/null +++ b/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactor.H @@ -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 + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactorI.H b/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactorI.H new file mode 100644 index 0000000000000000000000000000000000000000..5e903d5ed593373f5561899e6a4f625ec27941aa --- /dev/null +++ b/src/thermophysicalModels/radiationModels/radiationModel/viewFactor/viewFactorI.H @@ -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_; +} + + + +// ************************************************************************* // diff --git a/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C b/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C index 62c491b1040ba058435aa4df53857ff117d78deb..21dfa9786dad656c1ee0f7a71a827fee551384f9 100644 --- a/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C +++ b/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.C @@ -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; } diff --git a/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H b/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H index 6e8fbe8c456157123729696d23832042ffe67668..a41d2adf097ef288a6f6d37c10c9d439c6b1d116 100644 --- a/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H +++ b/src/thermophysicalModels/radiationModels/submodels/absorptionEmissionModel/greyMeanAbsorptionEmission/greyMeanAbsorptionEmission.H @@ -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_; diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/G b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/G index 5095d44209f6a69c6d97ba677092b5ed4fea6d30..dcd3b3a64404b9ac9bdc94a548ebd07c6003500c 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/G +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/G @@ -24,7 +24,8 @@ boundaryField { type MarshakRadiation; T T; - emissivity 1; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } } diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/IDefault b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/IDefault index 94f365296e9262ca775182d6bba125ae7bd39c16..f122ced6002a3f2c01d98cc81f056c8ee12b4d78 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/IDefault +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/IDefault @@ -24,7 +24,8 @@ boundaryField { type greyDiffusiveRadiation; T T; - emissivity 1.0; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } } diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/radiationProperties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/radiationProperties index 37b3eefe66e2c4b483666eb57be3033df214ad72..af43965719ae353a52bc14b3c2cb67eb2fcaa1a7 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/radiationProperties +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/radiationProperties @@ -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; diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/IDefault b/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/IDefault index 32b03c16d5e99f46447a0a02d11c9a3223b1ee33..e70bf3dec049007f0f422f82e0a9cab1950acdec 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/IDefault +++ b/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/IDefault @@ -24,7 +24,8 @@ boundaryField { type greyDiffusiveRadiation; T T; - emissivity 1.0; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } } diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/radiationProperties b/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/radiationProperties index 500834ae4afe2f9ec3ad0fcd30a4ccd8da91a1dc..ce19474d30478c00148f61901742e7785f83e452 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/radiationProperties +++ b/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/radiationProperties @@ -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; diff --git a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/G b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/G index d49a1b712b778f241fd43b9bf23c315b3d772fc3..1128a5d3bae3db01b7683f99f0cddbb870679afc 100644 --- a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/G +++ b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/G @@ -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; } } diff --git a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/IDefault b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/IDefault index 94f365296e9262ca775182d6bba125ae7bd39c16..f122ced6002a3f2c01d98cc81f056c8ee12b4d78 100644 --- a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/IDefault +++ b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/IDefault @@ -24,7 +24,8 @@ boundaryField { type greyDiffusiveRadiation; T T; - emissivity 1.0; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } } diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/G b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/G new file mode 100644 index 0000000000000000000000000000000000000000..63d9bdfee78f3e064b163214df83b0c8849fec6b --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/G @@ -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; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/IDefault b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/IDefault new file mode 100644 index 0000000000000000000000000000000000000000..c2261b23d53e41e6c191acfa3ab0c587b43180f4 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/IDefault @@ -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; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Qr b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Qr new file mode 100644 index 0000000000000000000000000000000000000000..b4f1299fde753a836599821147b314d548445d82 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Qr @@ -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; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/T b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/T new file mode 100644 index 0000000000000000000000000000000000000000..b1ac0594dee07fd287ba76f308f6f71ec0224a80 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/T @@ -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; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/U b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/U new file mode 100644 index 0000000000000000000000000000000000000000..8e47fbcddf8a6d77315c7deb728c6eb1215eb68e --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/U @@ -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; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Ychar b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Ychar new file mode 100644 index 0000000000000000000000000000000000000000..335b277e88e2621bf29a5198d608b665076fbee5 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Ychar @@ -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; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Ypmma b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Ypmma new file mode 100644 index 0000000000000000000000000000000000000000..93b284771015eb7eaa81355b9a3660f914a856ac --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/Ypmma @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object Ypmma; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0.5; + +boundaryField +{ + ".*" + { + type calculated; + value uniform 0.5; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/epsilon b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..f4e27ad95fb84fff1121e59c121f6d2c844d1b43 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/epsilon @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform 0.01; + +boundaryField +{ + ".*" + { + type calculated; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/k b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/k new file mode 100644 index 0000000000000000000000000000000000000000..b2509f967076c366a4ab4e410f070916983536e4 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/k @@ -0,0 +1,30 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + ".*" + { + type calculated; + } +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/p b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/p new file mode 100644 index 0000000000000000000000000000000000000000..66e0be0a837044ce28892d2cbb9cc839afb18156 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/p @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 1e5; + +boundaryField +{ + ".*" + { + type calculated; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/p_rgh b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/p_rgh new file mode 100644 index 0000000000000000000000000000000000000000..638c8c7d7cd472cf343b4fc5091d9a8f1bf038ae --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/p_rgh @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 1e5; + +boundaryField +{ + ".*" + { + type calculated; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/rho b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/rho new file mode 100644 index 0000000000000000000000000000000000000000..fb0aab998f609fabd656403d208b8b9a75ca0c28 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/0/rho @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object rho; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -3 0 0 0 0 0]; + +internalField uniform 8000; + +boundaryField +{ + ".*" + { + type calculated; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..4b005c9814b85af2ba0d893540661cfe1739b135 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allclean @@ -0,0 +1,35 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase +rm -rf VTK +rm -rf constant/cellToRegion constant/polyMesh/sets +rm -rf 0/bottomAir +rm -rf 0/topAir +rm -rf 0/heater +rm -rf 0/leftSolid +rm -rf 0/rightSolid +rm -f 0/cellToRegion + +rm -rf constant/bottomAir/polyMesh +rm -rf constant/topAir/polyMesh +rm -rf constant/heater/polyMesh +rm -rf constant/leftSolid/polyMesh +rm -rf constant/rightSolid/polyMesh + +rm -f constant/bottomAir/F +rm -f constant/bottomAir/constructMap* +rm -f constant/bottomAir/finalAgglom +rm -f constant/bottomAir/globalFaceFaces +rm -f constant/bottomAir/subMap + +rm -f constant/topAir/F +rm -f constant/topAir/constructMap* +rm -f constant/topAir/finalAgglom +rm -f constant/topAir/globalFaceFaces +rm -f constant/topAir/subMap + +# ----------------------------------------------------------------- end-of-file diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..e40aa7850a9fe09cf138114cfad16e6585ebb13b --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/Allrun @@ -0,0 +1,69 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication blockMesh +runApplication setSet -batch makeCellSets.setSet +runApplication splitMeshRegions -cellZones -overwrite + +# remove fluid fields from solid regions (important for post-processing) +for i in heater leftSolid rightSolid +do + rm -f 0*/$i/{rho,mut,alphat,epsilon,k,p,U,p_rgh,Qr,G,IDefault} +done + +## remove solid fields from fluid regions (important for post-processing) +for i in bottomAir topAir +do + rm -f 0*/$i/{Ypmma,Ychar} +done + +for i in bottomAir topAir heater leftSolid rightSolid +do + changeDictionary -region $i > log.changeDictionary.$i 2>&1 +done + + +for i in bottomAir topAir +do + faceAgglomerate -region $i > log.faceAgglomerate.$i 2>&1 +done + +for i in bottomAir topAir +do + viewFactorsGen -region $i > log.viewFactorsGen.$i 2>&1 +done + + + +#-- Run on single processor +runApplication chtMultiRegionSimpleFoam + +## Decompose +#for i in bottomAir topAir heater leftSolid rightSolid +#do +# decomposePar -region $i > log.decomposePar.$i 2>&1 +#done +# +## Run +#runParallel chtMultiRegionSimpleFoam 4 +# +## Reconstruct +#for i in bottomAir topAir heater leftSolid rightSolid +#do +# reconstructPar -region $i > log.reconstructPar.$i 2>&1 +#done + + +echo +echo "creating files for paraview post-processing" +echo +for i in bottomAir topAir heater leftSolid rightSolid +do + paraFoam -touch -region $i +done + +# ----------------------------------------------------------------- end-of-file diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/RASProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/RASProperties new file mode 100644 index 0000000000000000000000000000000000000000..1597ab89059120cb6f18a9c26f37c6599104e3c5 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/RASProperties @@ -0,0 +1,24 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel laminar; + +turbulence on; + +printCoeffs on; + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/g b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/g new file mode 100644 index 0000000000000000000000000000000000000000..2a29484f31d3d73ea1a085bd082fa8a9f73ca167 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/g @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/radiationProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/radiationProperties new file mode 100644 index 0000000000000000000000000000000000000000..cb4dce9a83a123b035a143431b62e1e459486f66 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/radiationProperties @@ -0,0 +1,156 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object radiationProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +radiation on; + +radiationModel viewFactor;//fvDOM;//P1; + +viewFactorCoeffs +{ + smoothing true; //Smooth view factor matrix (use when in a close surface + //to force Sum(Fij = 1) + constantEmissivity true; //constant emissivity on surfaces. +} + +noRadiation +{ +} + +P1Coeffs +{ +} + +fvDOMCoeffs +{ + nPhi 3; // azimuthal angles in PI/2 on X-Y.(from Y to X) + nTheta 4; // polar angles in PI (from Z to X-Y plane) + convergence 1e-3; // convergence criteria for radiation iteration + maxIter 5; // maximum number of iterations +} + +// Number of flow iterations per radiation iteration +solverFreq 3; + +absorptionEmissionModel constantAbsorptionEmission; + +constantAbsorptionEmissionCoeffs +{ + a a [ 0 -1 0 0 0 0 0 ] 0.01; + e e [ 0 -1 0 0 0 0 0 ] 0.01; + E E [ 1 -1 -3 0 0 0 0 ] 0; +} + +greyMeanAbsorptionEmissionCoeffs +{ + lookUpTableFileName "SpeciesTable"; + + EhrrCoeff 0.0; + + CO2 + { + Tcommon 300; //Common Temp + invTemp true; //Is the polynomio using inverse temperature. + Tlow 200; //Low Temp + Thigh 2500; //High Temp + + loTcoeffs //coefss for T < Tcommon + ( + 0 // a0 + + 0 // a1*T + + 0 // a2*T^(+/-)2 + + 0 // a3*T^(+/-)3 + + 0 // a4*T^(+/-)4 + + 0 // a5*T^(+/-)5 + + ); + hiTcoeffs //coefss for T > Tcommon + ( + 18.741 + -121.31e3 + 273.5e6 + -194.05e9 + 56.31e12 + -5.8169e15 + ); + + } + + H2O + { + Tcommon 300; + invTemp true; + Tlow 200; + Thigh 2500; + + loTcoeffs + ( + 0 + 0 + 0 + 0 + 0 + 0 + ); + hiTcoeffs + ( + -0.23093 + -1.12390e3 + 9.4153e6 + -2.99885e9 + 0.51382e12 + -1.868e10 + ); + } + + CH4 + { + Tcommon 300; + Tlow 200; + Thigh 2500; + invTemp false; + + loTcoeffs + ( + 0 + 0 + 0 + 0 + 0 + 0 + ); + hiTcoeffs + ( + 6.6334 + -0.0035686 + 1.6682e-8 + 2.5611e-10 + -2.6558e-14 + 0 + ); + } + +} + +scatterModel constantScatter; + +constantScatterCoeffs +{ + sigma sigma [ 0 -1 0 0 0 0 0 ] 0; + C C [ 0 0 0 0 0 0 0 ] 0; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/thermophysicalProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..1c4488eb5e030a7cb28293290fff08fd2e85ec38 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/thermophysicalProperties @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant/bottomAir"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType hRhoThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>; + +mixture +{ + nMoles 1; + molWeight 28.9; + Cp 1000; + Hf 0; + mu 1.8e-05; + Pr 0.7; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/turbulenceProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..e01c7d0bdb74fc55f9957b281c04de102e626f04 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/turbulenceProperties @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/viewFactorsDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/viewFactorsDict new file mode 100644 index 0000000000000000000000000000000000000000..073aa8d6e0eece9a17b55d55fc9be0e5e19addf6 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/bottomAir/viewFactorsDict @@ -0,0 +1,69 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object viewFactorsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +writeViewFactorMatrix true; +writeFacesAgglomeration true; + +bottomAir_to_heater +{ + nFacesInCoarsestLevel 30; + featureAngle 10; +} + +bottomAir_to_leftSolid +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + +bottomAir_to_rightSolid +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + +minX +{ + nFacesInCoarsestLevel 10; + featureAngle 10; +} + +minY +{ + nFacesInCoarsestLevel 30; + featureAngle 10; +} + +minZ +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + +maxX +{ + nFacesInCoarsestLevel 10; + featureAngle 10; +} + +maxZ +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/heater/solidThermophysicalProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/heater/solidThermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..08de18bfc63d2e8f010a149975f66cbd90eeac7f --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/heater/solidThermophysicalProperties @@ -0,0 +1,152 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object solidThermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType constSolidThermo; +//thermoType isotropicKSolidThermo; +//thermoType directionalKSolidThermo; +//thermoType solidMixtureThermo<multiComponentSolidMixture<exponentialSolidTransport<constSolidRad<exponentialSolidThermo<constRho>>>>>; + + +constSolidThermoCoeffs +{ + //- thermo properties + rho rho [1 -3 0 0 0 0 0] 8000; + Cp Cp [0 2 -2 -1 0 0 0] 450; + K K [1 1 -3 -1 0 0 0] 80; + + //- radiative properties + kappa kappa [0 -1 0 0 0 0 0] 0; + sigmaS sigmaS [0 -1 0 0 0 0 0] 0; + emissivity emissivity [0 0 0 0 0 0 0] 0.5; + + //- chemical properties + Hf Hf [0 2 -2 0 0 0 0] 0; +} + + +isotropicKSolidThermoCoeffs +{ + + //- thermo properties + TValues (100 1000); + rhoValues (1000 1700); + cpValues (1700 1700); + KValues (80 40); + + + //- radiative properties + emissivityValues (1 1); + kappaValues (0 0); + sigmaSValues (0 0); + + //- chemical properties + HfValues (1 1); + +} + + +directionalKSolidThermoCoeffs +{ + //- does interpolation and directional K in coordinate system. + // Specify multiple values, one for each temperature. Properties are + // interpolated according to the local temperature. + + //- thermo properties + TValues (100 1000); + rhoValues (1700 1700); + cpValues (1700 1700); + KValues ((10 10 10) (40 40 40)); + + coordinateSystem + { + origin (-0.000062 0.000019 0.000039); + coordinateRotation + { + type axes; + e1 (1 0 0); + e3 (-3.1807824e-6 -0.99813473 0.0610505); + } + } + + //- chemical properties + HfValues (1 1); + + //- radiative properties + emissivityValues (1 1); + kappaValues (1 1); + sigmaSValues (1 1); +} + +solidComponents +( + pmma char +); + +pmmaCoeffs +{ + transportProperties + { + K0 0.152; + n0 1.3; + Tref 300; //K0*pow(T/Tref_, n0)) + } + radiativeProperties + { + sigmaS 0.0; + kappa 0.0; + emissivity 0.1; + } + thermoProperties + { + Hf 0; + C0 1462; // Cp = C0*(T/Tref)^n0 + Tref 300; + n0 1.31; + } + densityProperties + { + rho 1114.0; + } +} + +charCoeffs +{ + transportProperties + { + K0 0.4; + n0 1.3; + Tref 300; //K0*pow(T/Tref_, n0)) + } + radiativeProperties + { + sigmaS 0.0; + kappa 0.0; + emissivity 0.0; + } + thermoProperties + { + Hf 0; + C0 611.0;; // Cp = C0*(T/Tref)^n0 + Tref 300; + n0 1.31; + } + densityProperties + { + rho 11.5; + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/leftSolid/solidThermophysicalProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/leftSolid/solidThermophysicalProperties new file mode 120000 index 0000000000000000000000000000000000000000..1da00bc6bdb7d81d0cfa13ba04762efad0bdeaa8 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/leftSolid/solidThermophysicalProperties @@ -0,0 +1 @@ +../heater/solidThermophysicalProperties \ No newline at end of file diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/polyMesh/blockMeshDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..506f06536461ad9a013aa1e90972d3d6a2e67079 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/polyMesh/blockMeshDict @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (-0.1 -0.04 -0.05) + ( 0.1 -0.04 -0.05) + ( 0.1 0.04 -0.05) + (-0.1 0.04 -0.05) + (-0.1 -0.04 0.05) + ( 0.1 -0.04 0.05) + ( 0.1 0.04 0.05) + (-0.1 0.04 0.05) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (30 10 10) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + wall maxY + ( + (3 7 6 2) + ) + patch minX + ( + (0 4 7 3) + ) + patch maxX + ( + (2 6 5 1) + ) + wall minY + ( + (1 5 4 0) + ) + wall minZ + ( + (0 3 2 1) + ) + wall maxZ + ( + (4 5 6 7) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/polyMesh/boundary b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/polyMesh/boundary new file mode 100644 index 0000000000000000000000000000000000000000..39c75e0d212e04c31d992b8a6bc1e7be7caa6a45 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/polyMesh/boundary @@ -0,0 +1,58 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +6 +( + maxY + { + type wall; + nFaces 300; + startFace 8300; + } + minX + { + type patch; + nFaces 100; + startFace 8600; + } + maxX + { + type patch; + nFaces 100; + startFace 8700; + } + minY + { + type wall; + nFaces 300; + startFace 8800; + } + minZ + { + type wall; + nFaces 300; + startFace 9100; + } + maxZ + { + type wall; + nFaces 300; + startFace 9400; + } +) + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/regionProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/regionProperties new file mode 100644 index 0000000000000000000000000000000000000000..da10e2d94af80b82e9cf0f23837d7b269ed0812b --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/regionProperties @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object regionProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +fluidRegionNames ( bottomAir topAir ); + +solidRegionNames ( heater leftSolid rightSolid ); + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/rightSolid/solidThermophysicalProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/rightSolid/solidThermophysicalProperties new file mode 120000 index 0000000000000000000000000000000000000000..1da00bc6bdb7d81d0cfa13ba04762efad0bdeaa8 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/rightSolid/solidThermophysicalProperties @@ -0,0 +1 @@ +../heater/solidThermophysicalProperties \ No newline at end of file diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/RASProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/RASProperties new file mode 100644 index 0000000000000000000000000000000000000000..1597ab89059120cb6f18a9c26f37c6599104e3c5 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/RASProperties @@ -0,0 +1,24 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel laminar; + +turbulence on; + +printCoeffs on; + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/g b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/g new file mode 100644 index 0000000000000000000000000000000000000000..2a29484f31d3d73ea1a085bd082fa8a9f73ca167 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/g @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 -9.81 0); + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/radiationProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/radiationProperties new file mode 100644 index 0000000000000000000000000000000000000000..95138d9acea1a4cf7bc1a00655a651f1ab8a22f7 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/radiationProperties @@ -0,0 +1,155 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object radiationProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +radiation on; + +radiationModel viewFactor;//fvDOM;//P1; + +viewFactorCoeffs +{ + smoothing true; //Smooth view factor matrix (use when in a close surface + //to force Sum(Fij = 1) + constantEmissivity true; //constant emissivity on surfaces. +} + +noRadiation +{ +} + +P1Coeffs +{ +} + +fvDOMCoeffs +{ + nPhi 3; // azimuthal angles in PI/2 on X-Y.(from Y to X) + nTheta 4; // polar angles in PI (from Z to X-Y plane) + convergence 1e-3; // convergence criteria for radiation iteration + maxIter 5; // maximum number of iterations +} + +// Number of flow iterations per radiation iteration +solverFreq 3; + +absorptionEmissionModel constantAbsorptionEmission; + +constantAbsorptionEmissionCoeffs +{ + a a [ 0 -1 0 0 0 0 0 ] 0.01; + e e [ 0 -1 0 0 0 0 0 ] 0.01; + E E [ 1 -1 -3 0 0 0 0 ] 0; +} + +greyMeanAbsorptionEmissionCoeffs +{ + lookUpTableFileName "SpeciesTable"; + + EhrrCoeff 0.0; + + CO2 + { + Tcommon 300; //Common Temp + invTemp true; //Is the polynomio using inverse temperature. + Tlow 200; //Low Temp + Thigh 2500; //High Temp + + loTcoeffs //coefss for T < Tcommon + ( + 0 // a0 + + 0 // a1*T + + 0 // a2*T^(+/-)2 + + 0 // a3*T^(+/-)3 + + 0 // a4*T^(+/-)4 + + 0 // a5*T^(+/-)5 + + ); + hiTcoeffs //coefss for T > Tcommon + ( + 18.741 + -121.31e3 + 273.5e6 + -194.05e9 + 56.31e12 + -5.8169e15 + ); + + } + + H2O + { + Tcommon 300; + invTemp true; + Tlow 200; + Thigh 2500; + + loTcoeffs + ( + 0 + 0 + 0 + 0 + 0 + 0 + ); + hiTcoeffs + ( + -0.23093 + -1.12390e3 + 9.4153e6 + -2.99885e9 + 0.51382e12 + -1.868e10 + ); + } + + CH4 + { + Tcommon 300; + Tlow 200; + Thigh 2500; + invTemp false; + + loTcoeffs + ( + 0 + 0 + 0 + 0 + 0 + 0 + ); + hiTcoeffs + ( + 6.6334 + -0.0035686 + 1.6682e-8 + 2.5611e-10 + -2.6558e-14 + 0 + ); + } + +} + +scatterModel constantScatter; + +constantScatterCoeffs +{ + sigma sigma [ 0 -1 0 0 0 0 0 ] 0; + C C [ 0 0 0 0 0 0 0 ] 0; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/thermophysicalProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/thermophysicalProperties new file mode 100644 index 0000000000000000000000000000000000000000..7f67791ae58ab8bd27e9dcb06a5dd7e7528cc8c0 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/thermophysicalProperties @@ -0,0 +1,31 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant/topAir"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType hRhoThermo<pureMixture<constTransport<specieThermo<hConstThermo<perfectGas>>>>>; + +mixture +{ + nMoles 1; + molWeight 28.9; + Cp 1000; + Hf 0; + mu 1.8e-05; + Pr 0.7; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/turbulenceProperties b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..e01c7d0bdb74fc55f9957b281c04de102e626f04 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/turbulenceProperties @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/viewFactorsDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/viewFactorsDict new file mode 100644 index 0000000000000000000000000000000000000000..afb506e8f02c2e889b1d5f7dc117513db82429e7 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/constant/topAir/viewFactorsDict @@ -0,0 +1,71 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object viewFactorsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +writeViewFactorMatrix true; +writeFacesAgglomeration true; +writePatchViewFactors false; + +topAir_to_heater +{ + nFacesInCoarsestLevel 24; + featureAngle 10; +} + +topAir_to_leftSolid +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + +topAir_to_rightSolid +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + +minX +{ + nFacesInCoarsestLevel 10; + featureAngle 10; +} + +maxY +{ + nFacesInCoarsestLevel 40; + featureAngle 10; +} + +minZ +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + +maxX +{ + nFacesInCoarsestLevel 10; + featureAngle 10; +} + +maxZ +{ + nFacesInCoarsestLevel 20; + featureAngle 10; +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/makeCellSets.setSet b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/makeCellSets.setSet new file mode 100644 index 0000000000000000000000000000000000000000..7e0c2bd5227ae42537bc60e7e21977eec679862a --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/makeCellSets.setSet @@ -0,0 +1,16 @@ +cellSet heater new boxToCell (-0.01 0 -100 )(0.01 0.01 100) +cellSet heater add boxToCell (-0.01 -100 -0.01)(0.01 0.01 0.01) +cellZoneSet heater new setToCellZone heater +cellSet leftSolid new boxToCell (-100 0 -100 )(-0.01 0.01 100) +cellZoneSet leftSolid new setToCellZone leftSolid +cellSet rightSolid new boxToCell (0.01 0 -100 )(100 0.01 100) +cellZoneSet rightSolid new setToCellZone rightSolid +cellSet topAir new boxToCell (-100 0.01 -100 )(100 100 100) +cellZoneSet topAir new setToCellZone topAir +cellSet bottomAir clear +cellSet bottomAir add cellToCell heater +cellSet bottomAir add cellToCell leftSolid +cellSet bottomAir add cellToCell rightSolid +cellSet bottomAir add cellToCell topAir +cellSet bottomAir invert +cellZoneSet bottomAir new setToCellZone bottomAir diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/README b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/README new file mode 100644 index 0000000000000000000000000000000000000000..69450ffe3af961bbc805e5a7b1a68f39bf5deff0 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/README @@ -0,0 +1,2 @@ +fvSolution is used for outer correctors specification. +fvSchemes is only so that pre-processing activities can proceed diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/changeDictionaryDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..10e064ff8915a68a4a08f96414270fde01196556 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/changeDictionaryDict @@ -0,0 +1,196 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dictionaryReplacement +{ + boundary + { + minX + { + type wall; + } + maxX + { + type wall; + } + } + + U + { + internalField uniform (0.01 0 0); + boundaryField + { + ".*" + { + type fixedValue; + value uniform (0 0 0); + } + } + } + + T + { + internalField uniform 300; + boundaryField + { + ".*" + { + type zeroGradient; + } + + "bottomAir_to_.*" + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K basicThermo; + QrNbr none; + Qr Qr; + KName none; + value uniform 300; + } + } + } + + epsilon + { + internalField uniform 0.01; + boundaryField + { + ".*" + { + type compressible::epsilonWallFunction; + value uniform 0.01; + } + } + } + + k + { + internalField uniform 0.1; + boundaryField + { + ".*" + { + type compressible::kqRWallFunction; + value uniform 0.1; + } + } + } + + p_rgh + { + internalField uniform 1e5; + boundaryField + { + ".*" + { + type buoyantPressure; + value uniform 1e5; + } + } + } + + p + { + internalField uniform 1e5; + boundaryField + { + ".*" + { + type calculated; + value uniform 1e5; + } + } + } + + Qr + { + internalField uniform 0; + boundaryField + { + ".*" + { + type greyDiffusiveRadiationViewFactor; + emissivityMode lookup; + Qro uniform 0; + emissivity uniform 1.0; + value uniform 0; + } + + "bottomAir_to_.*" + { + type greyDiffusiveRadiationViewFactor; + emissivityMode solidThermo; + Qro uniform 0; + value uniform 0; + } + } + } + + G + { + internalField uniform 0; + boundaryField + { + ".*" + { + type MarshakRadiation; + T T; + emissivityMode lookup; + emissivity uniform 1.0; + value uniform 0; + } + + "bottomAir_to_.*" + { + type MarshakRadiation; + T T; + emissivityMode solidThermo; + value uniform 0; + } + } + } + + IDefault + { + internalField uniform 0; + boundaryField + { + ".*" + { + type greyDiffusiveRadiation; + T T; + emissivityMode lookup; + Qro uniform 0; + emissivity uniform 1.0; + value uniform 0; + } + + "bottomAir_to_.*" + { + type greyDiffusiveRadiation; + T T; + emissivityMode solidThermo; + Qro uniform 0; + value uniform 0; + } + } + } + + +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..1aaedd5a48c4d36a6a74b659431807617a4362fc --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/decomposeParDict @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + location "system"; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +method scotch; +// method hierarchical; +// method simple; +// method manual; + +simpleCoeffs +{ + n (2 2 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + + +//// Is the case distributed +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..9a1e63c22091e59ecf0ab5af1e19ee2d4edaf68e --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSchemes @@ -0,0 +1,69 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss upwind; + div(U,p) Gauss linear; + div(phi,h) Gauss upwind; + div(phi,k) Gauss upwind; + div(phi,epsilon) Gauss upwind; + div(phi,R) Gauss upwind; + div(R) Gauss linear; + div(Ji,Ii_h) Gauss linearUpwind Gauss linear; //Gauss upwind; + div((muEff*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default none; + laplacian(muEff,U) Gauss linear corrected; + laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected; + laplacian(alphaEff,h) Gauss linear corrected; + laplacian(DkEff,k) Gauss linear corrected; + laplacian(DepsilonEff,epsilon) Gauss linear corrected; + laplacian(DREff,R) Gauss linear corrected; + laplacian(gammaRad,G) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p_rgh; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..377d97c1cda69a0a6800081dbc88fc7447ea422d --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSolution @@ -0,0 +1,82 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver PCG + preconditioner DIC; + tolerance 1e-7; + relTol 0; + } + + p_rgh + { + solver GAMG; + tolerance 1e-7; + relTol 0.01; + + smoother GaussSeidel; + + cacheAgglomeration true; + nCellsInCoarsestLevel 10; + agglomerator faceAreaPair; + mergeLevels 1; + } + + "(U|h|k|epsilon|G|Ii)" + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-7; + relTol 0.1; + } + + G + { + $p_rgh; + tolerance 1e-05; + relTol 0.1; + } +} + +SIMPLE +{ + momentumPredictor on; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 100000; + rhoMin rhoMin [1 -3 0 0 0] 0.2; + rhoMax rhoMax [1 -3 0 0 0] 2; +} + +relaxationFactors +{ + rho 1; + p_rgh 0.7; + U 0.3; + h 0.7; + nuTilda 0.7; + k 0.7; + epsilon 0.7; + omega 0.7; + G 0.7; + "ILambda.*" 0.7; + Qr 0.7; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/controlDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..714cde1a02f739c2251aa7e5cf52e44c8bf56095 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/controlDict @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application chtMultiRegionSimpleFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 2000; + +deltaT 1; + +writeControl timeStep; + +writeInterval 300; + +purgeWrite 10; + +writeFormat ascii; + +writePrecision 7; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..1aaedd5a48c4d36a6a74b659431807617a4362fc --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/decomposeParDict @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + location "system"; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +method scotch; +// method hierarchical; +// method simple; +// method manual; + +simpleCoeffs +{ + n (2 2 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + + +//// Is the case distributed +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..babfc9a5a207ed8e102d75e0cd760ae877cdd7ee --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/fvSchemes @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ +} + +gradSchemes +{ +} + +divSchemes +{ +} + +laplacianSchemes +{ +} + +interpolationSchemes +{ +} + +snGradSchemes +{ +} + +fluxRequired +{ +} + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..ae9961643efb151578e75b5918119ee5cb6a1fc1 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/fvSolution @@ -0,0 +1,17 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/changeDictionaryDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..419ad0950959ab13a68e29cc2abf963250f7a2aa --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/changeDictionaryDict @@ -0,0 +1,116 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dictionaryReplacement +{ + boundary + { + minY + { + type patch; + } + minZ + { + type patch; + } + maxZ + { + type patch; + } + } + + T + { + internalField uniform 300; + + boundaryField + { + ".*" + { + type zeroGradient; + value uniform 300; + } + + heater_to_topAir + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K solidThermo; + QrNbr Qr; + Qr none; + KName none; + value uniform 300; + } + + heater_to_bottomAir + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K solidThermo; + QrNbr Qr; + Qr none; + KName none; + value uniform 300; + } + + "heater_to_.*" + { + type compressible::turbulentTemperatureCoupledBaffleMixed; + neighbourFieldName T; + K solidThermo; + KName none; + value uniform 300; + } + minY + { + type fixedValue; + value uniform 500; + } + } + } + + Ypmma + { + internalField uniform 0.5; + + boundaryField + { + ".*" + { + type calculated; + value uniform 0.5; + } + } + + } + + Ychar + { + internalField uniform 0.5; + + boundaryField + { + ".*" + { + type calculated; + value uniform 0.5; + } + } + } + +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..1aaedd5a48c4d36a6a74b659431807617a4362fc --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/decomposeParDict @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + location "system"; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +method scotch; +// method hierarchical; +// method simple; +// method manual; + +simpleCoeffs +{ + n (2 2 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + + +//// Is the case distributed +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..58cefdaef271080284fe91b3029413fdbba65c83 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/fvSchemes @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; +} + +laplacianSchemes +{ + default none; + laplacian(K,T) Gauss linear limited 0.333; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default limited 0.333; +} + +fluxRequired +{ + default no; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..37e956afd7c43d4c1b35015c11b8b4a69e0230a3 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/heater/fvSolution @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0.1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + T 0.7; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/changeDictionaryDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..ae0253c9bab59b9588831acdcc80f590d6873b9f --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/changeDictionaryDict @@ -0,0 +1,107 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dictionaryReplacement +{ + boundary + { + minZ + { + type patch; + } + maxZ + { + type patch; + } + } + + T + { + internalField uniform 300; + + boundaryField + { + ".*" + { + type zeroGradient; + value uniform 300; + } + + leftSolid_to_topAir + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K solidThermo; + QrNbr Qr; + Qr none; + KName none; + value uniform 300; + } + + leftSolid_to_bottomAir + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K solidThermo; + QrNbr Qr; + Qr none; + KName none; + value uniform 300; + } + + "leftSolid_to_.*" + { + type compressible::turbulentTemperatureCoupledBaffleMixed; + neighbourFieldName T; + K solidThermo; + KName none; + value uniform 300; + } + } + } + + Ypmma + { + internalField uniform 0.5; + + + boundaryField + { + ".*" + { + type calculated; + value uniform 0.5; + } + } + + } + + Ychar + { + internalField uniform 0.5; + + boundaryField + { + ".*" + { + type calculated; + value uniform 0.5; + } + } + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..1aaedd5a48c4d36a6a74b659431807617a4362fc --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/decomposeParDict @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + location "system"; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +method scotch; +// method hierarchical; +// method simple; +// method manual; + +simpleCoeffs +{ + n (2 2 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + + +//// Is the case distributed +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..58cefdaef271080284fe91b3029413fdbba65c83 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/fvSchemes @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; +} + +laplacianSchemes +{ + default none; + laplacian(K,T) Gauss linear limited 0.333; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default limited 0.333; +} + +fluxRequired +{ + default no; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..37e956afd7c43d4c1b35015c11b8b4a69e0230a3 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/leftSolid/fvSolution @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0.1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + T 0.7; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/changeDictionaryDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..fa49ceab595b982061a1ab37a1ad8aa65b26f481 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/changeDictionaryDict @@ -0,0 +1,107 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dictionaryReplacement +{ + boundary + { + minZ + { + type patch; + } + maxZ + { + type patch; + } + } + + T + { + internalField uniform 300; + + boundaryField + { + ".*" + { + type zeroGradient; + value uniform 300; + } + + rightSolid_to_topAir + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K solidThermo; + QrNbr Qr; + Qr none; + KName none; + value uniform 300; + } + + rightSolid_to_bottomAir + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K solidThermo; + QrNbr Qr; + Qr none; + KName none; + value uniform 300; + } + + "rightSolid_to_.*" + { + type compressible::turbulentTemperatureCoupledBaffleMixed; + neighbourFieldName T; + K solidThermo; + KName none; + value uniform 300; + } + } + } + + Ypmma + { + internalField uniform 0.5; + + + boundaryField + { + ".*" + { + type calculated; + value uniform 0.5; + } + } + + } + + Ychar + { + internalField uniform 0.5; + + boundaryField + { + ".*" + { + type calculated; + value uniform 0.5; + } + } + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..1aaedd5a48c4d36a6a74b659431807617a4362fc --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/decomposeParDict @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + location "system"; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +method scotch; +// method hierarchical; +// method simple; +// method manual; + +simpleCoeffs +{ + n (2 2 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + + +//// Is the case distributed +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..58cefdaef271080284fe91b3029413fdbba65c83 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/fvSchemes @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; +} + +laplacianSchemes +{ + default none; + laplacian(K,T) Gauss linear limited 0.333; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default limited 0.333; +} + +fluxRequired +{ + default no; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..37e956afd7c43d4c1b35015c11b8b4a69e0230a3 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/rightSolid/fvSolution @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { + solver PCG; + preconditioner DIC; + tolerance 1e-06; + relTol 0.1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + T 0.7; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/changeDictionaryDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/changeDictionaryDict new file mode 100644 index 0000000000000000000000000000000000000000..a6d360b23c73a7dc6dcaedfc925d85c14e0311d0 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/changeDictionaryDict @@ -0,0 +1,241 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object changeDictionaryDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dictionaryReplacement +{ + U + { + internalField uniform (0.1 0 0); + boundaryField + { + ".*" + { + type fixedValue; + value uniform (0 0 0); + } + minX + { + type fixedValue; + value uniform ( 0.1 0 0 ); + } + maxX + { + type inletOutlet; + inletValue uniform ( 0 0 0 ); + value uniform ( 0.1 0 0 ); + } + } + } + + T + { + internalField uniform 300; + boundaryField + { + ".*" + { + type zeroGradient; + } + + minX + { + type fixedValue; + value uniform 300; + } + maxX + { + type inletOutlet; + inletValue uniform 300; + value uniform 300; + } + + "topAir_to_.*" + { + type compressible::turbulentTemperatureRadCoupledMixed; + Tnbr T; + K basicThermo; + QrNbr none; + Qr Qr; + KName none; + value uniform 300; + } + } + } + + epsilon + { + internalField uniform 0.01; + boundaryField + { + ".*" + { + type compressible::epsilonWallFunction; + value uniform 0.01; + } + + minX + { + type fixedValue; + value uniform 0.01; + } + maxX + { + type inletOutlet; + inletValue uniform 0.01; + value uniform 0.01; + } + } + } + + k + { + internalField uniform 0.1; + boundaryField + { + ".*" + { + type compressible::kqRWallFunction; + value uniform 0.1; + } + + minX + { + type fixedValue; + value uniform 0.1; + } + maxX + { + type inletOutlet; + inletValue uniform 0.1; + value uniform 0.1; + } + } + } + + p_rgh + { + internalField uniform 1e5; + boundaryField + { + ".*" + { + type buoyantPressure; + value uniform 1e5; + } + + maxX + { + type fixedValue; + value uniform 1e5; + } + } + } + + p + { + internalField uniform 1e5; + boundaryField + { + ".*" + { + type calculated; + value uniform 1e5; + } + + maxX + { + type calculated; + value uniform 1e5; + } + } + } + + Qr + { + internalField uniform 0; + boundaryField + { + ".*" + { + type greyDiffusiveRadiationViewFactor; + emissivityMode lookup; + Qro uniform 0; + emissivity uniform 1.0; + value uniform 0; + } + + "topAir_to_.*" + { + type greyDiffusiveRadiationViewFactor; + emissivityMode solidThermo; + Qro uniform 0; + value uniform 0; + } + } + } + + G + { + internalField uniform 0; + boundaryField + { + ".*" + { + type MarshakRadiation; + T T; + emissivityMode lookup; + emissivity uniform 1.0; + value uniform 0; + } + + "topAir_to_.*" + { + type MarshakRadiation; + T T; + emissivityMode solidThermo; + value uniform 0; + } + } + } + + IDefault + { + internalField uniform 0; + boundaryField + { + ".*" + { + type greyDiffusiveRadiation; + T T; + emissivityMode lookup; + Qro uniform 0; + emissivity uniform 1.0; + value uniform 0; + } + + "topAir_to_.*" + { + type greyDiffusiveRadiation; + T T; + emissivityMode solidThermo; + Qro uniform 0; + value uniform 0; + } + } + } +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/decomposeParDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..1aaedd5a48c4d36a6a74b659431807617a4362fc --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/decomposeParDict @@ -0,0 +1,72 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + location "system"; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +//- Keep owner and neighbour on same processor for faces in zones: +// preserveFaceZones (heater solid1 solid3); + +method scotch; +// method hierarchical; +// method simple; +// method manual; + +simpleCoeffs +{ + n (2 2 1); + delta 0.001; +} + +hierarchicalCoeffs +{ + n (2 2 1); + delta 0.001; + order xyz; +} + +scotchCoeffs +{ + //processorWeights + //( + // 1 + // 1 + // 1 + // 1 + //); + //writeGraph true; + //strategy "b"; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + + +//// Is the case distributed +//distributed yes; +//// Per slave (so nProcs-1 entries) the directory above the case. +//roots +//( +// "/tmp" +// "/tmp" +//); + + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..9a1e63c22091e59ecf0ab5af1e19ee2d4edaf68e --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSchemes @@ -0,0 +1,69 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) Gauss upwind; + div(U,p) Gauss linear; + div(phi,h) Gauss upwind; + div(phi,k) Gauss upwind; + div(phi,epsilon) Gauss upwind; + div(phi,R) Gauss upwind; + div(R) Gauss linear; + div(Ji,Ii_h) Gauss linearUpwind Gauss linear; //Gauss upwind; + div((muEff*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default none; + laplacian(muEff,U) Gauss linear corrected; + laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected; + laplacian(alphaEff,h) Gauss linear corrected; + laplacian(DkEff,k) Gauss linear corrected; + laplacian(DepsilonEff,epsilon) Gauss linear corrected; + laplacian(DREff,R) Gauss linear corrected; + laplacian(gammaRad,G) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p_rgh; +} + +// ************************************************************************* // diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..074e725cd1662d09c073df93e455b2ffae103df5 --- /dev/null +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSolution @@ -0,0 +1,83 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + rho + { + solver PCG + preconditioner DIC; + tolerance 1e-7; + relTol 0; + } + + p_rgh + { + solver GAMG; + tolerance 1e-7; + relTol 0.01; + + smoother GaussSeidel; + + cacheAgglomeration true; + nCellsInCoarsestLevel 10; + agglomerator faceAreaPair; + mergeLevels 1; + + maxIter 100; + } + + "(U|h|k|epsilon|Ii)" + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-7; + relTol 0.1; + } + + G + { + $p_rgh; + tolerance 1e-05; + relTol 0.1; + } +} + +SIMPLE +{ + momentumPredictor on; + nNonOrthogonalCorrectors 0; + pRefCell 0; + pRefValue 100000; + rhoMin rhoMin [1 -3 0 0 0] 0.2; + rhoMax rhoMax [1 -3 0 0 0] 2; +} + +relaxationFactors +{ + rho 1; + p_rgh 0.7; + U 0.3; + h 0.7; + nuTilda 0.7; + k 0.7; + epsilon 0.7; + omega 0.7; + "ILambda.*" 0.7; + Qr 0.7; +} + +// ************************************************************************* // diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/0/G b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/0/G index 3652534309de4a1b6ef098682956b048329280a5..4eaceb02223184f1a9e2af82e973efc9f90b6c48 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/0/G +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/0/G @@ -25,21 +25,24 @@ boundaryField { type MarshakRadiation; T T; - emissivity 1.0; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } bottom { type MarshakRadiation; T T; - emissivity 1.0; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } walls { type MarshakRadiation; T T; - emissivity 1.0; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } symmetry diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/0/G b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/0/G index 0b83afbf39cb8c1a1df791b61dcc2f7ff489eb30..05ad927952d44d9016d4e340f18e8854e5528a82 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/0/G +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/0/G @@ -25,7 +25,8 @@ boundaryField { type MarshakRadiation; T T; - emissivity 1; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; refValue uniform 0; refGradient uniform 0; @@ -35,7 +36,8 @@ boundaryField { type MarshakRadiation; T T; - emissivity 1; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; refValue uniform 0; refGradient uniform 0; diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/0/G b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/0/G index 35d242fe29eea1004cc1ab516c2c77adf174e60e..eca73ca4bd86626c5bf80ff07de606772385d557 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/0/G +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/parcelInBox/0/G @@ -33,7 +33,8 @@ boundaryField { type MarshakRadiation; T T; - emissivity 1; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } outlet @@ -44,7 +45,8 @@ boundaryField { type MarshakRadiation; T T; - emissivity 1; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } } diff --git a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/0/G b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/0/G index 002455197ea5ab77a1e19457bef1ca2e51ccee2f..3b08ef7eb6be0edd85438af00b5584f89dde00e6 100644 --- a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/0/G +++ b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/0/G @@ -25,7 +25,8 @@ boundaryField { type MarshakRadiation; T T; - emissivity 1.0; + emissivityMode lookup; + emissivity uniform 1.0; value uniform 0; } frontAndBack