diff --git a/.gitignore b/.gitignore index 150288aae2..b030d74e09 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ *.orig *.bak \#*\# +.directory # CVS recovered versions - anywhere .#* @@ -47,7 +48,9 @@ doc/[Dd]oxygen/man # source packages - anywhere *.tar.bz2 *.tar.gz +*.tar *.tgz +*.gtgz # ignore the persistent .build tag in the main directory /.build diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/Make/files b/applications/solvers/Lagrangian/reactingParcelFoam/Make/files deleted file mode 100644 index ea13ecb0c5..0000000000 --- a/applications/solvers/Lagrangian/reactingParcelFoam/Make/files +++ /dev/null @@ -1,3 +0,0 @@ -reactingParcelFoam.C - -EXE = $(FOAM_USER_APPBIN)/reactingParcelFoam diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/createClouds.H b/applications/solvers/Lagrangian/reactingParcelFoam/createClouds.H deleted file mode 100644 index b4ec5e4056..0000000000 --- a/applications/solvers/Lagrangian/reactingParcelFoam/createClouds.H +++ /dev/null @@ -1,40 +0,0 @@ -Info << "\nConstructing gas properties" << endl; -/* -PtrList gasProperties(Y.size()); -forAll(gasProperties, i) -{ - gasProperties.set - ( - i, - new specieConstProperties - ( - dynamic_cast > > >&> - (thermo()).speciesData()[i] - ) - ); -} -*/ -PtrList gasProperties(Y.size()); -forAll(gasProperties, i) -{ - gasProperties.set - ( - i, - new specieReactingProperties - ( - dynamic_cast(thermo()).speciesData()[i] - ) - ); -} - -Info<< "\nConstructing reacting cloud" << endl; -basicReactingCloud parcels -( - "reactingCloud1", - rho, - U, - g, - thermo(), - gasProperties -); diff --git a/applications/solvers/combustion/coalChemistryFoam/Make/files b/applications/solvers/combustion/coalChemistryFoam/Make/files index 6a1392f01c..552d734501 100644 --- a/applications/solvers/combustion/coalChemistryFoam/Make/files +++ b/applications/solvers/combustion/coalChemistryFoam/Make/files @@ -1,3 +1,3 @@ coalChemistryFoam.C -EXE = $(FOAM_USER_APPBIN)/coalChemistryFoam +EXE = $(FOAM_APPBIN)/coalChemistryFoam diff --git a/applications/solvers/combustion/coalChemistryFoam/Make/options b/applications/solvers/combustion/coalChemistryFoam/Make/options index 21575a94ae..d1dd07691b 100644 --- a/applications/solvers/combustion/coalChemistryFoam/Make/options +++ b/applications/solvers/combustion/coalChemistryFoam/Make/options @@ -19,7 +19,6 @@ EXE_INC = \ -I$(LIB_SRC)/ODE/lnInclude EXE_LIBS = \ - -L$(FOAM_USER_LIBBIN) \ -lfiniteVolume \ -lmeshTools \ -lcompressibleRASModels \ diff --git a/applications/solvers/combustion/coalChemistryFoam/coalChemistryFoam.C b/applications/solvers/combustion/coalChemistryFoam/coalChemistryFoam.C index 3bccc682d3..f5fc4faea6 100644 --- a/applications/solvers/combustion/coalChemistryFoam/coalChemistryFoam.C +++ b/applications/solvers/combustion/coalChemistryFoam/coalChemistryFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,11 +35,11 @@ Description #include "hCombustionThermo.H" #include "turbulenceModel.H" #include "basicThermoCloud.H" -#include "coalCloud.H" +#include "CoalCloud.H" #include "chemistryModel.H" #include "chemistrySolver.H" -#include "ReactingCloudThermoTypes.H" -#include "timeActivatedExplicitSource.H" +#include "reactingThermoTypes.H" +#include "timeActivatedExplicitCellSource.H" #include "radiationModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -113,8 +113,6 @@ int main(int argc, char *argv[]) turbulence->correct(); - enthalpySource.update(); - rho = thermo->rho(); if (runTime.write()) diff --git a/applications/solvers/combustion/coalChemistryFoam/createClouds.H b/applications/solvers/combustion/coalChemistryFoam/createClouds.H index 34398f6b82..4ed459b150 100644 --- a/applications/solvers/combustion/coalChemistryFoam/createClouds.H +++ b/applications/solvers/combustion/coalChemistryFoam/createClouds.H @@ -1,44 +1,11 @@ -Info<< "\nConstructing interpolation" << endl; - -Info << "\nConstructing gas properties" << endl; -/* -PtrList gasProperties(Y.size()); -forAll(gasProperties, i) -{ - gasProperties.set - ( - i, - new specieConstProperties - ( - dynamic_cast > > >&> - (thermo()).speciesData()[i] - ) - ); -} -*/ -PtrList gasProperties(Y.size()); -forAll(gasProperties, i) -{ - gasProperties.set - ( - i, - new specieReactingProperties - ( - dynamic_cast(thermo()).speciesData()[i] - ) - ); -} - Info<< "\nConstructing coal cloud" << endl; -coalCloud coalParcels +CoalCloud coalParcels ( "coalCloud1", rho, U, g, - thermo(), - gasProperties + thermo() ); Info<< "\nConstructing limestone cloud" << endl; diff --git a/applications/solvers/combustion/coalChemistryFoam/createFields.H b/applications/solvers/combustion/coalChemistryFoam/createFields.H index ebd8a44ab6..7232cc4244 100644 --- a/applications/solvers/combustion/coalChemistryFoam/createFields.H +++ b/applications/solvers/combustion/coalChemistryFoam/createFields.H @@ -105,8 +105,8 @@ volScalarField DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); - Info<< "\nConstructing explicit enthalpy source" << endl; - timeActivatedExplicitSource enthalpySource + Info<< "\nConstructing explicit enthalpy cell source" << endl; + timeActivatedExplicitCellSource enthalpySource ( "enthalpySource", mesh, diff --git a/applications/solvers/combustion/coalChemistryFoam/rhoEqn.H b/applications/solvers/combustion/coalChemistryFoam/rhoEqn.H index fdc338a959..ce337f5acf 100644 --- a/applications/solvers/combustion/coalChemistryFoam/rhoEqn.H +++ b/applications/solvers/combustion/coalChemistryFoam/rhoEqn.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2007 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/solvers/combustion/reactingFoam/createFields.H b/applications/solvers/combustion/reactingFoam/createFields.H index cf0532b0f3..510f7d4236 100644 --- a/applications/solvers/combustion/reactingFoam/createFields.H +++ b/applications/solvers/combustion/reactingFoam/createFields.H @@ -37,7 +37,6 @@ volVectorField U volScalarField& p = thermo->p(); const volScalarField& psi = thermo->psi(); -const volScalarField& T = thermo->T(); volScalarField& h = thermo->h(); @@ -99,5 +98,5 @@ volScalarField dQ IOobject::AUTO_WRITE ), mesh, - dimensionedScalar("zero", dimensionSet(1,-3,-1,0,0,0,0), 0.0) + dimensionedScalar("zero", dimensionSet(1, -3, -1, 0, 0, 0, 0), 0.0) ); diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C index bd0ce2ac37..e3cece5b91 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPisoFoam/buoyantBoussinesqPisoFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C index 26e732cf9c..fafb49d848 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/buoyantBoussinesqSimpleFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H index 24cfbf4f68..d4878d063d 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/UEqn.H @@ -15,12 +15,10 @@ ( UEqn == - -fvc::reconstruct + fvc::reconstruct ( - ( - fvc::snGrad(pd) - + ghf*fvc::snGrad(rho) - ) * mesh.magSf() + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() ) ); } diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H b/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H index 103b3ea3bb..f199713cf8 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/createFields.H @@ -59,27 +59,6 @@ fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) ); - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("ghf", g & mesh.Cf()); - - dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef")); - - Info<< "Creating field pd\n" << endl; - volScalarField pd - ( - IOobject - ( - "pd", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - p = pd + rho*gh + pRef; thermo->correct(); dimensionedScalar initialMass = fvc::domainIntegrate(rho); diff --git a/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H index 53f6688a6a..7e48167d67 100644 --- a/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantPisoFoam/pEqn.H @@ -1,5 +1,5 @@ { - bool closedVolume = pd.needReference(); + bool closedVolume = p.needReference(); rho = thermo->rho(); @@ -17,38 +17,35 @@ ) ); - phi = phiU - ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf(); + phi = phiU + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::ddt(psi, pd) - + fvc::ddt(psi)*pRef - + fvc::ddt(psi, rho)*gh + fvm::ddt(psi, p) + fvc::div(phi) - - fvm::laplacian(rhorUAf, pd) + - fvm::laplacian(rhorUAf, p) ); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) { - pdEqn.solve(mesh.solver(pd.name() + "Final")); + pEqn.solve(mesh.solver(p.name() + "Final")); } else { - pdEqn.solve(mesh.solver(pd.name())); + pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { - phi += pdEqn.flux(); + phi += pEqn.flux(); } } U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf); U.correctBoundaryConditions(); - p == pd + rho*gh + pRef; DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); #include "rhoEqn.H" @@ -62,6 +59,4 @@ /fvc::domainIntegrate(thermo->psi()); rho = thermo->rho(); } - - pd == p - (rho*gh + pRef); } diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H index 71a57cd2a9..aa476b4dc8 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/UEqn.H @@ -13,14 +13,11 @@ ( UEqn() == - -fvc::reconstruct + fvc::reconstruct ( - ( - fvc::snGrad(pd) - + ghf*fvc::snGrad(rho) - ) * mesh.magSf() + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() ) ).initialResidual(); maxResidual = max(eqnResidual, maxResidual); - diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C index d91b6398f2..b2a8c5c374 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/buoyantSimpleFoam.C @@ -39,15 +39,14 @@ Description int main(int argc, char *argv[]) { + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "createFields.H" + #include "initContinuityErrs.H" -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" -# include "readEnvironmentalProperties.H" -# include "createFields.H" -# include "initContinuityErrs.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; @@ -55,17 +54,17 @@ int main(int argc, char *argv[]) { Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readSIMPLEControls.H" -# include "initConvergenceCheck.H" + #include "readSIMPLEControls.H" + #include "initConvergenceCheck.H" - pd.storePrevIter(); + p.storePrevIter(); rho.storePrevIter(); // Pressure-velocity SIMPLE corrector { -# include "UEqn.H" -# include "hEqn.H" -# include "pEqn.H" + #include "UEqn.H" + #include "hEqn.H" + #include "pEqn.H" } turbulence->correct(); @@ -76,7 +75,7 @@ int main(int argc, char *argv[]) << " ClockTime = " << runTime.elapsedClockTime() << " s" << nl << endl; -# include "convergenceCheck.H" + #include "convergenceCheck.H" } Info<< "End\n" << endl; diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H index 879ee722b9..0d9d9d5ec7 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/createFields.H @@ -51,38 +51,16 @@ ) ); - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("ghf", g & mesh.Cf()); - - dimensionedScalar pRef("pRef", p.dimensions(), thermo->lookup("pRef")); - - Info<< "Creating field pd\n" << endl; - volScalarField pd - ( - IOobject - ( - "pd", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - p = pd + rho*gh + pRef; thermo->correct(); - - label pdRefCell = 0; - scalar pdRefValue = 0.0; + label pRefCell = 0; + scalar pRefValue = 0.0; setRefCell ( - pd, + p, mesh.solutionDict().subDict("SIMPLE"), - pdRefCell, - pdRefValue + pRefCell, + pRefValue ); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H index 8d97ad9048..d592bc3c43 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H @@ -1,4 +1,6 @@ { + rho = thermo->rho(); + volScalarField rUA = 1.0/UEqn().A(); surfaceScalarField rhorUAf("(rho*(1|A(U)))", fvc::interpolate(rho*rUA)); @@ -7,60 +9,57 @@ phi = fvc::interpolate(rho)*(fvc::interpolate(U) & mesh.Sf()); bool closedVolume = adjustPhi(phi, U, p); - surfaceScalarField buoyancyPhi = ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf(); - phi -= buoyancyPhi; + surfaceScalarField buoyancyPhi = + rhorUAf*fvc::interpolate(rho)*(g & mesh.Sf()); + phi += buoyancyPhi; for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::laplacian(rhorUAf, pd) == fvc::div(phi) + fvm::laplacian(rhorUAf, p) == fvc::div(phi) ); - pdEqn.setReference(pdRefCell, pdRefValue); + pEqn.setReference(pRefCell, p[pRefCell]); // retain the residual from the first iteration if (nonOrth == 0) { - eqnResidual = pdEqn.solve().initialResidual(); + eqnResidual = pEqn.solve().initialResidual(); maxResidual = max(eqnResidual, maxResidual); } else { - pdEqn.solve(); + 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(thermo->psi()*p)) + /fvc::domainIntegrate(thermo->psi()); + } + // Calculate the conservative fluxes - phi -= pdEqn.flux(); + phi -= pEqn.flux(); // Explicitly relax pressure for momentum corrector - pd.relax(); + p.relax(); // Correct the momentum source with the pressure gradient flux // calculated from the relaxed pressure - U -= rUA*fvc::reconstruct((buoyancyPhi + pdEqn.flux())/rhorUAf); + U += rUA*fvc::reconstruct((buoyancyPhi - pEqn.flux())/rhorUAf); U.correctBoundaryConditions(); } } #include "continuityErrs.H" - p == pd + rho*gh + pRef; - - // For closed-volume cases adjust the pressure and density levels - // to obey overall mass continuity - if (closedVolume) - { - p += (initialMass - fvc::domainIntegrate(thermo->psi()*p)) - /fvc::domainIntegrate(thermo->psi()); - } - rho = thermo->rho(); rho.relax(); Info<< "rho max/min : " << max(rho).value() << " " << min(rho).value() << endl; - - pd == p - (rho*gh + pRef); } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files index 9d9152930a..9b95197f54 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/files @@ -1,10 +1,6 @@ regionProperties/regionProperties.C -coupleManager/coupleManager.C - derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C -derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C -derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C fluid/compressibleCourantNo.C diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options index a8797ca456..12316d6bc7 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options @@ -2,9 +2,7 @@ EXE_INC = \ -Ifluid \ -Isolid \ -IregionProperties \ - -IcoupleManager \ - -IderivedFvPatchFields/solidWallTemperatureCoupled \ - -IderivedFvPatchFields/solidWallHeatFluxTemperatureCoupled \ + -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C index faff0edba0..7ad940bcff 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -67,6 +67,7 @@ int main(int argc, char *argv[]) while (runTime.run()) { # include "readTimeControls.H" +# include "readPIMPLEControls.H" if (fluidRegions.size()) { @@ -78,22 +79,36 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - forAll(fluidRegions, i) + if (nOuterCorr != 1) { - Info<< "\nSolving for fluid region " - << fluidRegions[i].name() << endl; -# include "setRegionFluidFields.H" -# include "readFluidMultiRegionPISOControls.H" -# include "solveFluid.H" + forAll(fluidRegions, i) + { +# include "setRegionFluidFields.H" +# include "storeOldFluidFields.H" + } } - forAll(solidRegions, i) + + // --- PIMPLE loop + for (int oCorr=0; oCorr - ( - "regionProperties" - ); - - label myIndex = findIndex(props.fluidRegionNames(), localRegion_.name()); - if (myIndex == -1) - { - label i = findIndex(props.solidRegionNames(), localRegion_.name()); - - if (i == -1) - { - FatalErrorIn("coupleManager::regionOwner() const") - << "Cannot find region " << localRegion_.name() - << " neither in fluids " << props.fluidRegionNames() - << " nor in solids " << props.solidRegionNames() - << exit(FatalError); - } - myIndex = props.fluidRegionNames().size() + i; - } - label nbrIndex = findIndex(props.fluidRegionNames(), nbrRegion.name()); - if (nbrIndex == -1) - { - label i = findIndex(props.solidRegionNames(), nbrRegion.name()); - - if (i == -1) - { - FatalErrorIn("coupleManager::regionOwner() const") - << "Cannot find region " << nbrRegion.name() - << " neither in fluids " << props.fluidRegionNames() - << " nor in solids " << props.solidRegionNames() - << exit(FatalError); - } - nbrIndex = props.fluidRegionNames().size() + i; - } - - return myIndex < nbrIndex; -} - - -void Foam::coupleManager::checkCouple() const -{ - Info<< "neighbourRegionName_ = " << neighbourRegionName_ << endl; - Info<< "neighbourPatchName_ = " << neighbourPatchName_ << endl; - Info<< "neighbourFieldName_ = " << neighbourFieldName_ << endl; - - const fvPatch& nPatch = neighbourPatch(); - - if (patch_.size() != nPatch.size()) - { - FatalErrorIn("Foam::coupleManager::checkCouple()") - << "Unequal patch sizes:" << nl - << " patch name (size) = " << patch_.name() - << "(" << patch_.size() << ")" << nl - << " neighbour patch name (size) = " - << nPatch.name() << "(" << patch_.size() << ")" << nl - << abort(FatalError); - } -} - - -void Foam::coupleManager::coupleToObj() const -{ - const fvPatch& nPatch = neighbourPatch(); - - OFstream obj - ( - patch_.name() + "_to_" + nPatch.name() + "_couple.obj" - ); - const vectorField& c1 = patch_.Cf(); - const vectorField& c2 = neighbourPatch().Cf(); - - if (c1.size() != c2.size()) - { - FatalErrorIn("coupleManager::coupleToObj() const") - << "Coupled patches are of unequal size:" << nl - << " patch0 = " << patch_.name() - << "(" << patch_.size() << ")" << nl - << " patch1 = " << nPatch.name() - << "(" << nPatch.size() << ")" << nl - << abort(FatalError); - } - - forAll(c1, i) - { - obj << "v " << c1[i].x() << " " << c1[i].y() << " " << c1[i].z() << nl - << "v " << c2[i].x() << " " << c2[i].y() << " " << c2[i].z() << nl - << "l " << (2*i + 1) << " " << (2*i + 2) << endl; - } -} - - -void Foam::coupleManager::writeEntries(Ostream& os) const -{ - os.writeKeyword("neighbourRegionName"); - os << neighbourRegionName_ << token::END_STATEMENT << nl; - os.writeKeyword("neighbourPatchName"); - os << neighbourPatchName_ << token::END_STATEMENT << nl; - os.writeKeyword("neighbourFieldName"); - os << neighbourFieldName_ << token::END_STATEMENT << nl; -} - - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H deleted file mode 100644 index f1f73d23ef..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManager.H +++ /dev/null @@ -1,170 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - coupleManager - -Description - Object to handle the coupling of region patches. It can be queried to - return the neighbour information. - -SourceFiles - coupleManager.C - -\*---------------------------------------------------------------------------*/ - -#ifndef coupleManager_H -#define coupleManager_H - -#include "Ostream.H" -#include "dictionary.H" -#include "fvPatch.H" -#include "fvMesh.H" -#include "Time.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class coupleManager Declaration -\*---------------------------------------------------------------------------*/ - -class coupleManager -{ - // Private data - - //- Reference to the local fvPatch - const fvPatch& patch_; - - //- Name of neighbour region - word neighbourRegionName_; - - //- Name of patch on the neighbour region - word neighbourPatchName_; - - //- Name of field on the neighbour region - word neighbourFieldName_; - - //- Reference to the local region - const fvMesh& localRegion_; - - - // Private Member Functions - - //- Disallow default bitwise assignment - void operator=(const coupleManager&); - - -public: - - // Constructors - - //- Construct from fvPatch - coupleManager(const fvPatch& patch); - - //- Construct from fvPatch and dictionary - coupleManager(const fvPatch& patch, const dictionary& dict); - - //- Copy constructor - coupleManager(const coupleManager& cm); - - - // Destructor - - ~coupleManager(); - - - // Member Functions - - // Access - - //- Return a reference to the local patch - inline const fvPatch& patch() const; - - //- Return the name of the neighbour region - inline const word& neighbourRegionName() const; - - //- Return the name of the patch on the neighbour region - inline const word& neighbourPatchName() const; - - //- Return the name of the field on the neighbour region - inline const word& neighbourFieldName() const; - - //- Return a reference to the neighbour mesh - inline const fvMesh& neighbourRegion() const; - - //- Return the neighbour patch ID - inline label neighbourPatchID() const; - - //- Return a reference to the neighbour patch - inline const fvPatch& neighbourPatch() const; - - //- Return a reference to the neighbour patch field - template - inline const fvPatchField& neighbourPatchField() const; - - //- Am I owner (= first to evaluate) of this region interface? - bool regionOwner() const; - - //- Check that the couple is valid - void checkCouple() const; - - - // Edit - - //- Return the name of the neighbour region - word& neighbourRegionName(); - - //- Return the name of the patch on the neighbour region - word& neighbourPatchName(); - - //- Return the name of the field on the neighbour region - word& neighbourFieldName(); - - - // Write - - //- Write couple to obj file - void coupleToObj() const; - - //- Write entries for patches - void writeEntries(Ostream& os) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#include "coupleManagerI.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManagerI.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManagerI.H deleted file mode 100644 index 45e059ebae..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/coupleManager/coupleManagerI.H +++ /dev/null @@ -1,98 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -inline const Foam::fvPatch& Foam::coupleManager::patch() const -{ - return patch_; -}; - - -inline const Foam::word& Foam::coupleManager::neighbourRegionName() const -{ - return neighbourRegionName_; -}; - - -inline const Foam::word& Foam::coupleManager::neighbourPatchName() const -{ - return neighbourPatchName_; -}; - - -inline const Foam::word& Foam::coupleManager::neighbourFieldName() const -{ - return neighbourFieldName_; -}; - - -inline const Foam::fvMesh& Foam::coupleManager::neighbourRegion() const -{ - return localRegion_.objectRegistry::parent() - .lookupObject(neighbourRegionName_); -} - - -inline Foam::label Foam::coupleManager::neighbourPatchID() const -{ - return neighbourRegion().boundaryMesh().findPatchID(neighbourPatchName_); -} - - -inline const Foam::fvPatch& Foam::coupleManager::neighbourPatch() const -{ - return neighbourRegion().boundary()[neighbourPatchID()]; -} - - -template -inline const Foam::fvPatchField& -Foam::coupleManager::neighbourPatchField() const -{ - return neighbourPatch().lookupPatchField - , Type> - (neighbourFieldName_); -} - - -inline Foam::word& Foam::coupleManager::neighbourRegionName() -{ - return neighbourRegionName_; -}; - - -inline Foam::word& Foam::coupleManager::neighbourPatchName() -{ - return neighbourPatchName_; -}; - - -inline Foam::word& Foam::coupleManager::neighbourFieldName() -{ - return neighbourFieldName_; -}; - - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C deleted file mode 100644 index 07bcac29a6..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C +++ /dev/null @@ -1,150 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H" -#include "addToRunTimeSelectionTable.H" -#include "fvPatchFieldMapper.H" -#include "volFields.H" - -#include "solidWallTemperatureCoupledFvPatchScalarField.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: -solidWallHeatFluxTemperatureCoupledFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedGradientFvPatchScalarField(p, iF), - coupleManager_(p), - KName_("undefined-K") -{} - - -Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: -solidWallHeatFluxTemperatureCoupledFvPatchScalarField -( - const solidWallHeatFluxTemperatureCoupledFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedGradientFvPatchScalarField(ptf, p, iF, mapper), - coupleManager_(ptf.coupleManager_), - KName_(ptf.KName_) -{} - - -Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: -solidWallHeatFluxTemperatureCoupledFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedGradientFvPatchScalarField(p, iF), - coupleManager_(p, dict), - KName_(dict.lookup("K")) -{ - if (dict.found("value")) - { - fvPatchField::operator= - ( - scalarField("value", dict, p.size()) - ); - } - else - { - evaluate(); - } -} - - -Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField:: -solidWallHeatFluxTemperatureCoupledFvPatchScalarField -( - const solidWallHeatFluxTemperatureCoupledFvPatchScalarField& whftcsf, - const DimensionedField& iF -) -: - fixedGradientFvPatchScalarField(whftcsf, iF), - coupleManager_(whftcsf.coupleManager_), - KName_(whftcsf.KName_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::updateCoeffs() -{ - if (updated()) - { - return; - } - - const fvPatchField& neighbourField = - coupleManager_.neighbourPatchField(); - - const fvPatchField& K = - patch().lookupPatchField(KName_); - - gradient() = -refCast - (neighbourField).flux()/K; - - fixedGradientFvPatchScalarField::updateCoeffs(); -} - - -void Foam::solidWallHeatFluxTemperatureCoupledFvPatchScalarField::write -( - Ostream& os -) const -{ - fvPatchScalarField::write(os); - coupleManager_.writeEntries(os); - os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; - writeEntry("value", os); -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -makePatchTypeField -( - fvPatchScalarField, - solidWallHeatFluxTemperatureCoupledFvPatchScalarField -); - -} // End namespace Foam - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H deleted file mode 100644 index b7867ca8ce..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallHeatFluxTemperatureCoupled/solidWallHeatFluxTemperatureCoupledFvPatchScalarField.H +++ /dev/null @@ -1,165 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - solidWallHeatFluxTemperatureCoupledFvPatchScalarField - -Description - Fixed heat-flux boundary condition for temperature, to be used by the - conjugate heat transfer solver. - - Example usage: - myInterfacePatchName - { - type solidWallHeatFluxTemperatureCoupled; - neighbourRegionName fluid; - neighbourPatchName fluidSolidInterface; - neighbourFieldName T; - K K; - value uniform 300; - } - -SourceFiles - solidWallHeatFluxTemperatureCoupledFvPatchScalarField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef solidWallHeatFluxTemperatureCoupledFvPatchScalarField_H -#define solidWallHeatFluxTemperatureCoupledFvPatchScalarField_H - -#include "fvPatchFields.H" -#include "fixedGradientFvPatchFields.H" -#include "coupleManager.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class solidWallHeatFluxTemperatureCoupledFvPatchScalarField Declaration -\*---------------------------------------------------------------------------*/ - -class solidWallHeatFluxTemperatureCoupledFvPatchScalarField -: - public fixedGradientFvPatchScalarField -{ - // Private data - - //- Couple manager object - coupleManager coupleManager_; - - //- Name of thermal conductivity field - word KName_; - - -public: - - //- Runtime type information - TypeName("solidWallHeatFluxTemperatureCoupled"); - - - // Constructors - - //- Construct from patch and internal field - solidWallHeatFluxTemperatureCoupledFvPatchScalarField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - solidWallHeatFluxTemperatureCoupledFvPatchScalarField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given - // solidWallHeatFluxTemperatureCoupledFvPatchScalarField - // onto a new patch - solidWallHeatFluxTemperatureCoupledFvPatchScalarField - ( - const solidWallHeatFluxTemperatureCoupledFvPatchScalarField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new solidWallHeatFluxTemperatureCoupledFvPatchScalarField - ( - *this - ) - ); - } - - //- Construct as copy setting internal field reference - solidWallHeatFluxTemperatureCoupledFvPatchScalarField - ( - const solidWallHeatFluxTemperatureCoupledFvPatchScalarField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new solidWallHeatFluxTemperatureCoupledFvPatchScalarField - ( - *this, - iF - ) - ); - } - - - // Member functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C index b6bcfffa3f..5bec567310 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C @@ -28,8 +28,62 @@ License #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" +#include "directMappedPatchBase.H" #include "regionProperties.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +bool Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::interfaceOwner +( + const polyMesh& nbrRegion +) const +{ + const fvMesh& myRegion = patch().boundaryMesh().mesh(); + + const regionProperties& props = + myRegion.objectRegistry::parent().lookupObject + ( + "regionProperties" + ); + + label myIndex = findIndex(props.fluidRegionNames(), myRegion.name()); + if (myIndex == -1) + { + label i = findIndex(props.solidRegionNames(), myRegion.name()); + + if (i == -1) + { + FatalErrorIn + ( + "solidWallMixedTemperatureCoupledFvPatchScalarField" + "::interfaceOwner(const polyMesh&) const" + ) << "Cannot find region " << myRegion.name() + << " neither in fluids " << props.fluidRegionNames() + << " nor in solids " << props.solidRegionNames() + << exit(FatalError); + } + myIndex = props.fluidRegionNames().size() + i; + } + label nbrIndex = findIndex(props.fluidRegionNames(), nbrRegion.name()); + if (nbrIndex == -1) + { + label i = findIndex(props.solidRegionNames(), nbrRegion.name()); + + if (i == -1) + { + FatalErrorIn("coupleManager::interfaceOwner(const polyMesh&) const") + << "Cannot find region " << nbrRegion.name() + << " neither in fluids " << props.fluidRegionNames() + << " nor in solids " << props.solidRegionNames() + << exit(FatalError); + } + nbrIndex = props.fluidRegionNames().size() + i; + } + + return myIndex < nbrIndex; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::solidWallMixedTemperatureCoupledFvPatchScalarField:: @@ -40,7 +94,7 @@ solidWallMixedTemperatureCoupledFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - coupleManager_(p), + neighbourFieldName_("undefined-neighbourFieldName"), KName_("undefined-K") { this->refValue() = 0.0; @@ -60,7 +114,7 @@ solidWallMixedTemperatureCoupledFvPatchScalarField ) : mixedFvPatchScalarField(ptf, p, iF, mapper), - coupleManager_(ptf.coupleManager_), + neighbourFieldName_(ptf.neighbourFieldName_), KName_(ptf.KName_), fixesValue_(ptf.fixesValue_) {} @@ -75,14 +129,46 @@ solidWallMixedTemperatureCoupledFvPatchScalarField ) : mixedFvPatchScalarField(p, iF), - coupleManager_(p, dict), + neighbourFieldName_(dict.lookup("neighbourFieldName")), KName_(dict.lookup("K")) { + if (!isA(this->patch().patch())) + { + FatalErrorIn + ( + "solidWallMixedTemperatureCoupledFvPatchScalarField::" + "solidWallMixedTemperatureCoupledFvPatchScalarField\n" + "(\n" + " const fvPatch& p,\n" + " const DimensionedField& 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())); - refValue() = static_cast(*this); - refGrad() = 0.0; - valueFraction() = 1.0; - fixesValue_ = true; + + if (dict.found("refValue")) + { + // Full restart + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); + fixesValue_ = readBool(dict.lookup("fixesValue")); + } + else + { + // Start from user entered data. Assume fixedValue. + refValue() = *this; + refGrad() = 0.0; + valueFraction() = 1.0; + fixesValue_ = true; + } } @@ -94,7 +180,7 @@ solidWallMixedTemperatureCoupledFvPatchScalarField ) : mixedFvPatchScalarField(wtcsf, iF), - coupleManager_(wtcsf.coupleManager_), + neighbourFieldName_(wtcsf.neighbourFieldName_), KName_(wtcsf.KName_), fixesValue_(wtcsf.fixesValue_) {} @@ -116,33 +202,111 @@ void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() return; } + // Get the coupling information from the directMappedPatchBase + const directMappedPatchBase& mpp = refCast + ( + patch().patch() + ); + const polyMesh& nbrMesh = mpp.sampleMesh(); + tmp intFld = patchInternalField(); + if (interfaceOwner(nbrMesh)) + { + // Note: other side information could be cached - it only needs + // to be updated the first time round the iteration (i.e. when + // switching regions) but unfortunately we don't have this information. + + const mapDistribute& distMap = mpp.map(); + const fvPatch& nbrPatch = refCast + ( + nbrMesh + ).boundary()[mpp.samplePolyPatch().index()]; + + + // Calculate the temperature by harmonic averaging + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + const solidWallMixedTemperatureCoupledFvPatchScalarField& nbrField = + refCast + ( + nbrPatch.lookupPatchField + ( + neighbourFieldName_ + ) + ); + + // Swap to obtain full local values of neighbour internal field + scalarField nbrIntFld = nbrField.patchInternalField(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrIntFld + ); + + // Swap to obtain full local values of neighbour K*delta + scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + distMap.constructSize(), + distMap.subMap(), // what to send + distMap.constructMap(), // what to receive + nbrKDelta + ); + + + tmp myKDelta = K()*patch().deltaCoeffs(); + + // Calculate common wall temperature. Reuse *this to store common value. + scalarField Twall + ( + (myKDelta()*intFld() + nbrKDelta*nbrIntFld) + / (myKDelta() + nbrKDelta) + ); + // Assign to me + fvPatchScalarField::operator=(Twall); + // Distribute back and assign to neighbour + mapDistribute::distribute + ( + Pstream::defaultCommsType, + distMap.schedule(), + nbrField.size(), + distMap.constructMap(), // reverse : what to send + distMap.subMap(), + Twall + ); + const_cast + ( + nbrField + ).fvPatchScalarField::operator=(Twall); + } + + + // Switch between fixed value (of harmonic avg) or gradient + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + label nFixed = 0; // Like snGrad but bypass switching on refValue/refGrad. - tmp normalGradient = - (*this-intFld()) - * patch().deltaCoeffs(); + tmp normalGradient = (*this-intFld())*patch().deltaCoeffs(); if (debug) { + scalar Q = gSum(K()*patch().magSf()*normalGradient()); + Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::" << "updateCoeffs() :" << " patch:" << patch().name() + << " heatFlux:" << Q << " walltemperature " - << " min:" - << returnReduce - ( - (this->size() > 0 ? min(*this) : VGREAT), - minOp() - ) - << " max:" - << returnReduce - ( - (this->size() > 0 ? max(*this) : -VGREAT), - maxOp() - ) + << " min:" << gMin(*this) + << " max:" << gMax(*this) << " avg:" << gAverage(*this) << endl; } @@ -150,7 +314,7 @@ void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() forAll(*this, i) { // if outgoing flux use fixed value. - if (intFld()[i] > operator[](i)) + if (normalGradient()[i] < 0.0) { this->refValue()[i] = operator[](i); this->refGrad()[i] = 0.0; // not used @@ -185,80 +349,16 @@ void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs() } -void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::evaluate -( - const Pstream::commsTypes -) -{ - if (!this->updated()) - { - this->updateCoeffs(); - } - - if (!coupleManager_.regionOwner()) - { - // I am the last one to evaluate. - - tmp intFld = patchInternalField(); - - const fvPatch& nbrPatch = coupleManager_.neighbourPatch(); - - solidWallMixedTemperatureCoupledFvPatchScalarField& nbrField = - refCast - ( - const_cast&> - ( - coupleManager_.neighbourPatchField() - ) - ); - tmp nbrIntFld = nbrField.patchInternalField(); - tmp myKDelta = K()*patch().deltaCoeffs(); - tmp nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs(); - - // Calculate common wall temperature and assign to both sides - scalarField::operator= - ( - (myKDelta()*intFld + nbrKDelta()*nbrIntFld) - / (myKDelta() + nbrKDelta()) - ); - - nbrField.scalarField::operator=(*this); - - if (debug) - { - Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::" - << "updateCoeffs() :" - << " patch:" << patch().name() - << " setting master and slave to wall temperature " - << " min:" - << returnReduce - ( - (this->size() > 0 ? min(*this) : VGREAT), - minOp() - ) - << " max:" - << returnReduce - ( - (this->size() > 0 ? max(*this) : -VGREAT), - maxOp() - ) - << " avg:" << gAverage(*this) - << endl; - } - } - - fvPatchScalarField::evaluate(); -} - - void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::write ( Ostream& os ) const { mixedFvPatchScalarField::write(os); - coupleManager_.writeEntries(os); + os.writeKeyword("neighbourFieldName")<< neighbourFieldName_ + << token::END_STATEMENT << nl; os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; + os.writeKeyword("fixesValue") << fixesValue_ << token::END_STATEMENT << nl; } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H index 34c32b1abf..f4abacf648 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.H @@ -37,13 +37,22 @@ Description myInterfacePatchName { type solidWallMixedTemperatureCoupled; - neighbourRegionName fluid; - neighbourPatchName fluidSolidInterface; neighbourFieldName T; K K; value uniform 300; } + Needs to be on underlying directMapped(Wall)FvPatch. + + Note: runs in parallel with arbitrary decomposition. Uses directMapped + functionality to calculate exchange. + + Note: lags interface data so both sides use same data. + - problem: schedule to calculate average would interfere + with standard processor swaps. + - so: updateCoeffs sets both to same Twall. Only need to do + this for last outer iteration but don't have access to this. + SourceFiles solidWallMixedTemperatureCoupledFvPatchScalarField.C @@ -54,7 +63,6 @@ SourceFiles #include "fvPatchFields.H" #include "mixedFvPatchFields.H" -#include "coupleManager.H" #include "fvPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -72,14 +80,21 @@ class solidWallMixedTemperatureCoupledFvPatchScalarField { // Private data - //- Couple manager object - coupleManager coupleManager_; - + //- Name of field on the neighbour region + const word neighbourFieldName_; + //- Name of thermal conductivity field - word KName_; + const word KName_; bool fixesValue_; + + // Private Member Functions + + //- Am I or neighbour owner of interface + bool interfaceOwner(const polyMesh& nbrRegion) const; + + public: //- Runtime type information @@ -162,12 +177,6 @@ public: //- Update the coefficients associated with the patch field virtual void updateCoeffs(); - //- Evaluate the patch field - virtual void evaluate - ( - const Pstream::commsTypes commsType=Pstream::blocking - ); - //- Write virtual void write(Ostream&) const; }; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C deleted file mode 100644 index 05bbdd1ba3..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.C +++ /dev/null @@ -1,156 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -\*---------------------------------------------------------------------------*/ - -#include "solidWallTemperatureCoupledFvPatchScalarField.H" -#include "addToRunTimeSelectionTable.H" -#include "fvPatchFieldMapper.H" -#include "volFields.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::solidWallTemperatureCoupledFvPatchScalarField:: -solidWallTemperatureCoupledFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(p, iF), - coupleManager_(p), - KName_("undefined-K") -{} - - -Foam::solidWallTemperatureCoupledFvPatchScalarField:: -solidWallTemperatureCoupledFvPatchScalarField -( - const solidWallTemperatureCoupledFvPatchScalarField& ptf, - const fvPatch& p, - const DimensionedField& iF, - const fvPatchFieldMapper& mapper -) -: - fixedValueFvPatchScalarField(ptf, p, iF, mapper), - coupleManager_(ptf.coupleManager_), - KName_(ptf.KName_) -{} - - -Foam::solidWallTemperatureCoupledFvPatchScalarField:: -solidWallTemperatureCoupledFvPatchScalarField -( - const fvPatch& p, - const DimensionedField& iF, - const dictionary& dict -) -: - fixedValueFvPatchScalarField(p, iF), - coupleManager_(p, dict), - KName_(dict.lookup("K")) -{ - if (dict.found("value")) - { - fvPatchField::operator= - ( - scalarField("value", dict, p.size()) - ); - } - else - { - evaluate(); - } -} - - -Foam::solidWallTemperatureCoupledFvPatchScalarField:: -solidWallTemperatureCoupledFvPatchScalarField -( - const solidWallTemperatureCoupledFvPatchScalarField& wtcsf, - const DimensionedField& iF -) -: - fixedValueFvPatchScalarField(wtcsf, iF), - coupleManager_(wtcsf.coupleManager_), - KName_(wtcsf.KName_) -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -void Foam::solidWallTemperatureCoupledFvPatchScalarField::updateCoeffs() -{ - if (updated()) - { - return; - } - - const fvPatchField& neighbourField = - coupleManager_.neighbourPatchField(); - - operator==(neighbourField); - - fixedValueFvPatchScalarField::updateCoeffs(); -} - - -void Foam::solidWallTemperatureCoupledFvPatchScalarField::write -( - Ostream& os -) const -{ - fvPatchScalarField::write(os); - coupleManager_.writeEntries(os); - os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl; - writeEntry("value", os); -} - - -Foam::tmp -Foam::solidWallTemperatureCoupledFvPatchScalarField::flux() const -{ - const fvPatchScalarField& Kw = - patch().lookupPatchField(KName_); - - const fvPatchScalarField& Tw = *this; - - return Tw.snGrad()*Kw; -} - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -makePatchTypeField -( - fvPatchScalarField, - solidWallTemperatureCoupledFvPatchScalarField -); - -} // End namespace Foam - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.H deleted file mode 100644 index 22fd168175..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/derivedFvPatchFields/solidWallTemperatureCoupled/solidWallTemperatureCoupledFvPatchScalarField.H +++ /dev/null @@ -1,160 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software; you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2 of the License, or (at your - option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM; if not, write to the Free Software Foundation, - Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -Class - solidWallHeatFluxCoupledFvPatchScalarField - -Description - Fixed value boundary condition for temperature, to be used by the - conjugate heat transfer solver. - - Example usage: - myInterfacePatchName - { - type solidWallTemperatureCoupled; - neighbourRegionName fluid; - neighbourPatchName fluidSolidInterface; - neighbourFieldName T; - K K; - value uniform 300; - } - -SourceFiles - solidWallTemperatureCoupledFvPatchScalarField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef solidWallTemperatureCoupledFvPatchScalarField_H -#define solidWallTemperatureCoupledFvPatchScalarField_H - -#include "fvPatchFields.H" -#include "fixedValueFvPatchFields.H" -#include "coupleManager.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class solidWallTemperatureCoupledFvPatchScalarField Declaration -\*---------------------------------------------------------------------------*/ - -class solidWallTemperatureCoupledFvPatchScalarField -: - public fixedValueFvPatchScalarField -{ - // Private data - - //- Couple manager object - coupleManager coupleManager_; - - //- Name of thermal conductivity field - word KName_; - - -public: - - //- Runtime type information - TypeName("solidWallTemperatureCoupled"); - - - // Constructors - - //- Construct from patch and internal field - solidWallTemperatureCoupledFvPatchScalarField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - solidWallTemperatureCoupledFvPatchScalarField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given solidWallTemperatureCoupledFvPatchScalarField - // onto a new patch - solidWallTemperatureCoupledFvPatchScalarField - ( - const solidWallTemperatureCoupledFvPatchScalarField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new solidWallTemperatureCoupledFvPatchScalarField(*this) - ); - } - - //- Construct as copy setting internal field reference - solidWallTemperatureCoupledFvPatchScalarField - ( - const solidWallTemperatureCoupledFvPatchScalarField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new solidWallTemperatureCoupledFvPatchScalarField(*this, iF) - ); - } - - - // Member functions - - //- (intensive) flux - tmp flux() const; - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H index e719d92433..65467f8086 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/UEqn.H @@ -14,12 +14,10 @@ ( UEqn() == - -fvc::reconstruct + fvc::reconstruct ( - ( - fvc::snGrad(pd) - + ghf*fvc::snGrad(rho) - ) * mesh.magSf() + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() ) ); } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index 1f6e50de0a..fd9624685f 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -6,43 +6,15 @@ PtrList phiFluid(fluidRegions.size()); PtrList turbulence(fluidRegions.size()); PtrList DpDtFluid(fluidRegions.size()); - PtrList ghFluid(fluidRegions.size()); - PtrList ghfFluid(fluidRegions.size()); - PtrList pdFluid(fluidRegions.size()); List initialMassFluid(fluidRegions.size()); - dimensionedScalar pRef - ( - "pRef", - dimensionSet(1, -1, -2, 0, 0), - rp.lookup("pRef") - ); - // Populate fluid field pointer lists forAll(fluidRegions, i) { Info<< "*** Reading fluid mesh thermophysical properties for region " << fluidRegions[i].name() << nl << endl; - Info<< " Adding to pdFluid\n" << endl; - pdFluid.set - ( - i, - new volScalarField - ( - IOobject - ( - "pd", - runTime.timeName(), - fluidRegions[i], - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - fluidRegions[i] - ) - ); - Info<< " Adding to thermoFluid\n" << endl; thermoFluid.set ( @@ -145,6 +117,7 @@ i, new volScalarField ( + "DpDt", fvc::DDt ( surfaceScalarField @@ -157,36 +130,5 @@ ) ); - const dictionary& environmentalProperties = - fluidRegions[i].lookupObject - ("environmentalProperties"); - dimensionedVector g(environmentalProperties.lookup("g")); - - Info<< " Adding to ghFluid\n" << endl; - ghFluid.set - ( - i, - new volScalarField - ( - "gh", - g & fluidRegions[i].C() - ) - ); - ghfFluid.set - ( - i, - new surfaceScalarField - ( - "ghf", - g & fluidRegions[i].Cf() - ) - ); - - Info<< " Updating p from pd\n" << endl; - thermoFluid[i].p() == pdFluid[i] + rhoFluid[i]*ghFluid[i] + pRef; - thermoFluid[i].correct(); - initialMassFluid[i] = fvc::domainIntegrate(rhoFluid[i]).value(); } - - diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H index 7f2202d593..e070537db2 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/hEqn.H @@ -1,5 +1,5 @@ { - tmp hEqn + fvScalarMatrix hEqn ( fvm::ddt(rho, h) + fvm::div(phi, h) @@ -7,8 +7,16 @@ == DpDt ); - hEqn().relax(); - hEqn().solve(); + if (oCorr == nOuterCorr-1) + { + hEqn.relax(); + hEqn.solve(mesh.solver("hFinal")); + } + else + { + hEqn.relax(); + hEqn.solve(); + } thermo.correct(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H index e297989809..a264b68fe5 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H @@ -1,5 +1,5 @@ { - bool closedVolume = pd.needReference(); + bool closedVolume = p.needReference(); rho = thermo.rho(); @@ -17,31 +17,34 @@ ) ); - phi = phiU - ghf*fvc::snGrad(rho)*rhorUAf*mesh.magSf(); + phi = phiU + fvc::interpolate(rho)*(g & mesh.Sf())*rhorUAf; for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::ddt(psi, pd) - + fvc::ddt(psi)*pRef - + fvc::ddt(psi, rho)*gh + fvm::ddt(psi, p) + fvc::div(phi) - - fvm::laplacian(rho*rUA, pd) + - fvm::laplacian(rhorUAf, p) ); - if (corr == nCorr-1 && nonOrth == nNonOrthCorr) + if + ( + oCorr == nOuterCorr-1 + && corr == nCorr-1 + && nonOrth == nNonOrthCorr + ) { - pdEqn.solve(mesh.solver(pd.name() + "Final")); + pEqn.solve(mesh.solver(p.name() + "Final")); } else { - pdEqn.solve(mesh.solver(pd.name())); + pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { - phi += pdEqn.flux(); + phi += pEqn.flux(); } } @@ -49,27 +52,24 @@ U += rUA*fvc::reconstruct((phi - phiU)/rhorUAf); U.correctBoundaryConditions(); - // Update pressure field (including bc) - p == pd + rho*gh + pRef; + // Update pressure substantive derivative DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); // Solve continuity -# include "rhoEqn.H" + #include "rhoEqn.H" // Update continuity errors -# include "compressibleContinuityErrors.H" + #include "compressibleContinuityErrors.H" // For closed-volume cases adjust the pressure and density levels // to obey overall mass continuity if (closedVolume) { - p += (massIni - fvc::domainIntegrate(psi*p))/fvc::domainIntegrate(psi); + p += (massIni - fvc::domainIntegrate(psi*p)) + /fvc::domainIntegrate(psi); rho = thermo.rho(); } // Update thermal conductivity K = thermoFluid[i].Cp()*turb.alphaEff(); - - // Update pd (including bc) - pd == p - (rho*gh + pRef); } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H new file mode 100644 index 0000000000..413c0225f0 --- /dev/null +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/readFluidMultiRegionPIMPLEControls.H @@ -0,0 +1,9 @@ + const dictionary& pimple = mesh.solutionDict().subDict("PIMPLE"); + + int nCorr(readInt(pimple.lookup("nCorrectors"))); + + int nNonOrthCorr = + pimple.lookupOrDefault("nNonOrthogonalCorrectors", 0); + + bool momentumPredictor = + pimple.lookupOrDefault("momentumPredictor", true); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rhoEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rhoEqn.H deleted file mode 100644 index a6b0ac9fe1..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rhoEqn.H +++ /dev/null @@ -1 +0,0 @@ - solve(fvm::ddt(rho) + fvc::div(phi)); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H index 35a64418a8..72c9bbc4fa 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H @@ -7,12 +7,15 @@ surfaceScalarField& phi = phiFluid[i]; compressible::turbulenceModel& turb = turbulence[i]; volScalarField& DpDt = DpDtFluid[i]; - const volScalarField& gh = ghFluid[i]; - const surfaceScalarField& ghf = ghfFluid[i]; - volScalarField& pd = pdFluid[i]; volScalarField& p = thermo.p(); const volScalarField& psi = thermo.psi(); volScalarField& h = thermo.h(); const dimensionedScalar massIni("massIni", dimMass, initialMassFluid[i]); + + const dictionary& environmentalProperties = + fluidRegions[i].lookupObject + ("environmentalProperties"); + + const dimensionedVector g(environmentalProperties.lookup("g")); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H index 19ec50cac2..86dd4344c1 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solveFluid.H @@ -1,15 +1,18 @@ -# include "rhoEqn.H" - for (int ocorr=0; ocorr("nNonOrthogonalCorrectors", 0); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H index 6373e79d49..ce6a1c5bb2 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/readSolidMultiRegionPISOControls.H @@ -1,4 +1,4 @@ - dictionary piso = solidRegions[i].solutionDict().subDict("PISO"); + const dictionary& piso = solidRegions[i].solutionDict().subDict("PISO"); int nNonOrthCorr = 0; if (piso.found("nNonOrthogonalCorrectors")) diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H index 04c90d2c4c..f9e80e3d72 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H @@ -1,4 +1,4 @@ -// fvMesh& mesh = solidRegions[i]; + fvMesh& mesh = solidRegions[i]; volScalarField& rho = rhos[i]; volScalarField& cp = cps[i]; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H index 5fa731824f..ce8b1d0f40 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H @@ -1,10 +1,13 @@ { for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - solve + tmp TEqn ( - fvm::ddt(rho*cp, T) - fvm::laplacian(K, T) + fvm::ddt(rho*cp, T) + - fvm::laplacian(K, T) ); + TEqn().relax(); + TEqn().solve(); } Info<< "Min/max T:" << min(T) << ' ' << max(T) << endl; diff --git a/applications/solvers/lagrangian/reactingParcelFoam/Make/files b/applications/solvers/lagrangian/reactingParcelFoam/Make/files new file mode 100644 index 0000000000..3710ca4e2d --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFoam/Make/files @@ -0,0 +1,3 @@ +reactingParcelFoam.C + +EXE = $(FOAM_APPBIN)/reactingParcelFoam diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFoam/Make/options similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/Make/options rename to applications/solvers/lagrangian/reactingParcelFoam/Make/options diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/UEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/UEqn.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/UEqn.H rename to applications/solvers/lagrangian/reactingParcelFoam/UEqn.H diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/YEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/YEqn.H rename to applications/solvers/lagrangian/reactingParcelFoam/YEqn.H diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/additionalOutput.H b/applications/solvers/lagrangian/reactingParcelFoam/additionalOutput.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/additionalOutput.H rename to applications/solvers/lagrangian/reactingParcelFoam/additionalOutput.H diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/chemistry.H b/applications/solvers/lagrangian/reactingParcelFoam/chemistry.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/chemistry.H rename to applications/solvers/lagrangian/reactingParcelFoam/chemistry.H diff --git a/applications/solvers/lagrangian/reactingParcelFoam/createClouds.H b/applications/solvers/lagrangian/reactingParcelFoam/createClouds.H new file mode 100644 index 0000000000..fcab29c923 --- /dev/null +++ b/applications/solvers/lagrangian/reactingParcelFoam/createClouds.H @@ -0,0 +1,9 @@ +Info<< "\nConstructing reacting cloud" << endl; +BasicReactingCloud parcels +( + "reactingCloud1", + rho, + U, + g, + thermo() +); diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/createFields.H b/applications/solvers/lagrangian/reactingParcelFoam/createFields.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/createFields.H rename to applications/solvers/lagrangian/reactingParcelFoam/createFields.H diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/hEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/hEqn.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/hEqn.H rename to applications/solvers/lagrangian/reactingParcelFoam/hEqn.H diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/pEqn.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/pEqn.H rename to applications/solvers/lagrangian/reactingParcelFoam/pEqn.H diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/reactingParcelFoam.C b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C similarity index 96% rename from applications/solvers/Lagrangian/reactingParcelFoam/reactingParcelFoam.C rename to applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C index ea57f0da0e..3c2182d2bc 100644 --- a/applications/solvers/Lagrangian/reactingParcelFoam/reactingParcelFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFoam/reactingParcelFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,10 +34,10 @@ Description #include "fvCFD.H" #include "hCombustionThermo.H" #include "turbulenceModel.H" -#include "basicReactingCloud.H" +#include "BasicReactingCloud.H" #include "chemistryModel.H" #include "chemistrySolver.H" -#include "ReactingCloudThermoTypes.H" +#include "reactingThermoTypes.H" #include "radiationModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/readChemistryProperties.H b/applications/solvers/lagrangian/reactingParcelFoam/readChemistryProperties.H similarity index 100% rename from applications/solvers/Lagrangian/reactingParcelFoam/readChemistryProperties.H rename to applications/solvers/lagrangian/reactingParcelFoam/readChemistryProperties.H diff --git a/applications/solvers/Lagrangian/reactingParcelFoam/rhoEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/rhoEqn.H similarity index 95% rename from applications/solvers/Lagrangian/reactingParcelFoam/rhoEqn.H rename to applications/solvers/lagrangian/reactingParcelFoam/rhoEqn.H index e30e721004..1b2882a2b7 100644 --- a/applications/solvers/Lagrangian/reactingParcelFoam/rhoEqn.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/rhoEqn.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2007 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/Make/files b/applications/solvers/lagrangian/trackedReactingParcelFoam/Make/files new file mode 100644 index 0000000000..90e8aa5b4b --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/Make/files @@ -0,0 +1,3 @@ +trackedReactingParcelFoam.C + +EXE = $(FOAM_APPBIN)/trackedReactingParcelFoam diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/Make/options b/applications/solvers/lagrangian/trackedReactingParcelFoam/Make/options new file mode 100644 index 0000000000..54d7b744d4 --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/Make/options @@ -0,0 +1,38 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I${LIB_SRC}/meshTools/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/intermediate/lnInclude \ + -I$(LIB_SRC)/lagrangian/coalCombustion/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/pdfs/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/liquids/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/liquidMixture/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solids/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/solidMixture/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/thermophysicalFunctions/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/combustion/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/chemistryModel/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/ODE/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -lcompressibleRASModels \ + -lcompressibleLESModels \ + -llagrangian \ + -llagrangianIntermediate \ + -lspecie \ + -lbasicThermophysicalModels \ + -lliquids \ + -lliquidMixture \ + -lsolids \ + -lsolidMixture \ + -lthermophysicalFunctions \ + -lcombustionThermophysicalModels \ + -lchemistryModel \ + -lradiation \ + -lODE diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/UEqn.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/UEqn.H new file mode 100644 index 0000000000..c82307305b --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/UEqn.H @@ -0,0 +1,47 @@ + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + + fvm::div(phi, U) + + turbulence->divDevRhoReff(U) + == + rho.dimensionedInternalField()*g + + reactingParcels.SU() + ); + + UEqn.relax(); + + tmp trAU; + tmp trTU; + + if (pressureImplicitPorosity) + { + tmp tTU = tensor(I)*UEqn.A(); + pZones.addResistance(UEqn, tTU()); + trTU = inv(tTU()); + trTU().rename("rAU"); + + volVectorField gradp = fvc::grad(p); + + for (int UCorr=0; UCorr > mvConvection +( + fv::convectionScheme::New + ( + mesh, + fields, + phi, + mesh.divScheme("div(phi,Yi_h)") + ) +); + + +{ + label inertIndex = -1; + volScalarField Yt = 0.0*Y[0]; + + for (label i=0; ifvmDiv(phi, Yi) + - fvm::laplacian(turbulence->muEff(), Yi) + == + reactingParcels.Srho(i) + + kappa*chemistry.RR(i)().dimensionedInternalField() + + pointMassSources.Su(i) + ); + + Yi.max(0.0); + Yt += Yi; + } + else + { + inertIndex = i; + } + } + + Y[inertIndex] = scalar(1) - Yt; + Y[inertIndex].max(0.0); + +} diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/additionalOutput.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/additionalOutput.H new file mode 100644 index 0000000000..9edd35eb7c --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/additionalOutput.H @@ -0,0 +1,48 @@ +{ + tmp tdQ + ( + new volScalarField + ( + IOobject + ( + "dQ", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar + ( + "zero", + dimensionSet(1, -3, -1, 0, 0, 0, 0), + 0.0 + ) + ) + ); + + scalarField& dQ = tdQ(); + + scalarField cp(dQ.size(), 0.0); + + forAll(Y, i) + { + volScalarField RRi = chemistry.RR(i); + + forAll(h, celli) + { + scalar Ti = T[celli]; + cp[celli] += Y[i][celli]*chemistry.specieThermo()[i].Cp(Ti); + scalar hi = chemistry.specieThermo()[i].h(Ti); + scalar RR = RRi[celli]; + dQ[celli] -= hi*RR; + } + } + + forAll(dQ, celli) + { + dQ[celli] /= cp[celli]; + } + + tdQ().write(); +} diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/chemistry.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/chemistry.H new file mode 100644 index 0000000000..07b1e9953b --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/chemistry.H @@ -0,0 +1,25 @@ +{ + Info << "Solving chemistry" << endl; + + chemistry.solve + ( + runTime.value() - runTime.deltaT().value(), + runTime.deltaT().value() + ); + + // turbulent time scale + if (turbulentReaction) + { + DimensionedField tk = + Cmix*sqrt(turbulence->muEff()/rho/turbulence->epsilon()); + DimensionedField tc = + chemistry.tc()().dimensionedInternalField(); + + // Chalmers PaSR model + kappa = (runTime.deltaT() + tc)/(runTime.deltaT() + tc + tk); + } + else + { + kappa = 1.0; + } +} diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/createClouds.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/createClouds.H new file mode 100644 index 0000000000..aaf91c81cc --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/createClouds.H @@ -0,0 +1,9 @@ +Info<< "\nConstructing reacting cloud" << endl; +BasicTrackedReactingCloud reactingParcels +( + "reactingCloud1", + rho, + U, + g, + thermo() +); diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/createFields.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/createFields.H new file mode 100644 index 0000000000..b9cea162f4 --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/createFields.H @@ -0,0 +1,111 @@ + Info<< "Reading thermophysical properties" << nl << endl; + + autoPtr thermo + ( + hCombustionThermo::New(mesh) + ); + + combustionMixture& composition = thermo->composition(); + PtrList& Y = composition.Y(); + + word inertSpecie(thermo->lookup("inertSpecie")); + + volScalarField& p = thermo->p(); + volScalarField& h = thermo->h(); + const volScalarField& T = thermo->T(); + const volScalarField& psi = thermo->psi(); + + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + thermo->rho() + ); + + Info<< "Reading field U" << nl << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "compressibleCreatePhi.H" + + DimensionedField kappa + ( + IOobject + ( + "kappa", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("zero", dimless, 0.0) + ); + + Info<< "Creating turbulence model" << nl << endl; + autoPtr turbulence + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo() + ) + ); + + Info<< "Creating field DpDt" << nl << endl; + volScalarField DpDt = + fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + + Info << "Constructing chemical mechanism" << nl << endl; + chemistryModel chemistry + ( + thermo(), + rho + ); + + multivariateSurfaceInterpolationScheme::fieldTable fields; + + forAll (Y, i) + { + fields.add(Y[i]); + } + fields.add(h); + + Info<< "Creating porous zones" << nl << endl; + porousZones pZones(mesh); + Switch pressureImplicitPorosity(false); + + label nUCorr = 0; + if (pZones.size()) + { + // nUCorrectors for pressureImplicitPorosity + if (mesh.solutionDict().subDict("PISO").found("nUCorrectors")) + { + mesh.solutionDict().subDict("PISO").lookup("nUCorrectors") + >> nUCorr; + } + + if (nUCorr > 0) + { + pressureImplicitPorosity = true; + } + } + diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/createMulticomponentPointSources.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/createMulticomponentPointSources.H new file mode 100644 index 0000000000..52de65dc50 --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/createMulticomponentPointSources.H @@ -0,0 +1,8 @@ +Info<< "\nConstructing multi-component mass flow rate point sources" << endl; +timeActivatedExplicitMulticomponentPointSource pointMassSources +( + "pointMassSources", + mesh, + Y, + dimMass/dimVolume/dimTime +); diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/hEqn.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/hEqn.H new file mode 100644 index 0000000000..32e7155536 --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/hEqn.H @@ -0,0 +1,20 @@ +{ + fvScalarMatrix hEqn + ( + fvm::ddt(rho, h) + + fvm::div(phi, h) + - fvm::laplacian(turbulence->alphaEff(), h) + == + DpDt + + reactingParcels.Sh() + + radiation->Sh(thermo()) + ); + + hEqn.relax(); + + hEqn.solve(); + + thermo->correct(); + + radiation->correct(); +} diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/pEqn.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/pEqn.H new file mode 100644 index 0000000000..b6207ce0c4 --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/pEqn.H @@ -0,0 +1,110 @@ +rho = thermo->rho(); + +if (pressureImplicitPorosity) +{ + U = trTU()&UEqn.H(); +} +else +{ + U = trAU()*UEqn.H(); +} + +if (transonic) +{ + surfaceScalarField phid + ( + "phid", + fvc::interpolate(thermo->psi()) + *( + (fvc::interpolate(U) & mesh.Sf()) +// + fvc::ddtPhiCorr(rUA, rho, U, phi) + ) + ); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + tmp lapTerm; + + if (pressureImplicitPorosity) + { + lapTerm = fvm::laplacian(rho*trTU(), p); + } + else + { + lapTerm = fvm::laplacian(rho*trAU(), p); + } + + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvm::div(phid, p) + - lapTerm() + == + reactingParcels.Srho() + + pointMassSources.Su() + ); + + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi == pEqn.flux(); + } + } +} +else +{ + phi = + fvc::interpolate(rho) + *( + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(trAU(), rho, U, phi) + ); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + tmp lapTerm; + + if (pressureImplicitPorosity) + { + lapTerm = fvm::laplacian(rho*trTU(), p); + } + else + { + lapTerm = fvm::laplacian(rho*trAU(), p); + } + + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvc::div(phi) + - lapTerm() + == + reactingParcels.Srho() + + pointMassSources.Su() + ); + + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi += pEqn.flux(); + } + } +} + +#include "rhoEqn.H" +#include "compressibleContinuityErrs.H" + +if (pressureImplicitPorosity) +{ + U -= trTU()&fvc::grad(p); +} +else +{ + U -= trAU()*fvc::grad(p); +} +U.correctBoundaryConditions(); + +DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/readChemistryProperties.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/readChemistryProperties.H new file mode 100644 index 0000000000..1a60e6fb34 --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/readChemistryProperties.H @@ -0,0 +1,22 @@ +Info<< "Reading chemistry properties\n" << endl; + +IOdictionary chemistryProperties +( + IOobject + ( + "chemistryProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + +Switch turbulentReaction(chemistryProperties.lookup("turbulentReaction")); + +dimensionedScalar Cmix("Cmix", dimless, 1.0); + +if (turbulentReaction) +{ + chemistryProperties.lookup("Cmix") >> Cmix; +} diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/rhoEqn.H b/applications/solvers/lagrangian/trackedReactingParcelFoam/rhoEqn.H new file mode 100644 index 0000000000..faadc1ecfb --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/rhoEqn.H @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2007 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 + +Global + rhoEqn + +Description + Solve the continuity for density. + +\*---------------------------------------------------------------------------*/ + +{ + solve + ( + fvm::ddt(rho) + + fvc::div(phi) + == + reactingParcels.Srho() + + pointMassSources.Su() + ); +} + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/trackedReactingParcelFoam/trackedReactingParcelFoam.C b/applications/solvers/lagrangian/trackedReactingParcelFoam/trackedReactingParcelFoam.C new file mode 100644 index 0000000000..62af964eba --- /dev/null +++ b/applications/solvers/lagrangian/trackedReactingParcelFoam/trackedReactingParcelFoam.C @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + +Description + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "hCombustionThermo.H" +#include "turbulenceModel.H" +#include "BasicTrackedReactingCloud.H" +#include "chemistryModel.H" +#include "chemistrySolver.H" +#include "reactingThermoTypes.H" +#include "radiationModel.H" +#include "porousZones.H" +#include "timeActivatedExplicitMulticomponentPointSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createMesh.H" + #include "readChemistryProperties.H" + #include "readEnvironmentalProperties.H" + #include "createFields.H" + #include "createRadiationModel.H" + #include "createClouds.H" + #include "createMulticomponentPointSources.H" + #include "readPISOControls.H" + #include "initContinuityErrs.H" + #include "readTimeControls.H" + #include "compressibleCourantNo.H" + #include "setInitialDeltaT.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "readPISOControls.H" + #include "compressibleCourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + reactingParcels.evolve(); + + reactingParcels.info(); + + #include "chemistry.H" + #include "rhoEqn.H" + + // --- PIMPLE loop + for (int ocorr=1; ocorr<=nOuterCorr; ocorr++) + { + #include "UEqn.H" + #include "YEqn.H" + + // --- PISO loop + for (int corr=1; corr<=nCorr; corr++) + { + #include "hEqn.H" + #include "pEqn.H" + } + + Info<< "T gas min/max = " << min(T).value() << ", " + << max(T).value() << endl; + } + + turbulence->correct(); + + rho = thermo->rho(); + + if (runTime.write()) + { + #include "additionalOutput.H" + } + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/Make/files b/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/files similarity index 100% rename from applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/Make/files rename to applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/files diff --git a/applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/Make/options b/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/options similarity index 100% rename from applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/Make/options rename to applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/options diff --git a/applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/createFields.H b/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/createFields.H similarity index 100% rename from applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/createFields.H rename to applications/solvers/lagrangian/uncoupledKinematicParcelFoam/createFields.H diff --git a/applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/uncoupledKinematicParcelFoam.C b/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/uncoupledKinematicParcelFoam.C similarity index 97% rename from applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/uncoupledKinematicParcelFoam.C rename to applications/solvers/lagrangian/uncoupledKinematicParcelFoam/uncoupledKinematicParcelFoam.C index 786146219b..e4c2b39665 100644 --- a/applications/solvers/Lagrangian/uncoupledKinematicParcelFoam/uncoupledKinematicParcelFoam.C +++ b/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/uncoupledKinematicParcelFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H b/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H index 1576f6ba78..138e58fc7f 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/UEqn.H @@ -24,10 +24,10 @@ == fvc::reconstruct ( - ( + fvc::interpolate(rho)*(g & mesh.Sf()) + + ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - - fvc::snGrad(pd) + - fvc::snGrad(p) ) * mesh.magSf() ) ); diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H b/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H index 4152105784..d82a03edb5 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/correctPhi.H @@ -12,7 +12,7 @@ IOobject::NO_WRITE ), mesh, - dimensionedScalar("pcorr", pd.dimensions(), 0.0), + dimensionedScalar("pcorr", p.dimensions(), 0.0), pcorrTypes ); diff --git a/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H b/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H index dc04fb4546..6b8e67cc49 100644 --- a/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterDyMFoam/createFields.H @@ -1,9 +1,9 @@ - Info<< "Reading field pd\n" << endl; - volScalarField pd + Info<< "Reading field p\n" << endl; + volScalarField p ( IOobject ( - "pd", + "p", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -88,24 +88,6 @@ dimensionedScalar pMin(twoPhaseProperties.lookup("pMin")); - volScalarField p - ( - IOobject - ( - "p", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - max - ( - (pd + gh*(alpha1*rho10 + alpha2*rho20)) - /(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), - pMin - ) - ); - volScalarField rho1 = rho10 + psi1*p; volScalarField rho2 = rho20 + psi2*p; @@ -152,11 +134,11 @@ ); - wordList pcorrTypes(pd.boundaryField().types()); + wordList pcorrTypes(p.boundaryField().types()); - for (label i=0; i pdEqnComp; + tmp pEqnComp; if (transonic) { - pdEqnComp = - (fvm::ddt(pd) + fvm::div(phi, pd) - fvm::Sp(fvc::div(phi), pd)); + pEqnComp = + (fvm::ddt(p) + fvm::div(phi, p) - fvm::Sp(fvc::div(phi), p)); } else { - pdEqnComp = - (fvm::ddt(pd) + fvc::div(phi, pd) - fvc::Sp(fvc::div(phi), pd)); + pEqnComp = + (fvm::ddt(p) + fvc::div(phi, p) - fvc::Sp(fvc::div(phi), p)); } @@ -26,16 +26,16 @@ phi = phiU + ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rUAf*mesh.magSf(); + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() + + fvc::interpolate(rho)*(g & mesh.Sf()) + )*rUAf; for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqnIncomp + fvScalarMatrix pEqnIncomp ( fvc::div(phi) - - fvm::laplacian(rUAf, pd) + - fvm::laplacian(rUAf, p) ); if @@ -51,9 +51,9 @@ max(alpha1, scalar(0))*(psi1/rho1) + max(alpha2, scalar(0))*(psi2/rho2) ) - *pdEqnComp() - + pdEqnIncomp, - mesh.solver(pd.name() + "Final") + *pEqnComp() + + pEqnIncomp, + mesh.solver(p.name() + "Final") ); } else @@ -64,8 +64,8 @@ max(alpha1, scalar(0))*(psi1/rho1) + max(alpha2, scalar(0))*(psi2/rho2) ) - *pdEqnComp() - + pdEqnIncomp + *pEqnComp() + + pEqnIncomp ); } @@ -73,26 +73,21 @@ { dgdt = (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) - *(pdEqnComp & pd); - phi += pdEqnIncomp.flux(); + *(pEqnComp & p); + phi += pEqnIncomp.flux(); } } U += rUA*fvc::reconstruct((phi - phiU)/rUAf); U.correctBoundaryConditions(); - p = max - ( - (pd + gh*(alpha1*rho10 + alpha2*rho20)) - /(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), - pMin - ); + p.max(pMin); rho1 = rho10 + psi1*p; rho2 = rho20 + psi2*p; Info<< "max(U) " << max(mag(U)).value() << endl; - Info<< "min(pd) " << min(pd).value() << endl; + Info<< "min(p) " << min(p).value() << endl; // Make the fluxes relative to the mesh motion fvc::makeRelative(phi, U); diff --git a/applications/solvers/multiphase/compressibleInterFoam/UEqn.H b/applications/solvers/multiphase/compressibleInterFoam/UEqn.H index 528e0aaafd..0b1a9ac029 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/UEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/UEqn.H @@ -24,10 +24,10 @@ == fvc::reconstruct ( - ( + fvc::interpolate(rho)*(g & mesh.Sf()) + + ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - - fvc::snGrad(pd) + - fvc::snGrad(p) ) * mesh.magSf() ) ); diff --git a/applications/solvers/multiphase/compressibleInterFoam/createFields.H b/applications/solvers/multiphase/compressibleInterFoam/createFields.H index 1f579d245b..3e6904d383 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterFoam/createFields.H @@ -1,9 +1,9 @@ - Info<< "Reading field pd\n" << endl; - volScalarField pd + Info<< "Reading field p\n" << endl; + volScalarField p ( IOobject ( - "pd", + "p", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -46,11 +46,6 @@ #include "createPhi.H" - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("ghf", g & mesh.Cf()); - - Info<< "Reading transportProperties\n" << endl; twoPhaseMixture twoPhaseProperties(U, phi); @@ -88,24 +83,6 @@ dimensionedScalar pMin(twoPhaseProperties.lookup("pMin")); - volScalarField p - ( - IOobject - ( - "p", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - max - ( - (pd + gh*(alpha1*rho10 + alpha2*rho20)) - /(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), - pMin - ) - ); - volScalarField rho1 = rho10 + psi1*p; volScalarField rho2 = rho20 + psi2*p; diff --git a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H index ebf24498ad..9d2dc23916 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H @@ -2,17 +2,17 @@ volScalarField rUA = 1.0/UEqn.A(); surfaceScalarField rUAf = fvc::interpolate(rUA); - tmp pdEqnComp; + tmp pEqnComp; if (transonic) { - pdEqnComp = - (fvm::ddt(pd) + fvm::div(phi, pd) - fvm::Sp(fvc::div(phi), pd)); + pEqnComp = + (fvm::ddt(p) + fvm::div(phi, p) - fvm::Sp(fvc::div(phi), p)); } else { - pdEqnComp = - (fvm::ddt(pd) + fvc::div(phi, pd) - fvc::Sp(fvc::div(phi), pd)); + pEqnComp = + (fvm::ddt(p) + fvc::div(phi, p) - fvc::Sp(fvc::div(phi), p)); } @@ -26,16 +26,16 @@ phi = phiU + ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rUAf*mesh.magSf(); + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() + + fvc::interpolate(rho)*(g & mesh.Sf()) + )*rUAf; for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqnIncomp + fvScalarMatrix pEqnIncomp ( fvc::div(phi) - - fvm::laplacian(rUAf, pd) + - fvm::laplacian(rUAf, p) ); solve @@ -44,31 +44,27 @@ max(alpha1, scalar(0))*(psi1/rho1) + max(alpha2, scalar(0))*(psi2/rho2) ) - *pdEqnComp() - + pdEqnIncomp + *pEqnComp() + + pEqnIncomp ); if (nonOrth == nNonOrthCorr) { dgdt = (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) - *(pdEqnComp & pd); - phi += pdEqnIncomp.flux(); + *(pEqnComp & p); + phi += pEqnIncomp.flux(); } } U += rUA*fvc::reconstruct((phi - phiU)/rUAf); U.correctBoundaryConditions(); - p = max - ( - (pd + gh*(alpha1*rho10 + alpha2*rho20))/(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), - pMin - ); + p.max(pMin); rho1 = rho10 + psi1*p; rho2 = rho20 + psi2*p; Info<< "max(U) " << max(mag(U)).value() << endl; - Info<< "min(pd) " << min(pd).value() << endl; + Info<< "min(p) " << min(p).value() << endl; } diff --git a/applications/solvers/multiphase/interDyMFoam/correctPhi.H b/applications/solvers/multiphase/interDyMFoam/correctPhi.H index c975c9b374..1f7845f347 100644 --- a/applications/solvers/multiphase/interDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/interDyMFoam/correctPhi.H @@ -12,7 +12,7 @@ IOobject::NO_WRITE ), mesh, - dimensionedScalar("pcorr", pd.dimensions(), 0.0), + dimensionedScalar("pcorr", p.dimensions(), 0.0), pcorrTypes ); @@ -27,7 +27,7 @@ fvm::laplacian(rAUf, pcorr) == fvc::div(phi) ); - pcorrEqn.setReference(pdRefCell, pdRefValue); + pcorrEqn.setReference(pRefCell, pRefValue); pcorrEqn.solve(); if (nonOrth == nNonOrthCorr) diff --git a/applications/solvers/multiphase/interDyMFoam/createFields.H b/applications/solvers/multiphase/interDyMFoam/createFields.H index bcceb9d748..26644e17f4 100644 --- a/applications/solvers/multiphase/interDyMFoam/createFields.H +++ b/applications/solvers/multiphase/interDyMFoam/createFields.H @@ -1,9 +1,9 @@ - Info<< "Reading field pd\n" << endl; - volScalarField pd + Info<< "Reading field p\n" << endl; + volScalarField p ( IOobject ( - "pd", + "p", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -92,47 +92,17 @@ incompressible::turbulenceModel::New(U, phi, twoPhaseProperties) ); - wordList pcorrTypes(pd.boundaryField().types()); + wordList pcorrTypes(p.boundaryField().types()); - for (label i=0; icorrect(); runTime.write(); diff --git a/applications/solvers/multiphase/interDyMFoam/pEqn.H b/applications/solvers/multiphase/interDyMFoam/pEqn.H index f8ff18f606..8825661c83 100644 --- a/applications/solvers/multiphase/interDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interDyMFoam/pEqn.H @@ -7,38 +7,38 @@ phi = phiU + ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() + + fvc::interpolate(rho)*(g & mesh.Sf()) + )*rAUf; - if (pd.needReference()) + if (p.needReference()) { fvc::makeRelative(phi, U); - adjustPhi(phi, U, pd); + adjustPhi(phi, U, p); fvc::makeAbsolute(phi, U); } for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::laplacian(rAUf, pd) == fvc::div(phi) + fvm::laplacian(rAUf, p) == fvc::div(phi) ); - pdEqn.setReference(pdRefCell, pdRefValue); + pEqn.setReference(pRefCell, pRefValue); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) { - pdEqn.solve(mesh.solver(pd.name() + "Final")); + pEqn.solve(mesh.solver(p.name() + "Final")); } else { - pdEqn.solve(mesh.solver(pd.name())); + pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { - phi -= pdEqn.flux(); + phi -= pEqn.flux(); } } diff --git a/applications/solvers/multiphase/interFoam/UEqn.H b/applications/solvers/multiphase/interFoam/UEqn.H index 528e0aaafd..0b1a9ac029 100644 --- a/applications/solvers/multiphase/interFoam/UEqn.H +++ b/applications/solvers/multiphase/interFoam/UEqn.H @@ -24,10 +24,10 @@ == fvc::reconstruct ( - ( + fvc::interpolate(rho)*(g & mesh.Sf()) + + ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - - fvc::snGrad(pd) + - fvc::snGrad(p) ) * mesh.magSf() ) ); diff --git a/applications/solvers/multiphase/interFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/correctPhi.H index 171e1670f4..642aa1c5d2 100644 --- a/applications/solvers/multiphase/interFoam/correctPhi.H +++ b/applications/solvers/multiphase/interFoam/correctPhi.H @@ -1,11 +1,11 @@ { # include "continuityErrs.H" - wordList pcorrTypes(pd.boundaryField().types()); + wordList pcorrTypes(p.boundaryField().types()); - for (label i=0; icorrect(); runTime.write(); diff --git a/applications/solvers/multiphase/interFoam/pEqn.H b/applications/solvers/multiphase/interFoam/pEqn.H index e5afbb8e4f..25482fa994 100644 --- a/applications/solvers/multiphase/interFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/pEqn.H @@ -12,33 +12,33 @@ phi = phiU + ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rUAf*mesh.magSf(); + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1)*mesh.magSf() + + fvc::interpolate(rho)*(g & mesh.Sf()) + )*rUAf; - adjustPhi(phi, U, pd); + adjustPhi(phi, U, p); for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::laplacian(rUAf, pd) == fvc::div(phi) + fvm::laplacian(rUAf, p) == fvc::div(phi) ); - pdEqn.setReference(pdRefCell, pdRefValue); + pEqn.setReference(pRefCell, pRefValue); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) { - pdEqn.solve(mesh.solver(pd.name() + "Final")); + pEqn.solve(mesh.solver(p.name() + "Final")); } else { - pdEqn.solve(mesh.solver(pd.name())); + pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { - phi -= pdEqn.flux(); + phi -= pEqn.flux(); } } diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H index c59137c7b8..757e37a2cf 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/UEqn.H @@ -25,10 +25,10 @@ == fvc::reconstruct ( - ( + fvc::interpolate(rho)*(g & mesh.Sf()) + + ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - - fvc::snGrad(pd) + - fvc::snGrad(p) ) * mesh.magSf() ) ); diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H b/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H index 171e1670f4..642aa1c5d2 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/correctPhi.H @@ -1,11 +1,11 @@ { # include "continuityErrs.H" - wordList pcorrTypes(pd.boundaryField().types()); + wordList pcorrTypes(p.boundaryField().types()); - for (label i=0; i > vDotP = twoPhaseProperties->vDotP(); const volScalarField& vDotcP = vDotP[0](); @@ -25,31 +25,29 @@ for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvc::div(phi) - fvm::laplacian(rUAf, pd) - + (vDotvP - vDotcP)*(rho*gh - pSat) + fvm::Sp(vDotvP - vDotcP, pd) + fvc::div(phi) - fvm::laplacian(rUAf, p) + - (vDotvP - vDotcP)*pSat + fvm::Sp(vDotvP - vDotcP, p) ); - pdEqn.setReference(pdRefCell, pdRefValue); + pEqn.setReference(pRefCell, pRefValue); if (corr == nCorr-1 && nonOrth == nNonOrthCorr) { - pdEqn.solve(mesh.solver(pd.name() + "Final")); + pEqn.solve(mesh.solver(p.name() + "Final")); } else { - pdEqn.solve(mesh.solver(pd.name())); + pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { - phi += pdEqn.flux(); + phi += pEqn.flux(); } } - p = pd + rho*gh; - U += rUA*fvc::reconstruct((phi - phiU)/rUAf); U.correctBoundaryConditions(); } diff --git a/applications/solvers/multiphase/multiphaseInterFoam/UEqn.H b/applications/solvers/multiphase/multiphaseInterFoam/UEqn.H index 5ce0c0c088..17686b592c 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/UEqn.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/UEqn.H @@ -24,10 +24,10 @@ == fvc::reconstruct ( - ( + fvc::interpolate(rho)*(g & mesh.Sf()) + + ( mixture.surfaceTensionForce() - - ghf*fvc::snGrad(rho) - - fvc::snGrad(pd) + - fvc::snGrad(p) ) * mesh.magSf() ) ); diff --git a/applications/solvers/multiphase/multiphaseInterFoam/createFields.H b/applications/solvers/multiphase/multiphaseInterFoam/createFields.H index 07650fd4dd..fb64496294 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/createFields.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/createFields.H @@ -1,9 +1,9 @@ - Info<< "Reading field pd\n" << endl; - volScalarField pd + Info<< "Reading field p\n" << endl; + volScalarField p ( IOobject ( - "pd", + "p", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -45,45 +45,9 @@ rho.oldTime(); - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("ghf", g & mesh.Cf()); - - - volScalarField p - ( - IOobject - ( - "p", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - pd + rho*gh - ); - - - label pdRefCell = 0; - scalar pdRefValue = 0.0; - setRefCell(pd, mesh.solutionDict().subDict("PISO"), pdRefCell, pdRefValue); - + label pRefCell = 0; scalar pRefValue = 0.0; - - if (pd.needReference()) - { - pRefValue = readScalar - ( - mesh.solutionDict().subDict("PISO").lookup("pRefValue") - ); - - p += dimensionedScalar - ( - "p", - p.dimensions(), - pRefValue - getRefCellValue(p, pdRefCell) - ); - } + setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); // Construct incompressible turbulence model diff --git a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C index c5fdb5f3c2..b6968ca1a1 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C +++ b/applications/solvers/multiphase/multiphaseInterFoam/multiphaseInterFoam.C @@ -81,18 +81,6 @@ int main(int argc, char *argv[]) #include "continuityErrs.H" - p = pd + rho*gh; - - if (pd.needReference()) - { - p += dimensionedScalar - ( - "p", - p.dimensions(), - pRefValue - getRefCellValue(p, pdRefCell) - ); - } - turbulence->correct(); runTime.write(); diff --git a/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H b/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H index 3fd1e3e606..9d7e36dc95 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H @@ -12,33 +12,33 @@ phi = phiU + ( - mixture.surfaceTensionForce() - - ghf*fvc::snGrad(rho) - )*rUAf*mesh.magSf(); + mixture.surfaceTensionForce()*mesh.magSf() + + fvc::interpolate(rho)*(g & mesh.Sf()) + )*rUAf; - adjustPhi(phi, U, pd); + adjustPhi(phi, U, p); for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::laplacian(rUAf, pd) == fvc::div(phi) + fvm::laplacian(rUAf, p) == fvc::div(phi) ); - pdEqn.setReference(pdRefCell, pdRefValue); + pEqn.setReference(pRefCell, pRefValue); if (corr == nCorr-1) { - pdEqn.solve(mesh.solver(pd.name() + "Final")); + pEqn.solve(mesh.solver(p.name() + "Final")); } else { - pdEqn.solve(mesh.solver(pd.name())); + pEqn.solve(mesh.solver(p.name())); } if (nonOrth == nNonOrthCorr) { - phi -= pdEqn.flux(); + phi -= pEqn.flux(); } } diff --git a/applications/solvers/multiphase/settlingFoam/UEqn.H b/applications/solvers/multiphase/settlingFoam/UEqn.H index ac4c18ab19..04e9194363 100644 --- a/applications/solvers/multiphase/settlingFoam/UEqn.H +++ b/applications/solvers/multiphase/settlingFoam/UEqn.H @@ -22,10 +22,8 @@ == fvc::reconstruct ( - ( - - ghf*fvc::snGrad(rho) - - fvc::snGrad(p) - )*mesh.magSf() + fvc::interpolate(rho)*(g & mesh.Sf()) + - fvc::snGrad(p)*mesh.magSf() ) ); } diff --git a/applications/solvers/multiphase/settlingFoam/createFields.H b/applications/solvers/multiphase/settlingFoam/createFields.H index b13649c312..7c8445a71d 100644 --- a/applications/solvers/multiphase/settlingFoam/createFields.H +++ b/applications/solvers/multiphase/settlingFoam/createFields.H @@ -337,6 +337,3 @@ ), mut + mul ); - - Info<< "Calculating field (g.h)f\n" << endl; - surfaceScalarField ghf = surfaceScalarField("ghf", g & mesh.Cf()); diff --git a/applications/solvers/multiphase/settlingFoam/pEqn.H b/applications/solvers/multiphase/settlingFoam/pEqn.H index 65b954c6da..b4fc05b32a 100644 --- a/applications/solvers/multiphase/settlingFoam/pEqn.H +++ b/applications/solvers/multiphase/settlingFoam/pEqn.H @@ -15,7 +15,7 @@ phi = ); surfaceScalarField phiU("phiU", phi); -phi -= ghf*fvc::snGrad(rho)*rUAf*mesh.magSf(); +phi += fvc::interpolate(rho)*(g & mesh.Sf())*rUAf; for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H b/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H index 5a945697ca..18b915b16b 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/UEqn.H @@ -14,7 +14,14 @@ //- fvc::div(muEff*(fvc::interpolate(dev(fvc::grad(U))) & mesh.Sf())) ); - UEqn.relax(); + if (oCorr == nOuterCorr-1) + { + UEqn.relax(1); + } + else + { + UEqn.relax(); + } if (momentumPredictor) { @@ -22,9 +29,11 @@ ( UEqn == - -fvc::reconstruct + fvc::reconstruct ( - mesh.magSf()*(fvc::snGrad(pd) + ghf*fvc::snGrad(rho)) - ) + fvc::interpolate(rho)*(g & mesh.Sf()) + - mesh.magSf()*fvc::snGrad(p) + ), + mesh.solver(oCorr == nOuterCorr-1 ? "UFinal" : "U") ); } diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqn.H b/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqn.H index c126025368..8194753c8f 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqn.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/alphaEqn.H @@ -3,7 +3,12 @@ ( fvm::ddt(alpha1) + fvm::div(phi, alpha1) - - fvm::laplacian(Dab, alpha1) + //- fvm::Sp(fvc::div(phi), alpha1) + - fvm::laplacian + ( + Dab + alphatab*turbulence->nut(), alpha1, + "laplacian(Dab,alpha1)" + ) ); alpha1Eqn.solve(); diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H b/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H index a38135dc19..b61566d924 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H @@ -1,9 +1,9 @@ - Info<< "Reading field pd\n" << endl; - volScalarField pd + Info<< "Reading field p\n" << endl; + volScalarField p ( IOobject ( - "pd", + "p", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -50,6 +50,9 @@ dimensionedScalar Dab(twoPhaseProperties.lookup("Dab")); + // Read the reciprocal of the turbulent Schmidt number + dimensionedScalar alphatab(twoPhaseProperties.lookup("alphatab")); + // Need to store rho for ddt(rho, U) volScalarField rho("rho", alpha1*rho1 + (scalar(1) - alpha1)*rho2); rho.oldTime(); @@ -72,45 +75,9 @@ ); - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("gh", g & mesh.Cf()); - - - volScalarField p - ( - IOobject - ( - "p", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - pd + rho*gh - ); - - - label pdRefCell = 0; - scalar pdRefValue = 0.0; - setRefCell(pd, mesh.solutionDict().subDict("PISO"), pdRefCell, pdRefValue); - + label pRefCell = 0; scalar pRefValue = 0.0; - - if (pd.needReference()) - { - pRefValue = readScalar - ( - mesh.solutionDict().subDict("PISO").lookup("pRefValue") - ); - - p += dimensionedScalar - ( - "p", - p.dimensions(), - pRefValue - getRefCellValue(p, pdRefCell) - ); - } + setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue); // Construct incompressible turbulence model diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H b/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H index eaa0cef629..7ba3cdba8a 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H @@ -7,26 +7,37 @@ surfaceScalarField phiU ( "phiU", - (fvc::interpolate(U) & mesh.Sf()) + fvc::ddtPhiCorr(rUA, rho, U, phi) + (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rUA, rho, U, phi) ); - phi = phiU - ghf*fvc::snGrad(rho)*rUAf*mesh.magSf(); - - adjustPhi(phi, U, pd); + phi = phiU + fvc::interpolate(rho)*(g & mesh.Sf())*rUAf; for(int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { - fvScalarMatrix pdEqn + fvScalarMatrix pEqn ( - fvm::laplacian(rUAf, pd) == fvc::div(phi) + fvm::laplacian(rUAf, p) == fvc::div(phi) ); - pdEqn.setReference(pdRefCell, pdRefValue); - pdEqn.solve(); + pEqn.setReference(pRefCell, pRefValue); + + if + ( + corr == nCorr-1 + && nonOrth == nNonOrthCorr + ) + { + pEqn.solve(mesh.solver(p.name() + "Final")); + } + else + { + pEqn.solve(mesh.solver(p.name())); + } if (nonOrth == nNonOrthCorr) { - phi -= pdEqn.flux(); + phi -= pEqn.flux(); } } diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C b/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C index 1caf455708..63991f149e 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/twoLiquidMixingFoam.C @@ -40,53 +40,52 @@ Description int main(int argc, char *argv[]) { + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readEnvironmentalProperties.H" + #include "readPIMPLEControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "readTimeControls.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" -# include "setRootCase.H" -# include "createTime.H" -# include "createMesh.H" -# include "readEnvironmentalProperties.H" -# include "initContinuityErrs.H" -# include "createFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; - while (runTime.loop()) + while (runTime.run()) { + #include "readPIMPLEControls.H" + #include "readTimeControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" + + runTime++; + Info<< "Time = " << runTime.timeName() << nl << endl; -# include "readPISOControls.H" -# include "CourantNo.H" - - twoPhaseProperties.correct(); - -# include "alphaEqn.H" - -# include "UEqn.H" - - // --- PISO loop - for (int corr=0; corrcorrect(); } -# include "continuityErrs.H" - - p = pd + rho*gh; - - if (pd.needReference()) - { - p += dimensionedScalar - ( - "p", - p.dimensions(), - pRefValue - getRefCellValue(p, pdRefCell) - ); - } - - turbulence->correct(); - runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" diff --git a/applications/test/directMappedPatch/Make/files b/applications/test/directMappedPatch/Make/files new file mode 100644 index 0000000000..65f39a47b8 --- /dev/null +++ b/applications/test/directMappedPatch/Make/files @@ -0,0 +1,4 @@ + +testDirectMappedPatch.C + +EXE = $(FOAM_USER_APPBIN)/testDirectMappedPatch diff --git a/applications/test/directMappedPatch/Make/options b/applications/test/directMappedPatch/Make/options new file mode 100644 index 0000000000..d76bd10c8f --- /dev/null +++ b/applications/test/directMappedPatch/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume diff --git a/applications/test/directMappedPatch/testDirectMappedPatch.C b/applications/test/directMappedPatch/testDirectMappedPatch.C new file mode 100644 index 0000000000..dd27ff6955 --- /dev/null +++ b/applications/test/directMappedPatch/testDirectMappedPatch.C @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + +Application + testDirectMappedPatch + +Description + Test direct mapped b.c. by mapping face centres (mesh.C().boundaryField()). + +\*---------------------------------------------------------------------------*/ + + +#include "argList.H" +#include "fvMesh.H" +#include "volFields.H" +#include "meshTools.H" +#include "Time.H" +#include "OFstream.H" +#include "volFields.H" +#include "directMappedFixedValueFvPatchFields.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +// Main program: + +int main(int argc, char *argv[]) +{ +# include "addTimeOptions.H" +# include "setRootCase.H" +# include "createTime.H" +# include "createMesh.H" + + wordList patchFieldTypes + ( + mesh.boundaryMesh().size(), + calculatedFvPatchVectorField::typeName + ); + + forAll(mesh.boundaryMesh(), patchI) + { + if (isA(mesh.boundaryMesh()[patchI])) + { + patchFieldTypes[patchI] = + directMappedFixedValueFvPatchVectorField::typeName; + } + } + + Pout<< "patchFieldTypes:" << patchFieldTypes << endl; + + volVectorField cc + ( + IOobject + ( + "cc", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedVector("zero", dimLength, vector::zero), + patchFieldTypes + ); + + cc.internalField() = mesh.C().internalField(); + cc.boundaryField().updateCoeffs(); + + forAll(cc.boundaryField(), patchI) + { + if + ( + isA + ( + cc.boundaryField()[patchI] + ) + ) + { + Pout<< "Detected a directMapped patch:" << patchI << endl; + + OFstream str(mesh.boundaryMesh()[patchI].name() + ".obj"); + Pout<< "Writing mapped values to " << str.name() << endl; + + label vertI = 0; + const fvPatchVectorField& fvp = cc.boundaryField()[patchI]; + + forAll(fvp, i) + { + meshTools::writeOBJ(str, fvp.patch().Cf()[i]); + vertI++; + meshTools::writeOBJ(str, fvp[i]); + vertI++; + str << "l " << vertI-1 << ' ' << vertI << nl; + } + } + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/extendedStencil/Make/files b/applications/test/extendedStencil/Make/files new file mode 100644 index 0000000000..236668cde8 --- /dev/null +++ b/applications/test/extendedStencil/Make/files @@ -0,0 +1,4 @@ + +testExtendedStencil.C + +EXE = $(FOAM_USER_APPBIN)/testExtendedStencil diff --git a/applications/test/extendedStencil/Make/options b/applications/test/extendedStencil/Make/options new file mode 100644 index 0000000000..b733f6ac04 --- /dev/null +++ b/applications/test/extendedStencil/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfiniteVolume diff --git a/applications/test/extendedStencil/testExtendedStencil.C b/applications/test/extendedStencil/testExtendedStencil.C new file mode 100644 index 0000000000..b8db2b89bf --- /dev/null +++ b/applications/test/extendedStencil/testExtendedStencil.C @@ -0,0 +1,499 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + +Application + testExtendedStencil + +Description + Test app for determining extended stencil. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "fvMesh.H" +#include "volFields.H" +#include "Time.H" +#include "mapDistribute.H" +#include "OFstream.H" +#include "meshTools.H" +//#include "FECCellToFaceStencil.H" +//#include "CFCCellToFaceStencil.H" +//#include "CPCCellToFaceStencil.H" +//#include "CECCellToFaceStencil.H" +//#include "extendedCentredCellToFaceStencil.H" +//#include "extendedUpwindCellToFaceStencil.H" + +//#include "centredCFCCellToFaceStencilObject.H" +//#include "centredFECCellToFaceStencilObject.H" +//#include "centredCPCCellToFaceStencilObject.H" +//#include "centredCECCellToFaceStencilObject.H" + +//#include "upwindFECCellToFaceStencilObject.H" +//#include "upwindCPCCellToFaceStencilObject.H" +//#include "upwindCECCellToFaceStencilObject.H" + +//#include "upwindCFCCellToFaceStencilObject.H" +#include "centredCFCFaceToCellStencilObject.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void writeStencilOBJ +( + const fileName& fName, + const point& fc, + const List& stencilCc +) +{ + OFstream str(fName); + label vertI = 0; + + meshTools::writeOBJ(str, fc); + vertI++; + + forAll(stencilCc, i) + { + meshTools::writeOBJ(str, stencilCc[i]); + vertI++; + str << "l 1 " << vertI << nl; + } +} + + +// Stats +void writeStencilStats(const labelListList& stencil) +{ + label sumSize = 0; + label nSum = 0; + label minSize = labelMax; + label maxSize = labelMin; + + forAll(stencil, i) + { + const labelList& sCells = stencil[i]; + + if (sCells.size() > 0) + { + sumSize += sCells.size(); + nSum++; + minSize = min(minSize, sCells.size()); + maxSize = max(maxSize, sCells.size()); + } + } + reduce(sumSize, sumOp