diff --git a/applications/solvers/combustion/PDRFoam/UEqn.H b/applications/solvers/combustion/PDRFoam/UEqn.H index 70912c7cfa..79d81663c4 100644 --- a/applications/solvers/combustion/PDRFoam/UEqn.H +++ b/applications/solvers/combustion/PDRFoam/UEqn.H @@ -13,4 +13,5 @@ { U = invA & (UEqn.H() - betav*fvc::grad(p)); U.correctBoundaryConditions(); + K = 0.5*magSqr(U); } diff --git a/applications/solvers/combustion/PDRFoam/createFields.H b/applications/solvers/combustion/PDRFoam/createFields.H index 15a0ecafea..2d8451c9ae 100644 --- a/applications/solvers/combustion/PDRFoam/createFields.H +++ b/applications/solvers/combustion/PDRFoam/createFields.H @@ -44,7 +44,7 @@ mesh ); -# include "compressibleCreatePhi.H" + #include "compressibleCreatePhi.H" Info<< "Creating turbulence model\n" << endl; autoPtr turbulence @@ -58,12 +58,12 @@ ) ); - Info<< "Creating field DpDt\n" << endl; - volScalarField DpDt - ( - "DpDt", - fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) - ); + + Info<< "Creating field dpdt\n" << endl; + volScalarField dpdt("dpdt", fvc::ddt(p)); + + Info<< "Creating field kinetic energy K\n" << endl; + volScalarField K("K", 0.5*magSqr(U)); Info<< "Creating the unstrained laminar flame speed\n" << endl; diff --git a/applications/solvers/combustion/PDRFoam/hEqn.H b/applications/solvers/combustion/PDRFoam/hEqn.H index 7f5292d01a..4d8bb54588 100644 --- a/applications/solvers/combustion/PDRFoam/hEqn.H +++ b/applications/solvers/combustion/PDRFoam/hEqn.H @@ -5,7 +5,8 @@ + mvConvection->fvmDiv(phi, h) - fvm::laplacian(Db, h) == - betav*DpDt + betav*dpdt + - betav*(fvc::ddt(rho, K) + fvc::div(phi, K)) ); thermo.correct(); diff --git a/applications/solvers/combustion/PDRFoam/huEqn.H b/applications/solvers/combustion/PDRFoam/huEqn.H index 3467bc6b75..f0fa7be5ea 100644 --- a/applications/solvers/combustion/PDRFoam/huEqn.H +++ b/applications/solvers/combustion/PDRFoam/huEqn.H @@ -13,6 +13,6 @@ if (ign.ignited()) //+ fvm::Sp(fvc::div(muEff*fvc::grad(b)/(b + 0.001)), hu) == - betav*DpDt*rho/thermo.rhou() + betav*(dpdt - (fvc::ddt(rho, K) + fvc::div(phi, K)))*rho/thermo.rhou() ); } diff --git a/applications/solvers/combustion/PDRFoam/pEqn.H b/applications/solvers/combustion/PDRFoam/pEqn.H index e2a2a471e2..45f982ba4d 100644 --- a/applications/solvers/combustion/PDRFoam/pEqn.H +++ b/applications/solvers/combustion/PDRFoam/pEqn.H @@ -64,5 +64,6 @@ else U -= invA & (betav*fvc::grad(p)); U.correctBoundaryConditions(); +K = 0.5*magSqr(U); -DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); +dpdt = fvc::ddt(p); diff --git a/applications/solvers/combustion/XiFoam/UEqn.H b/applications/solvers/combustion/XiFoam/UEqn.H index 1e626d75b8..b9bc567aae 100644 --- a/applications/solvers/combustion/XiFoam/UEqn.H +++ b/applications/solvers/combustion/XiFoam/UEqn.H @@ -12,4 +12,5 @@ if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); + K = 0.5*magSqr(U); } diff --git a/applications/solvers/combustion/XiFoam/createFields.H b/applications/solvers/combustion/XiFoam/createFields.H index 7a7e796b62..1750c693e5 100644 --- a/applications/solvers/combustion/XiFoam/createFields.H +++ b/applications/solvers/combustion/XiFoam/createFields.H @@ -60,12 +60,11 @@ ) ); - Info<< "Creating field DpDt\n" << endl; - volScalarField DpDt - ( - fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) - ); + Info<< "Creating field dpdt\n" << endl; + volScalarField dpdt("dpdt", fvc::ddt(p)); + Info<< "Creating field kinetic energy K\n" << endl; + volScalarField K("K", 0.5*magSqr(U)); Info<< "Creating field Xi\n" << endl; volScalarField Xi diff --git a/applications/solvers/combustion/XiFoam/hEqn.H b/applications/solvers/combustion/XiFoam/hEqn.H index 513ae60441..f562466b20 100644 --- a/applications/solvers/combustion/XiFoam/hEqn.H +++ b/applications/solvers/combustion/XiFoam/hEqn.H @@ -5,7 +5,8 @@ + mvConvection->fvmDiv(phi, h) - fvm::laplacian(turbulence->alphaEff(), h) == - DpDt + dpdt + - (fvc::ddt(rho, K) + fvc::div(phi, K)) ); hEqn.relax(); diff --git a/applications/solvers/combustion/XiFoam/huEqn.H b/applications/solvers/combustion/XiFoam/huEqn.H index 0b4068344b..3059b9445e 100644 --- a/applications/solvers/combustion/XiFoam/huEqn.H +++ b/applications/solvers/combustion/XiFoam/huEqn.H @@ -12,7 +12,7 @@ if (ign.ignited()) //- fvm::div(muEff*fvc::grad(b)/(b + 0.001), hu) //+ fvm::Sp(fvc::div(muEff*fvc::grad(b)/(b + 0.001)), hu) - == - DpDt*rho/thermo.rhou() + == + (dpdt - (fvc::ddt(rho, K) + fvc::div(phi, K)))*rho/thermo.rhou() ); } diff --git a/applications/solvers/combustion/XiFoam/pEqn.H b/applications/solvers/combustion/XiFoam/pEqn.H index 784e9ca6b7..cb25e7029f 100644 --- a/applications/solvers/combustion/XiFoam/pEqn.H +++ b/applications/solvers/combustion/XiFoam/pEqn.H @@ -64,5 +64,6 @@ else U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); +K = 0.5*magSqr(U); -DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); +dpdt = fvc::ddt(p); diff --git a/applications/solvers/combustion/coldEngineFoam/createFields.H b/applications/solvers/combustion/coldEngineFoam/createFields.H index 9705f04525..6286b1a555 100644 --- a/applications/solvers/combustion/coldEngineFoam/createFields.H +++ b/applications/solvers/combustion/coldEngineFoam/createFields.H @@ -54,8 +54,8 @@ ) ); - Info<< "Creating field DpDt\n" << endl; - volScalarField DpDt - ( - fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) - ); + Info<< "Creating field dpdt\n" << endl; + volScalarField dpdt("dpdt", fvc::ddt(p)); + + Info<< "Creating field kinetic energy K\n" << endl; + volScalarField K("K", 0.5*magSqr(U)); diff --git a/applications/solvers/combustion/coldEngineFoam/hEqn.H b/applications/solvers/combustion/coldEngineFoam/hEqn.H index ae60d3316e..2e1a2703a8 100644 --- a/applications/solvers/combustion/coldEngineFoam/hEqn.H +++ b/applications/solvers/combustion/coldEngineFoam/hEqn.H @@ -5,7 +5,7 @@ + fvm::div(phi, h) - fvm::laplacian(turbulence->alphaEff(), h) == - DpDt + - fvc::div(phi, 0.5*magSqr(U)) ); thermo.correct(); diff --git a/applications/solvers/combustion/engineFoam/UEqn.H b/applications/solvers/combustion/engineFoam/UEqn.H index eff9e1a5d2..f110051946 100644 --- a/applications/solvers/combustion/engineFoam/UEqn.H +++ b/applications/solvers/combustion/engineFoam/UEqn.H @@ -8,4 +8,5 @@ if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); + K = 0.5*magSqr(U); } diff --git a/applications/solvers/combustion/engineFoam/pEqn.H b/applications/solvers/combustion/engineFoam/pEqn.H index 580be2da56..d1b7135649 100644 --- a/applications/solvers/combustion/engineFoam/pEqn.H +++ b/applications/solvers/combustion/engineFoam/pEqn.H @@ -57,5 +57,6 @@ else U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); +K = 0.5*magSqr(U); -DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); +dpdt = fvc::ddt(p); diff --git a/applications/solvers/combustion/fireFoam/UEqn.H b/applications/solvers/combustion/fireFoam/UEqn.H index a64e50a2d2..31d01e4327 100644 --- a/applications/solvers/combustion/fireFoam/UEqn.H +++ b/applications/solvers/combustion/fireFoam/UEqn.H @@ -23,4 +23,6 @@ )*mesh.magSf() ) ); + + K = 0.5*magSqr(U); } diff --git a/applications/solvers/combustion/fireFoam/YhsEqn.H b/applications/solvers/combustion/fireFoam/YhsEqn.H index 299eb64ab7..b85396caa1 100644 --- a/applications/solvers/combustion/fireFoam/YhsEqn.H +++ b/applications/solvers/combustion/fireFoam/YhsEqn.H @@ -53,7 +53,8 @@ tmp > mvConvection + mvConvection->fvmDiv(phi, hs) - fvm::laplacian(turbulence->alphaEff(), hs) == - DpDt + dpdt + - (fvc::ddt(rho, K) + fvc::div(phi, K)) + combustion->Sh() + radiation->Shs(thermo) + parcels.Sh(hs) diff --git a/applications/solvers/combustion/fireFoam/createFields.H b/applications/solvers/combustion/fireFoam/createFields.H index afabd393c7..e0c11335e3 100644 --- a/applications/solvers/combustion/fireFoam/createFields.H +++ b/applications/solvers/combustion/fireFoam/createFields.H @@ -83,12 +83,12 @@ dimensionedScalar("dQ", dimEnergy/dimTime, 0.0) ); - Info<< "Creating field DpDt\n" << endl; - volScalarField DpDt - ( - "DpDt", - fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) - ); + + Info<< "Creating field dpdt\n" << endl; + volScalarField dpdt("dpdt", fvc::ddt(p)); + + Info<< "Creating field kinetic energy K\n" << endl; + volScalarField K("K", 0.5*magSqr(U)); Info<< "Calculating field g.h\n" << endl; diff --git a/applications/solvers/combustion/fireFoam/pEqn.H b/applications/solvers/combustion/fireFoam/pEqn.H index 65259391da..872a0513a3 100644 --- a/applications/solvers/combustion/fireFoam/pEqn.H +++ b/applications/solvers/combustion/fireFoam/pEqn.H @@ -43,5 +43,6 @@ p = p_rgh + rho*gh; U += rAU*fvc::reconstruct((phi - phiU)/rhorAUf); U.correctBoundaryConditions(); +K = 0.5*magSqr(U); -DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); +dpdt = fvc::ddt(p); diff --git a/applications/solvers/combustion/reactingFoam/UEqn.H b/applications/solvers/combustion/reactingFoam/UEqn.H index 1e626d75b8..b9bc567aae 100644 --- a/applications/solvers/combustion/reactingFoam/UEqn.H +++ b/applications/solvers/combustion/reactingFoam/UEqn.H @@ -12,4 +12,5 @@ if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); + K = 0.5*magSqr(U); } diff --git a/applications/solvers/combustion/reactingFoam/createFields.H b/applications/solvers/combustion/reactingFoam/createFields.H index 7cf94f754d..0b6e9ee2e1 100644 --- a/applications/solvers/combustion/reactingFoam/createFields.H +++ b/applications/solvers/combustion/reactingFoam/createFields.H @@ -65,11 +65,13 @@ autoPtr turbulence // Set the turbulence into the combustion model combustion->setTurbulence(turbulence()); -Info<< "Creating field DpDt\n" << endl; -volScalarField DpDt -( - fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) -); + +Info<< "Creating field dpdt\n" << endl; +volScalarField dpdt("dpdt", fvc::ddt(p)); + +Info<< "Creating field kinetic energy K\n" << endl; +volScalarField K("K", 0.5*magSqr(U)); + multivariateSurfaceInterpolationScheme::fieldTable fields; diff --git a/applications/solvers/combustion/reactingFoam/hsEqn.H b/applications/solvers/combustion/reactingFoam/hsEqn.H index de1a85fddf..642b7091bc 100644 --- a/applications/solvers/combustion/reactingFoam/hsEqn.H +++ b/applications/solvers/combustion/reactingFoam/hsEqn.H @@ -6,7 +6,8 @@ - fvm::laplacian(turbulence->alphaEff(), hs) // - fvm::laplacian(turbulence->muEff(), hs) // unit lewis no. == - DpDt + dpdt + - (fvc::ddt(rho, K) + fvc::div(phi, K)) + combustion->Sh() ); diff --git a/applications/solvers/combustion/reactingFoam/pEqn.H b/applications/solvers/combustion/reactingFoam/pEqn.H index 784e9ca6b7..cb25e7029f 100644 --- a/applications/solvers/combustion/reactingFoam/pEqn.H +++ b/applications/solvers/combustion/reactingFoam/pEqn.H @@ -64,5 +64,6 @@ else U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); +K = 0.5*magSqr(U); -DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); +dpdt = fvc::ddt(p); diff --git a/applications/solvers/combustion/rhoReactingFoam/UEqn.H b/applications/solvers/combustion/rhoReactingFoam/UEqn.H index 1e626d75b8..b9bc567aae 100644 --- a/applications/solvers/combustion/rhoReactingFoam/UEqn.H +++ b/applications/solvers/combustion/rhoReactingFoam/UEqn.H @@ -12,4 +12,5 @@ if (pimple.momentumPredictor()) { solve(UEqn == -fvc::grad(p)); + K = 0.5*magSqr(U); } diff --git a/applications/solvers/combustion/rhoReactingFoam/createFields.H b/applications/solvers/combustion/rhoReactingFoam/createFields.H index 65860a67eb..690cdc4b60 100644 --- a/applications/solvers/combustion/rhoReactingFoam/createFields.H +++ b/applications/solvers/combustion/rhoReactingFoam/createFields.H @@ -67,11 +67,13 @@ autoPtr turbulence // Set the turbulence into the combustion model combustion->setTurbulence(turbulence()); -Info<< "Creating field DpDt\n" << endl; -volScalarField DpDt -( - fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p) -); + +Info<< "Creating field dpdt\n" << endl; +volScalarField dpdt("dpdt", fvc::ddt(p)); + +Info<< "Creating field kinetic energy K\n" << endl; +volScalarField K("K", 0.5*magSqr(U)); + multivariateSurfaceInterpolationScheme::fieldTable fields; diff --git a/applications/solvers/combustion/rhoReactingFoam/hsEqn.H b/applications/solvers/combustion/rhoReactingFoam/hsEqn.H index 01f85ac1da..ba95be8452 100644 --- a/applications/solvers/combustion/rhoReactingFoam/hsEqn.H +++ b/applications/solvers/combustion/rhoReactingFoam/hsEqn.H @@ -6,7 +6,8 @@ - fvm::laplacian(turbulence->alphaEff(), hs) // - fvm::laplacian(turbulence->muEff(), hs) // unit lewis no. == - DpDt + dpdt + - (fvc::ddt(rho, K) + fvc::div(phi, K)) + combustion->Sh() ); diff --git a/applications/solvers/combustion/rhoReactingFoam/pEqn.H b/applications/solvers/combustion/rhoReactingFoam/pEqn.H index b22fc89079..4e94de243c 100644 --- a/applications/solvers/combustion/rhoReactingFoam/pEqn.H +++ b/applications/solvers/combustion/rhoReactingFoam/pEqn.H @@ -86,6 +86,7 @@ U -= rAU*fvc::grad(p); U.correctBoundaryConditions(); + K = 0.5*magSqr(U); - DpDt = fvc::DDt(surfaceScalarField("phiU", phi/fvc::interpolate(rho)), p); + dpdt = fvc::ddt(p); } diff --git a/applications/solvers/compressible/rhoSimpleFoam/hEqn.H b/applications/solvers/compressible/rhoSimpleFoam/hEqn.H index e6c74938ee..8ff402a2b1 100644 --- a/applications/solvers/compressible/rhoSimpleFoam/hEqn.H +++ b/applications/solvers/compressible/rhoSimpleFoam/hEqn.H @@ -5,8 +5,7 @@ - fvm::Sp(fvc::div(phi), h) - fvm::laplacian(turbulence->alphaEff(), h) == - fvc::div(phi/fvc::interpolate(rho), rho/psi, "div(U,p)") - - (rho/psi)*fvc::div(phi/fvc::interpolate(rho)) + - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)") ); hEqn.relax(); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H index 6e607f89e8..24ed135c08 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/hEqn.H @@ -5,8 +5,7 @@ - fvm::Sp(fvc::div(phi), h) - fvm::laplacian(turbulence->alphaEff(), h) == - fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p)) - - p*fvc::div(phi/fvc::interpolate(rho)) + - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)") ); hEqn.relax(); diff --git a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H index 57de44e4a0..2c422a5cab 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleRadiationFoam/hEqn.H @@ -5,8 +5,7 @@ - fvm::Sp(fvc::div(phi), h) - fvm::laplacian(turbulence->alphaEff(), h) == - fvc::div(phi/fvc::interpolate(rho)*fvc::interpolate(p)) - - p*fvc::div(phi/fvc::interpolate(rho)) + - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)") + radiation->Sh(thermo) ); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options index c896f86d16..2fcfff4126 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/Make/options @@ -8,9 +8,7 @@ EXE_INC = \ -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ -I$(LIB_SRC)/thermophysicalModels/basicSolidThermo/lnInclude \ -I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel/lnInclude \ - -I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude \ - -I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \ - -I$(LIB_SRC)/parallel/reconstruct/reconstruct/lnInclude + -I$(LIB_SRC)/thermophysicalModels/radiationModels/lnInclude EXE_LIBS = \ -lbasicThermophysicalModels \ @@ -21,6 +19,4 @@ EXE_LIBS = \ -lcompressibleLESModels \ -lmeshTools \ -lfiniteVolume \ - -lradiationModels \ - -ldecompose \ - -lreconstruct + -lradiationModels diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/allhEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/allhEqn.H deleted file mode 100644 index cfe2e84a0f..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/allhEqn.H +++ /dev/null @@ -1,84 +0,0 @@ - -// Get mapped alpha (surfaceScalarField) -tmp tallAlpha = procToAllMapper().reconstructFvSurfaceField - ( - IOobject - ( - "alpha", - allMesh().time().timeName(), - allMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - procAlpha - ); - -// Get alpha from harmonic interpolation of vol quantities -// (Note: really only needed at internal faces originating patches -// inbetween regions) -tmp allHarmonicAlpha -( - harmonic(allMesh()).interpolate(allVolAlpha()) -); - -// Loop over all fluid and solid regions to transfer -// allHarmonicAlpha to allAlpha -surfaceScalarField& allAlpha = tallAlpha(); -forAll(boundaryProcAddressing, procI) -{ - forAll(boundaryProcAddressing[procI], patchI) - { - if (boundaryProcAddressing[procI][patchI] == -1) - { - // Interface patch - const labelList::subList cp = - procMeshes[procI].boundary()[patchI].patchSlice - ( - faceProcAddressing[procI] - ); - - forAll(cp, faceI) - { - label curF = mag(cp[faceI])-1; - if (curF < allMesh().nInternalFaces()) - { - allAlpha[curF] = allHarmonicAlpha()[curF]; - } - } - } - } -} - - -tmp allPhi -( - procToAllMapper().reconstructFvSurfaceField - ( - IOobject - ( - "phi", - allMesh().time().timeName(), - allMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - procPhi - ) -); - -// So we have nNonOrthCorr -//#include "readSolidMultiRegionPIMPLEControls.H" -//for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) -{ - fvScalarMatrix hEqn - ( - fvm::ddt(allRho(), allh()) - + fvm::div(allPhi(), allh()) - - fvm::laplacian(allAlpha, allh()) - == - allSource() - ); - - hEqn.relax(); - hEqn.solve(allMesh().solver(allh().select(finalIter))); -} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C index 927562c144..b65ecf5118 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C @@ -39,11 +39,6 @@ Description #include "solidRegionDiffNo.H" #include "basicSolidThermo.H" #include "radiationModel.H" -#include "fvFieldReconstructor.H" -#include "mixedFvPatchFields.H" -#include "fvFieldDecomposer.H" -#include "harmonic.H" -#include "rmap.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -54,40 +49,12 @@ int main(int argc, char *argv[]) regionProperties rp(runTime); - const label nAllRegions = - rp.fluidRegionNames().size() - + rp.solidRegionNames().size(); - PtrList cellProcAddressing(nAllRegions); - PtrList faceProcAddressing(nAllRegions); - PtrList boundaryProcAddressing(nAllRegions); - PtrList procMeshes(nAllRegions); - - // Load meshes, fluid first - labelList fluidToProc(identity(rp.fluidRegionNames().size())); - labelList solidToProc(rp.solidRegionNames().size()); - forAll(solidToProc, i) - { - solidToProc[i] = fluidToProc.size()+i; - } - - // Get the coupled solution flag - #include "readPIMPLEControls.H" - - if (temperatureCoupled) - { - Info<< "Solving single enthalpy for all equations" << nl << endl; - } - #include "createFluidMeshes.H" #include "createSolidMeshes.H" #include "createFluidFields.H" #include "createSolidFields.H" - // Temperature solved on single mesh - #include "createAllMesh.H" - #include "createAllFields.H" - #include "initContinuityErrs.H" #include "readTimeControls.H" @@ -114,10 +81,9 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - if (nOuterCorr != 1) { - forAll(fluidToProc, i) + forAll(fluidRegions, i) { #include "setRegionFluidFields.H" #include "storeOldFluidFields.H" @@ -130,133 +96,22 @@ int main(int argc, char *argv[]) { bool finalIter = oCorr == nOuterCorr-1; - if (finalIter) + forAll(fluidRegions, i) { - forAll(procMeshes, procI) - { - procMeshes[procI].data::add("finalIteration", true); - } - } - - - PtrList procPhi(nAllRegions); - PtrList procAlpha(nAllRegions); - - - // Solve (uncoupled) or set up (coupled) the temperature equation - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - forAll(solidToProc, i) - { - label procI = solidToProc[i]; - - Info<< "\nSolving temperature for solid region " - << procMeshes[procI].name() << endl; - #include "setRegionSolidFields.H" - #include "readSolidMultiRegionPIMPLEControls.H" - - if (temperatureCoupled) - { - // Map my properties to overall h equation - #include "rmapSolid.H" - } - else - { - #include "solveSolid.H" - } - } - - - forAll(fluidToProc, i) - { - label procI = fluidToProc[i]; - - Info<< "\nSolving temperature for fluid region " - << procMeshes[procI].name() << endl; + Info<< "\nSolving for fluid region " + << fluidRegions[i].name() << endl; #include "setRegionFluidFields.H" #include "readFluidMultiRegionPIMPLEControls.H" - - if (oCorr == 0) - { - #include "rhoEqn.H" - } - - if (temperatureCoupled) - { - // Map my properties to overall h equation - #include "rmapFluid.H" - } - else - { - #include "hEqn.H" - } + #include "solveFluid.H" } - - // Solve combined h equation - // ~~~~~~~~~~~~~~~~~~~~~~~~~ - - if (temperatureCoupled) + forAll(solidRegions, i) { - Info<< "\nSolving single enthalpy for all regions" - << endl; - - // Solve combined h - #include "allhEqn.H" - - forAll(solidToProc, i) - { - label procI = solidToProc[i]; - #include "setRegionSolidFields.H" - #include "readSolidMultiRegionPIMPLEControls.H" - - #include "mapSolid.H" - } - - forAll(fluidToProc, i) - { - label procI = fluidToProc[i]; - #include "setRegionFluidFields.H" - #include "readFluidMultiRegionPIMPLEControls.H" - - #include "mapFluid.H" - } - } - - - // Update thermos - // ~~~~~~~~~~~~~~ - - forAll(fluidToProc, i) - { - Info<< "\nUpdating thermo for fluid region " - << procMeshes[fluidToProc[i]].name() << endl; - - #include "setRegionFluidFields.H" - #include "readFluidMultiRegionPIMPLEControls.H" - - thermo.correct(); - rad.correct(); - #include "solvePressureVelocityFluid.H" - } - - forAll(solidToProc, i) - { - Info<< "\nUpdating thermo for solid region " - << procMeshes[solidToProc[i]].name() << endl; + Info<< "\nSolving for solid region " + << solidRegions[i].name() << endl; #include "setRegionSolidFields.H" #include "readSolidMultiRegionPIMPLEControls.H" - - thermo.correct(); - } - - - if (finalIter) - { - forAll(procMeshes, procI) - { - procMeshes[procI].data::remove("finalIteration"); - } + #include "solveSolid.H" } } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H index 03b2580425..4505f77ed0 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/hEqn.H @@ -5,8 +5,7 @@ - fvm::Sp(fvc::div(phi), h) - fvm::laplacian(turb.alphaEff(), h) == - fvc::div(phi/fvc::interpolate(rho), p, "div(U,p)") - - p*fvc::div(phi/fvc::interpolate(rho)) + - fvc::div(phi, 0.5*magSqr(U), "div(phi,K)") + rad.Sh(thermo) ); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/createAllFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/createAllFields.H deleted file mode 100644 index faa8eaac58..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/createAllFields.H +++ /dev/null @@ -1,64 +0,0 @@ - autoPtr allRho; - autoPtr allh; - autoPtr allVolAlpha; - autoPtr allSource; - - if (temperatureCoupled) - { - allRho.reset - ( - new volScalarField - ( - IOobject - ( - "rho", - runTime.timeName(), - allMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - allMesh(), - dimensionedScalar("rho", dimDensity, 0.0) - ) - ); - - allh.reset - ( - new volScalarField - ( - IOobject - ( - "h", - runTime.timeName(), - allMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - allMesh(), - dimensionedScalar("h", dimEnergy/dimMass, 0.0), - mixedFvPatchScalarField::typeName - ) - ); - - allVolAlpha.reset - ( - new volScalarField - ( - IOobject - ( - "volAlpha", - runTime.timeName(), - allMesh(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - allMesh(), - dimensionedScalar("volAlpha", dimMass/dimLength/dimTime, 0.0) - ) - ); - - allSource.reset - ( - new fvMatrix(allh(), allh().dimensions()*dimMass/dimTime) - ); - } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/createAllMesh.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/createAllMesh.H deleted file mode 100644 index 8bff40e48a..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/createAllMesh.H +++ /dev/null @@ -1,63 +0,0 @@ -// -// createAllMesh.H -// ~~~~~~~~~~~~~~~ - - autoPtr allMesh; - autoPtr procToAllMapper; - PtrList allToProcMappers; - - if (temperatureCoupled) - { - Foam::Info - << "Create mesh for time = " - << runTime.timeName() << Foam::nl << Foam::endl; - - allMesh.reset - ( - new Foam::fvMesh - ( - Foam::IOobject - ( - Foam::fvMesh::defaultRegion, - runTime.timeName(), - runTime, - Foam::IOobject::MUST_READ - ) - ) - ); - - procToAllMapper.reset - ( - new fvFieldReconstructor - ( - allMesh(), - procMeshes, - faceProcAddressing, - cellProcAddressing, - boundaryProcAddressing - ) - ); - - - allToProcMappers.setSize - ( - rp.fluidRegionNames().size() - + rp.solidRegionNames().size() - ); - - forAll(allToProcMappers, i) - { - allToProcMappers.set - ( - i, - new fvFieldDecomposer - ( - allMesh(), - procMeshes[i], - faceProcAddressing[i], - cellProcAddressing[i], - boundaryProcAddressing[i] - ) - ); - } - } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H index 61b7b10340..b5db5078f1 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/compressibleMultiRegionCourantNo.H @@ -1,12 +1,12 @@ scalar CoNum = -GREAT; - forAll(fluidToProc, regionI) + forAll(fluidRegions, regionI) { CoNum = max ( compressibleCourantNo ( - procMeshes[fluidToProc[regionI]], + fluidRegions[regionI], runTime, rhoFluid[regionI], phiFluid[regionI] diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index 667b39d646..f6788d26eb 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -1,36 +1,30 @@ // Initialise fluid field pointer lists - PtrList thermoFluid(rp.fluidRegionNames().size()); - PtrList rhoFluid(rp.fluidRegionNames().size()); - PtrList KFluid(rp.fluidRegionNames().size()); - PtrList UFluid(rp.fluidRegionNames().size()); - PtrList phiFluid(rp.fluidRegionNames().size()); - PtrList gFluid(rp.fluidRegionNames().size()); - PtrList turbulence - ( - rp.fluidRegionNames().size() - ); - PtrList p_rghFluid(rp.fluidRegionNames().size()); - PtrList ghFluid(rp.fluidRegionNames().size()); - PtrList ghfFluid(rp.fluidRegionNames().size()); - PtrList radiation(rp.fluidRegionNames().size()); - PtrList DpDtFluid(rp.fluidRegionNames().size()); + PtrList thermoFluid(fluidRegions.size()); + PtrList rhoFluid(fluidRegions.size()); + PtrList KFluid(fluidRegions.size()); + PtrList UFluid(fluidRegions.size()); + PtrList phiFluid(fluidRegions.size()); + PtrList gFluid(fluidRegions.size()); + PtrList turbulence(fluidRegions.size()); + PtrList p_rghFluid(fluidRegions.size()); + PtrList ghFluid(fluidRegions.size()); + PtrList ghfFluid(fluidRegions.size()); + PtrList radiation(fluidRegions.size()); + PtrList DpDtFluid(fluidRegions.size()); - List initialMassFluid(rp.fluidRegionNames().size()); + List initialMassFluid(fluidRegions.size()); // Populate fluid field pointer lists - forAll(rp.fluidRegionNames(), i) + forAll(fluidRegions, i) { Info<< "*** Reading fluid mesh thermophysical properties for region " - << rp.fluidRegionNames()[i] << nl << endl; - - label procI = fluidToProc[i]; - + << fluidRegions[i].name() << nl << endl; Info<< " Adding to thermoFluid\n" << endl; thermoFluid.set ( i, - basicRhoThermo::New(procMeshes[procI]).ptr() + basicRhoThermo::New(fluidRegions[i]).ptr() ); Info<< " Adding to rhoFluid\n" << endl; @@ -43,7 +37,7 @@ ( "rho", runTime.timeName(), - procMeshes[procI], + fluidRegions[i], IOobject::NO_READ, IOobject::AUTO_WRITE ), @@ -61,7 +55,7 @@ ( "K", runTime.timeName(), - procMeshes[procI], + fluidRegions[i], IOobject::NO_READ, IOobject::NO_WRITE ), @@ -79,11 +73,11 @@ ( "U", runTime.timeName(), - procMeshes[procI], + fluidRegions[i], IOobject::MUST_READ, IOobject::AUTO_WRITE ), - procMeshes[procI] + fluidRegions[i] ) ); @@ -97,12 +91,12 @@ ( "phi", runTime.timeName(), - procMeshes[procI], + fluidRegions[i], IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), linearInterpolate(rhoFluid[i]*UFluid[i]) - & procMeshes[procI].Sf() + & fluidRegions[i].Sf() ) ); @@ -116,7 +110,7 @@ ( "g", runTime.constant(), - procMeshes[procI], + fluidRegions[i], IOobject::MUST_READ, IOobject::NO_WRITE ) @@ -143,14 +137,14 @@ ghFluid.set ( i, - new volScalarField("gh", gFluid[i] & procMeshes[procI].C()) + new volScalarField("gh", gFluid[i] & fluidRegions[i].C()) ); Info<< " Adding to ghfFluid\n" << endl; ghfFluid.set ( i, - new surfaceScalarField("ghf", gFluid[i] & procMeshes[procI].Cf()) + new surfaceScalarField("ghf", gFluid[i] & fluidRegions[i].Cf()) ); p_rghFluid.set @@ -162,11 +156,11 @@ ( "p_rgh", runTime.timeName(), - procMeshes[procI], + fluidRegions[i], IOobject::MUST_READ, IOobject::AUTO_WRITE ), - procMeshes[procI] + fluidRegions[i] ) ); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidMeshes.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidMeshes.H index 73b533b0d9..30a2e1089f 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidMeshes.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidMeshes.H @@ -1,13 +1,13 @@ + PtrList fluidRegions(rp.fluidRegionNames().size()); + forAll(rp.fluidRegionNames(), i) { Info<< "Create fluid mesh for region " << rp.fluidRegionNames()[i] << " for time = " << runTime.timeName() << nl << endl; - label procI = fluidToProc[i]; - - procMeshes.set + fluidRegions.set ( - procI, + i, new fvMesh ( IOobject @@ -19,58 +19,4 @@ ) ) ); - - if (temperatureCoupled) - { - cellProcAddressing.set - ( - procI, - new labelIOList - ( - IOobject - ( - "cellRegionAddressing", - procMeshes[procI].facesInstance(), - procMeshes[procI].meshSubDir, - procMeshes[procI], - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) - ); - - faceProcAddressing.set - ( - procI, - new labelIOList - ( - IOobject - ( - "faceRegionAddressing", - procMeshes[procI].facesInstance(), - procMeshes[procI].meshSubDir, - procMeshes[procI], - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) - ); - - boundaryProcAddressing.set - ( - procI, - new labelIOList - ( - IOobject - ( - "boundaryRegionAddressing", - procMeshes[procI].facesInstance(), - procMeshes[procI].meshSubDir, - procMeshes[procI], - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) - ); - } } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/initContinuityErrs.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/initContinuityErrs.H index 8cc47b1ca0..1a7f5a3262 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/initContinuityErrs.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/initContinuityErrs.H @@ -1 +1 @@ -List cumulativeContErr(fluidToProc.size(), 0.0); +List cumulativeContErr(fluidRegions.size(), 0.0); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/mapFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/mapFluid.H deleted file mode 100644 index 75d83afd09..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/mapFluid.H +++ /dev/null @@ -1,3 +0,0 @@ -h = allToProcMappers[procI].decomposeField(allh(), true); -h.oldTime().timeIndex() = allh().oldTime().timeIndex(); -h.correctBoundaryConditions(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rmapFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rmapFluid.H deleted file mode 100644 index 576d883f01..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/rmapFluid.H +++ /dev/null @@ -1,56 +0,0 @@ -// Note:Map rho and rho.oldTime() since fluid rho assigned to at -// end of iteration. -rmap -( - allRho(), - rho, - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] -); -rmap -( - allRho().oldTime(), - rho.oldTime(), - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] -); - -// Necessary? Probably only for boundary values since bcs on -// h are not the same as those on allh - -rmap -( - allh(), - h, - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] -); - -procAlpha.set(procI, fvc::interpolate(turb.alphaEff())); - -rmap -( - allVolAlpha(), - turb.alphaEff()(), - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] -); - -rmap -( - allSource(), - (DpDt + rad.Sh(thermo))(), - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] -); - -procPhi.set -( - procI, - new surfaceScalarField(phi) -); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H index 5bc0fffa40..81c6d25bb0 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/setRegionFluidFields.H @@ -1,4 +1,4 @@ - fvMesh& mesh = procMeshes[fluidToProc[i]]; + fvMesh& mesh = fluidRegions[i]; basicRhoThermo& thermo = thermoFluid[i]; volScalarField& rho = rhoFluid[i]; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solvePressureVelocityFluid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solvePressureVelocityFluid.H deleted file mode 100644 index d04a301112..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/solvePressureVelocityFluid.H +++ /dev/null @@ -1,11 +0,0 @@ -#include "UEqn.H" - -// --- PISO loop -for (int corr=0; corr("nOuterCorrectors", 1); - - const Switch temperatureCoupled = - pimple.lookupOrDefault("temperatureCoupled", false); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/rmap.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/rmap.H deleted file mode 100644 index d9c8e35060..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/rmap.H +++ /dev/null @@ -1,96 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Global - rmap - -Description - map field on subset of mesh onto overall field. Rewrites boundary - conditions to be mixed. - - The source fields can have different patch types for the same destination - patch. To work around this it attempts to convert all patch fields into - mixed type since this can accomodate anything from fixedValue to - fixedGradient. - -SourceFiles - rmap.C - -\*---------------------------------------------------------------------------*/ - -#ifndef rmap_H -#define rmap_H - -#include "volFields.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -//- Map patchField -template -static void rmap -( - fvPatchField& destBC, - const labelList& reverseAddressing, - const fvPatchField& sourceBC -); - -//- Map volField -template -static void rmap -( - GeometricField& dest, - const GeometricField& source, - const labelList& faceProcAddressing, - const labelList& cellProcAddressing, - const labelList& boundaryProcAddressing -); - -//- Map fvMatrix -template -static void rmap -( - fvMatrix& dest, - const fvMatrix& source, - const labelList& faceProcAddressing, - const labelList& cellProcAddressing, - const labelList& boundaryProcAddressing -); - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "rmapTemplates.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/rmapTemplates.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/rmapTemplates.C deleted file mode 100644 index 6dbf50a81c..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/rmapTemplates.C +++ /dev/null @@ -1,309 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "rmap.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template -void Foam::rmap -( - fvPatchField& destBC, - const labelList& reverseAddressing, - const fvPatchField& sourceBC -) -{ - // Assign value - destBC.Field::rmap(sourceBC, reverseAddressing); - - // Assign other properties - if (isA >(destBC)) - { - mixedFvPatchField& mp = - refCast >(destBC); - - if (isA >(sourceBC)) - { - const mixedFvPatchField& Tp = - refCast >(sourceBC); - - mp.refValue().rmap(Tp.refValue(), reverseAddressing); - mp.refGrad().rmap(Tp.refGrad(), reverseAddressing); - mp.valueFraction().rmap(Tp.valueFraction(), reverseAddressing); - } - else if (isA >(sourceBC)) - { - const fixedGradientFvPatchField& Tp = - refCast > - ( - sourceBC - ); - // Make pure fixedGradient - mp.refValue().rmap(Tp, reverseAddressing); // unused - mp.refGrad().rmap(Tp.gradient(), reverseAddressing); - mp.valueFraction().rmap - ( - Field(reverseAddressing.size(), 0.0), - reverseAddressing - ); - } - else if (isA >(sourceBC)) - { - // Make pure fixedGradient with gradient = 0 - mp.refValue().rmap(sourceBC, reverseAddressing); // unused - mp.refGrad().rmap - ( - Field(reverseAddressing.size(), 0.0), - reverseAddressing - ); - mp.valueFraction().rmap - ( - Field(reverseAddressing.size(), 0.0), - reverseAddressing - ); - } - else if (isA >(sourceBC)) - { - // Make pure fixedValue - mp.refValue().rmap(sourceBC, reverseAddressing); - mp.refGrad().rmap - ( - Field(reverseAddressing.size(), 0.0), - reverseAddressing - ); // unused - mp.valueFraction().rmap - ( - Field(reverseAddressing.size(), 1.0), - reverseAddressing - ); - } - else if (isA >(sourceBC)) - { - // Make pure fixedValue - mp.refValue().rmap(sourceBC, reverseAddressing); - mp.refGrad().rmap - ( - Field(reverseAddressing.size(), 0.0), - reverseAddressing - ); // unused - mp.valueFraction().rmap - ( - Field(reverseAddressing.size(), 1.0), - reverseAddressing - ); - } - else - { - FatalErrorIn("rmap(..)") - << "Don't know how to map source bc " - << sourceBC.type() - << " into a mixed boundary condition at " - << destBC.patch().name() - << exit(FatalError); - } - } - else if (isA >(destBC)) - { - fixedGradientFvPatchField& mp = - refCast >(destBC); - - if (isA >(sourceBC)) - { - const fixedGradientFvPatchField& Tp = - refCast > - ( - sourceBC - ); - mp.gradient().rmap(Tp.gradient(), reverseAddressing); - } - else if (isA >(sourceBC)) - { - const mixedFvPatchField& Tp = - refCast >(sourceBC); - mp.gradient().rmap(Tp.snGrad(), reverseAddressing); - } - else if (isA >(sourceBC)) - { - mp.gradient().rmap - ( - Field(reverseAddressing.size(), 0.0), - reverseAddressing - ); - } - else - { - FatalErrorIn("rmap(..)") - << "Don't know how to map source bc " - << sourceBC.type() - << " into a fixedGradient boundary condition at " - << destBC.patch().name() - << exit(FatalError); - } - } -} - - -template -void Foam::rmap -( - GeometricField& dest, - const GeometricField& source, - const labelList& faceProcAddressing, - const labelList& cellProcAddressing, - const labelList& boundaryProcAddressing -) -{ - if (dest.dimensions() != source.dimensions()) - { - FatalErrorIn("rmap(..)") - << "Different dimensions for = for fields " << dest.name() - << " and " << source.name() << endl - << " dimensions : " << dest.dimensions() - << " = " << source.dimensions() << endl - << exit(FatalError); - } - - // Copy internal field - dest.internalField().rmap(source.internalField(), cellProcAddressing); - - // Copy boundary properties as mixed - forAll(source.boundaryField(), patchI) - { - label curBPatch = boundaryProcAddressing[patchI]; - - if (curBPatch == -1) - { - // Unknown patch. Do not change any values. - } - else - { - // Get addressing slice for this patch - const labelList::subList cp = - source.mesh().boundary()[patchI].patchSlice - ( - faceProcAddressing - ); - - const label curPatchStart = - dest.mesh().boundaryMesh()[curBPatch].start(); - - labelList reverseAddressing(cp.size()); - - forAll(cp, faceI) - { - // Subtract one to take into account offsets for - // face direction. - if (cp[faceI] <= 0) - { - FatalErrorIn("rmap(..)") - << "Problem:" - << " patch:" << source.mesh().boundary()[patchI].name() - << " field:" << source.name() - << " local face:" << faceI - << " mapped to:" << cp[faceI] << exit(FatalError); - } - - reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart; - } - - // Map curBPatch from source patch. Is like rmap but also - // copies non-value properties from alike patchFields. - rmap - ( - dest.boundaryField()[curBPatch], - reverseAddressing, - source.boundaryField()[patchI] - ); - } - } - - // Copy timeIndex - dest.timeIndex() = source.timeIndex(); -} - - -template -void Foam::rmap -( - fvMatrix& dest, - const fvMatrix& source, - const labelList& faceProcAddressing, - const labelList& cellProcAddressing, - const labelList& boundaryProcAddressing -) -{ - dest.source().rmap(source.source(), cellProcAddressing); - - FieldField& sourceInternal = - const_cast&>(source).internalCoeffs(); - FieldField& sourceBoundary = - const_cast&>(source).boundaryCoeffs(); - - forAll(sourceInternal, patchI) - { - label curBPatch = boundaryProcAddressing[patchI]; - - if (curBPatch == -1) - { - // Unknown patch. Do not change any values. - } - else - { - // Get addressing slice for this patch - const fvMesh& sourceMesh = source.psi().mesh(); - - const labelList::subList cp = - sourceMesh.boundary()[patchI].patchSlice - ( - faceProcAddressing - ); - - const label curPatchStart = - dest.psi().mesh().boundaryMesh()[curBPatch].start(); - - labelList reverseAddressing(cp.size()); - - forAll(cp, faceI) - { - // Subtract one to take into account offsets for - // face direction. - reverseAddressing[faceI] = cp[faceI] - 1 - curPatchStart; - } - dest.internalCoeffs()[curBPatch].rmap - ( - sourceInternal[patchI], - reverseAddressing - ); - dest.boundaryCoeffs()[curBPatch].rmap - ( - sourceBoundary[patchI], - reverseAddressing - ); - } - } -} - - -// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H index ab58752d80..837305659e 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidFields.H @@ -1,36 +1,12 @@ // Initialise solid field pointer lists - PtrList thermoSolid(rp.solidRegionNames().size()); - PtrList hSolid(rp.solidRegionNames().size()); + PtrList thermos(solidRegions.size()); // Populate solid field pointer lists - forAll(rp.solidRegionNames(), i) + forAll(solidRegions, i) { Info<< "*** Reading solid mesh thermophysical properties for region " - << rp.solidRegionNames()[i] << nl << endl; + << solidRegions[i].name() << nl << endl; - label procI = solidToProc[i]; - - Info<< " Adding to thermoSolid\n" << endl; - thermoSolid.set(i, basicSolidThermo::New(procMeshes[procI])); - - if (temperatureCoupled) - { - Info<< " Adding to hSolid\n" << endl; - hSolid.set - ( - i, - new volScalarField - ( - IOobject - ( - "h", - runTime.timeName(), - procMeshes[procI], - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - procMeshes[procI] - ) - ); - } + Info<< " Adding to thermos\n" << endl; + thermos.set(i, basicSolidThermo::New(solidRegions[i])); } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidMeshes.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidMeshes.H index 10b5f4160c..eb50be2380 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidMeshes.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/createSolidMeshes.H @@ -1,13 +1,13 @@ + PtrList solidRegions(rp.solidRegionNames().size()); + forAll(rp.solidRegionNames(), i) { Info<< "Create solid mesh for region " << rp.solidRegionNames()[i] << " for time = " << runTime.timeName() << nl << endl; - label procI = solidToProc[i]; - - procMeshes.set + solidRegions.set ( - procI, + i, new fvMesh ( IOobject @@ -20,57 +20,8 @@ ) ); - if (temperatureCoupled) - { - cellProcAddressing.set - ( - procI, - new labelIOList - ( - IOobject - ( - "cellRegionAddressing", - procMeshes[procI].facesInstance(), - procMeshes[procI].meshSubDir, - procMeshes[procI], - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) - ); - - faceProcAddressing.set - ( - procI, - new labelIOList - ( - IOobject - ( - "faceRegionAddressing", - procMeshes[procI].facesInstance(), - procMeshes[procI].meshSubDir, - procMeshes[procI], - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) - ); - - boundaryProcAddressing.set - ( - procI, - new labelIOList - ( - IOobject - ( - "boundaryRegionAddressing", - procMeshes[procI].facesInstance(), - procMeshes[procI].meshSubDir, - procMeshes[procI], - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ) - ); - } + // Force calculation of geometric properties to prevent it being done + // later in e.g. some boundary evaluation + //(void)solidRegions[i].weights(); + //(void)solidRegions[i].deltaCoeffs(); } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/mapSolid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/mapSolid.H deleted file mode 100644 index ca6e506347..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/mapSolid.H +++ /dev/null @@ -1,15 +0,0 @@ -{ - volScalarField& h = hSolid[i]; - - h = allToProcMappers[procI].decomposeField(allh(), true); - h.oldTime().timeIndex() = allh().oldTime().timeIndex(); - - T += (h-h.oldTime())/cp; - // Correct T boundary conditions and update h boundary - // conditions accordingly. - volScalarField::GeometricBoundaryField Told = T.boundaryField(); - T.correctBoundaryConditions(); - h.boundaryField() += - cp.boundaryField() - * (T.boundaryField()-Told); -} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/rmapSolid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/rmapSolid.H deleted file mode 100644 index b36474a531..0000000000 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/rmapSolid.H +++ /dev/null @@ -1,90 +0,0 @@ -{ - volScalarField& h = hSolid[i]; - - procPhi.setSize(nAllRegions); - procAlpha.setSize(nAllRegions); - - rmap - ( - allRho(), - rho, - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] - ); - - // Necessary? Probably only for boundary values since bcs on - // h are not the same as those on allh - rmap - ( - allh(), - h, - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] - ); - - - tmp Kcp(K/cp); - - rmap - ( - allVolAlpha(), - Kcp(), - faceProcAddressing[procI], - cellProcAddressing[procI], - boundaryProcAddressing[procI] - ); - - procAlpha.set(procI, fvc::interpolate(Kcp)); - - // allSource is initialised to zero already - //rmap - //( - // allSource(), - // volScalarField - // ( - // IOobject - // ( - // "procSource", - // runTime.timeName(), - // mesh, - // IOobject::NO_READ, - // IOobject::AUTO_WRITE - // ), - // mesh, - // dimensionedScalar - // ( - // "procSource", - // allh().dimensions()*dimDensity/dimTime, - // 0.0 - // ) - // ), - // faceProcAddressing[procI], - // cellProcAddressing[procI], - // boundaryProcAddressing[procI] - //); - - procPhi.set - ( - procI, - new surfaceScalarField - ( - IOobject - ( - "phi", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - mesh, - dimensionedScalar - ( - "phi", - dimDensity*dimVelocity*dimArea, - 0.0 - ) - ) - ); -} diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H index a1dbe88c0a..a843ed8bd7 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/setRegionSolidFields.H @@ -1,5 +1,5 @@ - fvMesh& mesh = procMeshes[solidToProc[i]]; - basicSolidThermo& thermo = thermoSolid[i]; + fvMesh& mesh = solidRegions[i]; + basicSolidThermo& thermo = thermos[i]; tmp trho = thermo.rho(); const volScalarField& rho = trho(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H index 5564d3bd3a..77dc6f04bf 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solidRegionDiffusionNo.H @@ -1,6 +1,6 @@ scalar DiNum = -GREAT; - forAll(solidToProc, i) + forAll(solidRegions, i) { # include "setRegionSolidFields.H" @@ -8,7 +8,7 @@ ( solidRegionDiffNo ( - procMeshes[solidToProc[i]], + solidRegions[i], runTime, rho*cp, K diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H index 96cd32ddb3..d8aa03283b 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/solid/solveSolid.H @@ -1,3 +1,8 @@ +if (finalIter) +{ + mesh.data::add("finalIteration", true); +} + { for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { @@ -12,3 +17,10 @@ Info<< "Min/max T:" << min(T) << ' ' << max(T) << endl; } + +thermo.correct(); + +if (finalIter) +{ + mesh.data::remove("finalIteration"); +} diff --git a/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H b/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H index 743b1d68ff..d9ca1b09e0 100644 --- a/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H +++ b/applications/solvers/lagrangian/LTSReactingParcelFoam/YEqn.H @@ -31,7 +31,7 @@ if (solveSpecies) == parcels.SYi(i, Yi) + combustion->R(Yi) - + sources(Yi) + + sources(rho, Yi) ); sources.constrain(YEqn); diff --git a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H index 9ef9d6a1a0..3e4a041f90 100644 --- a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H +++ b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/createFields.H @@ -47,17 +47,10 @@ #include "createPhi.H" - Info<< "Creating turbulence model\n" << endl; - singlePhaseTransportModel laminarTransport(U, phi); const volScalarField nu(laminarTransport.nu()); - autoPtr turbulence - ( - incompressible::turbulenceModel::New(U, phi, laminarTransport) - ); - volScalarField mu ( IOobject diff --git a/applications/test/volPointInterpolation/Test-volPointInterpolation.C b/applications/test/volPointInterpolation/Test-volPointInterpolation.C index 1bbcd6da5e..96ffeeac37 100644 --- a/applications/test/volPointInterpolation/Test-volPointInterpolation.C +++ b/applications/test/volPointInterpolation/Test-volPointInterpolation.C @@ -33,11 +33,10 @@ Application int main(int argc, char *argv[]) { + #include "setRootCase.H" -# include "setRootCase.H" - -# include "createTime.H" -# include "createMesh.H" + #include "createTime.H" + #include "createMesh.H" Info<< "Reading field p\n" << endl; volScalarField p @@ -67,9 +66,29 @@ int main(int argc, char *argv[]) mesh ); + const pointMesh& pMesh = pointMesh::New(mesh); + const pointBoundaryMesh& pbm = pMesh.boundary(); + + Info<< "pointMesh boundary" << nl; + forAll(pbm, patchI) + { + Info<< "patch=" << pbm[patchI].name() + << ", type=" << pbm[patchI].type() + << ", coupled=" << pbm[patchI].coupled() + << endl; + } + const volPointInterpolation& pInterp = volPointInterpolation::New(mesh); + pointScalarField pp(pInterp.interpolate(p)); + Info<< pp.name() << " boundary" << endl; + forAll(pp.boundaryField(), patchI) + { + Info<< pbm[patchI].name() << " coupled=" + << pp.boundaryField()[patchI].coupled()<< endl; + } + pp.write(); pointVectorField pU(pInterp.interpolate(U)); diff --git a/etc/config/settings.csh b/etc/config/settings.csh index 2b0a132ebc..2566cd6a9a 100644 --- a/etc/config/settings.csh +++ b/etc/config/settings.csh @@ -512,6 +512,36 @@ case SGIMPI: _foamAddLib $MPI_ARCH_PATH/lib breaksw +case INTELMPI: + if ( ! $?MPI_ROOT) setenv MPI_ROOT /dummy + + if ( ! -d "$MPI_ROOT" ) then + echo "Warning in $WM_PROJECT_DIR/etc/config/settings.csh:" + echo " MPI_ROOT not a valid mpt installation directory." + echo " Please set MPI_ROOT to the mpt installation directory." + echo " (usually done by loading the mpt module)" + echo " MPI_ROOT currently set to '$MPI_ROOT'" + endif + + if ( "${MPI_ROOT:h}/" == $MPI_ROOT ) then + setenv MPI_ROOT ${MPI_ROOT:h} + endif + + setenv FOAM_MPI ${MPI_ROOT:t} + setenv MPI_ARCH_PATH $MPI_ROOT + + + if ($?FOAM_VERBOSE && $?prompt) then + echo "Using INTEL MPT:" + echo " MPI_ROOT : $MPI_ROOT" + echo " FOAM_MPI : $FOAM_MPI" + endif + + + _foamAddPath $MPI_ARCH_PATH/bin64 + _foamAddLib $MPI_ARCH_PATH/lib64 + breaksw + default: setenv FOAM_MPI dummy breaksw diff --git a/etc/config/settings.sh b/etc/config/settings.sh index e56afffa17..55810e6e9f 100644 --- a/etc/config/settings.sh +++ b/etc/config/settings.sh @@ -534,6 +534,34 @@ SGIMPI) _foamAddLib $MPI_ARCH_PATH/lib ;; +INTELMPI) + lastCharID=$(( ${#MPI_ROOT} - 1 )) + if [ "${MPI_ROOT:$lastCharID:1}" == '/' ] + then + MPI_ROOT=${MPI_ROOT:0:$lastCharID} + fi + + export FOAM_MPI=${MPI_ROOT##*/} + export MPI_ARCH_PATH=$MPI_ROOT + + if [ ! -d "$MPI_ROOT" -o -z "$MPI_ARCH_PATH" ] + then + echo "Warning in $WM_PROJECT_DIR/etc/config/settings.sh:" 1>&2 + echo " MPI_ROOT not a valid mpt installation directory or ending in a '/'." 1>&2 + echo " Please set MPI_ROOT to the mpt installation directory." 1>&2 + echo " MPI_ROOT currently set to '$MPI_ROOT'" 1>&2 + fi + + if [ "$FOAM_VERBOSE" -a "$PS1" ] + then + echo "Using INTEL MPI:" + echo " MPI_ROOT : $MPI_ROOT" + echo " FOAM_MPI : $FOAM_MPI" + fi + + _foamAddPath $MPI_ARCH_PATH/bin64 + _foamAddLib $MPI_ARCH_PATH/lib64 + ;; *) export FOAM_MPI=dummy ;; diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C new file mode 100644 index 0000000000..3fe17d24a0 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.C @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "CSV.H" +#include "DynamicList.H" +#include "IFstream.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +namespace Foam +{ + // doesn't recognize specialization otherwise + template<> + scalar CSV::readValue(const List& splitted) + { + if (componentColumns_[0] >= splitted.size()) + { + FatalErrorIn("CSV::readValue(const List&)") + << "No column " << componentColumns_[0] << " in " + << splitted << endl + << exit(FatalError); + } + + return readScalar(IStringStream(splitted[componentColumns_[0]])()); + } + + + template + Type CSV::readValue(const List& splitted) + { + Type result; + + for (label i = 0; i < pTraits::nComponents; i++) + { + if (componentColumns_[i] >= splitted.size()) + { + FatalErrorIn("CSV::readValue(const List&)") + << "No column " << componentColumns_[i] << " in " + << splitted << endl + << exit(FatalError); + } + + result[i] = + readScalar(IStringStream(splitted[componentColumns_[i]])()); + } + + return result; + } +} + + +template +void Foam::CSV::read() +{ + IFstream is(fName_.expand()); + + DynamicList > values; + + // skip header + if (headerLine_) + { + string line; + is.getLine(line); + } + + // read data + while (is.good()) + { + string line; + is.getLine(line); + + DynamicList splitted; + + std::size_t pos = 0; + while (pos != std::string::npos) + { + std::size_t nPos = line.find(separator_, pos); + + if (nPos == std::string::npos) + { + splitted.append(line.substr(pos)); + pos = nPos; + } + else + { + splitted.append(line.substr(pos, nPos - pos)); + pos = nPos + 1; + } + } + + if (splitted.size() <= 1) + { + break; + } + + scalar x = readScalar(IStringStream(splitted[refColumn_])()); + Type value = readValue(splitted); + + values.append(Tuple2(x, value)); + } + + this->table_.transfer(values); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CSV::CSV(const word& entryName, const dictionary& dict) +: + DataEntry(entryName), + TableBase(entryName, dict.subDict(type() + "Coeffs")), + coeffs_(dict.subDict(type() + "Coeffs")), + headerLine_(readBool(coeffs_.lookup("hasHeaderLine"))), + refColumn_(readLabel(coeffs_.lookup("refColumn"))), + componentColumns_(coeffs_.lookup("componentColumns")), + separator_(coeffs_.lookupOrDefault("separator", string(","))[0]), + fName_(coeffs_.lookup("fileName")) +{ + if (componentColumns_.size() != pTraits::nComponents) + { + FatalErrorIn("Foam::CSV::CSV(const word&, Istream&)") + << componentColumns_ << " does not have the expected length of " + << pTraits::nComponents << endl + << exit(FatalError); + } + + read(); + + TableBase::check(); +} + + +template +Foam::CSV::CSV(const CSV& tbl) +: + DataEntry(tbl), + TableBase(tbl), + headerLine_(tbl.headerLine_), + refColumn_(tbl.refColumn_), + componentColumns_(tbl.componentColumns_), + separator_(tbl.separator_), + fName_(tbl.fName_) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template +Foam::CSV::~CSV() +{} + + +// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * // + +#include "CSVIO.C" + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H new file mode 100644 index 0000000000..c95406350b --- /dev/null +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::CSV + +Description + Templated CSV container data entry. Reference column is always a scalar, + e.g. time + + \verbatim + csvFile + { + hasHeaderLine true; + refColumn 0; // reference column index + componentColumns (0 1 2); // component column indices + separator ","; // optional (defaults to ",") + fileName fileXYZ; // name of csv data file + outOfBounds clamp; // optional out-of-bounds handling + } + \endverbatim + +SourceFiles + CSV.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CSV_H +#define CSV_H + +#include "DataEntry.H" +#include "TableBase.H" +#include "Tuple2.H" +#include "labelList.H" +#include "ISstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template +class CSV; + +template +Ostream& operator<< +( + Ostream&, + const CSV& +); + +/*---------------------------------------------------------------------------*\ + Class CSV Declaration +\*---------------------------------------------------------------------------*/ + +template +class CSV +: + public DataEntry, + public TableBase +{ + // Private data + + //- Coefficients dictionary (for convenience on reading) + dictionary coeffs_; + + //- Does the file have a header line? + bool headerLine_; + + //- Column of the time + label refColumn_; + + //- Labels of the components + labelList componentColumns_; + + //- Separator character + char separator_; + + //- File name for csv table (optional) + fileName fName_; + + + // Private Member Functions + + //- Read csv data table + void read(); + + //- Read the next value from the splitted string + Type readValue(const List&); + + //- Disallow default bitwise assignment + void operator=(const CSV&); + + +public: + + //- Runtime type information + TypeName("csvFile"); + + + // Constructors + + //- Construct from entry name and Istream + CSV(const word& entryName, const dictionary& dict); + + //- Copy constructor + CSV(const CSV& tbl); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp >(new CSV(*this)); + } + + + //- Destructor + virtual ~CSV(); + + + // Member Functions + + //- Return Table value + virtual Type value(const scalar x) const + { + return TableBase::value(x); + } + + //- Integrate between two (scalar) values + virtual Type integrate(const scalar x1, const scalar x2) const + { + return TableBase::integrate(x1, x2); + } + + + // I/O + + //- Ostream Operator + friend Ostream& operator<< + ( + Ostream& os, + const CSV& cnst + ); + + //- Write in dictionary format + virtual void writeData(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "CSV.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C new file mode 100644 index 0000000000..d16ca23ab8 --- /dev/null +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "DataEntry.H" + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +template +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const CSV& tbl +) +{ + if (os.format() == IOstream::ASCII) + { + os << static_cast& >(tbl) + << token::SPACE << tbl.headerLine_ + << token::SPACE << tbl.timeColumn_ + << token::SPACE << tbl.componentColumns_ + << token::SPACE << tbl.separator_ + << token::SPACE << tbl.fileName_; + } + else + { + os << static_cast& >(tbl); + } + + // Check state of Ostream + os.check + ( + "Ostream& operator<<(Ostream&, const CSV&)" + ); + + return os; +} + + +template +void Foam::CSV::writeData(Ostream& os) const +{ + DataEntry::writeData(os); + + os << token::END_STATEMENT << nl; + os << indent << word(type() + "Coeffs") << nl; + os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.writeKeyword("headerLine") << headerLine_ << token::END_STATEMENT << nl; + os.writeKeyword("refColumn") << refColumn_ << token::END_STATEMENT << nl; + os.writeKeyword("componentColumns") << componentColumns_ + << token::END_STATEMENT << nl; + os.writeKeyword("separator") << string(separator_) + << token::END_STATEMENT << nl; + os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl; + os << decrIndent << indent << token::END_BLOCK << endl; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C index 2fe5238d8d..410052f560 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.C @@ -28,11 +28,14 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::Constant::Constant(const word& entryName, Istream& is) +Foam::Constant::Constant(const word& entryName, const dictionary& dict) : DataEntry(entryName), value_(pTraits::zero) { + Istream& is(dict.lookup(entryName)); + word entryType(is); + is >> value_; } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H index 658a667240..c42e07e054 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/Constant.H @@ -83,7 +83,7 @@ public: // Constructors //- Construct from entry name and Istream - Constant(const word& entryName, Istream& is); + Constant(const word& entryName, const dictionary& dict); //- Copy constructor Constant(const Constant& cnst); diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C b/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C index 46063b5830..e61a92e086 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Constant/ConstantIO.C @@ -65,7 +65,6 @@ void Foam::Constant::writeData(Ostream& os) const DataEntry::writeData(os); os << token::SPACE << value_ << token::END_STATEMENT << nl; - } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H index 03d1da361a..5b3e783101 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntry.H @@ -92,9 +92,9 @@ public: dictionary, ( const word& entryName, - Istream& is + const dictionary& dict ), - (entryName, is) + (entryName, dict) ); diff --git a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C index a62ce1054f..57cf79c419 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/DataEntry/DataEntryNew.C @@ -35,7 +35,6 @@ Foam::autoPtr > Foam::DataEntry::New ) { Istream& is(dict.lookup(entryName)); - word DataEntryType(is); typename dictionaryConstructorTable::iterator cstrIter = @@ -54,7 +53,7 @@ Foam::autoPtr > Foam::DataEntry::New << exit(FatalError); } - return autoPtr >(cstrIter()(entryName, is)); + return autoPtr >(cstrIter()(entryName, dict)); } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C index 91e501f5be..dd60ac90fb 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/Table.C @@ -28,17 +28,17 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template -Foam::Table::Table(const word& entryName, Istream& is) +Foam::Table::Table(const word& entryName, const dictionary& dict) : DataEntry(entryName), - table_(is) + TableBase(entryName, dictionary::null) { - if (!table_.size()) - { - FatalErrorIn("Foam::Table::Table(const Istream&)") - << "Table for entry " << this->name_ << " is invalid (empty)" - << nl << exit(FatalError); - } + Istream& is(dict.lookup(entryName)); + word entryType(is); + + is >> this->table_; + + TableBase::check(); } @@ -46,7 +46,7 @@ template Foam::Table::Table(const Table& tbl) : DataEntry(tbl), - table_(tbl.table_) + TableBase(tbl) {} @@ -57,98 +57,6 @@ Foam::Table::~Table() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -Type Foam::Table::value(const scalar x) const -{ - // Return zero if out of bounds - if (x < table_[0].first() || x > table_.last().first()) - { - return pTraits::zero; - } - - // Find i such that x(i) < x < x(i+1) - label i = 0; - while ((table_[i+1].first() < x) && (i+1 < table_.size())) - { - i++; - } - - // Linear interpolation to find value. Note constructor needed for - // Table