diff --git a/Allwmake b/Allwmake index 4ae49dca1d..f9edc15f28 100755 --- a/Allwmake +++ b/Allwmake @@ -24,7 +24,7 @@ command -v mpirun 2>/dev/null || true echo "========================================" date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown" -echo "Starting compile ${WM_PROJECT_DIR##*/} ${0##*}" +echo "Starting compile ${WM_PROJECT_DIR##*/} ${0##*/}" echo " $WM_COMPILER $WM_COMPILER_TYPE compiler" echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}" echo "========================================" diff --git a/README.md b/README.md index 60fe7d3c03..163f443c55 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,32 @@ Please [contact OpenCFD](http://www.openfoam.com/contact) if you have any questi Violations of the Trademark are continuously monitored, and will be duly prosecuted. +# Compiling OpenFOAM + +Please see the relevant guides: + +| Location | Readme | Requirements | Build | +|-------------|-----------|--------------|-------| +| [OpenFOAM][repo openfoam] | [readme][link openfoam-readme] | [system requirements][link openfoam-require] | [build][link openfoam-build] | +| [ThirdParty][repo third] | [readme][link third-readme] | [system requirements][link third-require] | [build][link third-build] | + + + + + +[repo openfoam]: https://develop.openfoam.com/Development/OpenFOAM-plus/ +[repo third]: https://develop.openfoam.com/Development/ThirdParty-plus/ + +[link openfoam-issues]: https://develop.openfoam.com/Development/OpenFOAM-plus/blob/develop/BuildIssues.txt +[link openfoam-readme]: https://develop.openfoam.com/Development/OpenFOAM-plus/blob/develop/README.md +[link openfoam-config]: https://develop.openfoam.com/Development/OpenFOAM-plus/blob/develop/etc/README.md +[link openfoam-build]: https://develop.openfoam.com/Development/OpenFOAM-plus/blob/develop/doc/Build.md +[link openfoam-require]: https://develop.openfoam.com/Development/OpenFOAM-plus/blob/develop/doc/Requirements.md +[link third-readme]: https://develop.openfoam.com/Development/ThirdParty-plus/blob/develop/README.md +[link third-build]: https://develop.openfoam.com/Development/ThirdParty-plus/blob/develop/BUILD.md +[link third-require]: https://develop.openfoam.com/Development/ThirdParty-plus/blob/develop/Requirements.md + + # Useful Links - [Download and installation instructions](http://www.openfoam.com/download/) - [Documentation](http://www.openfoam.com/documentation) @@ -24,4 +50,4 @@ Violations of the Trademark are continuously monitored, and will be duly prosecu - [OpenFOAM Community](http://www.openfoam.com/community/) - [Contacting OpenCFD](http://www.openfoam.com/contact/) -Copyright 2016-2018 OpenCFD Ltd +Copyright 2016-2019 OpenCFD Ltd diff --git a/applications/solvers/basic/potentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/createFields.H index 4b3352557a..0ce5a68edd 100644 --- a/applications/solvers/basic/potentialFoam/createFields.H +++ b/applications/solvers/basic/potentialFoam/createFields.H @@ -57,9 +57,6 @@ forAll(U.boundaryField(), patchi) } } -// Note that registerObject is false for the pressure field. The pressure -// field in this solver doesn't have a physical value during the solution. -// It shouldn't be looked up and used by sub models or boundary conditions. Info<< "Constructing pressure field " << pName << nl << endl; volScalarField p ( @@ -69,8 +66,7 @@ volScalarField p runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, - IOobject::NO_WRITE, - false + IOobject::NO_WRITE ), mesh, dimensionedScalar(sqr(dimVelocity), Zero), diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/Make/files new file mode 100644 index 0000000000..d676e48c65 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/Make/files @@ -0,0 +1,5 @@ +derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C +../solid/solidRegionDiffNo.C +chtMultiRegionTwoPhaseEulerFoam.C + +EXE = $(FOAM_APPBIN)/chtMultiRegionTwoPhaseEulerFoam diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/Make/options new file mode 100644 index 0000000000..4a667217bd --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/Make/options @@ -0,0 +1,41 @@ +EXE_INC = \ + -I. \ + -I.. \ + -I$(FOAM_SOLVERS)/multiphase/reactingEulerFoam/reactingTwoPhaseEulerFoam \ + -I$(LIB_SRC)/phaseSystemModels/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseSystem/lnInclude \ + -I$(LIB_SRC)/phaseSystemModels/reactingEulerFoam/reactingTwoPhaseEulerFoam/twoPhaseCompressibleTurbulenceModels/lnInclude \ + -I$(LIB_SRC)/phaseSystemModels/reactingEulerFoam/phaseSystems/lnInclude \ + -I$(LIB_SRC)/phaseSystemModels/reactingEulerFoam/interfacialModels/lnInclude \ + -I$(LIB_SRC)/phaseSystemModels/reactingEulerFoam/interfacialCompositionModels/lnInclude \ + -I./fluid \ + -I../solid \ + -I../fluid \ + -I../include \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/transportModels/compressible/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/phaseCompressible/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude + + +EXE_LIBS = \ + -lcompressibleTransportModels \ + -lfluidThermophysicalModels \ + -lspecie \ + -lsolidThermo \ + -ltwoPhaseReactingTurbulenceModels \ + -lmeshTools \ + -lfiniteVolume \ + -lfvOptions \ + -lradiationModels \ + -lregionModels \ + -lsampling \ + -lreactingTwoPhaseSystem \ + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/chtMultiRegionTwoPhaseEulerFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/chtMultiRegionTwoPhaseEulerFoam.C new file mode 100644 index 0000000000..9a69e5f088 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/chtMultiRegionTwoPhaseEulerFoam.C @@ -0,0 +1,166 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 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 . + +Application + chtMultiRegionTwoPhaseEulerFoam + +Group + grpHeatTransferSolvers + +Description + Transient solver for buoyant, turbulent fluid flow and solid heat + conduction with conjugate heat transfer between solid and fluid regions. + + It solves a two-phase Euler approach on the fluid region. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "turbulentFluidThermoModel.H" + +#include "twoPhaseSystem.H" +#include "phaseCompressibleTurbulenceModel.H" +#include "pimpleControl.H" +#include "fixedGradientFvPatchFields.H" +#include "regionProperties.H" +#include "solidRegionDiffNo.H" +#include "solidThermo.H" +#include "radiationModel.H" +#include "fvOptions.H" +#include "coordinateSystem.H" +#include "loopControl.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Transient solver for buoyant, turbulent two phase fluid flow and" + "solid heat conduction with conjugate heat transfer " + "between solid and fluid regions." + ); + + #define NO_CONTROL + #define CREATE_MESH createMeshesPostProcess.H + #include "postProcess.H" + + #include "setRootCase.H" + #include "createTime.H" + #include "createMeshes.H" + #include "createFields.H" + #include "initContinuityErrs.H" + #include "createTimeControls.H" + #include "readSolidTimeControls.H" + #include "compressibleMultiRegionCourantNo.H" + #include "solidRegionDiffusionNo.H" + #include "setInitialMultiRegionDeltaT.H" + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "readSolidTimeControls.H" + #include "readPIMPLEControls.H" + + #include "compressibleMultiRegionCourantNo.H" + #include "solidRegionDiffusionNo.H" + #include "setMultiRegionDeltaT.H" + + ++runTime; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + if (nOuterCorr != 1) + { + forAll(fluidRegions, i) + { + #include "storeOldFluidFields.H" + } + } + + // --- PIMPLE loop + for (int oCorr=0; oCorr 1) + { + loopControl looping(runTime, pimple, "energyCoupling"); + + while (looping.loop()) + { + Info<< nl << looping << nl; + + forAll(fluidRegions, i) + { + Info<< "\nSolving for fluid region " + << fluidRegions[i].name() << endl; + #include "setRegionFluidFields.H" + #include "readFluidMultiRegionPIMPLEControls.H" + frozenFlow = true; + #include "solveFluid.H" + } + + forAll(solidRegions, i) + { + Info<< "\nSolving for solid region " + << solidRegions[i].name() << endl; + #include "setRegionSolidFields.H" + #include "readSolidMultiRegionPIMPLEControls.H" + #include "solveSolid.H" + } + } + } + } + + runTime.write(); + + runTime.printExecutionTime(Info); + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C new file mode 100644 index 0000000000..5f4e839508 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C @@ -0,0 +1,516 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "phaseSystem.H" +#include "mappedPatchBase.H" +#include "solidThermo.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +const Foam::Enum +< + Foam::compressible:: + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField::regionType +> +Foam::compressible:: +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField::regionTypeNames_ +{ + { regionType::solid, "solid" }, + { regionType::fluid, "fluid" }, +}; + + +const Foam::Enum +< + Foam::compressible:: + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField::KMethodType +> +Foam::compressible:: +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField::KMethodTypeNames_ +{ + { KMethodType::mtSolidThermo, "solidThermo" }, + { KMethodType::mtLookup, "lookup" }, + { KMethodType::mtPhaseSystem, "phaseSystem" } +}; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + + +Foam::tmp Foam::compressible:: +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField:: +kappa +( + const scalarField& Tp +) const +{ + const polyMesh& mesh = patch().boundaryMesh().mesh(); + const label patchi = patch().index(); + + switch (method_) + { + case mtSolidThermo: + { + const solidThermo& thermo = + mesh.lookupObject(basicThermo::dictName); + + return thermo.kappa(patchi); + break; + } + + case mtLookup: + { + if (mesh.foundObject(kappaName_)) + { + return patch().lookupPatchField + ( + kappaName_ + ); + } + else if (mesh.foundObject(kappaName_)) + { + const symmTensorField& KWall = + patch().lookupPatchField + ( + kappaName_ + ); + + const vectorField n(patch().nf()); + + return n & KWall & n; + } + else + { + FatalErrorInFunction + << "Did not find field " << kappaName_ + << " on mesh " << mesh.name() << " patch " << patch().name() + << nl + << " Please set 'kappa' to the name of a volScalarField" + << " or volSymmTensorField." + << exit(FatalError); + } + + + + break; + } + + case mtPhaseSystem: + { + // Lookup the fluid model + const phaseSystem& fluid = + ( + mesh.lookupObject("phaseProperties") + ); + + tmp kappaEff + ( + new scalarField(patch().size(), 0.0) + ); + + forAll(fluid.phases(), phasei) + { + const phaseModel& phase = fluid.phases()[phasei]; + + const fvPatchScalarField& alpha = phase.boundaryField()[patchi]; + + kappaEff.ref() += alpha*phase.kappaEff(patchi)(); + } + + return kappaEff; + + break; + } + + default: + { + FatalErrorInFunction + << "Unimplemented method " << KMethodTypeNames_[method_] << nl + << "Please set 'kappaMethod' to one of " + << flatOutput(KMethodTypeNames_.sortedToc()) << nl + << "and 'kappa' to the name of the volScalar" + << exit(FatalError); + } + } + + return scalarField(0); +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +namespace Foam +{ +namespace compressible +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(p, iF), + regionType_(fluid), + method_(mtLookup), + kappaName_("none"), + otherPhaseName_("vapor"), + TnbrName_("undefined-Tnbr"), + qrNbrName_("undefined-qrNbr"), + qrName_("undefined-qr") +{ + this->refValue() = 0.0; + this->refGrad() = 0.0; + this->valueFraction() = 1.0; +} + + +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField +( + const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField& psf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(psf, p, iF, mapper), + regionType_(psf.regionType_), + method_(psf.method_), + kappaName_(psf.kappaName_), + otherPhaseName_(psf.otherPhaseName_), + TnbrName_(psf.TnbrName_), + qrNbrName_(psf.qrNbrName_), + qrName_(psf.qrName_) +{} + + +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + regionType_(regionTypeNames_.read(dict.lookup("region"))), + method_(KMethodTypeNames_.get("kappaMethod", dict)), + kappaName_(dict.lookupOrDefault("kappa", "none")), + otherPhaseName_(dict.lookup("otherPhase")), + TnbrName_(dict.lookupOrDefault("Tnbr", "T")), + qrNbrName_(dict.lookupOrDefault("qrNbr", "none")), + qrName_(dict.lookupOrDefault("qr", "none")) +{ + if (!isA(this->patch().patch())) + { + FatalErrorInFunction + << "' not type '" << mappedPatchBase::typeName << "'" + << "\n for patch " << p.name() + << " of field " << internalField().name() + << " in file " << internalField().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; + } +} + + +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField:: +turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField +( + const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField& psf, + const DimensionedField& iF +) +: + mixedFvPatchScalarField(psf, iF), + regionType_(psf.regionType_), + method_(psf.method_), + kappaName_(psf.kappaName_), + otherPhaseName_(psf.otherPhaseName_), + TnbrName_(psf.TnbrName_), + qrNbrName_(psf.qrNbrName_), + qrName_(psf.qrName_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField:: +updateCoeffs() +{ + if (updated()) + { + return; + } + + const polyMesh& mesh = patch().boundaryMesh().mesh(); + + // Since we're inside initEvaluate/evaluate there might be processor + // comms underway. Change the tag we use. + int oldTag = UPstream::msgType(); + UPstream::msgType() = oldTag+1; + + // Get the coupling information from the mappedPatchBase + const label patchi = patch().index(); + const mappedPatchBase& mpp = + refCast(patch().patch()); + const polyMesh& nbrMesh = mpp.sampleMesh(); + const label samplePatchi = mpp.samplePolyPatch().index(); + const fvPatch& nbrPatch = + refCast(nbrMesh).boundary()[samplePatchi]; + + scalarField& Tp = *this; + + const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField& + nbrField = refCast + + ( + nbrPatch.lookupPatchField(TnbrName_) + ); + + // Swap to obtain full local values of neighbour internal field + scalarField TcNbr(nbrField.patchInternalField()); + mpp.distribute(TcNbr); + + + // Swap to obtain full local values of neighbour K*delta + scalarField KDeltaNbr; + KDeltaNbr = nbrField.kappa(nbrField)*nbrPatch.deltaCoeffs(); + mpp.distribute(KDeltaNbr); + + scalarField KDelta(kappa(Tp)*patch().deltaCoeffs()); + + scalarField qr(Tp.size(), 0.0); + if (qrName_ != "none") + { + qr = patch().lookupPatchField(qrName_); + } + + scalarField qrNbr(Tp.size(), 0.0); + if (qrNbrName_ != "none") + { + qrNbr = nbrPatch.lookupPatchField(qrNbrName_); + mpp.distribute(qrNbr); + } + + + if (regionType_ == solid) + { + // Lookup the fluid model in the nbrFvMesh + const phaseSystem& fluid = + ( + nbrMesh.lookupObject("phaseProperties") + ); + + // The BC is applied to the liquid phase of the fluid + const phaseModel& liquid + ( + fluid.phases()[nbrField.internalField().group()] + ); + + const phaseModel& vapor(fluid.phases()[otherPhaseName_]); + + + scalarField KDeltaLiqNbr; + const fvPatchScalarField& alphal = liquid.boundaryField()[samplePatchi]; + KDeltaLiqNbr = + alphal*(liquid.kappaEff(samplePatchi))*nbrPatch.deltaCoeffs(); + mpp.distribute(KDeltaLiqNbr); + + scalarField KDeltaVapNbr; + const fvPatchScalarField& alphav = vapor.boundaryField()[samplePatchi]; + KDeltaVapNbr = + alphav*(vapor.kappaEff(samplePatchi))*nbrPatch.deltaCoeffs(); + mpp.distribute(KDeltaVapNbr); + + scalarField TvNbr; + const fvPatchScalarField& Tv = + vapor.thermo().T().boundaryField()[samplePatchi]; + TvNbr = Tv.patchInternalField(); + mpp.distribute(TvNbr); + + // TcNbr: liquid Tp + // TvNbr: vapour Tp + scalarField c(TcNbr*KDeltaLiqNbr + TvNbr*KDeltaVapNbr); + + valueFraction() = KDeltaNbr/(KDeltaNbr + KDelta); + refValue() = c/KDeltaNbr; + refGrad() = (qr + qrNbr)/kappa(Tp); + + if (debug) + { + scalar Q = gSum(kappa(Tp)*patch().magSf()*snGrad()); + + Info<< "T solid : " << nl << endl; + + Info + << " heat transfer rate from solid:" << Q + << " walltemperature " + << " min:" << gMin(Tp) + << " max:" << gMax(Tp) + << " avg:" << gAverage(Tp) + << endl; + } + } + else if (regionType_ == fluid) + { + const phaseSystem& fluid = + ( + mesh.lookupObject("phaseProperties") + ); + + const phaseModel& liquid + ( + fluid.phases()[internalField().group()] + ); + + const phaseModel& vapor(fluid.phases()[otherPhaseName_]); + + const fvPatchScalarField& Tv = + vapor.thermo().T().boundaryField()[patchi]; + + const fvPatchScalarField& alphav = vapor.boundaryField()[patchi]; + + const scalarField KdeltaVap + ( + alphav*(vapor.kappaEff(patchi))*patch().deltaCoeffs() + ); + + const fvPatchScalarField& alphal = liquid.boundaryField()[patchi]; + + const scalarField KdeltaLiq + ( + alphal*(liquid.kappaEff(patchi))*patch().deltaCoeffs() + ); + + // TcNbr: solid Tp + // Tv: vapour Tp + const scalarField c(TcNbr*KDeltaNbr + Tv.patchInternalField()*KdeltaVap); + + const scalarField a(KdeltaVap + KDeltaNbr); + + valueFraction() = a/(a + KdeltaLiq); + refValue() = c/a; + refGrad() = (qr + qrNbr)/kappa(Tp); + + if (debug) + { + scalarField Tc(patchInternalField()); + scalarField qLiq((Tp - Tc)*KdeltaLiq); + scalarField qVap((Tp - Tv.patchInternalField())*KdeltaVap); + + Info<< "T flow : " << nl << endl; + + Info<< " qLiq: " << gMin(qLiq) << " - " << gMax(qLiq) << endl; + Info<< " qVap: " << gMin(qVap) << " - " << gMax(qVap) << endl; + + scalar QLiq = gSum(qLiq*patch().magSf()); + scalar QVap = gSum(qVap*patch().magSf()); + + Info<< " Heat transfer to Liq: " << QLiq << endl; + Info<< " Heat transfer to Vap: " << QVap << endl; + + Info<< " walltemperature " + << " min:" << gMin(Tp) + << " max:" << gMax(Tp) + << " avg:" << gAverage(Tp) + << endl; + } + } + else + { + FatalErrorInFunction + << "Unknown phase type. Valid types are: " + << regionTypeNames_ << nl << exit(FatalError); + } + + mixedFvPatchScalarField::updateCoeffs(); + + // Restore tag + UPstream::msgType() = oldTag; +} + + +void turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField::write +( + Ostream& os +) const +{ + mixedFvPatchScalarField::write(os); + os.writeEntry("kappaMethod", KMethodTypeNames_[method_]); + os.writeEntryIfDifferent("kappa","none", kappaName_); + + os.writeEntry("Tnbr", TnbrName_); + + os.writeEntryIfDifferent("qrNbr", "none", qrNbrName_); + os.writeEntryIfDifferent("qr", "none", qrName_); + + os.writeKeyword("region") << regionTypeNames_[regionType_] + << token::END_STATEMENT << nl; + + os.writeKeyword("otherPhase") << otherPhaseName_ << token::END_STATEMENT + << nl; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace compressible +} // End namespace Foam + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.H new file mode 100644 index 0000000000..4a6256a0e5 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/derivedFvPatchFields/turbulentTemperatureTwoPhaseRadCoupledMixed/turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.H @@ -0,0 +1,252 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2018 OpenCFD Ltd + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::compressible:: + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField + +Description + Mixed boundary condition for temperature and radiation heat transfer + to be used for in multiregion cases with two phase Euler system + +Usage + \table + Property | Description | Required | Default value + Tnbr | name of the field | no | T + qrNbr | name of the radiative flux in the nbr region | no | none + qr | name of the radiative flux in this region | no | none + region | region to which this BC belongs | yes + otherPhase | name of the vapour phase in the fluid region | yes + kappaMethod | inherited from temperatureCoupledBase | inherited | + kappa | inherited from temperatureCoupledBase | inherited | + \endtable + + Example of the boundary condition specification on the fluid region: + \verbatim + + { + type compressible::turbulentTemperatureTwoPhaseRadCoupledMixed; + Tnbr T; + qrNbr none; + qr none; + kappaMethod phaseSystem; + region fluid; + otherPhase gas; + value uniform 300; + } + \endverbatim + + Example of the boundary condition specification on the solid region: + \verbatim + + { + type compressible::turbulentTemperatureTwoPhaseRadCoupledMixed; + Tnbr T.liquid; + qrNbr none; + qr none; + kappaMethod solidThermo; + region solid; + otherPhase gas; + value uniform 300; + } + \endverbatim + + Needs to be on underlying mapped(Wall)FvPatch. + + +SourceFiles + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField_H +#define turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField_H + +#include "mixedFvPatchFields.H" +#include "scalarList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace compressible +{ + +/*---------------------------------------------------------------------------*\ + Class turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField +: + public mixedFvPatchScalarField +{ +public: + + // Public enumerations + + //- Type of supplied Kappa + enum KMethodType + { + mtSolidThermo, + mtLookup, + mtPhaseSystem + }; + + // Data types + + //- Enumeration listing the region + enum regionType + { + solid, + fluid + }; + +private: + + // Private data + + //- Heat source type names + static const Enum regionTypeNames_; + + //- Kappa method types + static const Enum KMethodTypeNames_; + + //- Heat source type + regionType regionType_; + + //- How to get K + const KMethodType method_; + + //- Name of thermal conductivity field (if looked up from database) + const word kappaName_; + + //- name of the other phase (vapor/liquid phase) + word otherPhaseName_; + + //- Name of field on the neighbour region + const word TnbrName_; + + //- Name of the radiative heat flux in the neighbour region + const word qrNbrName_; + + //- Name of the radiative heat flux in local region + const word qrName_; + + + // Private members + + //- Given patch temperature calculate corresponding K field + tmp kappa(const scalarField& Tp) const; + + +public: + + //- Runtime type information + TypeName("compressible::turbulentTemperatureTwoPhaseRadCoupledMixed"); + + + // Constructors + + //- Construct from patch and internal field + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField onto a + // new patch + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField + ( + const + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField + ( + const turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new turbulentTemperatureTwoPhaseRadCoupledMixedFvPatchScalarField + ( + *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/chtMultiRegionTwoPhaseEulerFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/compressibleMultiRegionCourantNo.H new file mode 100644 index 0000000000..3e363440e8 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/compressibleMultiRegionCourantNo.H @@ -0,0 +1,51 @@ + scalar CoNum = -GREAT; + + forAll(fluidRegions, regioni) + { + if (fluidRegions[regioni].nInternalFaces()) + { + const surfaceScalarField& phi = + phaseSystemFluid[regioni].phi(); + + scalarField sumPhi + ( + fvc::surfaceSum(mag(phi))().primitiveField() + ); + + const surfaceScalarField& phi1 = + phaseSystemFluid[regioni].phase1().phiRef(); + + const surfaceScalarField& phi2 = + phaseSystemFluid[regioni].phase2().phiRef(); + + sumPhi = max + ( + sumPhi, + fvc::surfaceSum(mag(phi1))().primitiveField() + ); + + sumPhi = max + ( + sumPhi, + fvc::surfaceSum(mag(phi2))().primitiveField() + ); + + + CoNum = + 0.5*gMax + ( + sumPhi/fluidRegions[regioni].V().field() + )*runTime.deltaTValue(); + + scalar UrCoNum = 0.5*gMax + ( + fvc::surfaceSum(mag(phi1 - phi2))().primitiveField() + / fluidRegions[regioni].V().field() + )*runTime.deltaTValue(), + + CoNum = max(UrCoNum, CoNum); + } + } + + Info<< "Courant Number max: " << CoNum << endl; + diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/createFluidFields.H new file mode 100644 index 0000000000..6d1e3b9bcc --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionTwoPhaseEulerFoam/fluid/createFluidFields.H @@ -0,0 +1,147 @@ +// Initialise fluid field pointer lists +PtrList phaseSystemFluid(fluidRegions.size()); + +PtrList ghFluid(fluidRegions.size()); +PtrList ghfFluid(fluidRegions.size()); +PtrList hRefFluid(fluidRegions.size()); + +PtrList p_rghFluid(fluidRegions.size()); + +PtrList::fieldTable> + fieldsFluid(fluidRegions.size()); + +List initialMassFluid(fluidRegions.size()); +List frozenFlowFluid(fluidRegions.size(), false); + +List