diff --git a/applications/solvers/DNS/dnsFoam/dnsFoam.C b/applications/solvers/DNS/dnsFoam/dnsFoam.C index 0733802b086784842a013ce94e7d59161278889f..08073398a76a85f0009708a015f74fb4863a41ad 100644 --- a/applications/solvers/DNS/dnsFoam/dnsFoam.C +++ b/applications/solvers/DNS/dnsFoam/dnsFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -85,7 +85,7 @@ int main(int argc, char *argv[]) for (int corr=1; corr<=1; corr++) { - volScalarField rAU(1.0/UEqn.A()); + volScalarField rAU("Dp", 1.0/UEqn.A()); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); diff --git a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H index b5a9d283acd05775b37da4dbb56d4f8771da1f90..c125a7f31fb7dc6b7651df9dfb6d09ba99a0072a 100644 --- a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H +++ b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H @@ -23,7 +23,7 @@ fvMesh mesh fvMesh::defaultRegion, runTime.timeName(), runTime, - IOobject::MUST_READ + IOobject::READ_IF_PRESENT ), xferMove<Field<vector> >(points), faces.xfer(), diff --git a/applications/solvers/combustion/fireFoam/pEqn.H b/applications/solvers/combustion/fireFoam/pEqn.H index f5364ae3142ceeca923e458bb032ad3bbd1a0f86..3f4f485cf6b7e0abe4e43577558952568598e786 100644 --- a/applications/solvers/combustion/fireFoam/pEqn.H +++ b/applications/solvers/combustion/fireFoam/pEqn.H @@ -1,11 +1,11 @@ rho = thermo.rho(); volScalarField rAU(1.0/UEqn.A()); -surfaceScalarField rhorAUf(rAU.name() + 'f', fvc::interpolate(rho*rAU)); +surfaceScalarField rhorAUf("Dp", fvc::interpolate(rho*rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); -surfaceScalarField phig(rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); +surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); surfaceScalarField phiHbyA ( @@ -15,7 +15,7 @@ surfaceScalarField phiHbyA (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ) - - phig + + phig ); @@ -37,7 +37,7 @@ while (pimple.correctNonOrthogonal()) if (pimple.finalNonOrthogonalIter()) { phi = phiHbyA + p_rghEqn.flux(); - U = HbyA + rAU*fvc::reconstruct((p_rghEqn.flux() - phig)/rhorAUf); + U = HbyA + rAU*fvc::reconstruct((p_rghEqn.flux() + phig)/rhorAUf); U.correctBoundaryConditions(); } } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H index 9db0897efa91c397b2196ca94e5cdb771a627c53..06997e52ecd2182eaef16e16a89cd63fd01d73a3 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqPimpleFoam/pEqn.H @@ -1,18 +1,18 @@ { volScalarField rAU("rAU", 1.0/UEqn.A()); - surfaceScalarField rAUf("(1|A(U))", fvc::interpolate(rAU)); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); - surfaceScalarField phig(rAUf*ghf*fvc::snGrad(rhok)*mesh.magSf()); + surfaceScalarField phig(-rAUf*ghf*fvc::snGrad(rhok)*mesh.magSf()); surfaceScalarField phiHbyA ( "phiHbyA", (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, U, phi) - - phig + + phig ); while (pimple.correctNonOrthogonal()) @@ -36,7 +36,7 @@ // Correct the momentum source with the pressure gradient flux // calculated from the relaxed pressure - U = HbyA - rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf); + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); U.correctBoundaryConditions(); } } diff --git a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H index 61d4358a8a65dc638906b2b9e66b37910b251050..c07a344017abbc772bfb2cd09e5d7cd680ea63c7 100644 --- a/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantBoussinesqSimpleFoam/pEqn.H @@ -1,12 +1,12 @@ { volScalarField rAU("rAU", 1.0/UEqn().A()); - surfaceScalarField rAUf("(1|A(U))", fvc::interpolate(rAU)); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn().H(); UEqn.clear(); - surfaceScalarField phig(rAUf*ghf*fvc::snGrad(rhok)*mesh.magSf()); + surfaceScalarField phig(-rAUf*ghf*fvc::snGrad(rhok)*mesh.magSf()); surfaceScalarField phiHbyA ( @@ -16,7 +16,7 @@ adjustPhi(phiHbyA, U, p_rgh); - phiHbyA -= phig; + phiHbyA += phig; while (simple.correctNonOrthogonal()) { @@ -39,7 +39,7 @@ // Correct the momentum source with the pressure gradient flux // calculated from the relaxed pressure - U = HbyA - rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf); + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); U.correctBoundaryConditions(); } } diff --git a/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H index 462b96b17da126e40f31210f3607cd461fca5ce3..96389fee7b7215f48b21c7ed64c03e0791466dde 100644 --- a/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantPimpleFoam/pEqn.H @@ -6,7 +6,7 @@ thermo.rho() -= psi*p_rgh; volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rhorAUf("(rho*(1|A(U)))", fvc::interpolate(rho*rAU)); + surfaceScalarField rhorAUf("Dp", fvc::interpolate(rho*rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); diff --git a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H index d558f6c2177a3e608982d32016fb8ee105efeaac..f63e12f363774a88972459f748bd5162501fc0a4 100644 --- a/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H +++ b/applications/solvers/heatTransfer/buoyantSimpleFoam/pEqn.H @@ -3,13 +3,13 @@ rho.relax(); volScalarField rAU(1.0/UEqn().A()); - surfaceScalarField rhorAUf("(rho*(1|A(U)))", fvc::interpolate(rho*rAU)); + surfaceScalarField rhorAUf("Dp", fvc::interpolate(rho*rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn().H(); UEqn.clear(); - surfaceScalarField phig(rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); + surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); surfaceScalarField phiHbyA ( @@ -19,7 +19,7 @@ bool closedVolume = adjustPhi(phiHbyA, U, p_rgh); - phiHbyA -= phig; + phiHbyA += phig; while (simple.correctNonOrthogonal()) { @@ -41,7 +41,7 @@ // Correct the momentum source with the pressure gradient flux // calculated from the relaxed pressure - U = HbyA - rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rhorAUf); + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rhorAUf); U.correctBoundaryConditions(); } } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H index 73b72af316a7c3bf3cddc9eb05af4c35bc326d26..d23390edeb046e0efb7c5a32898ecb5ecd395dfb 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/pEqn.H @@ -5,7 +5,7 @@ rho.relax(); volScalarField rAU(1.0/UEqn().A()); - surfaceScalarField rhorAUf("(rho*(1|A(U)))", fvc::interpolate(rho*rAU)); + surfaceScalarField rhorAUf("Dp", fvc::interpolate(rho*rAU)); U = rAU*UEqn().H(); UEqn.clear(); @@ -15,8 +15,8 @@ dimensionedScalar compressibility = fvc::domainIntegrate(psi); bool compressible = (compressibility.value() > SMALL); - surfaceScalarField buoyancyPhi(rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); - phi -= buoyancyPhi; + surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); + phi += phig; // Solve pressure for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) @@ -44,7 +44,7 @@ // Correct the momentum source with the pressure gradient flux // calculated from the relaxed pressure - U -= rAU*fvc::reconstruct((buoyancyPhi + p_rghEqn.flux())/rhorAUf); + U += rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rhorAUf); U.correctBoundaryConditions(); } } diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H index 76f6f8e30e155336db0bdef1412177266341cca5..f260acc514d42924ea59abe2a246436207903bbf 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/pEqn.H @@ -6,7 +6,7 @@ rho = thermo.rho(); volScalarField rAU(1.0/UEqn().A()); - surfaceScalarField rhorAUf("(rho*(1|A(U)))", fvc::interpolate(rho*rAU)); + surfaceScalarField rhorAUf("Dp", fvc::interpolate(rho*rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn().H(); diff --git a/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C b/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C index b620536abbb13117c0e6154ae1c0bb0bb89e86b0..bf12294638d314c0b7d96d241afaea4c23e0b2ce 100644 --- a/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C +++ b/applications/solvers/incompressible/nonNewtonianIcoFoam/nonNewtonianIcoFoam.C @@ -61,6 +61,7 @@ int main(int argc, char *argv[]) fvm::ddt(U) + fvm::div(phi, U) - fvm::laplacian(fluid.nu(), U) + - (fvc::grad(U) & fvc::grad(fluid.nu())) ); solve(UEqn == -fvc::grad(p)); diff --git a/applications/solvers/incompressible/potentialFreeSurfaceFoam/pEqn.H b/applications/solvers/incompressible/potentialFreeSurfaceFoam/pEqn.H index 2271e85d9b52646ae26916f9026fcbd2b1febcd2..5a521a04fffd27c9b334a9266448f6c3e324f601 100644 --- a/applications/solvers/incompressible/potentialFreeSurfaceFoam/pEqn.H +++ b/applications/solvers/incompressible/potentialFreeSurfaceFoam/pEqn.H @@ -1,5 +1,5 @@ volScalarField rAU(1.0/UEqn().A()); -surfaceScalarField rAUf(rAU.name() + 'f', fvc::interpolate(rAU)); +surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*(UEqn() == sources(U))().H(); diff --git a/applications/solvers/lagrangian/reactingParcelFilmFoam/pEqn.H b/applications/solvers/lagrangian/reactingParcelFilmFoam/pEqn.H index f5364ae3142ceeca923e458bb032ad3bbd1a0f86..3f4f485cf6b7e0abe4e43577558952568598e786 100644 --- a/applications/solvers/lagrangian/reactingParcelFilmFoam/pEqn.H +++ b/applications/solvers/lagrangian/reactingParcelFilmFoam/pEqn.H @@ -1,11 +1,11 @@ rho = thermo.rho(); volScalarField rAU(1.0/UEqn.A()); -surfaceScalarField rhorAUf(rAU.name() + 'f', fvc::interpolate(rho*rAU)); +surfaceScalarField rhorAUf("Dp", fvc::interpolate(rho*rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); -surfaceScalarField phig(rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); +surfaceScalarField phig(-rhorAUf*ghf*fvc::snGrad(rho)*mesh.magSf()); surfaceScalarField phiHbyA ( @@ -15,7 +15,7 @@ surfaceScalarField phiHbyA (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ) - - phig + + phig ); @@ -37,7 +37,7 @@ while (pimple.correctNonOrthogonal()) if (pimple.finalNonOrthogonalIter()) { phi = phiHbyA + p_rghEqn.flux(); - U = HbyA + rAU*fvc::reconstruct((p_rghEqn.flux() - phig)/rhorAUf); + U = HbyA + rAU*fvc::reconstruct((p_rghEqn.flux() + phig)/rhorAUf); U.correctBoundaryConditions(); } } diff --git a/applications/solvers/multiphase/bubbleFoam/pEqn.H b/applications/solvers/multiphase/bubbleFoam/pEqn.H index 5f868f3da9d195881f09bd6e0256fe1a2bfcfb65..631c9cbba64c9040ca890d33a95f757bc3e90062 100644 --- a/applications/solvers/multiphase/bubbleFoam/pEqn.H +++ b/applications/solvers/multiphase/bubbleFoam/pEqn.H @@ -8,16 +8,21 @@ surfaceScalarField rAU1f(fvc::interpolate(rAU1)); surfaceScalarField rAU2f(fvc::interpolate(rAU2)); - U1 = rAU1*U1Eqn.H(); - U2 = rAU2*U2Eqn.H(); + volVectorField HbyA1("HbyA1", U1); + HbyA1 = rAU1*U1Eqn.H(); + + volVectorField HbyA2("HbyA2", U2); + HbyA2 = rAU2*U2Eqn.H(); surfaceScalarField phiDrag1 ( - fvc::interpolate(alpha2/rho1*dragCoef*rAU1)*phi2 + rAU1f*(g & mesh.Sf()) + fvc::interpolate(alpha2/rho1*dragCoef*rAU1)*phi2 + + rAU1f*(g & mesh.Sf()) ); surfaceScalarField phiDrag2 ( - fvc::interpolate(alpha1/rho2*dragCoef*rAU2)*phi1 + rAU2f*(g & mesh.Sf()) + fvc::interpolate(alpha1/rho2*dragCoef*rAU2)*phi1 + + rAU2f*(g & mesh.Sf()) ); forAll(p.boundaryField(), patchi) @@ -29,16 +34,25 @@ } } - phi1 = (fvc::interpolate(U1) & mesh.Sf()) + fvc::ddtPhiCorr(rAU1, U1, phi1) - + phiDrag1; - phi2 = (fvc::interpolate(U2) & mesh.Sf()) + fvc::ddtPhiCorr(rAU2, U2, phi2) - + phiDrag2; + surfaceScalarField phiHbyA1 + ( + (fvc::interpolate(HbyA1) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU1, U1, phi1) + + phiDrag1 + ); + + surfaceScalarField phiHbyA2 + ( + (fvc::interpolate(HbyA2) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU2, U2, phi2) + + phiDrag2 + ); - phi = alpha1f*phi1 + alpha2f*phi2; + surfaceScalarField phiHbyA("phiHbyA", alpha1f*phiHbyA1 + alpha2f*phiHbyA2); surfaceScalarField Dp ( - "(rho*(1|A(U)))", + "Dp", alpha1f*rAU1f/rho1 + alpha2f*rAU2f/rho2 ); @@ -46,7 +60,7 @@ { fvScalarMatrix pEqn ( - fvm::laplacian(Dp, p) == fvc::div(phi) + fvm::laplacian(Dp, p) == fvc::div(phiHbyA) ); pEqn.setReference(pRefCell, pRefValue); @@ -57,19 +71,17 @@ { surfaceScalarField SfGradp(pEqn.flux()/Dp); - phi1 -= rAU1f*SfGradp/rho1; - phi2 -= rAU2f*SfGradp/rho2; + phi1 = phiHbyA1 - rAU1f*SfGradp/rho1; + phi2 = phiHbyA2 - rAU2f*SfGradp/rho2; phi = alpha1f*phi1 + alpha2f*phi2; p.relax(); SfGradp = pEqn.flux()/Dp; - U1 += (fvc::reconstruct(phiDrag1 - rAU1f*SfGradp/rho1)); - //U1 += rAU1*(fvc::reconstruct(phiDrag1/rAU1f - SfGradp/rho1)); + U1 = HbyA1 + (fvc::reconstruct(phiDrag1 - rAU1f*SfGradp/rho1)); U1.correctBoundaryConditions(); - U2 += (fvc::reconstruct(phiDrag2 - rAU2f*SfGradp/rho2)); - //U2 += rAU2*(fvc::reconstruct(phiDrag2/rAU2f - SfGradp/rho2)); + U2 = HbyA2 + (fvc::reconstruct(phiDrag2 - rAU2f*SfGradp/rho2)); U2.correctBoundaryConditions(); U = alpha1*U1 + alpha2*U2; diff --git a/applications/solvers/multiphase/cavitatingFoam/createFields.H b/applications/solvers/multiphase/cavitatingFoam/createFields.H index 49c7de1473355e69429cf309091dc81aaea5a563..dbacf1dbd3f1c416bffccc6e2c3b5e7f67d4baf0 100644 --- a/applications/solvers/multiphase/cavitatingFoam/createFields.H +++ b/applications/solvers/multiphase/cavitatingFoam/createFields.H @@ -25,18 +25,28 @@ mesh ); - volScalarField gamma + Info<< "Reading field U\n" << endl; + volVectorField U ( IOobject ( - "gamma", + "U", runTime.timeName(), mesh, - IOobject::NO_READ, + IOobject::MUST_READ, IOobject::AUTO_WRITE ), - max(min((rho - rholSat)/(rhovSat - rholSat), scalar(1)), scalar(0)) + mesh ); + + #include "createPhiv.H" + #include "compressibleCreatePhi.H" + + Info<< "Reading transportProperties\n" << endl; + + twoPhaseMixture twoPhaseProperties(U, phiv, "gamma"); + + volScalarField& gamma(twoPhaseProperties.alpha1()); gamma.oldTime(); Info<< "Creating compressibilityModel\n" << endl; @@ -57,27 +67,6 @@ rhoMin ); - Info<< "Reading field U\n" << endl; - volVectorField U - ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - #include "createPhiv.H" - #include "compressibleCreatePhi.H" - - Info<< "Reading transportProperties\n" << endl; - - twoPhaseMixture twoPhaseProperties(U, phiv, "gamma"); - // Create incompressible turbulence model autoPtr<incompressible::turbulenceModel> turbulence ( diff --git a/applications/solvers/multiphase/cavitatingFoam/pEqn.H b/applications/solvers/multiphase/cavitatingFoam/pEqn.H index 34898172cea700cf3a9eaa9cb4c4808ed9d07ea9..ea35f79fa14c505d87f62be95f2bab9fd1c56bf9 100644 --- a/applications/solvers/multiphase/cavitatingFoam/pEqn.H +++ b/applications/solvers/multiphase/cavitatingFoam/pEqn.H @@ -12,7 +12,7 @@ surfaceScalarField rhof("rhof", fvc::interpolate(rho)); volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf("rAUf", rhof*fvc::interpolate(rAU)); + surfaceScalarField rAUf("Dp", rhof*fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); HbyA = rAU*UEqn.H(); diff --git a/applications/solvers/multiphase/compressibleInterFoam/Allwclean b/applications/solvers/multiphase/compressibleInterFoam/Allwclean index 2b936f934b86465239872eead52647f68585281e..2f4544cb4c0a192b4a83d7f39729bed83de3a23e 100755 --- a/applications/solvers/multiphase/compressibleInterFoam/Allwclean +++ b/applications/solvers/multiphase/compressibleInterFoam/Allwclean @@ -2,6 +2,7 @@ cd ${0%/*} || exit 1 # run from this directory set -x +wclean libso phaseEquationsOfState wclean wclean compressibleInterDyMFoam diff --git a/applications/solvers/multiphase/compressibleInterFoam/Allwmake b/applications/solvers/multiphase/compressibleInterFoam/Allwmake index 644094d070c06f795bc28a73aa33aa66db86114f..b4b7f6ffa7fbc5f1f247d108cdbe9270489850c1 100755 --- a/applications/solvers/multiphase/compressibleInterFoam/Allwmake +++ b/applications/solvers/multiphase/compressibleInterFoam/Allwmake @@ -2,6 +2,7 @@ cd ${0%/*} || exit 1 # run from this directory set -x +wmake libso phaseEquationsOfState wmake wmake compressibleInterDyMFoam diff --git a/applications/solvers/multiphase/compressibleInterFoam/Make/files b/applications/solvers/multiphase/compressibleInterFoam/Make/files index de5437219c00fd0ec616736c21ad3b570b7d9f5e..0e009f09bcd767c85f1541acab665277ce0f5175 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/Make/files +++ b/applications/solvers/multiphase/compressibleInterFoam/Make/files @@ -1,3 +1,4 @@ +derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.C compressibleInterFoam.C EXE = $(FOAM_APPBIN)/compressibleInterFoam diff --git a/applications/solvers/multiphase/compressibleInterFoam/Make/options b/applications/solvers/multiphase/compressibleInterFoam/Make/options index c8ce69c074b6f87f924a391ae8778b3f19e946ee..ca9a90cf77ff9ca13a6d06245e87bf179300fc1e 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/Make/options +++ b/applications/solvers/multiphase/compressibleInterFoam/Make/options @@ -2,12 +2,14 @@ EXE_INC = \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -IphaseEquationsOfState/lnInclude \ -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ -ltwoPhaseInterfaceProperties \ -lincompressibleTransportModels \ + -lphaseEquationsOfState \ -lincompressibleTurbulenceModel \ -lincompressibleRASModels \ -lincompressibleLESModels \ diff --git a/applications/solvers/multiphase/compressibleInterFoam/TEqn.H b/applications/solvers/multiphase/compressibleInterFoam/TEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..2605ce345a973f19d71f43f83bbc18a2070de16d --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/TEqn.H @@ -0,0 +1,20 @@ +{ + volScalarField kByCv + ( + "kByCv", + (alpha1*k1/Cv1 + alpha2*k2/Cv2) + + (alpha1*rho1 + alpha2*rho2)*turbulence->nut() + ); + + solve + ( + fvm::ddt(rho, T) + + fvm::div(rhoPhi, T) + - fvm::laplacian(kByCv, T) + + p*fvc::div(phi)*(alpha1/Cv1 + alpha2/Cv2) + ); + + // Update compressibilities + psi1 = eos1->psi(p, T); + psi2 = eos2->psi(p, T); +} diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/Make/options b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/Make/options index b9b0ec54daad947bcdc8beda5cc0acc93b435bc9..db259cfbc0163e1ba3ed20f8715937670c75e17d 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/Make/options +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/Make/options @@ -3,6 +3,7 @@ EXE_INC = \ -I$(LIB_SRC)/transportModels \ -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I../phaseEquationsOfState/lnInclude \ -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ @@ -12,6 +13,7 @@ EXE_INC = \ EXE_LIBS = \ -ltwoPhaseInterfaceProperties \ -lincompressibleTransportModels \ + -lphaseEquationsOfState \ -lincompressibleTurbulenceModel \ -lincompressibleRASModels \ -lincompressibleLESModels \ diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C index 1ac1596c4dbd1702fb0a4cf976226b331c2d11d7..b9f52944e84e453b1876b7afa368e516e1174d27 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/compressibleInterDyMFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ Application compressibleInterDyMFoam Description - Solver for 2 compressible, isothermal immiscible fluids using a VOF + Solver for 2 compressible, non-isothermal immiscible fluids using a VOF (volume of fluid) phase-fraction based interface capturing approach, with optional mesh motion and mesh topology changes including adaptive re-meshing. @@ -43,6 +43,7 @@ Description #include "subCycle.H" #include "interfaceProperties.H" #include "twoPhaseMixture.H" +#include "phaseEquationOfState.H" #include "turbulenceModel.H" #include "pimpleControl.H" @@ -124,11 +125,15 @@ int main(int argc, char *argv[]) solve(fvm::ddt(rho) + fvc::div(rhoPhi)); #include "UEqn.H" + #include "TEqn.H" // --- Pressure corrector loop while (pimple.correct()) { #include "pEqn.H" + + // Make the fluxes relative to the mesh motion + fvc::makeRelative(phi, U); } } diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/pEqn.H deleted file mode 100644 index 26666c41203f40d6ce9081648103f69d228f2060..0000000000000000000000000000000000000000 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/pEqn.H +++ /dev/null @@ -1,88 +0,0 @@ -{ - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); - - tmp<fvScalarMatrix> p_rghEqnComp; - - if (pimple.transonic()) - { - p_rghEqnComp = - ( - fvm::ddt(p_rgh) - + fvm::div(phi, p_rgh) - - fvm::Sp(fvc::div(phi), p_rgh) - ); - } - else - { - p_rghEqnComp = - ( - fvm::ddt(p_rgh) - + fvc::div(phi, p_rgh) - - fvc::Sp(fvc::div(phi), p_rgh) - ); - } - - - U = rAU*UEqn.H(); - - surfaceScalarField phiU - ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) - + fvc::ddtPhiCorr(rAU, rho, U, phi) - ); - - phi = phiU + - ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); - - while (pimple.correctNonOrthogonal()) - { - fvScalarMatrix p_rghEqnIncomp - ( - fvc::div(phi) - - fvm::laplacian(rAUf, p_rgh) - ); - - solve - ( - ( - max(alpha1, scalar(0))*(psi1/rho1) - + max(alpha2, scalar(0))*(psi2/rho2) - ) - *p_rghEqnComp() - + p_rghEqnIncomp, - mesh.solver(p_rgh.select(pimple.finalInnerIter())) - ); - - if (pimple.finalNonOrthogonalIter()) - { - dgdt = - (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) - *(p_rghEqnComp & p_rgh); - phi += p_rghEqnIncomp.flux(); - } - } - - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - - p = max - ( - (p_rgh + gh*(alpha1*rho10 + alpha2*rho20)) - /(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), - pMin - ); - - rho1 = rho10 + psi1*p; - rho2 = rho20 + psi2*p; - - Info<< "max(U) " << max(mag(U)).value() << endl; - Info<< "min(p_rgh) " << min(p_rgh).value() << endl; - - // Make the fluxes relative to the mesh motion - fvc::makeRelative(phi, U); -} diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C index 4ad1b3d01da6be39bcd818c33e989c9ec2986e23..7c24e05a1afbbcb4774a9934657cecb013e1ae03 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ Application compressibleInterFoam Description - Solver for 2 compressible, isothermal immiscible fluids using a VOF + Solver for 2 compressible, non-isothermal immiscible fluids using a VOF (volume of fluid) phase-fraction based interface capturing approach. The momentum and other fluid properties are of the "mixture" and a single @@ -40,6 +40,7 @@ Description #include "subCycle.H" #include "interfaceProperties.H" #include "twoPhaseMixture.H" +#include "phaseEquationOfState.H" #include "turbulenceModel.H" #include "pimpleControl.H" @@ -82,6 +83,7 @@ int main(int argc, char *argv[]) solve(fvm::ddt(rho) + fvc::div(rhoPhi)); #include "UEqn.H" + #include "TEqn.H" // --- Pressure corrector loop while (pimple.correct()) diff --git a/applications/solvers/multiphase/compressibleInterFoam/createFields.H b/applications/solvers/multiphase/compressibleInterFoam/createFields.H index c598cb75ce6f888500409a91246e0b95c50076d4..1c22600170bc1a4dbfa189d0041c341ee6256e63 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/createFields.H +++ b/applications/solvers/multiphase/compressibleInterFoam/createFields.H @@ -12,12 +12,12 @@ mesh ); - Info<< "Reading field alpha1\n" << endl; - volScalarField alpha1 + Info<< "Reading field U\n" << endl; + volVectorField U ( IOobject ( - "alpha1", + "U", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -26,15 +26,14 @@ mesh ); - Info<< "Calculating field alpha1\n" << endl; - volScalarField alpha2("alpha2", scalar(1) - alpha1); + #include "createPhi.H" - Info<< "Reading field U\n" << endl; - volVectorField U + Info<< "Reading field T\n" << endl; + volScalarField T ( IOobject ( - "U", + "T", runTime.timeName(), mesh, IOobject::MUST_READ, @@ -43,70 +42,127 @@ mesh ); - #include "createPhi.H" + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + p_rgh + ); Info<< "Reading transportProperties\n" << endl; twoPhaseMixture twoPhaseProperties(U, phi); - dimensionedScalar rho10 + volScalarField& alpha1(twoPhaseProperties.alpha1()); + + Info<< "Calculating phase-fraction alpha" << twoPhaseProperties.phase2Name() + << nl << endl; + volScalarField alpha2 ( + "alpha" + twoPhaseProperties.phase2Name(), + scalar(1) - alpha1 + ); + + dimensionedScalar k1 + ( + "k", + dimensionSet(1, 1, -3, -1, 0), twoPhaseProperties.subDict ( twoPhaseProperties.phase1Name() - ).lookup("rho0") + ).lookup("k") ); - dimensionedScalar rho20 + dimensionedScalar k2 ( + "k", + dimensionSet(1, 1, -3, -1, 0), twoPhaseProperties.subDict ( twoPhaseProperties.phase2Name() - ).lookup("rho0") + ).lookup("k") ); - dimensionedScalar psi1 + dimensionedScalar Cv1 ( + "Cv", + dimensionSet(0, 2, -2, -1, 0), twoPhaseProperties.subDict ( twoPhaseProperties.phase1Name() - ).lookup("psi") + ).lookup("Cv") ); - dimensionedScalar psi2 + dimensionedScalar Cv2 ( + "Cv", + dimensionSet(0, 2, -2, -1, 0), twoPhaseProperties.subDict ( twoPhaseProperties.phase2Name() - ).lookup("psi") + ).lookup("Cv") ); - dimensionedScalar pMin(twoPhaseProperties.lookup("pMin")); + autoPtr<phaseEquationOfState> eos1 + ( + phaseEquationOfState::New + ( + twoPhaseProperties.subDict + ( + twoPhaseProperties.phase1Name() + ) + ) + ); - Info<< "Calculating field g.h\n" << endl; - volScalarField gh("gh", g & mesh.C()); - surfaceScalarField ghf("ghf", g & mesh.Cf()); + autoPtr<phaseEquationOfState> eos2 + ( + phaseEquationOfState::New + ( + twoPhaseProperties.subDict + ( + twoPhaseProperties.phase2Name() + ) + ) + ); - volScalarField p + volScalarField psi1 ( IOobject ( - "p", + "psi1", runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE + mesh ), - max + eos1->psi(p, T) + ); + psi1.oldTime(); + + volScalarField psi2 + ( + IOobject ( - (p_rgh + gh*(alpha1*rho10 + alpha2*rho20)) - /(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), - pMin - ) + "psi2", + runTime.timeName(), + mesh + ), + eos2->psi(p, T) ); + psi2.oldTime(); + + dimensionedScalar pMin(twoPhaseProperties.lookup("pMin")); + + Info<< "Calculating field g.h\n" << endl; + volScalarField gh("gh", g & mesh.C()); + surfaceScalarField ghf("ghf", g & mesh.Cf()); - volScalarField rho1(rho10 + psi1*p); - volScalarField rho2(rho20 + psi2*p); + volScalarField rho1("rho1", eos1->rho(p, T)); + volScalarField rho2("rho2", eos2->rho(p, T)); volScalarField rho ( diff --git a/applications/solvers/multiphase/compressibleInterFoam/derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.C b/applications/solvers/multiphase/compressibleInterFoam/derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..e6782e8b3a9b1649a2053bea98af7becabbc51d1 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.C @@ -0,0 +1,184 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "wallHeatTransferFvPatchScalarField.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(p, iF), + Tinf_(p.size(), 0.0), + alphaWall_(p.size(), 0.0) +{ + refValue() = 0.0; + refGrad() = 0.0; + valueFraction() = 0.0; +} + + +Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField +( + const wallHeatTransferFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + mixedFvPatchScalarField(ptf, p, iF, mapper), + Tinf_(ptf.Tinf_, mapper), + alphaWall_(ptf.alphaWall_, mapper) +{} + + +Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + mixedFvPatchScalarField(p, iF), + Tinf_("Tinf", dict, p.size()), + alphaWall_("alphaWall", dict, p.size()) +{ + refValue() = Tinf_; + refGrad() = 0.0; + valueFraction() = 0.0; + + if (dict.found("value")) + { + fvPatchField<scalar>::operator= + ( + scalarField("value", dict, p.size()) + ); + } + else + { + evaluate(); + } +} + + +Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField +( + const wallHeatTransferFvPatchScalarField& tppsf +) +: + mixedFvPatchScalarField(tppsf), + Tinf_(tppsf.Tinf_), + alphaWall_(tppsf.alphaWall_) +{} + + +Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField +( + const wallHeatTransferFvPatchScalarField& tppsf, + const DimensionedField<scalar, volMesh>& iF +) +: + mixedFvPatchScalarField(tppsf, iF), + Tinf_(tppsf.Tinf_), + alphaWall_(tppsf.alphaWall_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::wallHeatTransferFvPatchScalarField::autoMap +( + const fvPatchFieldMapper& m +) +{ + scalarField::autoMap(m); + Tinf_.autoMap(m); + alphaWall_.autoMap(m); +} + + +void Foam::wallHeatTransferFvPatchScalarField::rmap +( + const fvPatchScalarField& ptf, + const labelList& addr +) +{ + mixedFvPatchScalarField::rmap(ptf, addr); + + const wallHeatTransferFvPatchScalarField& tiptf = + refCast<const wallHeatTransferFvPatchScalarField>(ptf); + + Tinf_.rmap(tiptf.Tinf_, addr); + alphaWall_.rmap(tiptf.alphaWall_, addr); +} + + +void Foam::wallHeatTransferFvPatchScalarField::updateCoeffs() +{ + if (updated()) + { + return; + } + + const fvPatchScalarField& Cpw = + patch().lookupPatchField<volScalarField, scalar>("Cp"); + + const fvPatchScalarField& kByCpw = + patch().lookupPatchField<volScalarField, scalar>("kByCp"); + + valueFraction() = + 1.0/ + ( + 1.0 + + Cpw*kByCpw*patch().deltaCoeffs()/alphaWall_ + ); + + mixedFvPatchScalarField::updateCoeffs(); +} + + +void Foam::wallHeatTransferFvPatchScalarField::write(Ostream& os) const +{ + fvPatchScalarField::write(os); + Tinf_.writeEntry("Tinf", os); + alphaWall_.writeEntry("alphaWall", os); + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makePatchTypeField(fvPatchScalarField, wallHeatTransferFvPatchScalarField); +} + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.H b/applications/solvers/multiphase/compressibleInterFoam/derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..cf5284a087d09fecd5df969ece76878f091ccd34 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/derivedFvPatchFields/wallHeatTransfer/wallHeatTransferFvPatchScalarField.H @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::wallHeatTransferFvPatchScalarField + +Description + Enthalpy boundary conditions for wall heat transfer + +SourceFiles + wallHeatTransferFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef wallHeatTransferFvPatchScalarField_H +#define wallHeatTransferFvPatchScalarField_H + +#include "mixedFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class wallHeatTransferFvPatch Declaration +\*---------------------------------------------------------------------------*/ + +class wallHeatTransferFvPatchScalarField +: + public mixedFvPatchScalarField +{ + // Private data + + //- Tinf + scalarField Tinf_; + + //- alphaWall + scalarField alphaWall_; + + +public: + + //- Runtime type information + TypeName("wallHeatTransfer"); + + + // Constructors + + //- Construct from patch and internal field + wallHeatTransferFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + wallHeatTransferFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given wallHeatTransferFvPatchScalarField + // onto a new patch + wallHeatTransferFvPatchScalarField + ( + const wallHeatTransferFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + wallHeatTransferFvPatchScalarField + ( + const wallHeatTransferFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new wallHeatTransferFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + wallHeatTransferFvPatchScalarField + ( + const wallHeatTransferFvPatchScalarField&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp<fvPatchScalarField> clone + ( + const DimensionedField<scalar, volMesh>& iF + ) const + { + return tmp<fvPatchScalarField> + ( + new wallHeatTransferFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Access + + //- Return Tinf + const scalarField& Tinf() const + { + return Tinf_; + } + + //- Return reference to Tinf to allow adjustment + scalarField& Tinf() + { + return Tinf_; + } + + //- Return alphaWall + const scalarField& alphaWall() const + { + return alphaWall_; + } + + //- Return reference to alphaWall to allow adjustment + scalarField& alphaWall() + { + return alphaWall_; + } + + + // Mapping functions + + //- Map (and resize as needed) from self given a mapping object + virtual void autoMap + ( + const fvPatchFieldMapper& + ); + + //- Reverse map the given fvPatchField onto this fvPatchField + virtual void rmap + ( + const fvPatchScalarField&, + const labelList& + ); + + + // Evaluation 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/multiphase/compressibleInterFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H index 035e8e237da1b02591154623c3b5ec90c1ea14d2..9e67a47c4f006bbe357049531d5855034c0d0d8b 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/pEqn.H @@ -1,84 +1,97 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + rho1 = eos1->rho(p, T); + rho2 = eos2->rho(p, T); - tmp<fvScalarMatrix> p_rghEqnComp; + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - if (pimple.transonic()) - { - p_rghEqnComp = - ( - fvm::ddt(p_rgh) - + fvm::div(phi, p_rgh) - - fvm::Sp(fvc::div(phi), p_rgh) - ); - } - else + tmp<fvScalarMatrix> p_rghEqnComp1; + tmp<fvScalarMatrix> p_rghEqnComp2; + + //if (transonic) + //{ + //} + //else { - p_rghEqnComp = - ( - fvm::ddt(p_rgh) - + fvc::div(phi, p_rgh) - - fvc::Sp(fvc::div(phi), p_rgh) - ); - } + surfaceScalarField phid1("phid1", fvc::interpolate(psi1)*phi); + surfaceScalarField phid2("phid2", fvc::interpolate(psi2)*phi); + p_rghEqnComp1 = + fvc::ddt(rho1) + psi1*correction(fvm::ddt(p_rgh)) + + fvc::div(phid1, p_rgh) + - fvc::Sp(fvc::div(phid1), p_rgh); - U = rAU*UEqn.H(); + p_rghEqnComp2 = + fvc::ddt(rho2) + psi2*correction(fvm::ddt(p_rgh)) + + fvc::div(phid2, p_rgh) + - fvc::Sp(fvc::div(phid2), p_rgh); + } - surfaceScalarField phiU + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + + surfaceScalarField phiHbyA ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ); - phi = phiU + + surfaceScalarField phig + ( ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + )*rAUf*mesh.magSf() + ); + + phiHbyA += phig; + + // Thermodynamic density needs to be updated by psi*d(p) after the + // pressure solution - done in 2 parts. Part 1: + //thermo.rho() -= psi*p_rgh; while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqnIncomp ( - fvc::div(phi) + fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh) ); solve ( ( - max(alpha1, scalar(0))*(psi1/rho1) - + max(alpha2, scalar(0))*(psi2/rho2) + (max(alpha1, scalar(0))/rho1)*p_rghEqnComp1() + + (max(alpha2, scalar(0))/rho2)*p_rghEqnComp2() ) - *p_rghEqnComp() + p_rghEqnIncomp, mesh.solver(p_rgh.select(pimple.finalInnerIter())) ); if (pimple.finalNonOrthogonalIter()) { + // Second part of thermodynamic density update + //thermo.rho() += psi*p_rgh; + dgdt = - (pos(alpha2)*(psi2/rho2) - pos(alpha1)*(psi1/rho1)) - *(p_rghEqnComp & p_rgh); - phi += p_rghEqnIncomp.flux(); + ( + pos(alpha2)*(p_rghEqnComp2 & p_rgh)/rho2 + - pos(alpha1)*(p_rghEqnComp1 & p_rgh)/rho1 + ); + + phi = phiHbyA + p_rghEqnIncomp.flux(); + + U = HbyA + + rAU*fvc::reconstruct((phig + p_rghEqnIncomp.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - - p = max - ( - (p_rgh + gh*(alpha1*rho10 + alpha2*rho20)) - /(1.0 - gh*(alpha1*psi1 + alpha2*psi2)), - pMin - ); + p = max(p_rgh + (alpha1*rho1 + alpha2*rho2)*gh, pMin); - rho1 = rho10 + psi1*p; - rho2 = rho20 + psi2*p; + rho1 = eos1->rho(p, T); + rho2 = eos2->rho(p, T); Info<< "max(U) " << max(mag(U)).value() << endl; Info<< "min(p_rgh) " << min(p_rgh).value() << endl; diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/Make/files b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..e6e260c74a68a195bde00195048386638e1c11f7 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/Make/files @@ -0,0 +1,8 @@ +phaseEquationOfState/phaseEquationOfState.C +phaseEquationOfState/newPhaseEquationOfState.C +constant/constant.C +linear/linear.C +perfectFluid/perfectFluid.C +adiabaticPerfectFluid/adiabaticPerfectFluid.C + +LIB = $(FOAM_LIBBIN)/libphaseEquationsOfState diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/Make/options b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..0ec11392098bd862e78e2790e25cf1f49ec557fd --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude + +LIB_LIBS = \ + -lincompressibleTransportModels diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/adiabaticPerfectFluid/adiabaticPerfectFluid.C b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/adiabaticPerfectFluid/adiabaticPerfectFluid.C new file mode 100644 index 0000000000000000000000000000000000000000..82a195dca955430147ad60e125aeb61721a83a7c --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/adiabaticPerfectFluid/adiabaticPerfectFluid.C @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "adiabaticPerfectFluid.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + defineTypeNameAndDebug(adiabaticPerfectFluid, 0); + + addToRunTimeSelectionTable + ( + phaseEquationOfState, + adiabaticPerfectFluid, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::adiabaticPerfectFluid::adiabaticPerfectFluid +( + const dictionary& dict +) +: + phaseEquationOfState(dict), + p0_("p0", dimPressure, dict.lookup("p0")), + rho0_("rho0", dimDensity, dict.lookup("rho0")), + gamma_("gamma", dimless, dict.lookup("gamma")), + B_("B", dimPressure, dict.lookup("B")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::adiabaticPerfectFluid::~adiabaticPerfectFluid() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> +Foam::phaseEquationsOfState::adiabaticPerfectFluid::rho +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "rho", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + rho0_*pow((p + B_)/(p0_ + B_), 1.0/gamma_) + ) + ); +} + + +Foam::tmp<Foam::volScalarField> +Foam::phaseEquationsOfState::adiabaticPerfectFluid::psi +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "psi", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + (rho0_/(gamma_*(p0_ + B_))) + *pow((p + B_)/(p0_ + B_), 1.0/gamma_ - 1.0) + ) + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/adiabaticPerfectFluid/adiabaticPerfectFluid.H b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/adiabaticPerfectFluid/adiabaticPerfectFluid.H new file mode 100644 index 0000000000000000000000000000000000000000..49f5218e4928119b189a16ad63b896d5c5dfd293 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/adiabaticPerfectFluid/adiabaticPerfectFluid.H @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::phaseEquationsOfState::adiabaticPerfectFluid + +Description + AdiabaticPerfectFluid phase density model. + +SourceFiles + adiabaticPerfectFluid.C + +\*---------------------------------------------------------------------------*/ + +#ifndef adiabaticPerfectFluid_H +#define adiabaticPerfectFluid_H + +#include "phaseEquationOfState.H" +#include "dimensionedTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + +/*---------------------------------------------------------------------------*\ + Class adiabaticPerfectFluid Declaration +\*---------------------------------------------------------------------------*/ + +class adiabaticPerfectFluid +: + public phaseEquationOfState +{ + // Private data + + //- Reference pressure + dimensionedScalar p0_; + + //- Reference density + dimensionedScalar rho0_; + + //- The isentropic exponent + dimensionedScalar gamma_; + + //- Pressure offset for a stiffened gas + dimensionedScalar B_; + + +public: + + //- Runtime type information + TypeName("adiabaticPerfectFluid"); + + + // Constructors + + //- Construct from components + adiabaticPerfectFluid + ( + const dictionary& dict + ); + + + //- Destructor + virtual ~adiabaticPerfectFluid(); + + + // Member Functions + + tmp<volScalarField> rho + ( + const volScalarField& p, + const volScalarField& T + ) const; + + tmp<volScalarField> psi + ( + const volScalarField& p, + const volScalarField& T + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace phaseEquationsOfState +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/constant/constant.C b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/constant/constant.C new file mode 100644 index 0000000000000000000000000000000000000000..54b6705dd9e1597cf6c37bbbaa02bef1ed5c9492 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/constant/constant.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "constant.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + defineTypeNameAndDebug(constant, 0); + + addToRunTimeSelectionTable + ( + phaseEquationOfState, + constant, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::constant::constant +( + const dictionary& dict +) +: + phaseEquationOfState(dict), + rho_("rho", dimDensity, dict.lookup("rho")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::constant::~constant() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> Foam::phaseEquationsOfState::constant::rho +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "rho", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + p.mesh(), + rho_ + ) + ); +} + + +Foam::tmp<Foam::volScalarField> Foam::phaseEquationsOfState::constant::psi +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "psi", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + p.mesh(), + dimensionedScalar("psi", dimDensity/dimPressure, 0) + ) + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/constant/constant.H b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/constant/constant.H new file mode 100644 index 0000000000000000000000000000000000000000..5cfe44c26e4546d5f6f19803fdaf63dd98eb5cc6 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/constant/constant.H @@ -0,0 +1,106 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::phaseEquationsOfState::constant + +Description + Constant phase density model. + +SourceFiles + constant.C + +\*---------------------------------------------------------------------------*/ + +#ifndef constant_H +#define constant_H + +#include "phaseEquationOfState.H" +#include "dimensionedTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + +/*---------------------------------------------------------------------------*\ + Class constant Declaration +\*---------------------------------------------------------------------------*/ + +class constant +: + public phaseEquationOfState +{ + // Private data + + //- The constant density of the phase + dimensionedScalar rho_; + + +public: + + //- Runtime type information + TypeName("constant"); + + + // Constructors + + //- Construct from components + constant + ( + const dictionary& dict + ); + + + //- Destructor + virtual ~constant(); + + + // Member Functions + + tmp<volScalarField> rho + ( + const volScalarField& p, + const volScalarField& T + ) const; + + tmp<volScalarField> psi + ( + const volScalarField& p, + const volScalarField& T + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace phaseEquationsOfState +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/linear/linear.C b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/linear/linear.C new file mode 100644 index 0000000000000000000000000000000000000000..3680735a1bccfa2d61f1dc1abe980ee4db2a8e42 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/linear/linear.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "linear.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + defineTypeNameAndDebug(linear, 0); + + addToRunTimeSelectionTable + ( + phaseEquationOfState, + linear, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::linear::linear +( + const dictionary& dict +) +: + phaseEquationOfState(dict), + rho0_("rho0", dimDensity, dict.lookup("rho0")), + psi_("psi", dimDensity/dimPressure, dict.lookup("psi")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::linear::~linear() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> Foam::phaseEquationsOfState::linear::rho +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "rho", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + rho0_ + psi_*p + ) + ); +} + + +Foam::tmp<Foam::volScalarField> Foam::phaseEquationsOfState::linear::psi +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "psi", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + p.mesh(), + psi_ + ) + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/linear/linear.H b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/linear/linear.H new file mode 100644 index 0000000000000000000000000000000000000000..d357bb3ec08884a45571588abb6353907bcc49c5 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/linear/linear.H @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::phaseEquationsOfState::linear + +Description + Linear phase density model. + +SourceFiles + linear.C + +\*---------------------------------------------------------------------------*/ + +#ifndef linear_H +#define linear_H + +#include "phaseEquationOfState.H" +#include "dimensionedTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + +/*---------------------------------------------------------------------------*\ + Class linear Declaration +\*---------------------------------------------------------------------------*/ + +class linear +: + public phaseEquationOfState +{ + // Private data + + //- The reference density of the phase + dimensionedScalar rho0_; + + //- The constant compressibility of the phase + dimensionedScalar psi_; + + +public: + + //- Runtime type information + TypeName("linear"); + + + // Constructors + + //- Construct from components + linear + ( + const dictionary& dict + ); + + + //- Destructor + virtual ~linear(); + + + // Member Functions + + tmp<volScalarField> rho + ( + const volScalarField& p, + const volScalarField& T + ) const; + + tmp<volScalarField> psi + ( + const volScalarField& p, + const volScalarField& T + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace phaseEquationsOfState +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/perfectFluid/perfectFluid.C b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/perfectFluid/perfectFluid.C new file mode 100644 index 0000000000000000000000000000000000000000..6a148d8d689a77c28b511265ce55255c0e34b725 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/perfectFluid/perfectFluid.C @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "perfectFluid.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + defineTypeNameAndDebug(perfectFluid, 0); + + addToRunTimeSelectionTable + ( + phaseEquationOfState, + perfectFluid, + dictionary + ); +} +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::perfectFluid::perfectFluid +( + const dictionary& dict +) +: + phaseEquationOfState(dict), + rho0_("rho0", dimDensity, dict.lookup("rho0")), + R_("R", dimensionSet(0, 2, -2, -1, 0), dict.lookup("R")) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::phaseEquationsOfState::perfectFluid::~perfectFluid() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> Foam::phaseEquationsOfState::perfectFluid::rho +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "rho", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + rho0_ + psi(p, T)*p + ) + ); +} + + +Foam::tmp<Foam::volScalarField> Foam::phaseEquationsOfState::perfectFluid::psi +( + const volScalarField& p, + const volScalarField& T +) const +{ + return tmp<Foam::volScalarField> + ( + new volScalarField + ( + IOobject + ( + "psi", + p.time().timeName(), + p.mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + 1.0/(R_*T) + ) + ); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/perfectFluid/perfectFluid.H b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/perfectFluid/perfectFluid.H new file mode 100644 index 0000000000000000000000000000000000000000..b854f1d84fb6b7ed6a2d7c1ae399f7fa1c9eeaef --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/perfectFluid/perfectFluid.H @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::phaseEquationsOfState::perfectFluid + +Description + PerfectFluid phase density model. + +SourceFiles + perfectFluid.C + +\*---------------------------------------------------------------------------*/ + +#ifndef perfectFluid_H +#define perfectFluid_H + +#include "phaseEquationOfState.H" +#include "dimensionedTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace phaseEquationsOfState +{ + +/*---------------------------------------------------------------------------*\ + Class perfectFluid Declaration +\*---------------------------------------------------------------------------*/ + +class perfectFluid +: + public phaseEquationOfState +{ + // Private data + + //- The reference density of the phase + dimensionedScalar rho0_; + + //- The fluid constant of the phase + dimensionedScalar R_; + + +public: + + //- Runtime type information + TypeName("perfectFluid"); + + + // Constructors + + //- Construct from components + perfectFluid + ( + const dictionary& dict + ); + + + //- Destructor + virtual ~perfectFluid(); + + + // Member Functions + + tmp<volScalarField> rho + ( + const volScalarField& p, + const volScalarField& T + ) const; + + tmp<volScalarField> psi + ( + const volScalarField& p, + const volScalarField& T + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace phaseEquationsOfState +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/newPhaseEquationOfState.C b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/newPhaseEquationOfState.C new file mode 100644 index 0000000000000000000000000000000000000000..3d9a842a9f31e171e5901c3ac5322f7d4bf1372a --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/newPhaseEquationOfState.C @@ -0,0 +1,60 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "phaseEquationOfState.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +Foam::autoPtr<Foam::phaseEquationOfState> Foam::phaseEquationOfState::New +( + const dictionary& dict +) +{ + word phaseEquationOfStateType + ( + dict.subDict("equationOfState").lookup("type") + ); + + Info<< "Selecting phaseEquationOfState " + << phaseEquationOfStateType << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(phaseEquationOfStateType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn("phaseEquationOfState::New") + << "Unknown phaseEquationOfStateType type " + << phaseEquationOfStateType << endl << endl + << "Valid phaseEquationOfState types are : " << endl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return cstrIter()(dict.subDict("equationOfState")); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/phaseEquationOfState.C b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/phaseEquationOfState.C new file mode 100644 index 0000000000000000000000000000000000000000..41ed49322b2a8c5dea3003a96969670e56408240 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/phaseEquationOfState.C @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "phaseEquationOfState.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(phaseEquationOfState, 0); + defineRunTimeSelectionTable(phaseEquationOfState, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::phaseEquationOfState::phaseEquationOfState +( + const dictionary& dict +) +: + dict_(dict) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::phaseEquationOfState::~phaseEquationOfState() +{} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/phaseEquationOfState.H b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/phaseEquationOfState.H new file mode 100644 index 0000000000000000000000000000000000000000..45a5079d0d98671696515eb1deed507b3cfcf881 --- /dev/null +++ b/applications/solvers/multiphase/compressibleInterFoam/phaseEquationsOfState/phaseEquationOfState/phaseEquationOfState.H @@ -0,0 +1,127 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::phaseEquationOfState + +Description + A2stract base-class for dispersed-phase particle diameter models. + +SourceFiles + phaseEquationOfState.C + newDiameterModel.C + +\*---------------------------------------------------------------------------*/ + +#ifndef phaseEquationOfState_H +#define phaseEquationOfState_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "dictionary.H" +#include "volFieldsFwd.H" +#include "runTimeSelectionTables.H" + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class phaseEquationOfState Declaration +\*---------------------------------------------------------------------------*/ + +class phaseEquationOfState +{ +protected: + + // Protected data + + const dictionary& dict_; + + +public: + + //- Runtime type information + TypeName("phaseEquationOfState"); + + + // Declare runtime construction + + declareRunTimeSelectionTable + ( + autoPtr, + phaseEquationOfState, + dictionary, + ( + const dictionary& dict + ), + (dict) + ); + + + // Constructors + + phaseEquationOfState + ( + const dictionary& dict + ); + + + //- Destructor + virtual ~phaseEquationOfState(); + + + // Selectors + + static autoPtr<phaseEquationOfState> New + ( + const dictionary& dict + ); + + + // Member Functions + + //- Return the phase density + virtual tmp<volScalarField> rho + ( + const volScalarField& p, + const volScalarField& T + ) const = 0; + + //- Return the phase compressibility + virtual tmp<volScalarField> psi + ( + const volScalarField& p, + const volScalarField& T + ) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/interFoam/MRFInterFoam/pEqn.H b/applications/solvers/multiphase/interFoam/MRFInterFoam/pEqn.H index 6fc51c7ceee25475e2558ce7549960caf20ff54c..9c56c4d26f3e9d975d931647734b4f0d94e26ef0 100644 --- a/applications/solvers/multiphase/interFoam/MRFInterFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/MRFInterFoam/pEqn.H @@ -1,29 +1,35 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - U = rAU*UEqn.H(); - surfaceScalarField phiU + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + + surfaceScalarField phiHbyA ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ); - mrfZones.relativeFlux(phiU); + mrfZones.relativeFlux(phiHbyA); - adjustPhi(phiU, U, p_rgh); + adjustPhi(phiHbyA, U, p_rgh); - phi = phiU + + surfaceScalarField phig ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + )*rAUf*mesh.magSf() + ); + + phiHbyA += phig; while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( - fvm::laplacian(rAUf, p_rgh) == fvc::div(phi) + fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA) ); p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); @@ -32,13 +38,13 @@ if (pimple.finalNonOrthogonalIter()) { - phi -= p_rghEqn.flux(); + phi = phiHbyA - p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - #include "continuityErrs.H" p == p_rgh + rho*gh; diff --git a/applications/solvers/multiphase/interFoam/createFields.H b/applications/solvers/multiphase/interFoam/createFields.H index 34dea334e8f16875cee4fa26f4f7ea73a2af5d6f..68765262dbad5fe9d18156fad26d8bf839eabb3e 100644 --- a/applications/solvers/multiphase/interFoam/createFields.H +++ b/applications/solvers/multiphase/interFoam/createFields.H @@ -12,20 +12,6 @@ mesh ); - Info<< "Reading field alpha1\n" << endl; - volScalarField alpha1 - ( - IOobject - ( - "alpha1", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - Info<< "Reading field U\n" << endl; volVectorField U ( @@ -46,6 +32,8 @@ Info<< "Reading transportProperties\n" << endl; twoPhaseMixture twoPhaseProperties(U, phi); + volScalarField& alpha1(twoPhaseProperties.alpha1()); + const dimensionedScalar& rho1 = twoPhaseProperties.rho1(); const dimensionedScalar& rho2 = twoPhaseProperties.rho2(); diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H index d94e075424aa1539099cf7e62c29612c0ee373fc..d942f2c5012634b2639e206b3e7a64aad7e6f375 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H @@ -1,31 +1,39 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - U = rAU*UEqn.H(); + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); - phiAbs = - (fvc::interpolate(U) & mesh.Sf()) - + fvc::ddtPhiCorr(rAU, rho, U, phiAbs); + surfaceScalarField phiHbyA + ( + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, rho, U, phiAbs) + ); if (p_rgh.needReference()) { - fvc::makeRelative(phiAbs, U); - adjustPhi(phiAbs, U, p_rgh); - fvc::makeAbsolute(phiAbs, U); + fvc::makeRelative(phiHbyA, U); + adjustPhi(phiHbyA, U, p_rgh); + fvc::makeAbsolute(phiHbyA, U); } - phi = phiAbs + + surfaceScalarField phig ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + )*rAUf*mesh.magSf() + ); + + phiHbyA += phig; while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( - fvm::laplacian(rAUf, p_rgh) == fvc::div(phi) + fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA) ); p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); @@ -34,13 +42,13 @@ if (pimple.finalNonOrthogonalIter()) { - phi -= p_rghEqn.flux(); + phi = phiHbyA - p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiAbs)/rAUf); - U.correctBoundaryConditions(); - #include "continuityErrs.H" phiAbs = phi; diff --git a/applications/solvers/multiphase/interFoam/pEqn.H b/applications/solvers/multiphase/interFoam/pEqn.H index a88b5627e2d8944bf97343eb8eca3f9b86a9f66b..d1bc7bf1edc008f2ca359b63bc60e0cc878bef36 100644 --- a/applications/solvers/multiphase/interFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/pEqn.H @@ -1,28 +1,34 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - U = rAU*UEqn.H(); - surfaceScalarField phiU + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + + surfaceScalarField phiHbyA ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ); - adjustPhi(phiU, U, p_rgh); + adjustPhi(phiHbyA, U, p_rgh); - phi = phiU + + surfaceScalarField phig ( - fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + ( + fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) + - ghf*fvc::snGrad(rho) + )*rAUf*mesh.magSf() + ); + + phiHbyA += phig; while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( - fvm::laplacian(rAUf, p_rgh) == fvc::div(phi) + fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA) ); p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); @@ -31,13 +37,13 @@ if (pimple.finalNonOrthogonalIter()) { - phi -= p_rghEqn.flux(); + phi = phiHbyA - p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - #include "continuityErrs.H" p == p_rgh + rho*gh; diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/pEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/pEqn.H index c9b65eb9d5a575e3b05f4487685f2d477b41559e..e3ef0dc9efb43c0bc48016b29401c2a31d75b668 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/pEqn.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/pEqn.H @@ -1,24 +1,28 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - U = rAU*UEqn.H(); + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); - surfaceScalarField phiU + surfaceScalarField phiHbyA ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ); - adjustPhi(phiU, U, p_rgh); + adjustPhi(phiHbyA, U, p_rgh); - phi = - phiU - + ( + surfaceScalarField phig + ( + ( fvc::interpolate(interface.sigmaK())*fvc::snGrad(alpha1) - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + )*rAUf*mesh.magSf() + ); + + phiHbyA += phig; Pair<tmp<volScalarField> > vDotP = twoPhaseProperties->vDotP(); const volScalarField& vDotcP = vDotP[0](); @@ -28,7 +32,7 @@ { fvScalarMatrix p_rghEqn ( - fvc::div(phi) - fvm::laplacian(rAUf, p_rgh) + fvc::div(phiHbyA) - fvm::laplacian(rAUf, p_rgh) - (vDotvP - vDotcP)*(pSat - rho*gh) + fvm::Sp(vDotvP - vDotcP, p_rgh) ); @@ -38,13 +42,13 @@ if (pimple.finalNonOrthogonalIter()) { - phi += p_rghEqn.flux(); + phi = phiHbyA + p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig + p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - #include "continuityErrs.H" p == p_rgh + rho*gh; diff --git a/applications/solvers/multiphase/multiphaseInterFoam/MRFMultiphaseInterFoam/pEqn.H b/applications/solvers/multiphase/multiphaseInterFoam/MRFMultiphaseInterFoam/pEqn.H index efb181f3f2d31740bdd8ea6c41c2d734bd06c2b2..7bc1eeb12cd6765cfd76bf229f3c69a8c2964f0e 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/MRFMultiphaseInterFoam/pEqn.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/MRFMultiphaseInterFoam/pEqn.H @@ -1,31 +1,32 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - U = rAU*UEqn.H(); + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); - surfaceScalarField phiU + surfaceScalarField phiHbyA ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) - //+ fvc::ddtPhiCorr(rAU, rho, U, phi) + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, rho, U, phi) ); - mrfZones.relativeFlux(phiU); + mrfZones.relativeFlux(phiHbyA); - adjustPhi(phiU, U, p_rgh); + adjustPhi(phiHbyA, U, p_rgh); - phi = - phiU - + ( - mixture.surfaceTensionForce() - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + surfaceScalarField phig + ( + - ghf*fvc::snGrad(rho)*rAUf*mesh.magSf() + ); + + phiHbyA += phig; while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( - fvm::laplacian(rAUf, p_rgh) == fvc::div(phi) + fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA) ); p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); @@ -34,13 +35,13 @@ if (pimple.finalNonOrthogonalIter()) { - phi -= p_rghEqn.flux(); + phi = phiHbyA - p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - #include "continuityErrs.H" p == p_rgh + rho*gh; diff --git a/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H b/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H index e7e5bc14cfc81ec2e1f4484f8ef39a6f1142fde3..c1e346ce43b26e945a9a270fd34d270737e59e86 100644 --- a/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H +++ b/applications/solvers/multiphase/multiphaseInterFoam/pEqn.H @@ -1,29 +1,34 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - U = rAU*UEqn.H(); + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); - surfaceScalarField phiU + surfaceScalarField phiHbyA ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ); - adjustPhi(phiU, U, p_rgh); + adjustPhi(phiHbyA, U, p_rgh); - phi = phiU + + surfaceScalarField phig ( - mixture.surfaceTensionForce() - - ghf*fvc::snGrad(rho) - )*rAUf*mesh.magSf(); + ( + mixture.surfaceTensionForce() + - ghf*fvc::snGrad(rho) + )*rAUf*mesh.magSf() + ); + + phiHbyA += phig; while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( - fvm::laplacian(rAUf, p_rgh) == fvc::div(phi) + fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA) ); p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); @@ -32,13 +37,13 @@ if (pimple.finalNonOrthogonalIter()) { - phi -= p_rghEqn.flux(); + phi = phiHbyA - p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - #include "continuityErrs.H" p == p_rgh + rho*gh; diff --git a/applications/solvers/multiphase/settlingFoam/pEqn.H b/applications/solvers/multiphase/settlingFoam/pEqn.H index d89fd3ef4ed05a3ea20b812f4d76ebf70ee24dec..9f27e992a89188859d93458a2ec2c444afa0be1c 100644 --- a/applications/solvers/multiphase/settlingFoam/pEqn.H +++ b/applications/solvers/multiphase/settlingFoam/pEqn.H @@ -1,54 +1,61 @@ -volScalarField rAU(1.0/UEqn.A()); - -surfaceScalarField rAUf -( - "(rho*(1|A(U)))", - fvc::interpolate(rho)*fvc::interpolate(rAU) -); - -U = rAU*UEqn.H(); -phi = - fvc::interpolate(rho) - *( - (fvc::interpolate(U) & mesh.Sf()) - + fvc::ddtPhiCorr(rAU, rho, U, phi) - ); +{ + volScalarField rAU("rAU", 1.0/UEqn.A()); -surfaceScalarField phiU("phiU", phi); -phi -= ghf*fvc::snGrad(rho)*rAUf*mesh.magSf(); + surfaceScalarField rAUf("Dp", fvc::interpolate(rho*rAU)); -while (pimple.correctNonOrthogonal()) -{ - fvScalarMatrix p_rghEqn + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + + surfaceScalarField phiHbyA ( - fvm::laplacian(rAUf, p_rgh) == fvc::ddt(rho) + fvc::div(phi) + "phiHbyA", + fvc::interpolate(rho) + *( + (fvc::interpolate(HbyA) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, rho, U, phi) + ) ); - p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); + surfaceScalarField phig + ( + - ghf*fvc::snGrad(rho)*rAUf*mesh.magSf() + ); - p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter()))); + phiHbyA += phig; - if (pimple.finalNonOrthogonalIter()) + while (pimple.correctNonOrthogonal()) { - phi -= p_rghEqn.flux(); - } -} + fvScalarMatrix p_rghEqn + ( + fvm::laplacian(rAUf, p_rgh) == fvc::ddt(rho) + fvc::div(phiHbyA) + ); -p == p_rgh + rho*gh; + p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); -if (p_rgh.needReference()) -{ - p += dimensionedScalar - ( - "p", - p.dimensions(), - pRefValue - getRefCellValue(p, pRefCell) - ); - p_rgh = p - rho*gh; -} + p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter()))); + + if (pimple.finalNonOrthogonalIter()) + { + phi = phiHbyA - p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); + } + } -#include "rhoEqn.H" -#include "compressibleContinuityErrs.H" + p == p_rgh + rho*gh; -U += rAU*fvc::reconstruct((phi - phiU)/rAUf); -U.correctBoundaryConditions(); + if (p_rgh.needReference()) + { + p += dimensionedScalar + ( + "p", + p.dimensions(), + pRefValue - getRefCellValue(p, pRefCell) + ); + p_rgh = p - rho*gh; + } + + #include "rhoEqn.H" + #include "compressibleContinuityErrs.H" +} diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H b/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H index 73af502ce2bc521d8c7d3cdb43d58f1cba4e56ea..0d01b9a9e5ed82abc4a0420ece0ca464830b7b97 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/createFields.H @@ -12,20 +12,6 @@ mesh ); - Info<< "Reading field alpha1\n" << endl; - volScalarField alpha1 - ( - IOobject - ( - "alpha1", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - Info<< "Reading field U\n" << endl; volVectorField U ( @@ -45,6 +31,8 @@ Info<< "Reading transportProperties\n" << endl; twoPhaseMixture twoPhaseProperties(U, phi); + volScalarField& alpha1(twoPhaseProperties.alpha1()); + const dimensionedScalar& rho1 = twoPhaseProperties.rho1(); const dimensionedScalar& rho2 = twoPhaseProperties.rho2(); diff --git a/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H b/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H index ac7fc35f68b9c55fecb6b1c2f8f0653abf7f9b68..ddfca4e3ea85924615cbebd652a343e4496b1115 100644 --- a/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H +++ b/applications/solvers/multiphase/twoLiquidMixingFoam/pEqn.H @@ -1,24 +1,31 @@ { - volScalarField rAU(1.0/UEqn.A()); - surfaceScalarField rAUf(fvc::interpolate(rAU)); + volScalarField rAU("rAU", 1.0/UEqn.A()); + surfaceScalarField rAUf("Dp", fvc::interpolate(rAU)); - U = rAU*UEqn.H(); - surfaceScalarField phiU + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + + surfaceScalarField phiHbyA ( - "phiU", - (fvc::interpolate(U) & mesh.Sf()) + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + fvc::ddtPhiCorr(rAU, rho, U, phi) ); - adjustPhi(phiU, U, p_rgh); + adjustPhi(phiHbyA, U, p_rgh); + + surfaceScalarField phig + ( + - ghf*fvc::snGrad(rho)*rAUf*mesh.magSf() + ); - phi = phiU - ghf*fvc::snGrad(rho)*rAUf*mesh.magSf(); + phiHbyA += phig; while (pimple.correctNonOrthogonal()) { fvScalarMatrix p_rghEqn ( - fvm::laplacian(rAUf, p_rgh) == fvc::div(phi) + fvm::laplacian(rAUf, p_rgh) == fvc::div(phiHbyA) ); p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); @@ -27,13 +34,13 @@ if (pimple.finalNonOrthogonalIter()) { - phi -= p_rghEqn.flux(); + phi = phiHbyA - p_rghEqn.flux(); + + U = HbyA + rAU*fvc::reconstruct((phig - p_rghEqn.flux())/rAUf); + U.correctBoundaryConditions(); } } - U += rAU*fvc::reconstruct((phi - phiU)/rAUf); - U.correctBoundaryConditions(); - #include "continuityErrs.H" p == p_rgh + rho*gh; diff --git a/applications/test/LduMatrix/LduMatrixTest.C b/applications/test/LduMatrix/LduMatrixTest.C new file mode 100644 index 0000000000000000000000000000000000000000..13038bef459b5f96a69f9c4918de3d04e6acc0f3 --- /dev/null +++ b/applications/test/LduMatrix/LduMatrixTest.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "fvMesh.H" +#include "volFields.H" +#include "LduMatrix.H" +#include "diagTensorField.H" +#include "TPCG.H" +#include "TPBiCG.H" +#include "NoPreconditioner.H" + +using namespace Foam; + +typedef Foam::LduMatrix<vector, diagTensor, scalar> + lduVectorMatrix; +defineNamedTemplateTypeNameAndDebug(lduVectorMatrix, 0); + +typedef Foam::DiagonalSolver<vector, diagTensor, scalar> + lduVectorDiagonalSolver; +defineNamedTemplateTypeNameAndDebug(lduVectorDiagonalSolver, 0); + +template<> +const vector lduVectorMatrix::great_(1e15, 1e15, 1e15); + +template<> +const vector lduVectorMatrix::small_(1e-15, 1e-15, 1e-15); + +namespace Foam +{ + typedef LduMatrix<vector, diagTensor, scalar>::preconditioner + lduVectorPreconditioner; + defineTemplateRunTimeSelectionTable(lduVectorPreconditioner, symMatrix); + defineTemplateRunTimeSelectionTable(lduVectorPreconditioner, asymMatrix); + + typedef LduMatrix<vector, diagTensor, scalar>::smoother + lduVectorSmoother; + defineTemplateRunTimeSelectionTable(lduVectorSmoother, symMatrix); + defineTemplateRunTimeSelectionTable(lduVectorSmoother, asymMatrix); + + typedef LduMatrix<vector, diagTensor, scalar>::solver + lduVectorSolver; + defineTemplateRunTimeSelectionTable(lduVectorSolver, symMatrix); + defineTemplateRunTimeSelectionTable(lduVectorSolver, asymMatrix); + + typedef TPCG<vector, diagTensor, scalar> TPCGVector; + defineNamedTemplateTypeNameAndDebug(TPCGVector, 0); + + LduMatrix<vector, diagTensor, scalar>::solver:: + addsymMatrixConstructorToTable<TPCGVector> + addTPCGSymMatrixConstructorToTable_; + + typedef TPBiCG<vector, diagTensor, scalar> TPBiCGVector; + defineNamedTemplateTypeNameAndDebug(TPBiCGVector, 0); + + LduMatrix<vector, diagTensor, scalar>::solver:: + addasymMatrixConstructorToTable<TPBiCGVector> + addTPBiCGSymMatrixConstructorToTable_; + + typedef NoPreconditioner<vector, diagTensor, scalar> NoPreconditionerVector; + defineNamedTemplateTypeNameAndDebug(NoPreconditionerVector, 0); + + LduMatrix<vector, diagTensor, scalar>::preconditioner:: + addsymMatrixConstructorToTable<NoPreconditionerVector> + addNoPreconditionerSymMatrixConstructorToTable_; + + LduMatrix<vector, diagTensor, scalar>::preconditioner:: + addasymMatrixConstructorToTable<NoPreconditionerVector> + addNoPreconditionerAsymMatrixConstructorToTable_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createMesh.H" + + volVectorField psi + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + lduVectorMatrix testMatrix(mesh); + testMatrix.diag() = 2*pTraits<diagTensor>::one; + testMatrix.source() = pTraits<vector>::one; + testMatrix.upper() = 0.1; + testMatrix.lower() = -0.1; + + Info<< testMatrix << endl; + + FieldField<Field, scalar> boundaryCoeffs(0); + FieldField<Field, scalar> internalCoeffs(0); + + autoPtr<lduVectorMatrix::solver> testMatrixSolver = + lduVectorMatrix::solver::New + ( + psi.name(), + testMatrix, + boundaryCoeffs, + internalCoeffs, + psi.boundaryField().interfaces(), + IStringStream + ( + "PBiCG" + "{" + " preconditioner none;" + " tolerance (1e-05 1e-05 1e-05);" + " relTol (0 0 0);" + "}" + )() + ); + + lduVectorMatrix::solverPerformance solverPerf = + testMatrixSolver->solve(psi); + + solverPerf.print(); + + Info<< psi << endl; + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/LduMatrix/LduMatrixTest2.C b/applications/test/LduMatrix/LduMatrixTest2.C new file mode 100644 index 0000000000000000000000000000000000000000..f8694eb4818252cf076f23fcbf1e4610a2e5c066 --- /dev/null +++ b/applications/test/LduMatrix/LduMatrixTest2.C @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "fvMesh.H" +#include "volFields.H" +#include "LduMatrix.H" +#include "tensorField.H" +#include "TPCG.H" +#include "TPBiCG.H" +#include "NoPreconditioner.H" + +using namespace Foam; + +typedef Foam::LduMatrix<vector, tensor, scalar> + lduVectorMatrix; +defineNamedTemplateTypeNameAndDebug(lduVectorMatrix, 0); + +typedef Foam::DiagonalSolver<vector, tensor, scalar> + lduVectorDiagonalSolver; +defineNamedTemplateTypeNameAndDebug(lduVectorDiagonalSolver, 0); + +template<> +const vector lduVectorMatrix::great_(1e15, 1e15, 1e15); + +template<> +const vector lduVectorMatrix::small_(1e-15, 1e-15, 1e-15); + +namespace Foam +{ + typedef LduMatrix<vector, tensor, scalar>::preconditioner + lduVectorPreconditioner; + defineTemplateRunTimeSelectionTable(lduVectorPreconditioner, symMatrix); + defineTemplateRunTimeSelectionTable(lduVectorPreconditioner, asymMatrix); + + typedef LduMatrix<vector, tensor, scalar>::smoother + lduVectorSmoother; + defineTemplateRunTimeSelectionTable(lduVectorSmoother, symMatrix); + defineTemplateRunTimeSelectionTable(lduVectorSmoother, asymMatrix); + + typedef LduMatrix<vector, tensor, scalar>::solver + lduVectorSolver; + defineTemplateRunTimeSelectionTable(lduVectorSolver, symMatrix); + defineTemplateRunTimeSelectionTable(lduVectorSolver, asymMatrix); + + typedef TPCG<vector, tensor, scalar> TPCGVector; + defineNamedTemplateTypeNameAndDebug(TPCGVector, 0); + + LduMatrix<vector, tensor, scalar>::solver:: + addsymMatrixConstructorToTable<TPCGVector> + addTPCGSymMatrixConstructorToTable_; + + typedef TPBiCG<vector, tensor, scalar> TPBiCGVector; + defineNamedTemplateTypeNameAndDebug(TPBiCGVector, 0); + + LduMatrix<vector, tensor, scalar>::solver:: + addasymMatrixConstructorToTable<TPBiCGVector> + addTPBiCGSymMatrixConstructorToTable_; + + typedef NoPreconditioner<vector, tensor, scalar> NoPreconditionerVector; + defineNamedTemplateTypeNameAndDebug(NoPreconditionerVector, 0); + + LduMatrix<vector, tensor, scalar>::preconditioner:: + addsymMatrixConstructorToTable<NoPreconditionerVector> + addNoPreconditionerSymMatrixConstructorToTable_; + + LduMatrix<vector, tensor, scalar>::preconditioner:: + addasymMatrixConstructorToTable<NoPreconditionerVector> + addNoPreconditionerAsymMatrixConstructorToTable_; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createMesh.H" + + volVectorField psi + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + lduVectorMatrix testMatrix(mesh); + testMatrix.diag() = 2*I; + testMatrix.source() = pTraits<vector>::one; + testMatrix.upper() = 0.1; + testMatrix.lower() = -0.1; + + Info<< testMatrix << endl; + + FieldField<Field, scalar> boundaryCoeffs(0); + FieldField<Field, scalar> internalCoeffs(0); + + autoPtr<lduVectorMatrix::solver> testMatrixSolver = + lduVectorMatrix::solver::New + ( + psi.name(), + testMatrix, + //boundaryCoeffs, + //internalCoeffs, + //psi.boundaryField().interfaces(), + IStringStream + ( + "PBiCG" + "{" + " preconditioner none;" + " tolerance (1e-05 1e-05 1e-05);" + " relTol (0 0 0);" + "}" + )() + ); + + lduVectorMatrix::solverPerformance solverPerf = + testMatrixSolver->solve(psi); + + solverPerf.print(); + + Info<< psi << endl; + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/LduMatrix/LduMatrixTest3.C b/applications/test/LduMatrix/LduMatrixTest3.C new file mode 100644 index 0000000000000000000000000000000000000000..596559e6a79eec67cb197e6bff02bce4ab4e5c21 --- /dev/null +++ b/applications/test/LduMatrix/LduMatrixTest3.C @@ -0,0 +1,147 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Application + icoFoam + +Description + Transient solver for incompressible, laminar flow of Newtonian fluids. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "LduMatrix.H" +#include "diagTensorField.H" + +typedef LduMatrix<vector, scalar, scalar> lduVectorMatrix; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + #include "initContinuityErrs.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.loop()) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + + #include "readPISOControls.H" + #include "CourantNo.H" + + fvVectorMatrix UEqn + ( + fvm::ddt(U) + + fvm::div(phi, U) + - fvm::laplacian(nu, U) + ); + + fvVectorMatrix UEqnp(UEqn == -fvc::grad(p)); + + lduVectorMatrix U3Eqnp(mesh); + U3Eqnp.diag() = UEqnp.diag(); + U3Eqnp.upper() = UEqnp.upper(); + U3Eqnp.lower() = UEqnp.lower(); + U3Eqnp.source() = UEqnp.source(); + + UEqnp.addBoundaryDiag(U3Eqnp.diag(), 0); + UEqnp.addBoundarySource(U3Eqnp.source(), false); + + autoPtr<lduVectorMatrix::solver> U3EqnpSolver = + lduVectorMatrix::solver::New + ( + U.name(), + U3Eqnp, + dictionary + ( + IStringStream + ( + "{" + " solver PBiCG;" + " preconditioner DILU;" + " tolerance (1e-5 1e-5 1);" + " relTol (0 0 0);" + "}" + )() + ) + ); + + U3EqnpSolver->solve(U).print(Info); + + // --- PISO loop + + for (int corr=0; corr<nCorr; corr++) + { + volScalarField rAU = 1.0/UEqn.A(); + + U = rAU*UEqn.H(); + phi = (fvc::interpolate(U) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, U, phi); + + adjustPhi(phi, U, p); + + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + fvScalarMatrix pEqn + ( + fvm::laplacian(rAU, p) == fvc::div(phi) + ); + + pEqn.setReference(pRefCell, pRefValue); + pEqn.solve(); + + if (nonOrth == nNonOrthCorr) + { + phi -= pEqn.flux(); + } + } + + #include "continuityErrs.H" + + U -= rAU*fvc::grad(p); + U.correctBoundaryConditions(); + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/LduMatrix/Make/files b/applications/test/LduMatrix/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..99fa29929c824855b4a012d1174bc0a46b8e64f6 --- /dev/null +++ b/applications/test/LduMatrix/Make/files @@ -0,0 +1,3 @@ +LduMatrixTest3.C + +EXE = $(FOAM_USER_APPBIN)/LduMatrixTest diff --git a/applications/test/LduMatrix/Make/options b/applications/test/LduMatrix/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..725122ea1df804ba46bb14bdca8a527b9e8386cc --- /dev/null +++ b/applications/test/LduMatrix/Make/options @@ -0,0 +1,4 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = -lfiniteVolume diff --git a/applications/test/LduMatrix/createFields.H b/applications/test/LduMatrix/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..02093c39386f9282418fa2cea1ff4a13099009ed --- /dev/null +++ b/applications/test/LduMatrix/createFields.H @@ -0,0 +1,55 @@ + Info<< "Reading transportProperties\n" << endl; + + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + dimensionedScalar nu + ( + transportProperties.lookup("nu") + ); + + Info<< "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + +# include "createPhi.H" + + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); diff --git a/applications/test/PisoFoam/Make/files b/applications/test/PisoFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..340f8016c268e338d05d5f49fc660ee66fa439fe --- /dev/null +++ b/applications/test/PisoFoam/Make/files @@ -0,0 +1,3 @@ +PisoFoam.C + +EXE = $(FOAM_USER_APPBIN)/PisoFoam diff --git a/applications/test/PisoFoam/Make/options b/applications/test/PisoFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..259f95f7b93158e2925f06bb839bba3ffb502079 --- /dev/null +++ b/applications/test/PisoFoam/Make/options @@ -0,0 +1,13 @@ +EXE_INC = \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lincompressibleTurbulenceModel \ + -lincompressibleRASModels \ + -lincompressibleLESModels \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/test/PisoFoam/PisoFoam.C b/applications/test/PisoFoam/PisoFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..1713e9747c77b09aa357ff547f9bf34743f40ea4 --- /dev/null +++ b/applications/test/PisoFoam/PisoFoam.C @@ -0,0 +1,191 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Application + pisoFoam + +Description + Transient solver for incompressible flow. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "turbulenceModel.H" + +#include "LduMatrix.H" +#include "diagTensorField.H" + +typedef LduMatrix<vector, scalar, scalar> lduVectorMatrix; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createMesh.H" + #include "createFields.H" + #include "initContinuityErrs.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.loop()) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + + #include "readPISOControls.H" + #include "CourantNo.H" + + // Pressure-velocity PISO corrector + { + // Momentum predictor + + fvVectorMatrix UEqn + ( + fvm::ddt(U) + + fvm::div(phi, U) + + turbulence->divDevReff(U) + ); + + //UEqn.relax(); + + fvVectorMatrix UEqnp(UEqn == -fvc::grad(p)); + + lduVectorMatrix U3Eqnp(mesh); + U3Eqnp.diag() = UEqnp.diag(); + U3Eqnp.upper() = UEqnp.upper(); + U3Eqnp.lower() = UEqnp.lower(); + U3Eqnp.source() = UEqnp.source(); + + UEqnp.addBoundaryDiag(U3Eqnp.diag(), 0); + UEqnp.addBoundarySource(U3Eqnp.source(), false); + + U3Eqnp.interfaces() = U.boundaryField().interfaces(); + U3Eqnp.interfacesUpper() = UEqnp.boundaryCoeffs().component(0); + U3Eqnp.interfacesLower() = UEqnp.internalCoeffs().component(0); + + autoPtr<lduVectorMatrix::solver> U3EqnpSolver = + lduVectorMatrix::solver::New + ( + U.name(), + U3Eqnp, + dictionary + ( + IStringStream + ( + "{" + " /*solver SmoothSolver;*/" + " smoother GaussSeidel;" + " solver PBiCCCG;" + " preconditioner none;" + " tolerance (1e-7 1e-7 1);" + " relTol (0 0 0);" + "}" + )() + ) + ); + + //for (int i=0; i<3; i++) + { + U3EqnpSolver->solve(U).print(Info); + U.correctBoundaryConditions(); + } + //solve(UEqnp); + + // --- PISO loop + + for (int corr=0; corr<nCorr; corr++) + { + volScalarField rAU(1.0/UEqn.A()); + + volVectorField HbyA("HbyA", U); + HbyA = rAU*UEqn.H(); + surfaceScalarField phiHbyA + ( + "phiHbyA", + (fvc::interpolate(HbyA) & mesh.Sf()) + + fvc::ddtPhiCorr(rAU, U, phi) + ); + + adjustPhi(phiHbyA, U, p); + + // Non-orthogonal pressure corrector loop + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + { + // Pressure corrector + + fvScalarMatrix pEqn + ( + fvm::laplacian(rAU, p) == fvc::div(phiHbyA) + ); + + pEqn.setReference(pRefCell, pRefValue); + + if + ( + corr == nCorr-1 + && nonOrth == nNonOrthCorr + ) + { + pEqn.solve(mesh.solver("pFinal")); + } + else + { + pEqn.solve(); + } + + if (nonOrth == nNonOrthCorr) + { + phi = phiHbyA - pEqn.flux(); + } + } + + #include "continuityErrs.H" + + U = HbyA - rAU*fvc::grad(p); + U.correctBoundaryConditions(); + } + } + + turbulence->correct(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/PisoFoam/createFields.H b/applications/test/PisoFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..7cae304f6f6d018824d5dba8ebbf3598fff7c3ad --- /dev/null +++ b/applications/test/PisoFoam/createFields.H @@ -0,0 +1,42 @@ + Info<< "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "createPhi.H" + + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + + + singlePhaseTransportModel laminarTransport(U, phi); + + autoPtr<incompressible::turbulenceModel> turbulence + ( + incompressible::turbulenceModel::New(U, phi, laminarTransport) + ); diff --git a/applications/test/extendedStencil/Test-ExtendedStencil2.C b/applications/test/extendedStencil/Test-ExtendedStencil2.C new file mode 100644 index 0000000000000000000000000000000000000000..eda8f986793c781bfc86f61a26667b7b03642fd8 --- /dev/null +++ b/applications/test/extendedStencil/Test-ExtendedStencil2.C @@ -0,0 +1,206 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Application + testExtendedStencil2 + +Description + Test app for determining extended cell-to-cell stencil. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "fvMesh.H" +#include "volFields.H" +#include "surfaceFields.H" +#include "Time.H" +#include "OFstream.H" +#include "meshTools.H" + +#include "CFCCellToCellStencil.H" + + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +void writeStencilOBJ +( + const fileName& fName, + const point& fc, + const List<point>& 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<label>()); + reduce(nSum, sumOp<label>()); + sumSize /= nSum; + + reduce(minSize, minOp<label>()); + reduce(maxSize, maxOp<label>()); + + Info<< "Stencil size :" << nl + << " average : " << sumSize << nl + << " min : " << minSize << nl + << " max : " << maxSize << nl + << endl; +} + + +// Main program: + +int main(int argc, char *argv[]) +{ +# include "addTimeOptions.H" +# include "setRootCase.H" +# include "createTime.H" + + // Get times list + instantList Times = runTime.times(); +# include "checkTimeOptions.H" + runTime.setTime(Times[startTime], startTime); +# include "createMesh.H" + + + //---- CELL CENTRED STENCIL ----- + + // Centred, cell stencil + // ~~~~~~~~~~~~~~~~~~~~~ + + { + // Full stencil. This is per local cell a set of global indices, either + // into cells or also boundary faces. + CFCCellToCellStencil stencil(mesh); + + // Construct exchange map and renumber stencil + List<Map<label> > compactMap(Pstream::nProcs()); + mapDistribute map + ( + stencil.globalNumbering(), + stencil, + compactMap + ); + + + // Print some stats + Info<< "cellFaceCell:" << endl; + writeStencilStats(stencil); + + + // Collect the data in stencil form + List<List<vector> > stencilPoints; + { + const volVectorField& fld = mesh.C(); + + // 1. Construct cell data in compact addressing + List<point> compactFld(map.constructSize(), pTraits<point>::zero); + + // Insert my internal values + forAll(fld, cellI) + { + compactFld[cellI] = fld[cellI]; + } + // Insert my boundary values + label nCompact = fld.size(); + forAll(fld.boundaryField(), patchI) + { + const fvPatchField<vector>& pfld = fld.boundaryField()[patchI]; + + forAll(pfld, i) + { + compactFld[nCompact++] = pfld[i]; + } + } + + // Do all swapping + map.distribute(compactFld); + + // 2. Pull to stencil + stencilPoints.setSize(stencil.size()); + + forAll(stencil, cellI) + { + const labelList& compactCells = stencil[cellI]; + + stencilPoints[cellI].setSize(compactCells.size()); + + forAll(compactCells, i) + { + stencilPoints[cellI][i] = compactFld[compactCells[i]]; + } + } + } + + + forAll(stencilPoints, cellI) + { + writeStencilOBJ + ( + runTime.path()/"centredCell" + Foam::name(cellI) + ".obj", + mesh.cellCentres()[cellI], + stencilPoints[cellI] + ); + } + } + + Pout<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/syncTools/Test-syncTools.C b/applications/test/syncTools/Test-syncTools.C index 83970e9ef2a3b29eddace9d28c7c52a9a797e03c..cf68380952748c7a5024f4ed0e2c50b6811a0577 100644 --- a/applications/test/syncTools/Test-syncTools.C +++ b/applications/test/syncTools/Test-syncTools.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -214,7 +214,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) forAll(localPoints, i) { - const point pt = localPoints[i] + 1E-4*rndGen.vector01(); + const point pt = localPoints[i] + 1e-4*rndGen.vector01(); label meshPointI = allBoundary.meshPoints()[i]; @@ -299,7 +299,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { const edge& e = edges[i]; - const point pt = e.centre(localPoints) + 1E-4*rndGen.vector01(); + const point pt = e.centre(localPoints) + 1e-4*rndGen.vector01(); label meshEdgeI = meshEdges[i]; diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C index 2f99404f9ae3e611ec9f30f6f8c531f45042496e..22b757e8610b237124c30c910ec93dac4074b3bb 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,7 +58,7 @@ using namespace Foam; // Max cos angle for edges to be considered aligned with axis. -static const scalar edgeTol = 1E-3; +static const scalar edgeTol = 1e-3; void writeSet(const cellSet& cells, const string& msg) diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C index 0f32935faecd90a25ddf28ebf7bfa4dff93ae467..f1eb28e5947759fe22aee59bf0c28a3ed3a2c0f0 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -528,7 +528,7 @@ int main(int argc, char *argv[]) ( mesh, boundaryPoint, - 1E-9, // factor of largest face area + 1e-9, // factor of largest face area 5, // factor between smallest and largest edge on // face collapser diff --git a/applications/utilities/mesh/advanced/selectCells/edgeStats.C b/applications/utilities/mesh/advanced/selectCells/edgeStats.C index 42627e7b6cca01f0f6bc038e9268a524a49adb84..2affa4053541ec9f03862219dfee79c91ea5298c 100644 --- a/applications/utilities/mesh/advanced/selectCells/edgeStats.C +++ b/applications/utilities/mesh/advanced/selectCells/edgeStats.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,7 +31,7 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::scalar Foam::edgeStats::edgeTol_ = 1E-3; +const Foam::scalar Foam::edgeStats::edgeTol_ = 1e-3; diff --git a/applications/utilities/mesh/generation/cv2DMesh/Make/options b/applications/utilities/mesh/generation/cv2DMesh/Make/options index 82659091b69ddf13c3ae892a944a9825a119ed93..56af8bace3433db234a916680832036ddddd1ad7 100755 --- a/applications/utilities/mesh/generation/cv2DMesh/Make/options +++ b/applications/utilities/mesh/generation/cv2DMesh/Make/options @@ -10,7 +10,6 @@ EXE_INC = \ ${EXE_NDEBUG} \ ${CGAL_INC} \ -I$(FOAM_APP)/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/lnInclude \ - -I$(FOAM_APP)/utilities/mesh/generation/extrude/extrudeModel/lnInclude \ -IconformalVoronoi2DMesh/lnInclude \ -I$(FOAM_APP)/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ @@ -18,10 +17,13 @@ EXE_INC = \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/mesh/extrudeModel/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude EXE_LIBS = \ $(CGAL_LIBS) \ + -lboost_thread \ + -lmpfr \ -lextrude2DMesh \ -lextrudeModel \ -lcv2DMesh \ diff --git a/applications/utilities/mesh/generation/cv2DMesh/cv2DMesh.C b/applications/utilities/mesh/generation/cv2DMesh/cv2DMesh.C index 6233edcab32b7e18011a5242ce7f6b59eff149c0..b868d5c83c3c7aea3dda0db9608c4d5a7a9cfd54 100644 --- a/applications/utilities/mesh/generation/cv2DMesh/cv2DMesh.C +++ b/applications/utilities/mesh/generation/cv2DMesh/cv2DMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -209,7 +209,7 @@ int main(int argc, char *argv[]) const pointField& points = pMesh.points(); const boundBox& bb = pMesh.bounds(); - const scalar mergeDim = 1E-4 * bb.minDim(); + const scalar mergeDim = 1e-4 * bb.minDim(); forAll(edges, edgeI) { diff --git a/applications/utilities/mesh/generation/cvMesh/Make/options b/applications/utilities/mesh/generation/cvMesh/Make/options index e7a3c9e0e3a8226cc31acc9b6be4c16ff24a6329..2255a9a27164813355db2e5b730673a3441dc4c9 100644 --- a/applications/utilities/mesh/generation/cvMesh/Make/options +++ b/applications/utilities/mesh/generation/cvMesh/Make/options @@ -22,6 +22,8 @@ EXE_INC = \ EXE_LIBS = \ $(CGAL_LIBS) \ + -lboost_thread \ + -lmpfr \ -lconformalVoronoiMesh \ -lmeshTools \ -ldecompositionMethods \ diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H index f9648dc1e7749c6cd78f444c5a872d8aefbc6fe2..cc22f92088cc3ec38cc23d05cf61c573d98a1e77 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.H @@ -45,8 +45,6 @@ SourceFiles #ifndef conformalVoronoiMesh_H #define conformalVoronoiMesh_H -#define CGAL_INEXACT - #include "CGALTriangulation3Ddefs.H" #include "uint.H" #include "ulong.H" diff --git a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C index e0fe697e88e437c90713bb15ba378c9b5d1ca30d..ec81b1e944a87fb5ce143b11443d6f430def8325 100644 --- a/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshCalcDualMesh.C @@ -561,7 +561,7 @@ Foam::label Foam::conformalVoronoiMesh::mergeCloseDualVertices scalar closenessTolerance = cvMeshControls().mergeClosenessCoeff(); // Absolute distance for points to be considered coincident. Bit adhoc - // but points were seen with distSqr ~ 1E-30 which is SMALL^2. Add a few + // but points were seen with distSqr ~ 1e-30 which is SMALL^2. Add a few // digits to account for truncation errors. scalar coincidentDistanceSqr = sqr ( diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options index 3c9ef8cd4b89e81c1eadf2202ec6416fdd93ddf1..2d1ad7bfdae88ad8cc5e9c295859aacad27d7198 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/Make/options @@ -19,6 +19,8 @@ EXE_INC = \ EXE_LIBS = \ $(CGAL_LIBS) \ + -lboost_thread \ + -lmpfr \ -lconformalVoronoiMesh \ -ldecompositionMethods /* -L$(FOAM_LIBBIN)/dummy -lscotchDecomp */ \ -ledgeMesh \ diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C index 72d05293b9c6c866bf66071c95ab6904a717b070..485c5568b4846f077ba4e6aabed1ccee647a91ff 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshBackgroundMesh/cvMeshBackgroundMesh.C @@ -51,7 +51,7 @@ using namespace Foam; // Tolerance (as fraction of the bounding box). Needs to be fairly lax since // usually meshes get written with limited precision (6 digits) -static const scalar defaultMergeTol = 1E-6; +static const scalar defaultMergeTol = 1e-6; // Get merging distance when matching face centres scalar getMergeDistance @@ -397,7 +397,7 @@ int main(int argc, char *argv[]) "mergeTol", "scalar", "specify the merge distance relative to the bounding box size " - "(default 1E-6)" + "(default 1e-6)" ); #include "setRootCase.H" diff --git a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options index 3b9b222ba8343d500079b8137861acc19aaae6b4..c7c073ab1764bc3672e63a10d8aa3ec580b88156 100644 --- a/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options +++ b/applications/utilities/mesh/generation/cvMesh/cvMeshSurfaceSimplify/Make/options @@ -14,6 +14,8 @@ EXE_INC = \ EXE_LIBS = \ $(CGAL_LIBS) \ + -lboost_thread \ + -lmpfr \ -L$(FASTDUALOCTREE_SRC_PATH) -lperf_main \ -lGL \ -lconformalVoronoiMesh \ diff --git a/applications/utilities/mesh/generation/extrude/Allwclean b/applications/utilities/mesh/generation/extrude/Allwclean index c1c94a806b4edd6723fa500c5953ed8fa7c60caf..253b4b4d6d627bee970c961d953dbdcd6f6f965c 100755 --- a/applications/utilities/mesh/generation/extrude/Allwclean +++ b/applications/utilities/mesh/generation/extrude/Allwclean @@ -2,7 +2,6 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wclean libso extrudeModel wclean extrudeMesh wclean extrudeToRegionMesh diff --git a/applications/utilities/mesh/generation/extrude/Allwmake b/applications/utilities/mesh/generation/extrude/Allwmake index 5f09893321f37f8063e6e976ac8f809f841a48bb..3fd3d2314a976adae9d45588d9fcd25d845f8032 100755 --- a/applications/utilities/mesh/generation/extrude/Allwmake +++ b/applications/utilities/mesh/generation/extrude/Allwmake @@ -2,10 +2,7 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso extrudeModel wmake extrudeMesh - -wmake libso extrudeToRegionMesh/createShellMesh wmake extrudeToRegionMesh diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options b/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options index 3445b811eabf9aec7b97ba7dd4e1f3edae4270e9..94b355be3c8f27e97d386b914cc7e0f753f494d0 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/Make/options @@ -1,10 +1,10 @@ EXE_INC = \ -IextrudedMesh \ - -I../extrudeModel/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/dynamicMesh/lnInclude + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/mesh/extrudeModel/lnInclude EXE_LIBS = \ -lfiniteVolume \ diff --git a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C index 38a2430376116149c99f9b345b410422c7028ed8..1c769a4346f59795792ed7e89d925313c21222ff 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C +++ b/applications/utilities/mesh/generation/extrude/extrudeMesh/extrudeMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -666,7 +666,7 @@ int main(int argc, char *argv[]) const boundBox& bb = mesh.bounds(); const vector span = bb.span(); - const scalar mergeDim = 1E-4 * bb.minDim(); + const scalar mergeDim = 1e-4 * bb.minDim(); Info<< "Mesh bounding box : " << bb << nl << " with span : " << span << nl diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/Make/options b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/Make/options index 5732f9761dbd1621922793350690be076fe144b3..9a1bd9942c97cc352b8d14e5a92e62de35537a7a 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/Make/options +++ b/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/Make/options @@ -1,13 +1,11 @@ EXE_INC = \ - -I../extrudeModel/lnInclude \ - -IcreateShellMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/dynamicMesh/lnInclude + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/mesh/extrudeModel/lnInclude EXE_LIBS = \ - -lextrudeModel \ - -lcreateShellMesh \ -lfiniteVolume \ -lmeshTools \ - -ldynamicMesh + -ldynamicMesh \ + -lextrudeModel diff --git a/applications/utilities/mesh/generation/extrude2DMesh/Make/options b/applications/utilities/mesh/generation/extrude2DMesh/Make/options index 8adfe67b36e15e255eb2af9850933535e3f8b3b4..3be2f34c18e8d2a6bd2ab26664b25466bfa057b6 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/Make/options +++ b/applications/utilities/mesh/generation/extrude2DMesh/Make/options @@ -3,7 +3,7 @@ EXE_INC = \ -I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -Iextrude2DMesh/lnInclude \ - -I../extrude/extrudeModel/lnInclude + -I$(LIB_SRC)/mesh/extrudeModel/lnInclude EXE_LIBS = \ -lsurfMesh \ diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options index 8ace7c50daad576ef0b060bf048908f4cf8d073a..f1db60d53ffc10f9c888abe43bf6cd36e525aa65 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options @@ -4,7 +4,7 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \ - -I$(FOAM_APP)/utilities/mesh/generation/extrude/extrudeModel/lnInclude + -I$(LIB_SRC)/mesh/extrudeModel/lnInclude LIB_LIBS = \ -lmeshTools \ diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C index 5381c0b57afb01302dcee21f067928da4a292a40..667b0a9b2b895ee130461af53cd7882f1d501120 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMeshApp.C @@ -257,7 +257,7 @@ int main(int argc, char *argv[]) const pointField& points = mesh().points(); const boundBox& bb = mesh().bounds(); - const scalar mergeDim = 1E-4 * bb.minDim(); + const scalar mergeDim = 1e-4 * bb.minDim(); forAll(edges, edgeI) { diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C index a2f6a84d17f785953f379e6a7f979bc58675b510..443576601d1564e411e839fcbc28a921e63d80e8 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkGeometry.C @@ -41,8 +41,8 @@ Foam::label Foam::findOppositeWedge if ( pp.size() == wpp.size() - && mag(pp.axis() & wpp.axis()) >= (1-1E-3) - && mag(ppCosAngle - wppCosAngle) >= 1E-3 + && mag(pp.axis() & wpp.axis()) >= (1-1e-3) + && mag(ppCosAngle - wppCosAngle) >= 1e-3 ) { return patchI; @@ -106,7 +106,7 @@ bool Foam::checkWedges ); - if (mag(opp.axis() & pp.axis()) < (1-1E-3)) + if (mag(opp.axis() & pp.axis()) < (1-1e-3)) { if (report) { diff --git a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C index f050d82a79023582d9cd2165726e84d57aa0f48f..e607080a66d3fb34b541b507823b929cd679f391 100644 --- a/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C +++ b/applications/utilities/mesh/manipulation/mirrorMesh/mirrorMesh.C @@ -37,15 +37,24 @@ using namespace Foam; int main(int argc, char *argv[]) { + +# include "addOverwriteOption.H" # include "setRootCase.H" # include "createTime.H" + const bool overwrite = args.optionFound("overwrite"); + + if (!overwrite) + { + runTime++; + } + mirrorFvMesh mesh ( IOobject ( mirrorFvMesh::defaultRegion, - runTime.timeName(), + runTime.constant(), runTime ) ); diff --git a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C index 9ef58b47e40934bcf8a0a2cc5c14953b333769f4..e0dabffedb69980041d9c36b3b440f5ffc17174a 100644 --- a/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C +++ b/applications/utilities/mesh/manipulation/polyDualMesh/meshDualiser.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,7 +52,7 @@ void Foam::meshDualiser::checkPolyTopoChange(const polyTopoChange& meshMod) label nUnique = mergePoints ( points, - 1E-6, + 1e-6, false, oldToNew ); @@ -226,7 +226,7 @@ Foam::label Foam::meshDualiser::addInternalFace label nUnique = mergePoints ( facePoints, - 1E-6, + 1e-6, false, oldToNew ); diff --git a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C index f10fbde116396afa5762e8a441d904a20f7a3d78..f8a206e651cee834f7b39288bd2d22955ad47ef6 100644 --- a/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C +++ b/applications/utilities/mesh/manipulation/refineMesh/refineMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -52,7 +52,7 @@ using namespace Foam; // Max cos angle for edges to be considered aligned with axis. -static const scalar edgeTol = 1E-3; +static const scalar edgeTol = 1e-3; // Calculate some edge statistics on mesh. @@ -206,7 +206,7 @@ label twoDNess(const polyMesh& mesh) minLen = min(minLen, mesh.edges()[cEdges[i]].mag(mesh.points())); } - if (cellPlane.distance(ctrs[cellI]) > 1E-6*minLen) + if (cellPlane.distance(ctrs[cellI]) > 1e-6*minLen) { // Centres not in plane return -1; @@ -274,7 +274,7 @@ label twoDNess(const polyMesh& mesh) const scalarField cosAngle(mag(n/mag(n) & cellPlane.normal())); - if (mag(min(cosAngle) - max(cosAngle)) > 1E-6) + if (mag(min(cosAngle) - max(cosAngle)) > 1e-6) { // cosAngle should be either ~1 over all faces (2D front and // back) or ~0 (all other patches perp to 2D) diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 5f724095ca4a36b58dc5e1ca7314b54962c71e10..395ee77cbebfeac6951b6e8cf86a9c78e706e5ad 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -1036,6 +1036,22 @@ int main(int argc, char *argv[]) ( UIndirectList<label>(faceProcAddressing, map().faceMap()) ); + + // Detect any flips. + const labelHashSet& fff = map().flipFaceFlux(); + forAllConstIter(labelHashSet, fff, iter) + { + label faceI = iter.key(); + label masterFaceI = faceProcAddressing[faceI]; + + faceProcAddressing[faceI] = -masterFaceI; + + if (masterFaceI == 0) + { + FatalErrorIn(args.executable()) << "problem faceI:" << faceI + << " masterFaceI:" << masterFaceI << exit(FatalError); + } + } } if (pointProcAddressing.headerOk()) { @@ -1083,9 +1099,13 @@ int main(int argc, char *argv[]) ); Info<< "After renumbering :" << nl << " band : " << band << nl - << " profile : " << profile << nl - << " rms frontwidth : " << rmsFrontwidth << nl - << endl; + << " profile : " << profile << nl; + if (doFrontWidth) + { + + Info<< " rms frontwidth : " << rmsFrontwidth << nl; + } + Info<< endl; } if (orderPoints) diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 02acd59236545782ba806d64b01ae7c8ae2496e2..49304aadcd71423d530b5c502abb0a22bd3e39b2 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,10 @@ Usage Copy any \a uniform directories too. \param -constant \n - Override controlDict settings and use constant directory. + \param -time xxx:yyy \n + Override controlDict settings and decompose selected times. Does not + re-decompose the mesh i.e. does not handle moving mesh or changing + mesh cases. \param -fields \n Use existing geometry decomposition and convert fields only. @@ -123,11 +126,9 @@ int main(int argc, char *argv[]) "ifRequired", "only decompose geometry if the number of domains has changed" ); - argList::addBoolOption - ( - "constant", - "include the 'constant/' dir in the times list" - ); + + // Include explicit constant options, have zero from time range + timeSelector::addOptions(true, false); #include "setRootCase.H" @@ -146,23 +147,10 @@ int main(int argc, char *argv[]) bool forceOverwrite = args.optionFound("force"); bool ifRequiredDecomposition = args.optionFound("ifRequired"); + // Set time from database #include "createTime.H" - - // Allow -constant to override controlDict settings. - if (args.optionFound("constant")) - { - instantList timeDirs = timeSelector::select0(runTime, args); - if (runTime.timeName() != runTime.constant()) - { - FatalErrorIn(args.executable()) - << "No '" << runTime.constant() << "' time present." << endl - << "Valid times are " << runTime.times() - << exit(FatalError); - } - } - - - Info<< "Time = " << runTime.timeName() << endl; + // Allow override of time + instantList times = timeSelector::selectIfPresent(runTime, args); // determine the existing processor count directly label nProcs = 0; @@ -334,615 +322,760 @@ int main(int argc, char *argv[]) } - // Search for list of objects for this time - IOobjectList objects(mesh, runTime.timeName()); - - // Construct the vol fields - // ~~~~~~~~~~~~~~~~~~~~~~~~ - PtrList<volScalarField> volScalarFields; - readFields(mesh, objects, volScalarFields); - - PtrList<volVectorField> volVectorFields; - readFields(mesh, objects, volVectorFields); - - PtrList<volSphericalTensorField> volSphericalTensorFields; - readFields(mesh, objects, volSphericalTensorFields); - - PtrList<volSymmTensorField> volSymmTensorFields; - readFields(mesh, objects, volSymmTensorFields); - - PtrList<volTensorField> volTensorFields; - readFields(mesh, objects, volTensorFields); - - - // Construct the dimensioned fields - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - PtrList<DimensionedField<scalar, volMesh> > dimScalarFields; - readFields(mesh, objects, dimScalarFields); - - PtrList<DimensionedField<vector, volMesh> > dimVectorFields; - readFields(mesh, objects, dimVectorFields); - PtrList<DimensionedField<sphericalTensor, volMesh> > - dimSphericalTensorFields; - readFields(mesh, objects, dimSphericalTensorFields); + // Caches + // ~~~~~~ + // Cached processor meshes and maps. These are only preserved if running + // with multiple times. + PtrList<Time> processorDbList(mesh.nProcs()); + PtrList<fvMesh> procMeshList(mesh.nProcs()); + PtrList<labelIOList> faceProcAddressingList(mesh.nProcs()); + PtrList<labelIOList> cellProcAddressingList(mesh.nProcs()); + PtrList<labelIOList> boundaryProcAddressingList(mesh.nProcs()); + PtrList<fvFieldDecomposer> fieldDecomposerList(mesh.nProcs()); + PtrList<dimFieldDecomposer> dimFieldDecomposerList(mesh.nProcs()); + PtrList<labelIOList> pointProcAddressingList(mesh.nProcs()); + PtrList<pointFieldDecomposer> pointFieldDecomposerList(mesh.nProcs()); - PtrList<DimensionedField<symmTensor, volMesh> > dimSymmTensorFields; - readFields(mesh, objects, dimSymmTensorFields); - - PtrList<DimensionedField<tensor, volMesh> > dimTensorFields; - readFields(mesh, objects, dimTensorFields); - - - // Construct the surface fields - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - PtrList<surfaceScalarField> surfaceScalarFields; - readFields(mesh, objects, surfaceScalarFields); - PtrList<surfaceVectorField> surfaceVectorFields; - readFields(mesh, objects, surfaceVectorFields); - PtrList<surfaceSphericalTensorField> surfaceSphericalTensorFields; - readFields(mesh, objects, surfaceSphericalTensorFields); - PtrList<surfaceSymmTensorField> surfaceSymmTensorFields; - readFields(mesh, objects, surfaceSymmTensorFields); - PtrList<surfaceTensorField> surfaceTensorFields; - readFields(mesh, objects, surfaceTensorFields); - - - // Construct the point fields - // ~~~~~~~~~~~~~~~~~~~~~~~~~~ - pointMesh pMesh(mesh); - - PtrList<pointScalarField> pointScalarFields; - readFields(pMesh, objects, pointScalarFields); - - PtrList<pointVectorField> pointVectorFields; - readFields(pMesh, objects, pointVectorFields); - - PtrList<pointSphericalTensorField> pointSphericalTensorFields; - readFields(pMesh, objects, pointSphericalTensorFields); - - PtrList<pointSymmTensorField> pointSymmTensorFields; - readFields(pMesh, objects, pointSymmTensorFields); - - PtrList<pointTensorField> pointTensorFields; - readFields(pMesh, objects, pointTensorFields); - - - // Construct the Lagrangian fields - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - fileNameList cloudDirs - ( - readDir(runTime.timePath()/cloud::prefix, fileName::DIRECTORY) - ); - - // Particles - PtrList<Cloud<indexedParticle> > lagrangianPositions(cloudDirs.size()); - // Particles per cell - PtrList< List<SLList<indexedParticle*>*> > cellParticles(cloudDirs.size()); - - PtrList<PtrList<labelIOField> > lagrangianLabelFields(cloudDirs.size()); - PtrList<PtrList<labelFieldCompactIOField> > lagrangianLabelFieldFields - ( - cloudDirs.size() - ); - PtrList<PtrList<scalarIOField> > lagrangianScalarFields(cloudDirs.size()); - PtrList<PtrList<scalarFieldCompactIOField> > lagrangianScalarFieldFields - ( - cloudDirs.size() - ); - PtrList<PtrList<vectorIOField> > lagrangianVectorFields(cloudDirs.size()); - PtrList<PtrList<vectorFieldCompactIOField> > lagrangianVectorFieldFields - ( - cloudDirs.size() - ); - PtrList<PtrList<sphericalTensorIOField> > lagrangianSphericalTensorFields - ( - cloudDirs.size() - ); - PtrList<PtrList<sphericalTensorFieldCompactIOField> > - lagrangianSphericalTensorFieldFields(cloudDirs.size()); - PtrList<PtrList<symmTensorIOField> > lagrangianSymmTensorFields - ( - cloudDirs.size() - ); - PtrList<PtrList<symmTensorFieldCompactIOField> > - lagrangianSymmTensorFieldFields - ( - cloudDirs.size() - ); - PtrList<PtrList<tensorIOField> > lagrangianTensorFields - ( - cloudDirs.size() - ); - PtrList<PtrList<tensorFieldCompactIOField> > lagrangianTensorFieldFields - ( - cloudDirs.size() - ); - label cloudI = 0; - forAll(cloudDirs, i) + // Loop over all times + forAll(times, timeI) { - IOobjectList sprayObjs + runTime.setTime(times[timeI], timeI); + + Info<< "Time = " << runTime.timeName() << endl; + + // Search for list of objects for this time + IOobjectList objects(mesh, runTime.timeName()); + + + // Construct the vol fields + // ~~~~~~~~~~~~~~~~~~~~~~~~ + PtrList<volScalarField> volScalarFields; + readFields(mesh, objects, volScalarFields); + PtrList<volVectorField> volVectorFields; + readFields(mesh, objects, volVectorFields); + PtrList<volSphericalTensorField> volSphericalTensorFields; + readFields(mesh, objects, volSphericalTensorFields); + PtrList<volSymmTensorField> volSymmTensorFields; + readFields(mesh, objects, volSymmTensorFields); + PtrList<volTensorField> volTensorFields; + readFields(mesh, objects, volTensorFields); + + + // Construct the dimensioned fields + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + PtrList<DimensionedField<scalar, volMesh> > dimScalarFields; + readFields(mesh, objects, dimScalarFields); + PtrList<DimensionedField<vector, volMesh> > dimVectorFields; + readFields(mesh, objects, dimVectorFields); + PtrList<DimensionedField<sphericalTensor, volMesh> > + dimSphericalTensorFields; + readFields(mesh, objects, dimSphericalTensorFields); + PtrList<DimensionedField<symmTensor, volMesh> > dimSymmTensorFields; + readFields(mesh, objects, dimSymmTensorFields); + PtrList<DimensionedField<tensor, volMesh> > dimTensorFields; + readFields(mesh, objects, dimTensorFields); + + + // Construct the surface fields + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + PtrList<surfaceScalarField> surfaceScalarFields; + readFields(mesh, objects, surfaceScalarFields); + PtrList<surfaceVectorField> surfaceVectorFields; + readFields(mesh, objects, surfaceVectorFields); + PtrList<surfaceSphericalTensorField> surfaceSphericalTensorFields; + readFields(mesh, objects, surfaceSphericalTensorFields); + PtrList<surfaceSymmTensorField> surfaceSymmTensorFields; + readFields(mesh, objects, surfaceSymmTensorFields); + PtrList<surfaceTensorField> surfaceTensorFields; + readFields(mesh, objects, surfaceTensorFields); + + + // Construct the point fields + // ~~~~~~~~~~~~~~~~~~~~~~~~~~ + pointMesh pMesh(mesh); + + PtrList<pointScalarField> pointScalarFields; + readFields(pMesh, objects, pointScalarFields); + PtrList<pointVectorField> pointVectorFields; + readFields(pMesh, objects, pointVectorFields); + PtrList<pointSphericalTensorField> pointSphericalTensorFields; + readFields(pMesh, objects, pointSphericalTensorFields); + PtrList<pointSymmTensorField> pointSymmTensorFields; + readFields(pMesh, objects, pointSymmTensorFields); + PtrList<pointTensorField> pointTensorFields; + readFields(pMesh, objects, pointTensorFields); + + + // Construct the Lagrangian fields + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + fileNameList cloudDirs ( - mesh, - runTime.timeName(), - cloud::prefix/cloudDirs[i] + readDir(runTime.timePath()/cloud::prefix, fileName::DIRECTORY) ); - IOobject* positionsPtr = sprayObjs.lookup("positions"); + // Particles + PtrList<Cloud<indexedParticle> > lagrangianPositions(cloudDirs.size()); + // Particles per cell + PtrList< List<SLList<indexedParticle*>*> > cellParticles + ( + cloudDirs.size() + ); - if (positionsPtr) - { - // Read lagrangian particles - // ~~~~~~~~~~~~~~~~~~~~~~~~~ + PtrList<PtrList<labelIOField> > lagrangianLabelFields + ( + cloudDirs.size() + ); + PtrList<PtrList<labelFieldCompactIOField> > lagrangianLabelFieldFields + ( + cloudDirs.size() + ); + PtrList<PtrList<scalarIOField> > lagrangianScalarFields + ( + cloudDirs.size() + ); + PtrList<PtrList<scalarFieldCompactIOField> > lagrangianScalarFieldFields + ( + cloudDirs.size() + ); + PtrList<PtrList<vectorIOField> > lagrangianVectorFields + ( + cloudDirs.size() + ); + PtrList<PtrList<vectorFieldCompactIOField> > lagrangianVectorFieldFields + ( + cloudDirs.size() + ); + PtrList<PtrList<sphericalTensorIOField> > + lagrangianSphericalTensorFields + ( + cloudDirs.size() + ); + PtrList<PtrList<sphericalTensorFieldCompactIOField> > + lagrangianSphericalTensorFieldFields(cloudDirs.size()); + PtrList<PtrList<symmTensorIOField> > lagrangianSymmTensorFields + ( + cloudDirs.size() + ); + PtrList<PtrList<symmTensorFieldCompactIOField> > + lagrangianSymmTensorFieldFields + ( + cloudDirs.size() + ); + PtrList<PtrList<tensorIOField> > lagrangianTensorFields + ( + cloudDirs.size() + ); + PtrList<PtrList<tensorFieldCompactIOField> > lagrangianTensorFieldFields + ( + cloudDirs.size() + ); - Info<< "Identified lagrangian data set: " << cloudDirs[i] << endl; + label cloudI = 0; - lagrangianPositions.set + forAll(cloudDirs, i) + { + IOobjectList sprayObjs ( - cloudI, - new Cloud<indexedParticle> - ( - mesh, - cloudDirs[i], - false - ) + mesh, + runTime.timeName(), + cloud::prefix/cloudDirs[i] ); + IOobject* positionsPtr = sprayObjs.lookup("positions"); - // Sort particles per cell - // ~~~~~~~~~~~~~~~~~~~~~~~ + if (positionsPtr) + { + // Read lagrangian particles + // ~~~~~~~~~~~~~~~~~~~~~~~~~ - cellParticles.set - ( - cloudI, - new List<SLList<indexedParticle*>*> + Info<< "Identified lagrangian data set: " << cloudDirs[i] + << endl; + + lagrangianPositions.set ( - mesh.nCells(), - static_cast<SLList<indexedParticle*>*>(NULL) - ) - ); + cloudI, + new Cloud<indexedParticle> + ( + mesh, + cloudDirs[i], + false + ) + ); - label i = 0; - forAllIter - ( - Cloud<indexedParticle>, - lagrangianPositions[cloudI], - iter - ) - { - iter().index() = i++; + // Sort particles per cell + // ~~~~~~~~~~~~~~~~~~~~~~~ - label celli = iter().cell(); + cellParticles.set + ( + cloudI, + new List<SLList<indexedParticle*>*> + ( + mesh.nCells(), + static_cast<SLList<indexedParticle*>*>(NULL) + ) + ); - // Check - if (celli < 0 || celli >= mesh.nCells()) - { - FatalErrorIn(args.executable()) - << "Illegal cell number " << celli - << " for particle with index " << iter().index() - << " at position " << iter().position() << nl - << "Cell number should be between 0 and " - << mesh.nCells()-1 << nl - << "On this mesh the particle should be in cell " - << mesh.findCell(iter().position()) - << exit(FatalError); - } + label i = 0; - if (!cellParticles[cloudI][celli]) + forAllIter + ( + Cloud<indexedParticle>, + lagrangianPositions[cloudI], + iter + ) { - cellParticles[cloudI][celli] = new SLList<indexedParticle*> - (); + iter().index() = i++; + + label celli = iter().cell(); + + // Check + if (celli < 0 || celli >= mesh.nCells()) + { + FatalErrorIn(args.executable()) + << "Illegal cell number " << celli + << " for particle with index " << iter().index() + << " at position " << iter().position() << nl + << "Cell number should be between 0 and " + << mesh.nCells()-1 << nl + << "On this mesh the particle should be in cell " + << mesh.findCell(iter().position()) + << exit(FatalError); + } + + if (!cellParticles[cloudI][celli]) + { + cellParticles[cloudI][celli] = + new SLList<indexedParticle*>(); + } + + cellParticles[cloudI][celli]->append(&iter()); } - cellParticles[cloudI][celli]->append(&iter()); - } + // Read fields + // ~~~~~~~~~~~ - // Read fields - // ~~~~~~~~~~~ - - IOobjectList lagrangianObjects - ( - mesh, - runTime.timeName(), - cloud::prefix/cloudDirs[cloudI] - ); + IOobjectList lagrangianObjects + ( + mesh, + runTime.timeName(), + cloud::prefix/cloudDirs[cloudI] + ); - lagrangianFieldDecomposer::readFields - ( - cloudI, - lagrangianObjects, - lagrangianLabelFields - ); + lagrangianFieldDecomposer::readFields + ( + cloudI, + lagrangianObjects, + lagrangianLabelFields + ); - lagrangianFieldDecomposer::readFieldFields - ( - cloudI, - lagrangianObjects, - lagrangianLabelFieldFields - ); + lagrangianFieldDecomposer::readFieldFields + ( + cloudI, + lagrangianObjects, + lagrangianLabelFieldFields + ); - lagrangianFieldDecomposer::readFields - ( - cloudI, - lagrangianObjects, - lagrangianScalarFields - ); + lagrangianFieldDecomposer::readFields + ( + cloudI, + lagrangianObjects, + lagrangianScalarFields + ); - lagrangianFieldDecomposer::readFieldFields - ( - cloudI, - lagrangianObjects, - lagrangianScalarFieldFields - ); + lagrangianFieldDecomposer::readFieldFields + ( + cloudI, + lagrangianObjects, + lagrangianScalarFieldFields + ); - lagrangianFieldDecomposer::readFields - ( - cloudI, - lagrangianObjects, - lagrangianVectorFields - ); + lagrangianFieldDecomposer::readFields + ( + cloudI, + lagrangianObjects, + lagrangianVectorFields + ); - lagrangianFieldDecomposer::readFieldFields - ( - cloudI, - lagrangianObjects, - lagrangianVectorFieldFields - ); + lagrangianFieldDecomposer::readFieldFields + ( + cloudI, + lagrangianObjects, + lagrangianVectorFieldFields + ); - lagrangianFieldDecomposer::readFields - ( - cloudI, - lagrangianObjects, - lagrangianSphericalTensorFields - ); + lagrangianFieldDecomposer::readFields + ( + cloudI, + lagrangianObjects, + lagrangianSphericalTensorFields + ); - lagrangianFieldDecomposer::readFieldFields - ( - cloudI, - lagrangianObjects, - lagrangianSphericalTensorFieldFields - ); + lagrangianFieldDecomposer::readFieldFields + ( + cloudI, + lagrangianObjects, + lagrangianSphericalTensorFieldFields + ); - lagrangianFieldDecomposer::readFields - ( - cloudI, - lagrangianObjects, - lagrangianSymmTensorFields - ); + lagrangianFieldDecomposer::readFields + ( + cloudI, + lagrangianObjects, + lagrangianSymmTensorFields + ); - lagrangianFieldDecomposer::readFieldFields - ( - cloudI, - lagrangianObjects, - lagrangianSymmTensorFieldFields - ); + lagrangianFieldDecomposer::readFieldFields + ( + cloudI, + lagrangianObjects, + lagrangianSymmTensorFieldFields + ); - lagrangianFieldDecomposer::readFields - ( - cloudI, - lagrangianObjects, - lagrangianTensorFields - ); + lagrangianFieldDecomposer::readFields + ( + cloudI, + lagrangianObjects, + lagrangianTensorFields + ); - lagrangianFieldDecomposer::readFieldFields - ( - cloudI, - lagrangianObjects, - lagrangianTensorFieldFields - ); + lagrangianFieldDecomposer::readFieldFields + ( + cloudI, + lagrangianObjects, + lagrangianTensorFieldFields + ); - cloudI++; + cloudI++; + } } - } - - lagrangianPositions.setSize(cloudI); - cellParticles.setSize(cloudI); - lagrangianLabelFields.setSize(cloudI); - lagrangianLabelFieldFields.setSize(cloudI); - lagrangianScalarFields.setSize(cloudI); - lagrangianScalarFieldFields.setSize(cloudI); - lagrangianVectorFields.setSize(cloudI); - lagrangianVectorFieldFields.setSize(cloudI); - lagrangianSphericalTensorFields.setSize(cloudI); - lagrangianSphericalTensorFieldFields.setSize(cloudI); - lagrangianSymmTensorFields.setSize(cloudI); - lagrangianSymmTensorFieldFields.setSize(cloudI); - lagrangianTensorFields.setSize(cloudI); - lagrangianTensorFieldFields.setSize(cloudI); - - - // Any uniform data to copy/link? - fileName uniformDir("uniform"); - - if (isDir(runTime.timePath()/uniformDir)) - { - Info<< "Detected additional non-decomposed files in " - << runTime.timePath()/uniformDir - << endl; - } - else - { - uniformDir.clear(); - } - Info<< endl; - - // split the fields over processors - for (label procI = 0; procI < mesh.nProcs(); procI++) - { - Info<< "Processor " << procI << ": field transfer" << endl; - - // open the database - Time processorDb - ( - Time::controlDictName, - args.rootPath(), - args.caseName()/fileName(word("processor") + name(procI)) - ); - - processorDb.setTime(runTime); - - // remove files remnants that can cause horrible problems - // - mut and nut are used to mark the new turbulence models, - // their existence prevents old models from being upgraded + lagrangianPositions.setSize(cloudI); + cellParticles.setSize(cloudI); + lagrangianLabelFields.setSize(cloudI); + lagrangianLabelFieldFields.setSize(cloudI); + lagrangianScalarFields.setSize(cloudI); + lagrangianScalarFieldFields.setSize(cloudI); + lagrangianVectorFields.setSize(cloudI); + lagrangianVectorFieldFields.setSize(cloudI); + lagrangianSphericalTensorFields.setSize(cloudI); + lagrangianSphericalTensorFieldFields.setSize(cloudI); + lagrangianSymmTensorFields.setSize(cloudI); + lagrangianSymmTensorFieldFields.setSize(cloudI); + lagrangianTensorFields.setSize(cloudI); + lagrangianTensorFieldFields.setSize(cloudI); + + + // Any uniform data to copy/link? + fileName uniformDir("uniform"); + + if (isDir(runTime.timePath()/uniformDir)) { - fileName timeDir(processorDb.path()/processorDb.timeName()); - - rm(timeDir/"mut"); - rm(timeDir/"nut"); + Info<< "Detected additional non-decomposed files in " + << runTime.timePath()/uniformDir + << endl; + } + else + { + uniformDir.clear(); } - // read the mesh - fvMesh procMesh - ( - IOobject - ( - regionName, - processorDb.timeName(), - processorDb - ) - ); - - labelIOList faceProcAddressing - ( - IOobject - ( - "faceProcAddressing", - procMesh.facesInstance(), - procMesh.meshSubDir, - procMesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); + Info<< endl; - labelIOList cellProcAddressing - ( - IOobject - ( - "cellProcAddressing", - procMesh.facesInstance(), - procMesh.meshSubDir, - procMesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); + // split the fields over processors + for (label procI = 0; procI < mesh.nProcs(); procI++) + { + Info<< "Processor " << procI << ": field transfer" << endl; - labelIOList boundaryProcAddressing - ( - IOobject - ( - "boundaryProcAddressing", - procMesh.facesInstance(), - procMesh.meshSubDir, - procMesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); - // FV fields - { - fvFieldDecomposer fieldDecomposer - ( - mesh, - procMesh, - faceProcAddressing, - cellProcAddressing, - boundaryProcAddressing - ); + // open the database + if (!processorDbList.set(procI)) + { + processorDbList.set + ( + procI, + new Time + ( + Time::controlDictName, + args.rootPath(), + args.caseName() + /fileName(word("processor") + name(procI)) + ) + ); + } + Time& processorDb = processorDbList[procI]; - fieldDecomposer.decomposeFields(volScalarFields); - fieldDecomposer.decomposeFields(volVectorFields); - fieldDecomposer.decomposeFields(volSphericalTensorFields); - fieldDecomposer.decomposeFields(volSymmTensorFields); - fieldDecomposer.decomposeFields(volTensorFields); - - fieldDecomposer.decomposeFields(surfaceScalarFields); - fieldDecomposer.decomposeFields(surfaceVectorFields); - fieldDecomposer.decomposeFields(surfaceSphericalTensorFields); - fieldDecomposer.decomposeFields(surfaceSymmTensorFields); - fieldDecomposer.decomposeFields(surfaceTensorFields); - } - // Dimensioned fields - { - dimFieldDecomposer fieldDecomposer - ( - mesh, - procMesh, - faceProcAddressing, - cellProcAddressing - ); + processorDb.setTime(runTime); - fieldDecomposer.decomposeFields(dimScalarFields); - fieldDecomposer.decomposeFields(dimVectorFields); - fieldDecomposer.decomposeFields(dimSphericalTensorFields); - fieldDecomposer.decomposeFields(dimSymmTensorFields); - fieldDecomposer.decomposeFields(dimTensorFields); - } + // remove files remnants that can cause horrible problems + // - mut and nut are used to mark the new turbulence models, + // their existence prevents old models from being upgraded + { + fileName timeDir(processorDb.path()/processorDb.timeName()); + rm(timeDir/"mut"); + rm(timeDir/"nut"); + } - // Point fields - if - ( - pointScalarFields.size() - || pointVectorFields.size() - || pointSphericalTensorFields.size() - || pointSymmTensorFields.size() - || pointTensorFields.size() - ) - { - labelIOList pointProcAddressing - ( - IOobject + // read the mesh + if (!procMeshList.set(procI)) + { + procMeshList.set ( - "pointProcAddressing", - procMesh.facesInstance(), - procMesh.meshSubDir, - procMesh, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ); + procI, + new fvMesh + ( + IOobject + ( + regionName, + processorDb.timeName(), + processorDb + ) + ) + ); + } + const fvMesh& procMesh = procMeshList[procI]; - pointMesh procPMesh(procMesh); - pointFieldDecomposer fieldDecomposer - ( - pMesh, - procPMesh, - pointProcAddressing, - boundaryProcAddressing - ); + if (!faceProcAddressingList.set(procI)) + { + faceProcAddressingList.set + ( + procI, + new labelIOList + ( + IOobject + ( + "faceProcAddressing", + procMesh.facesInstance(), + procMesh.meshSubDir, + procMesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) + ); + } + const labelIOList& faceProcAddressing = + faceProcAddressingList[procI]; - fieldDecomposer.decomposeFields(pointScalarFields); - fieldDecomposer.decomposeFields(pointVectorFields); - fieldDecomposer.decomposeFields(pointSphericalTensorFields); - fieldDecomposer.decomposeFields(pointSymmTensorFields); - fieldDecomposer.decomposeFields(pointTensorFields); - } + + if (!cellProcAddressingList.set(procI)) + { + cellProcAddressingList.set + ( + procI, + new labelIOList + ( + IOobject + ( + "cellProcAddressing", + procMesh.facesInstance(), + procMesh.meshSubDir, + procMesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) + ); + } + const labelIOList& cellProcAddressing = + cellProcAddressingList[procI]; - // If there is lagrangian data write it out - forAll(lagrangianPositions, cloudI) - { - if (lagrangianPositions[cloudI].size()) + if (!boundaryProcAddressingList.set(procI)) { - lagrangianFieldDecomposer fieldDecomposer + boundaryProcAddressingList.set ( - mesh, - procMesh, - faceProcAddressing, - cellProcAddressing, - cloudDirs[cloudI], - lagrangianPositions[cloudI], - cellParticles[cloudI] + procI, + new labelIOList + ( + IOobject + ( + "boundaryProcAddressing", + procMesh.facesInstance(), + procMesh.meshSubDir, + procMesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) ); + } + const labelIOList& boundaryProcAddressing = + boundaryProcAddressingList[procI]; + - // Lagrangian fields + // FV fields + { + if (!fieldDecomposerList.set(procI)) { - fieldDecomposer.decomposeFields + fieldDecomposerList.set ( - cloudDirs[cloudI], - lagrangianLabelFields[cloudI] + procI, + new fvFieldDecomposer + ( + mesh, + procMesh, + faceProcAddressing, + cellProcAddressing, + boundaryProcAddressing + ) ); - fieldDecomposer.decomposeFieldFields - ( - cloudDirs[cloudI], - lagrangianLabelFieldFields[cloudI] - ); - fieldDecomposer.decomposeFields - ( - cloudDirs[cloudI], - lagrangianScalarFields[cloudI] - ); - fieldDecomposer.decomposeFieldFields - ( - cloudDirs[cloudI], - lagrangianScalarFieldFields[cloudI] - ); - fieldDecomposer.decomposeFields - ( - cloudDirs[cloudI], - lagrangianVectorFields[cloudI] - ); - fieldDecomposer.decomposeFieldFields - ( - cloudDirs[cloudI], - lagrangianVectorFieldFields[cloudI] - ); - fieldDecomposer.decomposeFields + } + const fvFieldDecomposer& fieldDecomposer = + fieldDecomposerList[procI]; + + fieldDecomposer.decomposeFields(volScalarFields); + fieldDecomposer.decomposeFields(volVectorFields); + fieldDecomposer.decomposeFields(volSphericalTensorFields); + fieldDecomposer.decomposeFields(volSymmTensorFields); + fieldDecomposer.decomposeFields(volTensorFields); + + fieldDecomposer.decomposeFields(surfaceScalarFields); + fieldDecomposer.decomposeFields(surfaceVectorFields); + fieldDecomposer.decomposeFields(surfaceSphericalTensorFields); + fieldDecomposer.decomposeFields(surfaceSymmTensorFields); + fieldDecomposer.decomposeFields(surfaceTensorFields); + + if (times.size() == 1) + { + // Clear cached decomposer + fieldDecomposerList.set(procI, NULL); + } + } + + // Dimensioned fields + { + if (!dimFieldDecomposerList.set(procI)) + { + dimFieldDecomposerList.set ( - cloudDirs[cloudI], - lagrangianSphericalTensorFields[cloudI] + procI, + new dimFieldDecomposer + ( + mesh, + procMesh, + faceProcAddressing, + cellProcAddressing + ) ); - fieldDecomposer.decomposeFieldFields + } + const dimFieldDecomposer& dimDecomposer = + dimFieldDecomposerList[procI]; + + dimDecomposer.decomposeFields(dimScalarFields); + dimDecomposer.decomposeFields(dimVectorFields); + dimDecomposer.decomposeFields(dimSphericalTensorFields); + dimDecomposer.decomposeFields(dimSymmTensorFields); + dimDecomposer.decomposeFields(dimTensorFields); + + if (times.size() == 1) + { + dimFieldDecomposerList.set(procI, NULL); + } + } + + + // Point fields + if + ( + pointScalarFields.size() + || pointVectorFields.size() + || pointSphericalTensorFields.size() + || pointSymmTensorFields.size() + || pointTensorFields.size() + ) + { + if (!pointProcAddressingList.set(procI)) + { + pointProcAddressingList.set ( - cloudDirs[cloudI], - lagrangianSphericalTensorFieldFields[cloudI] + procI, + new labelIOList + ( + IOobject + ( + "pointProcAddressing", + procMesh.facesInstance(), + procMesh.meshSubDir, + procMesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) ); - fieldDecomposer.decomposeFields + } + const labelIOList& pointProcAddressing = + pointProcAddressingList[procI]; + + const pointMesh& procPMesh = pointMesh::New(procMesh); + + if (!pointFieldDecomposerList.set(procI)) + { + pointFieldDecomposerList.set ( - cloudDirs[cloudI], - lagrangianSymmTensorFields[cloudI] + procI, + new pointFieldDecomposer + ( + pMesh, + procPMesh, + pointProcAddressing, + boundaryProcAddressing + ) ); - fieldDecomposer.decomposeFieldFields + } + const pointFieldDecomposer& pointDecomposer = + pointFieldDecomposerList[procI]; + + pointDecomposer.decomposeFields(pointScalarFields); + pointDecomposer.decomposeFields(pointVectorFields); + pointDecomposer.decomposeFields(pointSphericalTensorFields); + pointDecomposer.decomposeFields(pointSymmTensorFields); + pointDecomposer.decomposeFields(pointTensorFields); + + + if (times.size() == 1) + { + pointProcAddressingList.set(procI, NULL); + pointFieldDecomposerList.set(procI, NULL); + } + } + + + // If there is lagrangian data write it out + forAll(lagrangianPositions, cloudI) + { + if (lagrangianPositions[cloudI].size()) + { + lagrangianFieldDecomposer fieldDecomposer ( + mesh, + procMesh, + faceProcAddressing, + cellProcAddressing, cloudDirs[cloudI], - lagrangianSymmTensorFieldFields[cloudI] + lagrangianPositions[cloudI], + cellParticles[cloudI] ); - fieldDecomposer.decomposeFields + + // Lagrangian fields + { + fieldDecomposer.decomposeFields + ( + cloudDirs[cloudI], + lagrangianLabelFields[cloudI] + ); + fieldDecomposer.decomposeFieldFields + ( + cloudDirs[cloudI], + lagrangianLabelFieldFields[cloudI] + ); + fieldDecomposer.decomposeFields + ( + cloudDirs[cloudI], + lagrangianScalarFields[cloudI] + ); + fieldDecomposer.decomposeFieldFields + ( + cloudDirs[cloudI], + lagrangianScalarFieldFields[cloudI] + ); + fieldDecomposer.decomposeFields + ( + cloudDirs[cloudI], + lagrangianVectorFields[cloudI] + ); + fieldDecomposer.decomposeFieldFields + ( + cloudDirs[cloudI], + lagrangianVectorFieldFields[cloudI] + ); + fieldDecomposer.decomposeFields + ( + cloudDirs[cloudI], + lagrangianSphericalTensorFields[cloudI] + ); + fieldDecomposer.decomposeFieldFields + ( + cloudDirs[cloudI], + lagrangianSphericalTensorFieldFields[cloudI] + ); + fieldDecomposer.decomposeFields + ( + cloudDirs[cloudI], + lagrangianSymmTensorFields[cloudI] + ); + fieldDecomposer.decomposeFieldFields + ( + cloudDirs[cloudI], + lagrangianSymmTensorFieldFields[cloudI] + ); + fieldDecomposer.decomposeFields + ( + cloudDirs[cloudI], + lagrangianTensorFields[cloudI] + ); + fieldDecomposer.decomposeFieldFields + ( + cloudDirs[cloudI], + lagrangianTensorFieldFields[cloudI] + ); + } + } + } + + + // Any non-decomposed data to copy? + if (uniformDir.size()) + { + const fileName timePath = processorDb.timePath(); + + if (copyUniform || mesh.distributed()) + { + cp ( - cloudDirs[cloudI], - lagrangianTensorFields[cloudI] + runTime.timePath()/uniformDir, + timePath/uniformDir ); - fieldDecomposer.decomposeFieldFields + } + else + { + // link with relative paths + const string parentPath = string("..")/".."; + + fileName currentDir(cwd()); + chDir(timePath); + ln ( - cloudDirs[cloudI], - lagrangianTensorFieldFields[cloudI] + parentPath/runTime.timeName()/uniformDir, + uniformDir ); + chDir(currentDir); } } - } - // Any non-decomposed data to copy? - if (uniformDir.size()) - { - const fileName timePath = processorDb.timePath(); - if (copyUniform || mesh.distributed()) - { - cp - ( - runTime.timePath()/uniformDir, - timePath/uniformDir - ); - } - else + // We have cached all the constant mesh data for the current + // processor. This is only important if running with multiple + // times, otherwise it is just extra storage. + if (times.size() == 1) { - // link with relative paths - const string parentPath = string("..")/".."; - - fileName currentDir(cwd()); - chDir(timePath); - ln - ( - parentPath/runTime.timeName()/uniformDir, - uniformDir - ); - chDir(currentDir); + boundaryProcAddressingList.set(procI, NULL); + cellProcAddressingList.set(procI, NULL); + faceProcAddressingList.set(procI, NULL); + procMeshList.set(procI, NULL); + processorDbList.set(procI, NULL); } } } - Info<< "\nEnd.\n" << endl; return 0; diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C index 4526e79e082080de88c4dc41e9110a4a64fb3315..3085ff1897f4d66374dc31d36d7930fd657be124 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C +++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,7 +55,7 @@ using namespace Foam; // Tolerance (as fraction of the bounding box). Needs to be fairly lax since // usually meshes get written with limited precision (6 digits) -static const scalar defaultMergeTol = 1E-7; +static const scalar defaultMergeTol = 1e-7; static void renumber @@ -290,7 +290,7 @@ int main(int argc, char *argv[]) "mergeTol", "scalar", "specify the merge distance relative to the bounding box size " - "(default 1E-7)" + "(default 1e-7)" ); argList::addBoolOption ( diff --git a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C index 4d02655955fa3a5c10f12ed2be1d9688fe60406e..9a337d757305f155281281ca7708df9fe5ed1587 100644 --- a/applications/utilities/parallelProcessing/redistributePar/redistributePar.C +++ b/applications/utilities/parallelProcessing/redistributePar/redistributePar.C @@ -60,7 +60,7 @@ Description // Tolerance (as fraction of the bounding box). Needs to be fairly lax since // usually meshes get written with limited precision (6 digits) -static const scalar defaultMergeTol = 1E-6; +static const scalar defaultMergeTol = 1e-6; //// Read mesh if available. Otherwise create empty mesh with same non-proc @@ -721,7 +721,7 @@ int main(int argc, char *argv[]) "mergeTol", "scalar", "specify the merge distance relative to the bounding box size " - "(default 1E-6)" + "(default 1e-6)" ); # include "setRootCase.H" diff --git a/applications/utilities/postProcessing/miscellaneous/temporalInterpolate/temporalInterpolate.C b/applications/utilities/postProcessing/miscellaneous/temporalInterpolate/temporalInterpolate.C index 14959901f7921e634ceabab35fa23f2321c9c691..98ead1f4bbe808d2676ce1e352f24e41e69e3887 100644 --- a/applications/utilities/postProcessing/miscellaneous/temporalInterpolate/temporalInterpolate.C +++ b/applications/utilities/postProcessing/miscellaneous/temporalInterpolate/temporalInterpolate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,6 +37,8 @@ Description #include "surfaceFields.H" #include "pointFields.H" #include "ReadFields.H" +#include "interpolationWeights.H" +#include "uniformInterpolate.H" using namespace Foam; @@ -48,6 +50,8 @@ class fieldInterpolator const HashSet<word>& selectedFields_; instant ti_; instant ti1_; + const interpolationWeights& interpolator_; + const wordList& timeNames_; int divisions_; public: @@ -60,6 +64,8 @@ public: const HashSet<word>& selectedFields, const instant& ti, const instant& ti1, + const interpolationWeights& interpolator, + const wordList& timeNames, int divisions ) : @@ -69,6 +75,8 @@ public: selectedFields_(selectedFields), ti_(ti), ti1_(ti1), + interpolator_(interpolator), + timeNames_(timeNames), divisions_(divisions) {} @@ -98,34 +106,6 @@ void fieldInterpolator::interpolate() { Info<< " " << fieldIter()->name() << '('; - GeoFieldType fieldi - ( - IOobject - ( - fieldIter()->name(), - ti_.name(), - fieldIter()->db(), - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), - mesh_ - ); - - GeoFieldType fieldi1 - ( - IOobject - ( - fieldIter()->name(), - ti1_.name(), - fieldIter()->db(), - IOobject::MUST_READ, - IOobject::NO_WRITE, - false - ), - mesh_ - ); - scalar deltaT = (ti1_.value() - ti_.value())/(divisions_ + 1); for (int j=0; j<divisions_; j++) @@ -141,20 +121,51 @@ void fieldInterpolator::interpolate() Info<< " "; } - scalar lambda = scalar(j + 1)/scalar(divisions_ + 1); + // Calculate times to read and weights + labelList indices; + scalarField weights; + interpolator_.valueWeights + ( + runTime_.value(), + indices, + weights + ); + + const wordList selectedTimeNames + ( + UIndirectList<word>(timeNames_, indices)() + ); + + //Info<< "For time " << runTime_.value() + // << " need times " << selectedTimeNames + // << " need weights " << weights << endl; + + + // Read on the objectRegistry all the required fields + ReadFields<GeoFieldType> + ( + fieldIter()->name(), + mesh_, + selectedTimeNames + ); GeoFieldType fieldj ( - IOobject + uniformInterpolate<GeoFieldType> ( + IOobject + ( + fieldIter()->name(), + runTime_.timeName(), + fieldIter()->db(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), fieldIter()->name(), - timej.name(), - fieldIter()->db(), - IOobject::NO_READ, - IOobject::NO_WRITE, - false - ), - (1.0 - lambda)*fieldi + lambda*fieldi1 + selectedTimeNames, + weights + ) ); fieldj.write(); @@ -188,6 +199,12 @@ int main(int argc, char *argv[]) "integer", "specify number of temporal sub-divisions to create (default = 1)." ); + argList::addOption + ( + "interpolationType", + "word", + "specify type of interpolation (linear or spline)" + ); #include "setRootCase.H" #include "createTime.H" @@ -198,15 +215,51 @@ int main(int argc, char *argv[]) { args.optionLookup("fields")() >> selectedFields; } + if (selectedFields.size()) + { + Info<< "Interpolating fields " << selectedFields << nl << endl; + } + else + { + Info<< "Interpolating all fields" << nl << endl; + } + int divisions = 1; if (args.optionFound("divisions")) { args.optionLookup("divisions")() >> divisions; } + Info<< "Using " << divisions << " per time interval" << nl << endl; + + + const word interpolationType = args.optionLookupOrDefault<word> + ( + "interpolationType", + "linear" + ); + Info<< "Using interpolation " << interpolationType << nl << endl; + instantList timeDirs = timeSelector::select0(runTime, args); + scalarField timeVals(timeDirs.size()); + wordList timeNames(timeDirs.size()); + forAll(timeDirs, i) + { + timeVals[i] = timeDirs[i].value(); + timeNames[i] = timeDirs[i].name(); + } + autoPtr<interpolationWeights> interpolatorPtr + ( + interpolationWeights::New + ( + interpolationType, + timeVals + ) + ); + + #include "createMesh.H" Info<< "Interpolating fields for times:" << endl; @@ -226,6 +279,8 @@ int main(int argc, char *argv[]) selectedFields, timeDirs[timei], timeDirs[timei+1], + interpolatorPtr(), + timeNames, divisions ); diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index 85ce0db890f4a80c036c70930175fbef2bbc3255..ac3b733b038228f347dbe2c8651e19a75a3a50fe 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -70,6 +70,7 @@ Usage #include "IOPtrList.H" #include "volFields.H" #include "stringListOps.H" +#include "timeSelector.H" using namespace Foam; @@ -256,8 +257,12 @@ int main(int argc, char *argv[]) ( "instance", "name", - "specify alternate time instance - default is latest time" + "override instance setting (default is the time name)" ); + + // Add explicit time option + timeSelector::addOptions(); + argList::addBoolOption ( "literalRE", @@ -272,6 +277,18 @@ int main(int argc, char *argv[]) #include "setRootCase.H" #include "createTime.H" + + // Optionally override controlDict time with -time options + instantList times = timeSelector::selectIfPresent(runTime, args); + if (times.size() < 1) + { + FatalErrorIn(args.executable()) + << "No times selected." << exit(FatalError); + } + runTime.setTime(times[0], 0); + word instance = args.optionLookupOrDefault("instance", runTime.timeName()); + + #include "createNamedMesh.H" const word dictName("changeDictionaryDict"); @@ -317,11 +334,6 @@ int main(int argc, char *argv[]) regionPrefix = regionName; } - word instance = runTime.timeName(); - if (args.options().found("instance")) - { - instance = args.options()["instance"]; - } // Make sure we do not use the master-only reading since we read // fields (different per processor) as dictionaries. diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C index f73029529ee08f96966bc2ceb7b880d32e8afb12..37ad7c26c2ba1d6c51c6c18d999d05cbc97db6be 100644 --- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C +++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,7 +32,7 @@ License namespace Foam { -static const scalar perturbFactor = 1E-6; +static const scalar perturbFactor = 1e-6; // Special version of findCell that generates a cell guaranteed to be diff --git a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H index fad039b3b2ca8208383ee779fe92b572ec1d6dff..a48fd193f124c43532892acfb27ede445b7a7ac4 100644 --- a/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H +++ b/applications/utilities/preProcessing/viewFactorsGen/searchingEngine.H @@ -7,7 +7,7 @@ List<treeBoundBox> meshBb treeBoundBox ( boundBox(coarseMesh.points(), false) - ).extend(rndGen, 1E-3) + ).extend(rndGen, 1e-3) ); // Dummy bounds dictionary diff --git a/applications/utilities/surface/surfaceCheck/surfaceCheck.C b/applications/utilities/surface/surfaceCheck/surfaceCheck.C index 09a030d77b28181af8c11ff63518759e4bdb210f..1000f845141bf4afd04800698d85414349c3dc33 100644 --- a/applications/utilities/surface/surfaceCheck/surfaceCheck.C +++ b/applications/utilities/surface/surfaceCheck/surfaceCheck.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -367,7 +367,7 @@ int main(int argc, char *argv[]) forAll(triQ, faceI) { - if (triQ[faceI] < 1E-11) + if (triQ[faceI] < 1e-11) { problemFaces.append(faceI); } @@ -427,9 +427,9 @@ int main(int argc, char *argv[]) const pointField& localPoints = surf.localPoints(); const boundBox bb(localPoints); - scalar smallDim = 1E-6 * bb.mag(); + scalar smallDim = 1e-6 * bb.mag(); - Info<< "Checking for points less than 1E-6 of bounding box (" + Info<< "Checking for points less than 1e-6 of bounding box (" << bb.span() << " meter) apart." << endl; diff --git a/applications/utilities/surface/surfaceFeatureExtract/Allwmake b/applications/utilities/surface/surfaceFeatureExtract/Allwmake index 369428e1713ee11a3f49aadc110376bcaf2aaa79..2b9a927dc32e4ddfeb9fbec6e8f5289b6349650b 100755 --- a/applications/utilities/surface/surfaceFeatureExtract/Allwmake +++ b/applications/utilities/surface/surfaceFeatureExtract/Allwmake @@ -15,7 +15,9 @@ then CGAL_LIBDIR=-L$CGAL_ARCH_PATH/lib \ LAPACK_LIB=-llapack \ BLAS_LIB=-lblas \ - CGAL_LIB=-lCGAL" + CGAL_LIB=-lCGAL \ + CGAL_BOOST_LIB=-lboost_thread \ + CGAL_MPFR_LIB=-lmpfr" else echo echo "Compiling surfaceFeatureExtract without CGAL curvature support" diff --git a/applications/utilities/surface/surfaceFeatureExtract/Make/options b/applications/utilities/surface/surfaceFeatureExtract/Make/options index b2e5dcf5f7abef5f52c4472ffc0030b91944366e..461cec9f8134bc1a2622e08bbe9914f5143d8a06 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/Make/options +++ b/applications/utilities/surface/surfaceFeatureExtract/Make/options @@ -15,6 +15,8 @@ EXE_INC = \ EXE_LIBS = \ $(CGAL_LIBS) \ + ${CGAL_BOOST_LIB} \ + ${CGAL_MPFR_LIB} \ ${CGAL_LIBDIR} \ ${LAPACK_LIB} \ ${BLAS_LIB} \ diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict index b5084ec10390041c0d3dbc197f28180fa4db2ab6..e9741543bd59330d94fa79d1ee37db2169cabd1e 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtractDict @@ -30,9 +30,6 @@ surface1.stl // Write options - // Write .eMesh file (for snappyHexMesh) - writeFeatureEdgeMesh yes; - // Write features to obj format for postprocessing writeObj yes; } diff --git a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C index 98c56dabd6a5830dd4a003dca00377efe6a016b0..76a385733eb0e77ae7f641fb3b9c71fefa2991b1 100644 --- a/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C +++ b/applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -159,7 +159,7 @@ int main(int argc, char *argv[]) treeBoundBox ( boundBox(mesh.points(), false) - ).extend(rndGen, 1E-3) + ).extend(rndGen, 1e-3) ); Pstream::gatherList(meshBb); Pstream::scatterList(meshBb); diff --git a/applications/utilities/surface/surfaceSubset/surfaceSubset.C b/applications/utilities/surface/surfaceSubset/surfaceSubset.C index 89f200283f263360ee36ec4941cc5ba9cee39e6e..5ca325acba9266c813d98bad4b7caf5a84128a68 100644 --- a/applications/utilities/surface/surfaceSubset/surfaceSubset.C +++ b/applications/utilities/surface/surfaceSubset/surfaceSubset.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -254,7 +254,7 @@ int main(int argc, char *argv[]) selectSurf, indexedOctree<treeDataTriSurface>::perturbTol() ), - bb.extend(rndGen, 1E-4), // slightly randomize bb + bb.extend(rndGen, 1e-4), // slightly randomize bb 8, // maxLevel 10, // leafsize 3.0 // duplicity diff --git a/etc/config/settings.csh b/etc/config/settings.csh index 94e5618bff1c69a1c2481be98138fa08ad2dd907..8c9ac17c7a822d3aa1f06d765fc61fa5be71650d 100644 --- a/etc/config/settings.csh +++ b/etc/config/settings.csh @@ -213,6 +213,13 @@ case ThirdParty: set mpfr_version=mpfr-3.1.0 set mpc_version=mpc-0.9 breaksw + case Gcc47: + case Gcc47++0x: + set gcc_version=gcc-4.7.0 + set gmp_version=gmp-5.0.4 + set mpfr_version=mpfr-3.1.0 + set mpc_version=mpc-0.9 + breaksw case Gcc45: case Gcc45++0x: set gcc_version=gcc-4.5.2 diff --git a/etc/config/settings.sh b/etc/config/settings.sh index dc39c480e1f09433e083ef98e0987b0825536915..0b12e4e453881a79484bfd374b58bc64709e51b5 100644 --- a/etc/config/settings.sh +++ b/etc/config/settings.sh @@ -233,7 +233,13 @@ case "${foamCompiler}" in OpenFOAM | ThirdParty) case "$WM_COMPILER" in Gcc | Gcc++0x | Gcc46 | Gcc46++0x) - gcc_version=gcc-4.6.2 + gcc_version=gcc-4.6.1 + gmp_version=gmp-5.0.4 + mpfr_version=mpfr-3.1.0 + mpc_version=mpc-0.9 + ;; + Gcc47 | Gcc47++0x) + gcc_version=gcc-4.7.0 gmp_version=gmp-5.0.4 mpfr_version=mpfr-3.1.0 mpc_version=mpc-0.9 diff --git a/src/Allwmake b/src/Allwmake index c4cbe16c95bd1db26c6c04cad1f1e9afcb1fe3cf..a61c7a2e3e28a4b4f90763fc505c67785dd5f72f 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -52,6 +52,8 @@ wmake $makeType conversion wmake $makeType sampling +wmake $makeType mesh/extrudeModel + wmake $makeType dynamicMesh wmake $makeType dynamicFvMesh wmake $makeType topoChangerFvMesh diff --git a/src/OSspecific/POSIX/clockTime/clockTime.C b/src/OSspecific/POSIX/clockTime/clockTime.C index 1081019c4fd6f1051b03441c728a6803c9844aeb..56b80ad5053f90ac5f32c762e9abfccf7dd57049 100644 --- a/src/OSspecific/POSIX/clockTime/clockTime.C +++ b/src/OSspecific/POSIX/clockTime/clockTime.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,7 +36,7 @@ void Foam::clockTime::getTime(timeType& t) double Foam::clockTime::timeDifference(const timeType& beg, const timeType& end) { - return end.tv_sec - beg.tv_sec + 1E-6*(end.tv_usec - beg.tv_usec); + return end.tv_sec - beg.tv_sec + 1e-6*(end.tv_usec - beg.tv_usec); } diff --git a/src/OSspecific/POSIX/fileMonitor.C b/src/OSspecific/POSIX/fileMonitor.C index 31a734740d0fb814dfc0971dfd6bc99f865637e4..030e7639f4b69d3e3b6ce60104efb46cec6fb4ce 100644 --- a/src/OSspecific/POSIX/fileMonitor.C +++ b/src/OSspecific/POSIX/fileMonitor.C @@ -32,6 +32,7 @@ License #include "regIOobject.H" // for fileModificationSkew symbol #ifdef FOAM_USE_INOTIFY +# include <unistd.h> # include <sys/inotify.h> # include <sys/ioctl.h> # include <errno.h> diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index c58cf1afc292006cb18bc77bdd9e82540d2663c7..614a7cdae59f39b501b7b296ec9d81e3f6cac746 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -240,7 +240,6 @@ lduMatrix = matrices/lduMatrix $(lduMatrix)/lduMatrix/lduMatrix.C $(lduMatrix)/lduMatrix/lduMatrixOperations.C $(lduMatrix)/lduMatrix/lduMatrixATmul.C -$(lduMatrix)/lduMatrix/lduMatrixTests.C $(lduMatrix)/lduMatrix/lduMatrixUpdateMatrixInterfaces.C $(lduMatrix)/lduMatrix/lduMatrixSolver.C $(lduMatrix)/lduMatrix/lduMatrixSmoother.C @@ -314,6 +313,14 @@ $(algebraicPairGAMGAgglomeration)/algebraicPairGAMGAgglomeration.C meshes/lduMesh/lduMesh.C +LduMatrix = matrices/LduMatrix +$(LduMatrix)/LduMatrix/lduMatrices.C +$(LduMatrix)/LduMatrix/solverPerformance.C +$(LduMatrix)/LduMatrix/LduInterfaceField/LduInterfaceFields.C +$(LduMatrix)/Smoothers/lduSmoothers.C +$(LduMatrix)/Preconditioners/lduPreconditioners.C +$(LduMatrix)/Solvers/lduSolvers.C + primitiveShapes = meshes/primitiveShapes $(primitiveShapes)/line/line.C @@ -576,6 +583,13 @@ $(interpolations)/interpolationTable/tableReaders/tableReaders.C $(interpolations)/interpolationTable/tableReaders/openFoam/openFoamTableReaders.C $(interpolations)/interpolationTable/tableReaders/csv/csvTableReaders.C +interpolationWeights = $(interpolations)/interpolationWeights +$(interpolationWeights)/interpolationWeights/interpolationWeights.C +$(interpolationWeights)/linearInterpolationWeights/linearInterpolationWeights.C +$(interpolationWeights)/splineInterpolationWeights/splineInterpolationWeights.C + + + algorithms/indexedOctree/indexedOctreeName.C algorithms/indexedOctree/treeDataCell.C diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H index 90d70cc26bf929142a17f0f84deda9bb1d02fadc..d0689b0eb1955f82bb2ffee45f8d72e846a49fa0 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOps.H +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOps.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -37,6 +37,7 @@ SourceFiles #define ListOps_H #include "labelList.H" +#include "ops.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -209,6 +210,18 @@ label findSortedIndex ); +//- Find last element < given value in sorted list and return index, +// return -1 if not found. Binary search. +template<class ListType, class BinaryOp> +label findLower +( + const ListType&, + typename ListType::const_reference, + const label stary, + const BinaryOp& bop +); + + //- Find last element < given value in sorted list and return index, // return -1 if not found. Binary search. template<class ListType> diff --git a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C index 41e28c3f64eef5e008f2cb47f4ee0e0dddc4e5e5..be6337a4283e6e5f039ba9a8fc5e6ee9cb52fb87 100644 --- a/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C +++ b/src/OpenFOAM/containers/Lists/ListOps/ListOpsTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -592,12 +592,13 @@ Foam::label Foam::findSortedIndex } -template<class ListType> +template<class ListType, class BinaryOp> Foam::label Foam::findLower ( const ListType& l, typename ListType::const_reference t, - const label start + const label start, + const BinaryOp& bop ) { if (start >= l.size()) @@ -612,7 +613,7 @@ Foam::label Foam::findLower { label mid = (low + high)/2; - if (l[mid] < t) + if (bop(l[mid], t)) { low = mid; } @@ -622,13 +623,13 @@ Foam::label Foam::findLower } } - if (l[high] < t) + if (bop(l[high], t)) { return high; } else { - if (l[low] < t) + if (bop(l[low], t)) { return low; } @@ -640,6 +641,18 @@ Foam::label Foam::findLower } +template<class ListType> +Foam::label Foam::findLower +( + const ListType& l, + typename ListType::const_reference t, + const label start +) +{ + return findLower(l, t, start, lessOp<typename ListType::value_type>()); +} + + template<class Container, class T, int nRows> Foam::List<Container> Foam::initList(const T elems[nRows]) { diff --git a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H index 33e929baccdfe64220b30295a9ce7c7cd28621c3..e33acfa4643c3a01029c5300ba41759f6e74790e 100644 --- a/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H +++ b/src/OpenFOAM/containers/Lists/UIndirectList/UIndirectList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -119,6 +119,12 @@ public: inline void operator=(const T&); + // STL type definitions + + //- Type of values the UList contains. + typedef T value_type; + + // Ostream operator //- Write UIndirectList to Ostream diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.C b/src/OpenFOAM/db/objectRegistry/objectRegistry.C index 6fcaed2e2eab3df27a80a878edccd0d3e469ed0b..09307c3a5ce20194f5822e604829133d65748826 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.C +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -151,9 +151,25 @@ Foam::wordList Foam::objectRegistry::sortedNames(const word& ClassName) const const Foam::objectRegistry& Foam::objectRegistry::subRegistry ( - const word& name + const word& name, + const bool forceCreate ) const { + if (forceCreate && !foundObject<objectRegistry>(name)) + { + objectRegistry* fieldsCachePtr = new objectRegistry + ( + IOobject + ( + name, + time().constant(), + *this, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ); + fieldsCachePtr->store(); + } return lookupObject<objectRegistry>(name); } diff --git a/src/OpenFOAM/db/objectRegistry/objectRegistry.H b/src/OpenFOAM/db/objectRegistry/objectRegistry.H index 34ddc8fc348946e1a2869d527ad27cd80dbd2582..48cabcc1cfa79c63242306fb2654e3099cecaf59 100644 --- a/src/OpenFOAM/db/objectRegistry/objectRegistry.H +++ b/src/OpenFOAM/db/objectRegistry/objectRegistry.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -147,8 +147,13 @@ public: template<class Type> wordList names() const; - //- Lookup and return a const sub-objectRegistry - const objectRegistry& subRegistry(const word& name) const; + //- Lookup and return a const sub-objectRegistry. Optionally create + // it if it does not exist. + const objectRegistry& subRegistry + ( + const word& name, + const bool forceCreate = false + ) const; //- Lookup and return all objects of the given Type template<class Type> diff --git a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C index cf841919b8bf8bbc0565920f542855e79743f1f2..4e96c3012a53ab50cbeebdf30ef9f7f9456b486c 100644 --- a/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C +++ b/src/OpenFOAM/dimensionedTypes/dimensionedType/dimensionedType.C @@ -131,6 +131,16 @@ dimensioned<Type>::dimensioned token nextToken(is); is.putBack(nextToken); + // Check if the original format is used in which the name is provided + // and reset the name to that read + if (nextToken.isWord()) + { + is >> name_; + is >> nextToken; + is.putBack(nextToken); + } + + // If the dimensions are provided compare with the argument if (nextToken == token::BEGIN_SQR) { dimensionSet dims(is); @@ -391,8 +401,26 @@ dimensioned<Type> min template <class Type> Istream& operator>>(Istream& is, dimensioned<Type>& dt) { - // do a stream read op for a Type and a dimensions()et - is >> dt.name_ >> dt.dimensions_ >> dt.value_; + token nextToken(is); + is.putBack(nextToken); + + // Check if the original format is used in which the name is provided + // and reset the name to that read + if (nextToken.isWord()) + { + is >> dt.name_; + is >> nextToken; + is.putBack(nextToken); + } + + // If the dimensions are provided reset the dimensions to those read + if (nextToken == token::BEGIN_SQR) + { + is >> dt.dimensions_; + } + + // Read the value + is >> dt.value_; // Check state of Istream is.check("Istream& operator>>(Istream&, dimensioned<Type>&)"); diff --git a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C index 9397411ec41c0f12f884dffb30dc29b9493bb3c5..c26227cd0023258d364f61ed5480377beb655103 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C +++ b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.C @@ -365,7 +365,7 @@ scalar sumProd(const UList<Type>& f1, const UList<Type>& f2) if (f1.size() && (f1.size() == f2.size())) { scalar SumProd = 0.0; - TFOR_ALL_S_OP_F_OP_F(scalar, SumProd, +=, Type, f1, *, Type, f2) + TFOR_ALL_S_OP_F_OP_F(scalar, SumProd, +=, Type, f1, &&, Type, f2) return SumProd; } else @@ -498,7 +498,7 @@ template<class Type> scalar gSumProd(const UList<Type>& f1, const UList<Type>& f2) { scalar SumProd = sumProd(f1, f2); - reduce(SumProd, sumOp<Type>()); + reduce(SumProd, sumOp<scalar>()); return SumProd; } diff --git a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H index e3fd66afaf4baf65733ac23a07a80d9a93d1b625..869346e29aebfeb6d59896458c973df7f89de7dd 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H +++ b/src/OpenFOAM/fields/Fields/Field/FieldFunctions.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,8 +23,6 @@ License \*---------------------------------------------------------------------------*/ -#include "scalarField.H" - #define TEMPLATE template<class Type> #include "FieldFunctionsM.H" @@ -332,5 +330,6 @@ PRODUCT_OPERATOR(scalarProduct, &&, dotdot) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #include "undefFieldFunctionsM.H" +#include "scalarField.H" // ************************************************************************* // diff --git a/src/OpenFOAM/fields/Fields/scalarField/scalarField.C b/src/OpenFOAM/fields/Fields/scalarField/scalarField.C index 9000bb533a5df8938c5389a29be0f6b9e2a339b2..cd1859226525d9a6fa2d51e15c370baf40d0962e 100644 --- a/src/OpenFOAM/fields/Fields/scalarField/scalarField.C +++ b/src/OpenFOAM/fields/Fields/scalarField/scalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -86,6 +86,24 @@ tmp<scalarField> stabilise(const tmp<scalarField>& tsf, const scalar s) } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<> +scalar sumProd(const UList<scalar>& f1, const UList<scalar>& f2) +{ + if (f1.size() && (f1.size() == f2.size())) + { + scalar SumProd = 0.0; + TFOR_ALL_S_OP_F_OP_F(scalar, SumProd, +=, scalar, f1, *, scalar, f2) + return SumProd; + } + else + { + return 0.0; + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add) diff --git a/src/OpenFOAM/fields/Fields/scalarField/scalarField.H b/src/OpenFOAM/fields/Fields/scalarField/scalarField.H index 8d39528b9fa87b7ad13d7173762b5f0f12bb1291..d5a3b7659bf1e20af4bf7e151187eebca3218190 100644 --- a/src/OpenFOAM/fields/Fields/scalarField/scalarField.H +++ b/src/OpenFOAM/fields/Fields/scalarField/scalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,6 +72,12 @@ tmp<scalarField> stabilise(const UList<scalar>&, const scalar s); tmp<scalarField> stabilise(const tmp<scalarField>&, const scalar s); +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<> +scalar sumProd(const UList<scalar>& f1, const UList<scalar>& f2); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // BINARY_TYPE_OPERATOR(scalar, scalar, scalar, +, add) diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C index 448a009caba0396c33dfb38009d824e71d266113..5117f8cb23f5112aca4351c7ce8223ecde894c45 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricBoundaryField.C @@ -485,9 +485,35 @@ boundaryInternalField() const template<class Type, template<class> class PatchField, class GeoMesh> -Foam::lduInterfaceFieldPtrsList +Foam::LduInterfaceFieldPtrsList<Type> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField:: interfaces() const +{ + LduInterfaceFieldPtrsList<Type> interfaces(this->size()); + + forAll(interfaces, patchi) + { + if (isA<LduInterfaceField<Type> >(this->operator[](patchi))) + { + interfaces.set + ( + patchi, + &refCast<const LduInterfaceField<Type> > + ( + this->operator[](patchi) + ) + ); + } + } + + return interfaces; +} + + +template<class Type, template<class> class PatchField, class GeoMesh> +Foam::lduInterfaceFieldPtrsList +Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField:: +scalarInterfaces() const { lduInterfaceFieldPtrsList interfaces(this->size()); @@ -498,7 +524,10 @@ interfaces() const interfaces.set ( patchi, - &refCast<const lduInterfaceField>(this->operator[](patchi)) + &refCast<const lduInterfaceField> + ( + this->operator[](patchi) + ) ); } } diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index 56b9beee49ca4eb04e244fd36cba63b8f71efb11..5aef9e0fb819c61bf75c7e5122b3f30d35dc6733 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,6 +44,7 @@ SourceFiles #include "DimensionedField.H" #include "FieldField.H" #include "lduInterfaceFieldPtrsList.H" +#include "LduInterfaceFieldPtrsList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -191,7 +192,11 @@ public: //- Return a list of pointers for each patch field with only those // pointing to interfaces being set - lduInterfaceFieldPtrsList interfaces() const; + LduInterfaceFieldPtrsList<Type> interfaces() const; + + //- Return a list of pointers for each patch field with only those + // pointing to interfaces being set + lduInterfaceFieldPtrsList scalarInterfaces() const; //- Write boundary field as dictionary entry void writeEntry(const word& keyword, Ostream& os) const; diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C new file mode 100644 index 0000000000000000000000000000000000000000..968f5f4c0f0529d5dce4d573359b0b524c53761c --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.C @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class GeoField> +Foam::tmp<GeoField> Foam::uniformInterpolate +( + const HashPtrTable<GeoField, label, Hash<label> >& fields, + const labelList& indices, + const scalarField& weights +) +{ + const GeoField& field0 = *(*fields.begin()); + + // Interpolate + tmp<GeoField> tfld + ( + new GeoField + ( + IOobject + ( + "uniformInterpolate(" + field0.name() + ')', + field0.time().timeName(), + field0.db(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + weights[0]*(*fields[indices[0]]) + ) + ); + GeoField& fld = tfld(); + + for (label i = 1; i < indices.size(); ++i) + { + fld += weights[i]*(*fields[indices[i]]); + } + + return tfld; +} + + +template<class GeoField> +Foam::tmp<GeoField> Foam::uniformInterpolate +( + const IOobject& fieldIO, + const word& fieldName, + const wordList& times, + const scalarField& weights, + const objectRegistry& fieldsCache +) +{ + // Look up the first field + const objectRegistry& time0Fields = fieldsCache.lookupObject + < + const objectRegistry + > + ( + times[0] + ); + const GeoField& field0 = time0Fields.lookupObject + < + const GeoField + > + ( + fieldName + ); + + + // Interpolate + tmp<GeoField> tfld(new GeoField(fieldIO, weights[0]*field0)); + GeoField& fld = tfld(); + + for (label i = 1; i < times.size(); ++i) + { + const objectRegistry& timeIFields = fieldsCache.lookupObject + < + const objectRegistry + > + ( + times[i] + ); + const GeoField& fieldI = timeIFields.lookupObject + < + const GeoField + > + ( + fieldName + ); + + fld += weights[i]*fieldI; + } + + return tfld; +} + + +template<class GeoField> +Foam::tmp<GeoField> Foam::uniformInterpolate +( + const IOobject& fieldIO, + const word& fieldName, + const wordList& times, + const scalarField& weights, + const word& registryName +) +{ + return uniformInterpolate<GeoField> + ( + fieldIO, + fieldName, + times, + weights, + fieldIO.db().subRegistry(registryName, true) + ); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.H new file mode 100644 index 0000000000000000000000000000000000000000..f196f71c192e64e4bae65f268a2e57396b048d42 --- /dev/null +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/uniformInterpolate.H @@ -0,0 +1,83 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "GeometricField.H" +#include "HashPtrTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Global functions * * * * * * * * * * * * * // + +//- Interpolate selected fields (given by indices and corresponding weights) +// (boundary type becomes calculated). Fields stored per index. Field gets name +// "uniformInterpolate(" + fld.name() + ')'. +template<class GeoField> +tmp<GeoField> uniformInterpolate +( + const HashPtrTable<GeoField, label, Hash<label> >& fields, + const labelList& indices, + const scalarField& weights +); + +//- Interpolate fields. fieldsCache contains per timeName all loaded fields. +// Resulting field gets properties according to fieldIO +template<class GeoField> +tmp<GeoField> uniformInterpolate +( + const IOobject& fieldIO, + const word& fieldName, + const wordList& times, + const scalarField& weights, + const objectRegistry& fieldsCache +); + +//- Interpolate fields. fieldsCache contains per timeName all loaded fields. +// Resulting field gets properties according to fieldIO +template<class GeoField> +tmp<GeoField> uniformInterpolate +( + const IOobject& fieldIO, + const word& fieldName, + const wordList& times, + const scalarField& weights, + const word& registryName = "fieldsCache" +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "uniformInterpolate.C" +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/ReadFields/ReadFields.C b/src/OpenFOAM/fields/ReadFields/ReadFields.C index 7a17b362dc3a5eaa568081840ffddde5884f452f..a679082b417626c95f1928af2cc1c84ee8dd3b78 100644 --- a/src/OpenFOAM/fields/ReadFields/ReadFields.C +++ b/src/OpenFOAM/fields/ReadFields/ReadFields.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -127,4 +127,134 @@ Foam::wordList Foam::ReadFields } +template<class GeoField> +void Foam::ReadFields +( + const word& fieldName, + const typename GeoField::Mesh& mesh, + const wordList& timeNames, + objectRegistry& fieldsCache +) +{ + // Collect all times that are no longer used + { + HashSet<word> usedTimes(timeNames); + + DynamicList<word> unusedTimes(fieldsCache.size()); + + forAllIter(objectRegistry, fieldsCache, timeIter) + { + const word& tm = timeIter.key(); + if (!usedTimes.found(tm)) + { + unusedTimes.append(tm); + } + } + + //Info<< "Unloading times " << unusedTimes << endl; + + forAll(unusedTimes, i) + { + objectRegistry& timeCache = const_cast<objectRegistry&> + ( + fieldsCache.lookupObject<objectRegistry>(unusedTimes[i]) + ); + fieldsCache.checkOut(timeCache); + } + } + + + // Load any new fields + forAll(timeNames, i) + { + const word& tm = timeNames[i]; + + // Create if not found + if (!fieldsCache.found(tm)) + { + //Info<< "Creating registry for time " << tm << endl; + + // Create objectRegistry if not found + objectRegistry* timeCachePtr = new objectRegistry + ( + IOobject + ( + tm, + tm, + fieldsCache, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ); + timeCachePtr->store(); + } + + // Obtain cache for current time + const objectRegistry& timeCache = + fieldsCache.lookupObject<objectRegistry> + ( + tm + ); + + // Store field if not found + if (!timeCache.found(fieldName)) + { + //Info<< "Loading field " << fieldName + // << " for time " << tm << endl; + + GeoField loadedFld + ( + IOobject + ( + fieldName, + tm, + mesh.thisDb(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + mesh + ); + + // Transfer to timeCache (new objectRegistry and store flag) + GeoField* fldPtr = new GeoField + ( + IOobject + ( + fieldName, + tm, + timeCache, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + loadedFld + ); + fldPtr->store(); + } + } +} + + +template<class GeoField> +void Foam::ReadFields +( + const word& fieldName, + const typename GeoField::Mesh& mesh, + const wordList& timeNames, + const word& registryName +) +{ + ReadFields<GeoField> + ( + fieldName, + mesh, + timeNames, + const_cast<objectRegistry&> + ( + mesh.thisDb().subRegistry(registryName, true) + ) + ); +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/fields/ReadFields/ReadFields.H b/src/OpenFOAM/fields/ReadFields/ReadFields.H index 11ff547935c953a0d304addb781c0f2f204bd0d1..ac4bdb37c740e385ee3ad4b1a14ceadb0459ceca 100644 --- a/src/OpenFOAM/fields/ReadFields/ReadFields.H +++ b/src/OpenFOAM/fields/ReadFields/ReadFields.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -55,6 +55,28 @@ wordList ReadFields const bool syncPar = true ); +//- Helper routine to read GeometricFields. The fieldsCache is per time +// an objectRegistry of all stored fields +template<class GeoField> +static void ReadFields +( + const word& fieldName, + const typename GeoField::Mesh& mesh, + const wordList& timeNames, + objectRegistry& fieldsCache +); + +//- Helper routine to read GeometricFields. The fieldsCache is per time +// an objectRegistry of all stored fields +template<class GeoField> +static void ReadFields +( + const word& fieldName, + const typename GeoField::Mesh& mesh, + const wordList& timeNames, + const word& registryName = "fieldsCache" +); + } // End namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index edf94f38480d3830a0c2c5ac24f48d5d9aba42d0..4ec3bd407503688ef63465b8c36b502fd989cbbc 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -270,7 +270,7 @@ public: ) const; //- Read a value from the named option if present. - // Return true if the named option was found. + // Return supplied default otherwise. template<class T> inline T optionLookupOrDefault ( diff --git a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C new file mode 100644 index 0000000000000000000000000000000000000000..30fc2fc0f69fe8fb9018dfc057788f6ffd9013ad --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.C @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "interpolationWeights.H" +#include "addToRunTimeSelectionTable.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defineTypeNameAndDebug(interpolationWeights, 0); +defineRunTimeSelectionTable(interpolationWeights, word); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +interpolationWeights::interpolationWeights +( + const scalarField& samples +) +: + samples_(samples) +{} + + +// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // + +autoPtr<interpolationWeights> interpolationWeights::New +( + const word& type, + const scalarField& samples +) +{ + Info<< nl << "Selecting interpolationWeights " + << type << endl; + + wordConstructorTable::iterator cstrIter = + wordConstructorTablePtr_->find(type); + + if (cstrIter == wordConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "interpolationWeights::New(const word&, " + "const scalarField&)" + ) << "Unknown interpolationWeights type " + << type + << endl << endl + << "Valid interpolationWeights types are :" << endl + << wordConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<interpolationWeights>(cstrIter()(samples)); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +interpolationWeights::~interpolationWeights() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +//objectRegistry& interpolationWeights::registry +//( +// const objectRegistry& obr, +// const word& name +//) +//{ +// if (!obr.foundObject<objectRegistry>(name)) +// { +// objectRegistry* fieldsCachePtr = new objectRegistry +// ( +// IOobject +// ( +// name, +// obr.time().constant(), +// obr, +// IOobject::NO_READ, +// IOobject::NO_WRITE +// ) +// ); +// fieldsCachePtr->store(); +// } +// return const_cast<objectRegistry&>(obr.subRegistry(name)); +//} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.H b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.H new file mode 100644 index 0000000000000000000000000000000000000000..36e34728356902bd958b4958660cf1e68973f34f --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeights.H @@ -0,0 +1,159 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::interpolationWeights + +Description + Abstract base class for interpolating in 1D + +SourceFiles + interpolationWeights.C + interpolationWeightsTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef interpolationWeights_H +#define interpolationWeights_H + +#include "scalarField.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" +#include "pointField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class fvMesh; +class objectRegistry; + +/*---------------------------------------------------------------------------*\ + Class interpolationWeights Declaration +\*---------------------------------------------------------------------------*/ + +class interpolationWeights +{ + +private: + + // Private Member Functions + + //- Disallow default bitwise copy construct + interpolationWeights(const interpolationWeights&); + + //- Disallow default bitwise assignment + void operator=(const interpolationWeights&); + +protected: + + const scalarField& samples_; + +public: + + //- Runtime type information + TypeName("interpolationWeights"); + + + // Declare run-time constructor selection table + + declareRunTimeSelectionTable + ( + autoPtr, + interpolationWeights, + word, + ( + const scalarField& samples + ), + (samples) + ); + + + // Constructors + + //- Construct from components + interpolationWeights(const scalarField& samples); + + + // Selectors + + //- Return a reference to the selected interpolationWeights + static autoPtr<interpolationWeights> New + ( + const word& type, + const scalarField& samples + ); + + + //- Destructor + virtual ~interpolationWeights(); + + + // Member Functions + + //- Calculate weights and indices to calculate t from samples. + // Returns true if indices changed. + virtual bool valueWeights + ( + const scalar t, + labelList& indices, + scalarField& weights + ) const = 0; + + //- Calculate weights and indices to calculate integrand of t1..t2 + // from samples. Returns true if indices changed. + virtual bool integrationWeights + ( + const scalar t1, + const scalar t2, + labelList& indices, + scalarField& weights + ) const = 0; + + //- Helper: weighted sum + template<class ListType1, class ListType2> + static typename outerProduct + < + typename ListType1::value_type, + typename ListType2::value_type + >::type + weightedSum(const ListType1& f1, const ListType2& f2); + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "interpolationWeightsTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchScalarField.C b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeightsTemplates.C similarity index 57% rename from src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchScalarField.C rename to src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeightsTemplates.C index f70ca47a7834c042713f9fdb106b09eaad3fd1a2..9050921b9e59214a2d8cce18205faa645e2f0368 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchScalarField.C +++ b/src/OpenFOAM/interpolations/interpolationWeights/interpolationWeights/interpolationWeightsTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,7 +23,11 @@ License \*---------------------------------------------------------------------------*/ -#include "processorCyclicFvPatchScalarField.H" +#include "interpolationWeights.H" +#include "ListOps.H" +#include "IOobject.H" +#include "HashSet.H" +#include "objectRegistry.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -32,48 +36,38 @@ namespace Foam // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//template<> -//void processorCyclicFvPatchField<scalar>::initInterfaceMatrixUpdate -//( -// const scalarField& psiInternal, -// scalarField&, -// const lduMatrix&, -// const scalarField&, -// const direction, -// const Pstream::commsTypes commsType -//) const -//{ -// procPatch_.compressedSend -// ( -// commsType, -// patch().patchInternalField(psiInternal)() -// ); -//} -// -// -//template<> -//void processorCyclicFvPatchField<scalar>::updateInterfaceMatrix -//( -// const scalarField&, -// scalarField& result, -// const lduMatrix&, -// const scalarField& coeffs, -// const direction, -// const Pstream::commsTypes commsType -//) const -//{ -// scalarField pnf -// ( -// procPatch_.compressedReceive<scalar>(commsType, this->size())() -// ); -// -// const labelUList& faceCells = patch().faceCells(); -// -// forAll(faceCells, facei) -// { -// result[faceCells[facei]] -= coeffs[facei]*pnf[facei]; -// } -//} +template<class ListType1, class ListType2> +typename Foam::outerProduct +< + typename ListType1::value_type, + typename ListType2::value_type +>::type +Foam::interpolationWeights::weightedSum +( + const ListType1& f1, + const ListType2& f2 +) +{ + typedef typename outerProduct + < + typename ListType1::value_type, + typename ListType2::value_type + >::type returnType; + + if (f1.size()) + { + returnType SumProd = f1[0]*f2[0]; + for (label i = 1; i < f1.size(); ++i) + { + SumProd += f1[i]*f2[i]; + } + return SumProd; + } + else + { + return pTraits<returnType>::zero; + } +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C new file mode 100644 index 0000000000000000000000000000000000000000..89497fba3769e9404af15a09c4a67503a17ecbf6 --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.C @@ -0,0 +1,252 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "linearInterpolationWeights.H" +#include "addToRunTimeSelectionTable.H" +#include "ListOps.H" +#include "Pair.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(linearInterpolationWeights, 0); +addToRunTimeSelectionTable +( + interpolationWeights, + linearInterpolationWeights, + word +); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::Pair<Foam::scalar> linearInterpolationWeights::integrationWeights +( + const label i, + const scalar t +) const +{ + // t is in range samples_[i] .. samples_[i+1] + + scalar s = (t-samples_[i])/(samples_[i+1]-samples_[i]); + + if (s < -SMALL || s > 1+SMALL) + { + FatalErrorIn("linearInterpolationWeights::integrationWeights(..)") + << "Value " << t << " outside range " << samples_[i] + << " .. " << samples_[i+1] + << exit(FatalError); + } + + scalar d = samples_[i+1]-t; + + return Pair<scalar>(d*0.5*(1-s), d*0.5*(1+s)); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +linearInterpolationWeights::linearInterpolationWeights +( + const scalarField& samples +) +: + interpolationWeights(samples), + index_(-1) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool linearInterpolationWeights::valueWeights +( + const scalar t, + labelList& indices, + scalarField& weights +) const +{ + bool indexChanged = false; + + // Check if current timeIndex is still valid + if + ( + index_ >= 0 + && index_ < samples_.size() + && ( + samples_[index_] <= t + && (index_ == samples_.size()-1 || t <= samples_[index_+1]) + ) + ) + { + // index_ still at correct slot + } + else + { + // search for correct index + index_ = findLower(samples_, t); + indexChanged = true; + } + + + if (index_ == -1) + { + // Use first element only + indices.setSize(1); + weights.setSize(1); + indices[0] = 0; + weights[0] = 1.0; + } + else if (index_ == samples_.size()-1) + { + // Use last element only + indices.setSize(1); + weights.setSize(1); + indices[0] = samples_.size()-1; + weights[0] = 1.0; + } + else + { + // Interpolate + indices.setSize(2); + weights.setSize(2); + + indices[0] = index_; + indices[1] = index_+1; + + scalar t0 = samples_[indices[0]]; + scalar t1 = samples_[indices[1]]; + scalar deltaT = t1-t0; + + weights[0] = (t1-t)/deltaT; + weights[1] = 1.0-weights[0]; + } + + return indexChanged; +} + + +bool linearInterpolationWeights::integrationWeights +( + const scalar t1, + const scalar t2, + labelList& indices, + scalarField& weights +) const +{ + if (t2 < t1-VSMALL) + { + FatalErrorIn("linearInterpolationWeights::integrationWeights(..)") + << "Integration should be in positive direction." + << " t1:" << t1 << " t2:" << t2 + << exit(FatalError); + } + + // Currently no fancy logic on cached index like in value + + //- Find lower or equal index + label i1 = findLower(samples_, t1, 0, lessEqOp<scalar>()); + //- Find lower index + label i2 = findLower(samples_, t2); + + // For now just fail if any outside table + if (i1 == -1 || i2 == samples_.size()-1) + { + FatalErrorIn("linearInterpolationWeights::integrationWeights(..)") + << "Integrating outside table " << samples_[0] << ".." + << samples_.last() << " not implemented." + << " t1:" << t1 << " t2:" << t2 << exit(FatalError); + } + + label nIndices = i2-i1+2; + + + // Determine if indices already correct + bool anyChanged = false; + + if (nIndices != indices.size()) + { + anyChanged = true; + } + else + { + // Closer check + + label index = i1; + forAll(indices, i) + { + if (indices[i] != index) + { + anyChanged = true; + break; + } + index++; + } + } + + indices.setSize(nIndices); + weights.setSize(nIndices); + weights = 0.0; + + // Sum from i1+1 to i2+1 + for (label i = i1+1; i <= i2; i++) + { + scalar d = samples_[i+1]-samples_[i]; + indices[i-i1] = i; + weights[i-i1] += 0.5*d; + indices[i+1-i1] = i+1; + weights[i+1-i1] += 0.5*d; + } + + // Add from i1 to t1 + { + Pair<scalar> i1Tot1 = integrationWeights(i1, t1); + indices[0] = i1; + weights[0] += i1Tot1.first(); + indices[1] = i1+1; + weights[1] += i1Tot1.second(); + } + + // Subtract from t2 to i2+1 + { + Pair<scalar> wghts = integrationWeights(i2, t2); + indices[i2-i1] = i2; + weights[i2-i1] += -wghts.first(); + indices[i2-i1+1] = i2+1; + weights[i2-i1+1] += -wghts.second(); + } + + return anyChanged; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.H b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.H new file mode 100644 index 0000000000000000000000000000000000000000..871eb30599cdd5a06d73ad9671af22a190d4152c --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolationWeights/linearInterpolationWeights/linearInterpolationWeights.H @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::linearInterpolationWeights + +Description + +SourceFiles + linearInterpolationWeights.C + +\*---------------------------------------------------------------------------*/ + +#ifndef linearInterpolationWeights_H +#define linearInterpolationWeights_H + +#include "interpolationWeights.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class linearInterpolationWeights Declaration +\*---------------------------------------------------------------------------*/ + +class linearInterpolationWeights +: + public interpolationWeights +{ + +private: + + // Private data + + //- Cached index in samples from previous invocation + mutable label index_; + + // Private Member Functions + + //- Get weights of i and i+1 to calculate integration from t to + // samples_[i+1] + Pair<scalar> integrationWeights + ( + const label i, + const scalar t + ) const; + +public: + + //- Runtime type information + TypeName("linear"); + + // Constructors + + //- Construct from components + linearInterpolationWeights + ( + const scalarField& samples + ); + + + //- Destructor + virtual ~linearInterpolationWeights() + {} + + + // Member Functions + + //- Calculate weights and indices to calculate t from samples. + // Returns true if indices changed. + virtual bool valueWeights + ( + const scalar t, + labelList& indices, + scalarField& weights + ) const; + + //- Calculate weights and indices to calculate integrand of t1..t2 + // from samples. Returns true if indices changed. + virtual bool integrationWeights + ( + const scalar t1, + const scalar t2, + labelList& indices, + scalarField& weights + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.C b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.C new file mode 100644 index 0000000000000000000000000000000000000000..854146cdff53e41efdcab8204dcdee1883d962e6 --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.C @@ -0,0 +1,228 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "splineInterpolationWeights.H" +#include "addToRunTimeSelectionTable.H" +#include "ListOps.H" +#include "linearInterpolationWeights.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(splineInterpolationWeights, 0); +addToRunTimeSelectionTable +( + interpolationWeights, + splineInterpolationWeights, + word +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +splineInterpolationWeights::splineInterpolationWeights +( + const scalarField& samples, + const bool checkEqualDistance +) +: + interpolationWeights(samples), + index_(-1) +{ + if (checkEqualDistance && samples_.size() > 2) + { + const scalar interval = samples_[1]-samples[0]; + for (label i = 2; i < samples_.size(); i++) + { + scalar d = samples_[i]-samples[i-1]; + + if (mag(d-interval) > SMALL) + { + WarningIn + ( + "splineInterpolationWeights::splineInterpolationWeights" + "(const scalarField&)" + ) << "Spline interpolation only valid for constant intervals." + << nl + << "Interval 0-1 : " << interval << nl + << "Interval " << i-1 << '-' << i << " : " + << d << endl; + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool splineInterpolationWeights::valueWeights +( + const scalar t, + labelList& indices, + scalarField& weights +) const +{ + bool indexChanged = false; + + // linear interpolation + if (samples_.size() <= 2) + { + return linearInterpolationWeights(samples_).valueWeights + ( + t, + indices, + weights + ); + } + + // Check if current timeIndex is still valid + if + ( + index_ >= 0 + && index_ < samples_.size() + && ( + samples_[index_] <= t + && (index_ == samples_.size()-1 || t <= samples_[index_+1]) + ) + ) + { + // index_ still at correct slot + } + else + { + // search for correct index + index_ = findLower(samples_, t); + indexChanged = true; + } + + + // Clamp if outside table + if (index_ == -1) + { + indices.setSize(1); + weights.setSize(1); + + indices[0] = 0; + weights[0] = 1; + return indexChanged; + } + else if (index_ == samples_.size()-1) + { + indices.setSize(1); + weights.setSize(1); + + indices[0] = samples_.size()-1; + weights[0] = 1; + return indexChanged; + } + + + + label lo = index_; + label hi = index_+1; + + // weighting + scalar mu = (t - samples_[lo])/(samples_[hi] - samples_[lo]); + + scalar w0 = 0.5*(mu*(-1+mu*(2-mu))); // coeff of lo-1 + scalar w1 = 0.5*(2+mu*(mu*(-5 + mu*(3)))); // coeff of lo + scalar w2 = 0.5*(mu*(1 + mu*(4 + mu*(-3)))); // coeff of hi + scalar w3 = 0.5*(mu*mu*(-1 + mu)); // coeff of hi+1 + + if (lo > 0) + { + if (hi < samples_.size()-1) + { + // Four points available + indices.setSize(4); + weights.setSize(4); + + indices[0] = lo-1; + indices[1] = lo; + indices[2] = hi; + indices[3] = hi+1; + + weights[0] = w0; + weights[1] = w1; + weights[2] = w2; + weights[3] = w3; + } + else + { + // No y3 available. Extrapolate: y3=3*y2-y1 + indices.setSize(3); + weights.setSize(3); + + indices[0] = lo-1; + indices[1] = lo; + indices[2] = hi; + + weights[0] = w0; + weights[1] = w1 - w3; + weights[2] = w2 + 2*w3; + } + } + else + { + // No y0 available. Extrapolate: y0=2*y1-y2; + if (hi < samples_.size()-1) + { + indices.setSize(3); + weights.setSize(3); + + indices[0] = lo; + indices[1] = hi; + indices[2] = hi+1; + + weights[0] = w1 + 2*w0; + weights[1] = w2 - w0; + weights[2] = w3; + } + else + { + indices.setSize(2); + weights.setSize(2); + + indices[0] = lo; + indices[1] = hi; + + weights[0] = w1 + 2*w0 - w3; + weights[1] = w2 - w0 + 2*w3; + } + } + + return indexChanged; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.H b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.H new file mode 100644 index 0000000000000000000000000000000000000000..15660ff90cf5233ee310e68148414d274c9bd979 --- /dev/null +++ b/src/OpenFOAM/interpolations/interpolationWeights/splineInterpolationWeights/splineInterpolationWeights.H @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::splineInterpolationWeights + +Description + Catmull-Rom spline interpolation. + +SourceFiles + splineInterpolationWeights.C + +\*---------------------------------------------------------------------------*/ + +#ifndef splineInterpolationWeights_H +#define splineInterpolationWeights_H + +#include "interpolationWeights.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class splineInterpolationWeights Declaration +\*---------------------------------------------------------------------------*/ + +class splineInterpolationWeights +: + public interpolationWeights +{ + +private: + + // Private data + + //- Cached index in samples from previous invocation + mutable label index_; + +public: + + //- Runtime type information + TypeName("spline"); + + // Constructors + + //- Construct from components. By default make sure samples are + // equidistant. + splineInterpolationWeights + ( + const scalarField& samples, + const bool checkEqualDistance = true + ); + + + //- Destructor + virtual ~splineInterpolationWeights() + {} + + + // Member Functions + + //- Calculate weights and indices to calculate t from samples. + // Returns true if indices changed. + virtual bool valueWeights + ( + const scalar t, + labelList& indices, + scalarField& weights + ) const; + + //- Calculate weights and indices to calculate integrand of t1..t2 + // from samples. Returns true if indices changed. + virtual bool integrationWeights + ( + const scalar t1, + const scalar t2, + labelList& indices, + scalarField& weights + ) const + { + notImplemented + ( + "splineInterpolationWeights::integrationWeights(..)" + ); + return false; + } + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.C new file mode 100644 index 0000000000000000000000000000000000000000..6f8d95bafa384b36acf858cc9b021f8c446000dd --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.C @@ -0,0 +1,33 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template<class Type> +Foam::LduInterfaceField<Type>::~LduInterfaceField() +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H new file mode 100644 index 0000000000000000000000000000000000000000..06718d1c786674a484c14ecb967dd3c1ca7074e5 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H @@ -0,0 +1,128 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::LduInterfaceField + +Description + An abstract base class for implicitly-coupled interface fields + e.g. processor and cyclic patch fields. + +SourceFiles + LduInterfaceField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef LduInterfaceField_H +#define LduInterfaceField_H + +#include "lduInterfaceField.H" +#include "primitiveFieldsFwd.H" +#include "Pstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +class lduMatrix; + +/*---------------------------------------------------------------------------*\ + Class LduInterfaceField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class LduInterfaceField +: + public lduInterfaceField +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + LduInterfaceField(const LduInterfaceField&); + + //- Disallow default bitwise assignment + void operator=(const LduInterfaceField&); + + +public: + + //- Runtime type information + TypeName("LduInterfaceField"); + + + // Constructors + + //- Construct given coupled patch + LduInterfaceField(const lduInterface& patch) + : + lduInterfaceField(patch) + {} + + + //- Destructor + virtual ~LduInterfaceField(); + + + // Member Functions + + // Coupled interface functionality + + //- Initialise neighbour matrix update + virtual void initInterfaceMatrixUpdate + ( + Field<Type>&, + const Field<Type>&, + const scalarField&, + const Pstream::commsTypes commsType + ) const + {} + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field<Type>&, + const Field<Type>&, + const scalarField&, + const Pstream::commsTypes commsType + ) const = 0; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "LduInterfaceField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFieldPtrsList.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFieldPtrsList.H new file mode 100644 index 0000000000000000000000000000000000000000..b669a565d90b62c5b24ba9f3127f3c9df8744724 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFieldPtrsList.H @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Type + lduInterfaceFieldPtrsList + +Description + List of coupled interface fields to be used in coupling. + +\*---------------------------------------------------------------------------*/ + +#ifndef LduInterfaceFieldPtrsList_H +#define LduInterfaceFieldPtrsList_H + +#include "LduInterfaceField.H" +#include "UPtrList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class LduInterfaceFieldPtrsList Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class LduInterfaceFieldPtrsList +: + public UPtrList<const LduInterfaceField<Type> > +{ +public: + + LduInterfaceFieldPtrsList(label size) + : + UPtrList<const LduInterfaceField<Type> >(size) + {} +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFields.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFields.C new file mode 100644 index 0000000000000000000000000000000000000000..002e3cf7005092d1c0253ff89496199afe00a050 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceFields.C @@ -0,0 +1,41 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "LduInterfaceField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTemplateTypeNameAndDebug(Foam::LduInterfaceField<Foam::scalar>, 0); +defineTemplateTypeNameAndDebug(Foam::LduInterfaceField<Foam::vector>, 0); +defineTemplateTypeNameAndDebug +( + Foam::LduInterfaceField<Foam::sphericalTensor>, + 0 +); +defineTemplateTypeNameAndDebug(Foam::LduInterfaceField<Foam::symmTensor>, 0); +defineTemplateTypeNameAndDebug(Foam::LduInterfaceField<Foam::tensor>, 0); + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.C new file mode 100644 index 0000000000000000000000000000000000000000..fb131308b37e5773bae74f85525e529d5f11f574 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.C @@ -0,0 +1,389 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "lduMatrix.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::LduMatrix<Type, DType, LUType>::LduMatrix(const lduMesh& mesh) +: + lduMesh_(mesh), + diagPtr_(NULL), + upperPtr_(NULL), + lowerPtr_(NULL), + sourcePtr_(NULL), + interfaces_(0), + interfacesUpper_(0), + interfacesLower_(0) +{} + + +template<class Type, class DType, class LUType> +Foam::LduMatrix<Type, DType, LUType>::LduMatrix(const LduMatrix& A) +: + lduMesh_(A.lduMesh_), + diagPtr_(NULL), + upperPtr_(NULL), + lowerPtr_(NULL), + sourcePtr_(NULL), + interfaces_(0), + interfacesUpper_(0), + interfacesLower_(0) +{ + if (A.diagPtr_) + { + diagPtr_ = new Field<DType>(*(A.diagPtr_)); + } + + if (A.upperPtr_) + { + upperPtr_ = new Field<LUType>(*(A.upperPtr_)); + } + + if (A.lowerPtr_) + { + lowerPtr_ = new Field<LUType>(*(A.lowerPtr_)); + } + + if (A.sourcePtr_) + { + sourcePtr_ = new Field<Type>(*(A.sourcePtr_)); + } +} + + +template<class Type, class DType, class LUType> +Foam::LduMatrix<Type, DType, LUType>::LduMatrix(LduMatrix& A, bool reUse) +: + lduMesh_(A.lduMesh_), + diagPtr_(NULL), + upperPtr_(NULL), + lowerPtr_(NULL), + sourcePtr_(NULL), + interfaces_(0), + interfacesUpper_(0), + interfacesLower_(0) +{ + if (reUse) + { + if (A.diagPtr_) + { + diagPtr_ = A.diagPtr_; + A.diagPtr_ = NULL; + } + + if (A.upperPtr_) + { + upperPtr_ = A.upperPtr_; + A.upperPtr_ = NULL; + } + + if (A.lowerPtr_) + { + lowerPtr_ = A.lowerPtr_; + A.lowerPtr_ = NULL; + } + + if (A.sourcePtr_) + { + sourcePtr_ = A.sourcePtr_; + A.sourcePtr_ = NULL; + } + } + else + { + if (A.diagPtr_) + { + diagPtr_ = new Field<DType>(*(A.diagPtr_)); + } + + if (A.upperPtr_) + { + upperPtr_ = new Field<LUType>(*(A.upperPtr_)); + } + + if (A.lowerPtr_) + { + lowerPtr_ = new Field<LUType>(*(A.lowerPtr_)); + } + + if (A.sourcePtr_) + { + sourcePtr_ = new Field<Type>(*(A.sourcePtr_)); + } + } +} + + +template<class Type, class DType, class LUType> +Foam::LduMatrix<Type, DType, LUType>::LduMatrix +( + const lduMesh& mesh, + Istream& is +) +: + lduMesh_(mesh), + diagPtr_(new Field<DType>(is)), + upperPtr_(new Field<LUType>(is)), + lowerPtr_(new Field<LUType>(is)), + sourcePtr_(new Field<Type>(is)), + interfaces_(0), + interfacesUpper_(0), + interfacesLower_(0) +{} + + +// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::LduMatrix<Type, DType, LUType>::~LduMatrix() +{ + if (diagPtr_) + { + delete diagPtr_; + } + + if (upperPtr_) + { + delete upperPtr_; + } + + if (lowerPtr_) + { + delete lowerPtr_; + } + + if (sourcePtr_) + { + delete sourcePtr_; + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::Field<DType>& Foam::LduMatrix<Type, DType, LUType>::diag() +{ + if (!diagPtr_) + { + diagPtr_ = new Field<DType>(lduAddr().size(), pTraits<DType>::zero); + } + + return *diagPtr_; +} + + +template<class Type, class DType, class LUType> +Foam::Field<LUType>& Foam::LduMatrix<Type, DType, LUType>::upper() +{ + if (!upperPtr_) + { + if (lowerPtr_) + { + upperPtr_ = new Field<LUType>(*lowerPtr_); + } + else + { + upperPtr_ = new Field<LUType> + ( + lduAddr().lowerAddr().size(), + pTraits<LUType>::zero + ); + } + } + + return *upperPtr_; +} + + +template<class Type, class DType, class LUType> +Foam::Field<LUType>& Foam::LduMatrix<Type, DType, LUType>::lower() +{ + if (!lowerPtr_) + { + if (upperPtr_) + { + lowerPtr_ = new Field<LUType>(*upperPtr_); + } + else + { + lowerPtr_ = new Field<LUType> + ( + lduAddr().lowerAddr().size(), + pTraits<LUType>::zero + ); + } + } + + return *lowerPtr_; +} + + +template<class Type, class DType, class LUType> +Foam::Field<Type>& Foam::LduMatrix<Type, DType, LUType>::source() +{ + if (!sourcePtr_) + { + sourcePtr_ = new Field<Type>(lduAddr().size(), pTraits<Type>::zero); + } + + return *sourcePtr_; +} + + +template<class Type, class DType, class LUType> +const Foam::Field<DType>& Foam::LduMatrix<Type, DType, LUType>::diag() const +{ + if (!diagPtr_) + { + FatalErrorIn + ( + "const Field<DType>& LduMatrix<Type, DType, LUType>::diag() const" + ) << "diagPtr_ unallocated" + << abort(FatalError); + } + + return *diagPtr_; +} + + +template<class Type, class DType, class LUType> +const Foam::Field<LUType>& Foam::LduMatrix<Type, DType, LUType>::upper() const +{ + if (!lowerPtr_ && !upperPtr_) + { + FatalErrorIn + ( + "const Field<LUType>& LduMatrix<Type, DType, LUType>::upper() const" + ) << "lowerPtr_ or upperPtr_ unallocated" + << abort(FatalError); + } + + if (upperPtr_) + { + return *upperPtr_; + } + else + { + return *lowerPtr_; + } +} + + +template<class Type, class DType, class LUType> +const Foam::Field<LUType>& Foam::LduMatrix<Type, DType, LUType>::lower() const +{ + if (!lowerPtr_ && !upperPtr_) + { + FatalErrorIn + ( + "const Field<LUType>& LduMatrix<Type, DType, LUType>::lower() const" + ) << "lowerPtr_ or upperPtr_ unallocated" + << abort(FatalError); + } + + if (lowerPtr_) + { + return *lowerPtr_; + } + else + { + return *upperPtr_; + } +} + + +template<class Type, class DType, class LUType> +const Foam::Field<Type>& Foam::LduMatrix<Type, DType, LUType>::source() const +{ + if (!sourcePtr_) + { + FatalErrorIn + ( + "const Field<Type>& LduMatrix<Type, DType, LUType>::source() const" + ) << "sourcePtr_ unallocated" + << abort(FatalError); + } + + return *sourcePtr_; +} + + +// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const LduMatrix<Type, DType, LUType>& ldum +) +{ + if (ldum.diagPtr_) + { + os << "Diagonal = " + << *ldum.diagPtr_ + << endl << endl; + } + + if (ldum.upperPtr_) + { + os << "Upper triangle = " + << *ldum.upperPtr_ + << endl << endl; + } + + if (ldum.lowerPtr_) + { + os << "Lower triangle = " + << *ldum.lowerPtr_ + << endl << endl; + } + + if (ldum.sourcePtr_) + { + os << "Source = " + << *ldum.sourcePtr_ + << endl << endl; + } + + os.check("Ostream& operator<<(Ostream&, const LduMatrix&"); + + return os; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "LduMatrixOperations.C" +#include "LduMatrixATmul.C" +#include "LduMatrixUpdateMatrixInterfaces.C" +#include "LduMatrixPreconditioner.C" +#include "LduMatrixSmoother.C" +#include "LduMatrixSolver.C" + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H new file mode 100644 index 0000000000000000000000000000000000000000..c2414b0f8bc24a44a14a4421f8368a2a437d939f --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H @@ -0,0 +1,806 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::LduMatrix + +Description + LduMatrix is a general matrix class in which the coefficients are + stored as three arrays, one for the upper triangle, one for the + lower triangle and a third for the diagonal. + + Addressing arrays must be supplied for the upper and lower triangles. + +Note + It might be better if this class were organised as a hierachy starting + from an empty matrix, then deriving diagonal, symmetric and asymmetric + matrices. + +SourceFiles + LduMatrixATmul.C + LduMatrix.C + LduMatrixOperations.C + LduMatrixSolver.C + LduMatrixPreconditioner.C + LduMatrixTests.C + LduMatrixUpdateMatrixInterfaces.C + +\*---------------------------------------------------------------------------*/ + +#ifndef LduMatrix_H +#define LduMatrix_H + +#include "lduMesh.H" +#include "Field.H" +#include "FieldField.H" +#include "LduInterfaceFieldPtrsList.H" +#include "SolverPerformance.H" +#include "typeInfo.H" +#include "autoPtr.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template<class Type, class DType, class LUType> +class LduMatrix; + +template<class Type, class DType, class LUType> +Ostream& operator<< +( + Ostream&, + const LduMatrix<Type, DType, LUType>& +); + + +/*---------------------------------------------------------------------------*\ + Class LduMatrix Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class LduMatrix +{ + // private data + + //- LDU mesh reference + const lduMesh& lduMesh_; + + //- Diagonal coefficients + Field<DType> *diagPtr_; + + //- Off-diagonal coefficients + Field<LUType> *upperPtr_, *lowerPtr_; + + //- Source + Field<Type> *sourcePtr_; + + //- Field interfaces (processor patches etc.) + LduInterfaceFieldPtrsList<Type> interfaces_; + + //- Off-diagonal coefficients for interfaces + FieldField<Field, LUType> interfacesUpper_, interfacesLower_; + + +public: + + friend class SolverPerformance<Type>; + + //- Abstract base-class for LduMatrix solvers + class solver + { + protected: + + // Protected data + + word fieldName_; + const LduMatrix<Type, DType, LUType>& matrix_; + + //- dictionary of controls + dictionary controlDict_; + + //- Maximum number of iterations in the solver + label maxIter_; + + //- Final convergence tolerance + Type tolerance_; + + //- Convergence tolerance relative to the initial + Type relTol_; + + + // Protected Member Functions + + //- Read a control parameter from controlDict + template<class T> + inline void readControl + ( + const dictionary& controlDict, + T& control, + const word& controlName + ); + + + //- Read the control parameters from the controlDict_ + virtual void readControls(); + + + public: + + //- Runtime type information + virtual const word& type() const = 0; + + + // Declare run-time constructor selection tables + + declareRunTimeSelectionTable + ( + autoPtr, + solver, + symMatrix, + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ), + ( + fieldName, + matrix, + solverDict + ) + ); + + declareRunTimeSelectionTable + ( + autoPtr, + solver, + asymMatrix, + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ), + ( + fieldName, + matrix, + solverDict + ) + ); + + + // Constructors + + solver + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ); + + + // Selectors + + //- Return a new solver + static autoPtr<solver> New + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ); + + + // Destructor + + virtual ~solver() + {} + + + // Member functions + + // Access + + const word& fieldName() const + { + return fieldName_; + } + + const LduMatrix<Type, DType, LUType>& matrix() const + { + return matrix_; + } + + + //- Read and reset the solver parameters from the given dictionary + virtual void read(const dictionary& solverDict); + + virtual SolverPerformance<Type> solve + ( + Field<Type>& psi + ) const = 0; + + //- Return the matrix norm used to normalise the residual for the + // stopping criterion + Type normFactor + ( + const Field<Type>& psi, + const Field<Type>& Apsi, + Field<Type>& tmpField + ) const; + }; + + + //- Abstract base-class for LduMatrix smoothers + class smoother + { + protected: + + // Protected data + + word fieldName_; + const LduMatrix<Type, DType, LUType>& matrix_; + + + public: + + //- Runtime type information + virtual const word& type() const = 0; + + + // Declare run-time constructor selection tables + + declareRunTimeSelectionTable + ( + autoPtr, + smoother, + symMatrix, + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix + ), + ( + fieldName, + matrix + ) + ); + + declareRunTimeSelectionTable + ( + autoPtr, + smoother, + asymMatrix, + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix + ), + ( + fieldName, + matrix + ) + ); + + + // Constructors + + smoother + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix + ); + + + // Selectors + + //- Return a new smoother + static autoPtr<smoother> New + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& smootherDict + ); + + + // Destructor + + virtual ~smoother() + {} + + + // Member functions + + // Access + + const word& fieldName() const + { + return fieldName_; + } + + const LduMatrix<Type, DType, LUType>& matrix() const + { + return matrix_; + } + + + //- Smooth the solution for a given number of sweeps + virtual void smooth + ( + Field<Type>& psi, + const label nSweeps + ) const = 0; + }; + + + //- Abstract base-class for LduMatrix preconditioners + class preconditioner + { + protected: + + // Protected data + + //- Reference to the base-solver this preconditioner is used with + const solver& solver_; + + + public: + + //- Runtime type information + virtual const word& type() const = 0; + + + // Declare run-time constructor selection tables + + declareRunTimeSelectionTable + ( + autoPtr, + preconditioner, + symMatrix, + ( + const solver& sol, + const dictionary& preconditionerDict + ), + (sol, preconditionerDict) + ); + + declareRunTimeSelectionTable + ( + autoPtr, + preconditioner, + asymMatrix, + ( + const solver& sol, + const dictionary& preconditionerDict + ), + (sol, preconditionerDict) + ); + + + // Constructors + + preconditioner + ( + const solver& sol + ) + : + solver_(sol) + {} + + + // Selectors + + //- Return a new preconditioner + static autoPtr<preconditioner> New + ( + const solver& sol, + const dictionary& preconditionerDict + ); + + + // Destructor + + virtual ~preconditioner() + {} + + + // Member functions + + //- Read and reset the preconditioner parameters + // from the given dictionary + virtual void read(const dictionary& preconditionerDict) + {} + + //- Return wA the preconditioned form of residual rA + virtual void precondition + ( + Field<Type>& wA, + const Field<Type>& rA + ) const = 0; + + //- Return wT the transpose-matrix preconditioned form of + // residual rT. + // This is only required for preconditioning asymmetric matrices. + virtual void preconditionT + ( + Field<Type>& wT, + const Field<Type>& rT + ) const + { + notImplemented + ( + type() +"::preconditionT" + "(Field<Type>& wT, const Field<Type>& rT)" + ); + } + }; + + + // Static data + + // Declare name of the class and its debug switch + ClassName("LduMatrix"); + + + // Constructors + + //- Construct given an LDU addressed mesh. + // The coefficients are initially empty for subsequent setting. + LduMatrix(const lduMesh&); + + //- Construct as copy + LduMatrix(const LduMatrix<Type, DType, LUType>&); + + //- Construct as copy or re-use as specified. + LduMatrix(LduMatrix<Type, DType, LUType>&, bool reUse); + + //- Construct given an LDU addressed mesh and an Istream + // from which the coefficients are read + LduMatrix(const lduMesh&, Istream&); + + + // Destructor + + ~LduMatrix(); + + + // Member functions + + // Access to addressing + + //- Return the LDU mesh from which the addressing is obtained + const lduMesh& mesh() const + { + return lduMesh_; + } + + //- Return the LDU addressing + const lduAddressing& lduAddr() const + { + return lduMesh_.lduAddr(); + } + + //- Return the patch evaluation schedule + const lduSchedule& patchSchedule() const + { + return lduAddr().patchSchedule(); + } + + //- Return interfaces + const LduInterfaceFieldPtrsList<Type>& interfaces() const + { + return interfaces_; + } + + //- Return interfaces + LduInterfaceFieldPtrsList<Type>& interfaces() + { + return interfaces_; + } + + + // Access to coefficients + + Field<DType>& diag(); + Field<LUType>& upper(); + Field<LUType>& lower(); + Field<Type>& source(); + + FieldField<Field, LUType>& interfacesUpper() + { + return interfacesUpper_; + } + + FieldField<Field, LUType>& interfacesLower() + { + return interfacesLower_; + } + + + const Field<DType>& diag() const; + const Field<LUType>& upper() const; + const Field<LUType>& lower() const; + const Field<Type>& source() const; + + const FieldField<Field, LUType>& interfacesUpper() const + { + return interfacesUpper_; + } + + const FieldField<Field, LUType>& interfacesLower() const + { + return interfacesLower_; + } + + + bool hasDiag() const + { + return (diagPtr_); + } + + bool hasUpper() const + { + return (upperPtr_); + } + + bool hasLower() const + { + return (lowerPtr_); + } + + bool hasSource() const + { + return (sourcePtr_); + } + + bool diagonal() const + { + return (diagPtr_ && !lowerPtr_ && !upperPtr_); + } + + bool symmetric() const + { + return (diagPtr_ && (!lowerPtr_ && upperPtr_)); + } + + bool asymmetric() const + { + return (diagPtr_ && lowerPtr_ && upperPtr_); + } + + + // operations + + void sumDiag(); + void negSumDiag(); + + void sumMagOffDiag(Field<LUType>& sumOff) const; + + //- Matrix multiplication + void Amul(Field<Type>&, const tmp<Field<Type> >&) const; + + //- Matrix transpose multiplication + void Tmul(Field<Type>&, const tmp<Field<Type> >&) const; + + + //- Sum the coefficients on each row of the matrix + void sumA(Field<Type>&) const; + + + void residual(Field<Type>& rA, const Field<Type>& psi) const; + + tmp<Field<Type> > residual(const Field<Type>& psi) const; + + + //- Initialise the update of interfaced interfaces + // for matrix operations + void initMatrixInterfaces + ( + const FieldField<Field, LUType>& interfaceCoeffs, + const Field<Type>& psiif, + Field<Type>& result + ) const; + + //- Update interfaced interfaces for matrix operations + void updateMatrixInterfaces + ( + const FieldField<Field, LUType>& interfaceCoeffs, + const Field<Type>& psiif, + Field<Type>& result + ) const; + + + tmp<Field<Type> > H(const Field<Type>&) const; + tmp<Field<Type> > H(const tmp<Field<Type> >&) const; + + tmp<Field<Type> > faceH(const Field<Type>&) const; + tmp<Field<Type> > faceH(const tmp<Field<Type> >&) const; + + + // Member operators + + void operator=(const LduMatrix<Type, DType, LUType>&); + + void negate(); + + void operator+=(const LduMatrix<Type, DType, LUType>&); + void operator-=(const LduMatrix<Type, DType, LUType>&); + + void operator*=(const scalarField&); + void operator*=(scalar); + + + // Ostream operator + + friend Ostream& operator<< <Type, DType, LUType> + ( + Ostream&, + const LduMatrix<Type, DType, LUType>& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeLduMatrix(Type, DType, LUType) \ + \ +typedef Foam::LduMatrix<Type, DType, LUType> \ + ldu##Type##DType##LUType##Matrix; \ + \ +defineNamedTemplateTypeNameAndDebug(ldu##Type##DType##LUType##Matrix, 0); \ + \ + \ +typedef LduMatrix<Type, DType, LUType>::smoother \ + ldu##Type##DType##LUType##Smoother; \ + \ +defineTemplateRunTimeSelectionTable \ +( \ + ldu##Type##DType##LUType##Smoother, \ + symMatrix \ +); \ + \ +defineTemplateRunTimeSelectionTable \ +( \ + ldu##Type##DType##LUType##Smoother, \ + asymMatrix \ +); \ + \ + \ +typedef LduMatrix<Type, DType, LUType>::preconditioner \ + ldu##Type##DType##LUType##Preconditioner; \ + \ +defineTemplateRunTimeSelectionTable \ +( \ + ldu##Type##DType##LUType##Preconditioner, \ + symMatrix \ +); \ + \ +defineTemplateRunTimeSelectionTable \ +( \ + ldu##Type##DType##LUType##Preconditioner, \ + asymMatrix \ +); \ + \ + \ +typedef LduMatrix<Type, DType, LUType>::solver \ + ldu##Type##DType##LUType##Solver; \ + \ +defineTemplateRunTimeSelectionTable \ +( \ + ldu##Type##DType##LUType##Solver, \ + symMatrix \ +); \ + \ +defineTemplateRunTimeSelectionTable \ +( \ + ldu##Type##DType##LUType##Solver, \ + asymMatrix \ +); + + +#define makeLduPreconditioner(Precon, Type, DType, LUType) \ + \ +typedef Precon<Type, DType, LUType> \ + Precon##Type##DType##LUType##Preconditioner; \ +defineNamedTemplateTypeNameAndDebug \ +( \ + Precon##Type##DType##LUType##Preconditioner, \ + 0 \ +); + +#define makeLduSymPreconditioner(Precon, Type, DType, LUType) \ + \ +LduMatrix<Type, DType, LUType>::preconditioner:: \ +addsymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \ +add##Precon##Type##DType##LUType##PreconditionerSymMatrixConstructorToTable_; + +#define makeLduAsymPreconditioner(Precon, Type, DType, LUType) \ + \ +LduMatrix<Type, DType, LUType>::preconditioner:: \ +addasymMatrixConstructorToTable<Precon##Type##DType##LUType##Preconditioner> \ +add##Precon##Type##DType##LUType##PreconditionerAsymMatrixConstructorToTable_; + + +#define makeLduSmoother(Smoother, Type, DType, LUType) \ + \ +typedef Smoother<Type, DType, LUType> \ + Smoother##Type##DType##LUType##Smoother; \ + \ +defineNamedTemplateTypeNameAndDebug \ +( \ + Smoother##Type##DType##LUType##Smoother, \ + 0 \ +); + +#define makeLduSymSmoother(Smoother, Type, DType, LUType) \ + \ +LduMatrix<Type, DType, LUType>::smoother:: \ + addsymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \ + add##Smoother##Type##DType##LUType##SymMatrixConstructorToTable_; + +#define makeLduAsymSmoother(Smoother, Type, DType, LUType) \ + \ +LduMatrix<Type, DType, LUType>::smoother:: \ + addasymMatrixConstructorToTable<Smoother##Type##DType##LUType##Smoother> \ + add##Smoother##Type##DType##LUType##AsymMatrixConstructorToTable_; + + +#define makeLduSolver(Solver, Type, DType, LUType) \ + \ +typedef Solver<Type, DType, LUType> \ + Solver##Type##DType##LUType##Solver; \ + \ +defineNamedTemplateTypeNameAndDebug \ +( \ + Solver##Type##DType##LUType##Solver, \ + 0 \ +); + +#define makeLduSymSolver(Solver, Type, DType, LUType) \ + \ +LduMatrix<Type, DType, LUType>::solver:: \ + addsymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \ + add##Solver##Type##DType##LUType##SymMatrixConstructorToTable_; + +#define makeLduAsymSolver(Solver, Type, DType, LUType) \ + \ +LduMatrix<Type, DType, LUType>::solver:: \ + addasymMatrixConstructorToTable<Solver##Type##DType##LUType##Solver> \ + add##Solver##Type##DType##LUType##AsymMatrixConstructorToTable_; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "LduMatrixI.H" +# include "LduMatrix.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C new file mode 100644 index 0000000000000000000000000000000000000000..98d24f4e9b03d4529bbfb109c72d139f2cd8a5b3 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C @@ -0,0 +1,294 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "LduMatrix.H" +#include "LduInterfaceFieldPtrsList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +template<class Type, class LUType> +class Amultiplier +: + public LduInterfaceField<Type>::Amultiplier +{ + const Field<LUType>& A_; + +public: + + Amultiplier(const Field<LUType>& A) + : + A_(A) + {} + + virtual ~Amultiplier() + {} + + virtual void addAmul(Field<Type>& Apsi, const Field<Type>& psi) const + { + Apsi += A_*psi; + } +}; + +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::Amul +( + Field<Type>& Apsi, + const tmp<Field<Type> >& tpsi +) const +{ + Type* __restrict__ ApsiPtr = Apsi.begin(); + + const Field<Type>& psi = tpsi(); + const Type* const __restrict__ psiPtr = psi.begin(); + + const DType* const __restrict__ diagPtr = diag().begin(); + + const label* const __restrict__ uPtr = lduAddr().upperAddr().begin(); + const label* const __restrict__ lPtr = lduAddr().lowerAddr().begin(); + + const LUType* const __restrict__ upperPtr = upper().begin(); + const LUType* const __restrict__ lowerPtr = lower().begin(); + + // Initialise the update of interfaced interfaces + initMatrixInterfaces + ( + interfacesUpper_, + psi, + Apsi + ); + + register const label nCells = diag().size(); + for (register label cell=0; cell<nCells; cell++) + { + ApsiPtr[cell] = dot(diagPtr[cell], psiPtr[cell]); + } + + + register const label nFaces = upper().size(); + for (register label face=0; face<nFaces; face++) + { + ApsiPtr[uPtr[face]] += dot(lowerPtr[face], psiPtr[lPtr[face]]); + ApsiPtr[lPtr[face]] += dot(upperPtr[face], psiPtr[uPtr[face]]); + } + + // Update interface interfaces + updateMatrixInterfaces + ( + interfacesUpper_, + psi, + Apsi + ); + + tpsi.clear(); +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::Tmul +( + Field<Type>& Tpsi, + const tmp<Field<Type> >& tpsi +) const +{ + Type* __restrict__ TpsiPtr = Tpsi.begin(); + + const Field<Type>& psi = tpsi(); + const Type* const __restrict__ psiPtr = psi.begin(); + + const DType* const __restrict__ diagPtr = diag().begin(); + + const label* const __restrict__ uPtr = lduAddr().upperAddr().begin(); + const label* const __restrict__ lPtr = lduAddr().lowerAddr().begin(); + + const LUType* const __restrict__ lowerPtr = lower().begin(); + const LUType* const __restrict__ upperPtr = upper().begin(); + + // Initialise the update of interfaced interfaces + initMatrixInterfaces + ( + interfacesLower_, + psi, + Tpsi + ); + + register const label nCells = diag().size(); + for (register label cell=0; cell<nCells; cell++) + { + TpsiPtr[cell] = dot(diagPtr[cell], psiPtr[cell]); + } + + register const label nFaces = upper().size(); + for (register label face=0; face<nFaces; face++) + { + TpsiPtr[uPtr[face]] += dot(upperPtr[face], psiPtr[lPtr[face]]); + TpsiPtr[lPtr[face]] += dot(lowerPtr[face], psiPtr[uPtr[face]]); + } + + // Update interface interfaces + updateMatrixInterfaces + ( + interfacesLower_, + psi, + Tpsi + ); + + tpsi.clear(); +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::sumA +( + Field<Type>& sumA +) const +{ + Type* __restrict__ sumAPtr = sumA.begin(); + + const DType* __restrict__ diagPtr = diag().begin(); + + const label* __restrict__ uPtr = lduAddr().upperAddr().begin(); + const label* __restrict__ lPtr = lduAddr().lowerAddr().begin(); + + const LUType* __restrict__ lowerPtr = lower().begin(); + const LUType* __restrict__ upperPtr = upper().begin(); + + register const label nCells = diag().size(); + register const label nFaces = upper().size(); + + for (register label cell=0; cell<nCells; cell++) + { + sumAPtr[cell] = dot(diagPtr[cell], pTraits<Type>::one); + } + + for (register label face=0; face<nFaces; face++) + { + sumAPtr[uPtr[face]] += dot(lowerPtr[face], pTraits<Type>::one); + sumAPtr[lPtr[face]] += dot(upperPtr[face], pTraits<Type>::one); + } + + // Add the interface internal coefficients to diagonal + // and the interface boundary coefficients to the sum-off-diagonal + forAll(interfaces_, patchI) + { + if (interfaces_.set(patchI)) + { + const unallocLabelList& pa = lduAddr().patchAddr(patchI); + const Field<LUType>& pCoeffs = interfacesUpper_[patchI]; + + forAll(pa, face) + { + sumAPtr[pa[face]] -= dot(pCoeffs[face], pTraits<Type>::one); + } + } + } +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::residual +( + Field<Type>& rA, + const Field<Type>& psi +) const +{ + Type* __restrict__ rAPtr = rA.begin(); + + const Type* const __restrict__ psiPtr = psi.begin(); + const DType* const __restrict__ diagPtr = diag().begin(); + const Type* const __restrict__ sourcePtr = source().begin(); + + const label* const __restrict__ uPtr = lduAddr().upperAddr().begin(); + const label* const __restrict__ lPtr = lduAddr().lowerAddr().begin(); + + const LUType* const __restrict__ upperPtr = upper().begin(); + const LUType* const __restrict__ lowerPtr = lower().begin(); + + // Parallel boundary initialisation. + // Note: there is a change of sign in the coupled + // interface update to add the contibution to the r.h.s. + + FieldField<Field, LUType> mBouCoeffs(interfacesUpper_.size()); + + forAll(mBouCoeffs, patchi) + { + if (interfaces_.set(patchi)) + { + mBouCoeffs.set(patchi, -interfacesUpper_[patchi]); + } + } + + // Initialise the update of interfaced interfaces + initMatrixInterfaces + ( + mBouCoeffs, + psi, + rA + ); + + register const label nCells = diag().size(); + for (register label cell=0; cell<nCells; cell++) + { + rAPtr[cell] = sourcePtr[cell] - dot(diagPtr[cell], psiPtr[cell]); + } + + + register const label nFaces = upper().size(); + for (register label face=0; face<nFaces; face++) + { + rAPtr[uPtr[face]] -= dot(lowerPtr[face], psiPtr[lPtr[face]]); + rAPtr[lPtr[face]] -= dot(upperPtr[face], psiPtr[uPtr[face]]); + } + + // Update interface interfaces + updateMatrixInterfaces + ( + mBouCoeffs, + psi, + rA + ); +} + + +template<class Type, class DType, class LUType> +Foam::tmp<Foam::Field<Type> > Foam::LduMatrix<Type, DType, LUType>::residual +( + const Field<Type>& psi +) const +{ + tmp<Field<Type> > trA(new Field<Type>(psi.size())); + residual(trA(), psi); + return trA; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixI.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixI.H new file mode 100644 index 0000000000000000000000000000000000000000..f1ab9e773cee9dd28c3a17dfdf4f61ecc972f4a5 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixI.H @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +template<class T> +inline void Foam::LduMatrix<Type, DType, LUType>::solver::readControl +( + const dictionary& controlDict, + T& control, + const word& controlName +) +{ + if (controlDict.found(controlName)) + { + controlDict.lookup(controlName) >> control; + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C new file mode 100644 index 0000000000000000000000000000000000000000..d35c0c12d40f71cbe6b40959e491946ddd5eb86f --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixOperations.C @@ -0,0 +1,480 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "lduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::sumDiag() +{ + const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower(); + const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); + Field<DType>& Diag = diag(); + + const unallocLabelList& l = lduAddr().lowerAddr(); + const unallocLabelList& u = lduAddr().upperAddr(); + + for (register label face=0; face<l.size(); face++) + { + Diag[l[face]] += Lower[face]; + Diag[u[face]] += Upper[face]; + } +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::negSumDiag() +{ + const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower(); + const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); + Field<DType>& Diag = diag(); + + const unallocLabelList& l = lduAddr().lowerAddr(); + const unallocLabelList& u = lduAddr().upperAddr(); + + for (register label face=0; face<l.size(); face++) + { + Diag[l[face]] -= Lower[face]; + Diag[u[face]] -= Upper[face]; + } +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::sumMagOffDiag +( + Field<LUType>& sumOff +) const +{ + const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower(); + const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); + + const unallocLabelList& l = lduAddr().lowerAddr(); + const unallocLabelList& u = lduAddr().upperAddr(); + + for (register label face = 0; face < l.size(); face++) + { + sumOff[u[face]] += cmptMag(Lower[face]); + sumOff[l[face]] += cmptMag(Upper[face]); + } +} + + +template<class Type, class DType, class LUType> +Foam::tmp<Foam::Field<Type> > +Foam::LduMatrix<Type, DType, LUType>::H(const Field<Type>& psi) const +{ + tmp<Field<Type> > tHpsi + ( + new Field<Type>(lduAddr().size(), pTraits<Type>::zero) + ); + + if (lowerPtr_ || upperPtr_) + { + Field<Type> & Hpsi = tHpsi(); + + Type* __restrict__ HpsiPtr = Hpsi.begin(); + + const Type* __restrict__ psiPtr = psi.begin(); + + const label* __restrict__ uPtr = lduAddr().upperAddr().begin(); + const label* __restrict__ lPtr = lduAddr().lowerAddr().begin(); + + const LUType* __restrict__ lowerPtr = lower().begin(); + const LUType* __restrict__ upperPtr = upper().begin(); + + register const label nFaces = upper().size(); + + for (register label face=0; face<nFaces; face++) + { + HpsiPtr[uPtr[face]] -= lowerPtr[face]*psiPtr[lPtr[face]]; + HpsiPtr[lPtr[face]] -= upperPtr[face]*psiPtr[uPtr[face]]; + } + } + + return tHpsi; +} + +template<class Type, class DType, class LUType> +Foam::tmp<Foam::Field<Type> > +Foam::LduMatrix<Type, DType, LUType>::H(const tmp<Field<Type> >& tpsi) const +{ + tmp<Field<Type> > tHpsi(H(tpsi())); + tpsi.clear(); + return tHpsi; +} + + +template<class Type, class DType, class LUType> +Foam::tmp<Foam::Field<Type> > +Foam::LduMatrix<Type, DType, LUType>::faceH(const Field<Type>& psi) const +{ + const Field<LUType>& Lower = const_cast<const LduMatrix&>(*this).lower(); + const Field<LUType>& Upper = const_cast<const LduMatrix&>(*this).upper(); + + // Take refereces to addressing + const unallocLabelList& l = lduAddr().lowerAddr(); + const unallocLabelList& u = lduAddr().upperAddr(); + + tmp<Field<Type> > tfaceHpsi(new Field<Type> (Lower.size())); + Field<Type> & faceHpsi = tfaceHpsi(); + + for (register label face=0; face<l.size(); face++) + { + faceHpsi[face] = Upper[face]*psi[u[face]] - Lower[face]*psi[l[face]]; + } + + return tfaceHpsi; +} + + +template<class Type, class DType, class LUType> +Foam::tmp<Foam::Field<Type> > +Foam::LduMatrix<Type, DType, LUType>::faceH(const tmp<Field<Type> >& tpsi) const +{ + tmp<Field<Type> > tfaceHpsi(faceH(tpsi())); + tpsi.clear(); + return tfaceHpsi; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::operator=(const LduMatrix& A) +{ + if (this == &A) + { + FatalErrorIn + ( + "LduMatrix<Type, DType, LUType>::operator=(const LduMatrix&)" + ) << "attempted assignment to self" + << abort(FatalError); + } + + if (A.diagPtr_) + { + diag() = A.diag(); + } + + if (A.upperPtr_) + { + upper() = A.upper(); + } + else if (upperPtr_) + { + delete upperPtr_; + upperPtr_ = NULL; + } + + if (A.lowerPtr_) + { + lower() = A.lower(); + } + else if (lowerPtr_) + { + delete lowerPtr_; + lowerPtr_ = NULL; + } + + if (A.sourcePtr_) + { + source() = A.source(); + } + + interfacesUpper_ = A.interfacesUpper_; + interfacesLower_ = A.interfacesLower_; +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::negate() +{ + if (diagPtr_) + { + diagPtr_->negate(); + } + + if (upperPtr_) + { + upperPtr_->negate(); + } + + if (lowerPtr_) + { + lowerPtr_->negate(); + } + + if (sourcePtr_) + { + sourcePtr_->negate(); + } + + negate(interfacesUpper_); + negate(interfacesLower_); +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::operator+=(const LduMatrix& A) +{ + if (A.diagPtr_) + { + diag() += A.diag(); + } + + if (A.sourcePtr_) + { + source() += A.source(); + } + + if (symmetric() && A.symmetric()) + { + upper() += A.upper(); + } + else if (symmetric() && A.asymmetric()) + { + if (upperPtr_) + { + lower(); + } + else + { + upper(); + } + + upper() += A.upper(); + lower() += A.lower(); + } + else if (asymmetric() && A.symmetric()) + { + if (A.upperPtr_) + { + lower() += A.upper(); + upper() += A.upper(); + } + else + { + lower() += A.lower(); + upper() += A.lower(); + } + + } + else if (asymmetric() && A.asymmetric()) + { + lower() += A.lower(); + upper() += A.upper(); + } + else if (diagonal()) + { + if (A.upperPtr_) + { + upper() = A.upper(); + } + + if (A.lowerPtr_) + { + lower() = A.lower(); + } + } + else if (A.diagonal()) + { + } + else + { + FatalErrorIn + ( + "LduMatrix<Type, DType, LUType>::operator+=(const LduMatrix& A)" + ) << "Unknown matrix type combination" + << abort(FatalError); + } + + interfacesUpper_ += A.interfacesUpper_; + interfacesLower_ += A.interfacesLower_; +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::operator-=(const LduMatrix& A) +{ + if (A.diagPtr_) + { + diag() -= A.diag(); + } + + if (A.sourcePtr_) + { + source() -= A.source(); + } + + if (symmetric() && A.symmetric()) + { + upper() -= A.upper(); + } + else if (symmetric() && A.asymmetric()) + { + if (upperPtr_) + { + lower(); + } + else + { + upper(); + } + + upper() -= A.upper(); + lower() -= A.lower(); + } + else if (asymmetric() && A.symmetric()) + { + if (A.upperPtr_) + { + lower() -= A.upper(); + upper() -= A.upper(); + } + else + { + lower() -= A.lower(); + upper() -= A.lower(); + } + + } + else if (asymmetric() && A.asymmetric()) + { + lower() -= A.lower(); + upper() -= A.upper(); + } + else if (diagonal()) + { + if (A.upperPtr_) + { + upper() = -A.upper(); + } + + if (A.lowerPtr_) + { + lower() = -A.lower(); + } + } + else if (A.diagonal()) + { + } + else + { + FatalErrorIn + ( + "LduMatrix<Type, DType, LUType>::operator-=(const LduMatrix& A)" + ) << "Unknown matrix type combination" + << abort(FatalError); + } + + interfacesUpper_ -= A.interfacesUpper_; + interfacesLower_ -= A.interfacesLower_; +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::operator*= +( + const scalarField& sf +) +{ + if (diagPtr_) + { + *diagPtr_ *= sf; + } + + if (sourcePtr_) + { + *sourcePtr_ *= sf; + } + + if (upperPtr_) + { + Field<LUType>& upper = *upperPtr_; + + const unallocLabelList& l = lduAddr().lowerAddr(); + + for (register label face=0; face<upper.size(); face++) + { + upper[face] *= sf[l[face]]; + } + } + + if (lowerPtr_) + { + Field<LUType>& lower = *lowerPtr_; + + const unallocLabelList& u = lduAddr().upperAddr(); + + for (register label face=0; face<lower.size(); face++) + { + lower[face] *= sf[u[face]]; + } + } + + FatalErrorIn + ( + "LduMatrix<Type, DType, LUType>::operator*=(const scalarField& sf)" + ) << "Scaling a matrix by scalarField is not currently supported\n" + "because scaling interfacesUpper_ and interfacesLower_ " + "require special transfers" + << abort(FatalError); + + //interfacesUpper_ *= ; + //interfacesLower_ *= sf; +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::operator*=(scalar s) +{ + if (diagPtr_) + { + *diagPtr_ *= s; + } + + if (sourcePtr_) + { + *sourcePtr_ *= s; + } + + if (upperPtr_) + { + *upperPtr_ *= s; + } + + if (lowerPtr_) + { + *lowerPtr_ *= s; + } + + interfacesUpper_ *= s; + interfacesLower_ *= s; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C new file mode 100644 index 0000000000000000000000000000000000000000..230eb0d2b655986ac374a235d500cc0fe8b54cd1 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixPreconditioner.C @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::autoPtr<typename Foam::LduMatrix<Type, DType, LUType>::preconditioner> +Foam::LduMatrix<Type, DType, LUType>::preconditioner::New +( + const solver& sol, + const dictionary& preconditionerDict +) +{ + word preconditionerName = preconditionerDict.lookup("preconditioner"); + + if (sol.matrix().symmetric()) + { + typename symMatrixConstructorTable::iterator constructorIter = + symMatrixConstructorTablePtr_->find(preconditionerName); + + if (constructorIter == symMatrixConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::preconditioner::New" + "(const solver&, Istream&)", + preconditionerDict + ) << "Unknown symmetric matrix preconditioner " + << preconditionerName << endl << endl + << "Valid symmetric matrix preconditioners are :" << endl + << symMatrixConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> + ( + constructorIter() + ( + sol, + preconditionerDict + ) + ); + } + else if (sol.matrix().asymmetric()) + { + typename asymMatrixConstructorTable::iterator constructorIter = + asymMatrixConstructorTablePtr_->find(preconditionerName); + + if (constructorIter == asymMatrixConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::preconditioner::New" + "(const solver&, Istream&)", + preconditionerDict + ) << "Unknown asymmetric matrix preconditioner " + << preconditionerName << endl << endl + << "Valid asymmetric matrix preconditioners are :" << endl + << asymMatrixConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> + ( + constructorIter() + ( + sol, + preconditionerDict + ) + ); + } + else + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::preconditioner::New" + "(const solver&, Istream&)", + preconditionerDict + ) << "cannot preconditione incomplete matrix, " + "no diagonal or off-diagonal coefficient" + << exit(FatalIOError); + + return autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> + ( + NULL + ); + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C new file mode 100644 index 0000000000000000000000000000000000000000..4377f6da941c7603aef55424eb9f7314156eccb1 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSmoother.C @@ -0,0 +1,120 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::autoPtr<typename Foam::LduMatrix<Type, DType, LUType>::smoother> +Foam::LduMatrix<Type, DType, LUType>::smoother::New +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& smootherDict +) +{ + word smootherName = smootherDict.lookup("smoother"); + + if (matrix.symmetric()) + { + typename symMatrixConstructorTable::iterator constructorIter = + symMatrixConstructorTablePtr_->find(smootherName); + + if (constructorIter == symMatrixConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::smoother::New", smootherDict + ) << "Unknown symmetric matrix smoother " << smootherName + << endl << endl + << "Valid symmetric matrix smoothers are :" << endl + << symMatrixConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> + ( + constructorIter() + ( + fieldName, + matrix + ) + ); + } + else if (matrix.asymmetric()) + { + typename asymMatrixConstructorTable::iterator constructorIter = + asymMatrixConstructorTablePtr_->find(smootherName); + + if (constructorIter == asymMatrixConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::smoother::New", smootherDict + ) << "Unknown asymmetric matrix smoother " << smootherName + << endl << endl + << "Valid asymmetric matrix smoothers are :" << endl + << asymMatrixConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> + ( + constructorIter() + ( + fieldName, + matrix + ) + ); + } + else + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::smoother::New", smootherDict + ) << "cannot solve incomplete matrix, no off-diagonal coefficients" + << exit(FatalIOError); + + return autoPtr<typename LduMatrix<Type, DType, LUType>::smoother>(NULL); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::LduMatrix<Type, DType, LUType>::smoother::smoother +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix +) +: + fieldName_(fieldName), + matrix_(matrix) +{} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C new file mode 100644 index 0000000000000000000000000000000000000000..50831a0ec94afeac0f52aeca75926b7e31ad5a90 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixSolver.C @@ -0,0 +1,190 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "LduMatrix.H" +#include "DiagonalSolver.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::autoPtr<typename Foam::LduMatrix<Type, DType, LUType>::solver> +Foam::LduMatrix<Type, DType, LUType>::solver::New +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict +) +{ + word solverName = solverDict.lookup("solver"); + + if (matrix.diagonal()) + { + return autoPtr<typename LduMatrix<Type, DType, LUType>::solver> + ( + new DiagonalSolver<Type, DType, LUType> + ( + fieldName, + matrix, + solverDict + ) + ); + } + else if (matrix.symmetric()) + { + typename symMatrixConstructorTable::iterator constructorIter = + symMatrixConstructorTablePtr_->find(solverName); + + if (constructorIter == symMatrixConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::solver::New", solverDict + ) << "Unknown symmetric matrix solver " << solverName + << endl << endl + << "Valid symmetric matrix solvers are :" << endl + << symMatrixConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr<typename LduMatrix<Type, DType, LUType>::solver> + ( + constructorIter() + ( + fieldName, + matrix, + solverDict + ) + ); + } + else if (matrix.asymmetric()) + { + typename asymMatrixConstructorTable::iterator constructorIter = + asymMatrixConstructorTablePtr_->find(solverName); + + if (constructorIter == asymMatrixConstructorTablePtr_->end()) + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::solver::New", solverDict + ) << "Unknown asymmetric matrix solver " << solverName + << endl << endl + << "Valid asymmetric matrix solvers are :" << endl + << asymMatrixConstructorTablePtr_->toc() + << exit(FatalIOError); + } + + return autoPtr<typename LduMatrix<Type, DType, LUType>::solver> + ( + constructorIter() + ( + fieldName, + matrix, + solverDict + ) + ); + } + else + { + FatalIOErrorIn + ( + "LduMatrix<Type, DType, LUType>::solver::New", solverDict + ) << "cannot solve incomplete matrix, " + "no diagonal or off-diagonal coefficient" + << exit(FatalIOError); + + return autoPtr<typename LduMatrix<Type, DType, LUType>::solver>(NULL); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::LduMatrix<Type, DType, LUType>::solver::solver +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict +) +: + fieldName_(fieldName), + matrix_(matrix), + + controlDict_(solverDict), + + maxIter_(1000), + tolerance_(1e-6*pTraits<Type>::one), + relTol_(pTraits<Type>::zero) +{ + readControls(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::solver::readControls() +{ + readControl(controlDict_, maxIter_, "maxIter"); + readControl(controlDict_, tolerance_, "tolerance"); + readControl(controlDict_, relTol_, "relTol"); +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::solver::read +( + const dictionary& solverDict +) +{ + controlDict_ = solverDict; + readControls(); +} + + +template<class Type, class DType, class LUType> +Type Foam::LduMatrix<Type, DType, LUType>::solver::normFactor +( + const Field<Type>& psi, + const Field<Type>& Apsi, + Field<Type>& tmpField +) const +{ + // --- Calculate A dot reference value of psi + matrix_.sumA(tmpField); + cmptMultiply(tmpField, tmpField, gAverage(psi)); + + return stabilise + ( + gSum(cmptMag(Apsi - tmpField) + cmptMag(matrix_.source() - tmpField)), + SolverPerformance<Type>::small_ + ); + + // At convergence this simpler method is equivalent to the above + // return stabilise(2*gSumCmptMag(matrix_.source()), matrix_.small_); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C new file mode 100644 index 0000000000000000000000000000000000000000..d3d8de20a01a020cc04fdc89c721337d66c6e1d6 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C @@ -0,0 +1,200 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "LduMatrix.H" +#include "lduInterfaceField.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::initMatrixInterfaces +( + const FieldField<Field, LUType>& interfaceCoeffs, + const Field<Type>& psiif, + Field<Type>& result +) const +{ + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) + { + forAll (interfaces_, interfaceI) + { + if (interfaces_.set(interfaceI)) + { + interfaces_[interfaceI].initInterfaceMatrixUpdate + ( + result, + psiif, + interfaceCoeffs[interfaceI], + //Amultiplier<Type, LUType>(interfaceCoeffs[interfaceI]), + Pstream::defaultCommsType + ); + } + } + } + else if (Pstream::defaultCommsType == Pstream::scheduled) + { + const lduSchedule& patchSchedule = this->patchSchedule(); + + // Loop over the "global" patches are on the list of interfaces but + // beyond the end of the schedule which only handles "normal" patches + for + ( + label interfaceI=patchSchedule.size()/2; + interfaceI<interfaces_.size(); + interfaceI++ + ) + { + if (interfaces_.set(interfaceI)) + { + interfaces_[interfaceI].initInterfaceMatrixUpdate + ( + result, + psiif, + interfaceCoeffs[interfaceI], + //Amultiplier<Type, LUType>(interfaceCoeffs[interfaceI]), + Pstream::blocking + ); + } + } + } + else + { + FatalErrorIn("LduMatrix<Type, DType, LUType>::initMatrixInterfaces") + << "Unsuported communications type " + << Pstream::commsTypeNames[Pstream::defaultCommsType] + << exit(FatalError); + } +} + + +template<class Type, class DType, class LUType> +void Foam::LduMatrix<Type, DType, LUType>::updateMatrixInterfaces +( + const FieldField<Field, LUType>& interfaceCoeffs, + const Field<Type>& psiif, + Field<Type>& result +) const +{ + if + ( + Pstream::defaultCommsType == Pstream::blocking + || Pstream::defaultCommsType == Pstream::nonBlocking + ) + { + // Block until all sends/receives have been finished + if (Pstream::defaultCommsType == Pstream::nonBlocking) + { + IPstream::waitRequests(); + OPstream::waitRequests(); + } + + forAll (interfaces_, interfaceI) + { + if (interfaces_.set(interfaceI)) + { + interfaces_[interfaceI].updateInterfaceMatrix + ( + result, + psiif, + interfaceCoeffs[interfaceI], + //Amultiplier<Type, LUType>(interfaceCoeffs[interfaceI]), + Pstream::defaultCommsType + ); + } + } + } + else if (Pstream::defaultCommsType == Pstream::scheduled) + { + const lduSchedule& patchSchedule = this->patchSchedule(); + + // Loop over all the "normal" interfaces relating to standard patches + forAll (patchSchedule, i) + { + label interfaceI = patchSchedule[i].patch; + + if (interfaces_.set(interfaceI)) + { + if (patchSchedule[i].init) + { + interfaces_[interfaceI].initInterfaceMatrixUpdate + ( + result, + psiif, + interfaceCoeffs[interfaceI], + //Amultiplier<Type, LUType>(interfaceCoeffs[interfaceI]), + Pstream::scheduled + ); + } + else + { + interfaces_[interfaceI].updateInterfaceMatrix + ( + result, + psiif, + interfaceCoeffs[interfaceI], + //Amultiplier<Type, LUType>(interfaceCoeffs[interfaceI]), + Pstream::scheduled + ); + } + } + } + + // Loop over the "global" patches are on the list of interfaces but + // beyond the end of the schedule which only handles "normal" patches + for + ( + label interfaceI=patchSchedule.size()/2; + interfaceI<interfaces_.size(); + interfaceI++ + ) + { + if (interfaces_.set(interfaceI)) + { + interfaces_[interfaceI].updateInterfaceMatrix + ( + result, + psiif, + interfaceCoeffs[interfaceI], + //Amultiplier<Type, LUType>(interfaceCoeffs[interfaceI]), + Pstream::blocking + ); + } + } + } + else + { + FatalErrorIn("LduMatrix<Type, DType, LUType>::updateMatrixInterfaces") + << "Unsuported communications type " + << Pstream::commsTypeNames[Pstream::defaultCommsType] + << exit(FatalError); + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/SolverPerformance.C similarity index 62% rename from src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C rename to src/OpenFOAM/matrices/LduMatrix/LduMatrix/SolverPerformance.C index e9294d6a22729d321763413438c7280cff9b3769..62ce85abb7f9f438408235c0c2192ef6922812d1 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixTests.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/SolverPerformance.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,25 +21,45 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. -Description - Convergence and singularity tests for solvers. - \*---------------------------------------------------------------------------*/ -#include "lduMatrix.H" +#include "SolverPerformance.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::lduMatrix::solverPerformance::solverPerformance(Istream& is) +template<class Type> +bool Foam::SolverPerformance<Type>::checkSingularity +( + const Type& wApA +) { - is >> *this; + for(direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) + { + singular_[cmpt] = + component(wApA, cmpt) < vsmall_; + } + + return singular(); +} + + +template<class Type> +bool Foam::SolverPerformance<Type>::singular() const +{ + for(direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) + { + if (!singular_[cmpt]) return false; + } + + return true; } -bool Foam::lduMatrix::solverPerformance::checkConvergence +template<class Type> +bool Foam::SolverPerformance<Type>::checkConvergence ( - const scalar Tolerance, - const scalar RelTolerance + const Type& Tolerance, + const Type& RelTolerance ) { if (debug >= 2) @@ -54,10 +74,10 @@ bool Foam::lduMatrix::solverPerformance::checkConvergence ( finalResidual_ < Tolerance || ( - RelTolerance > SMALL - && finalResidual_ <= RelTolerance*initialResidual_ + RelTolerance + > small_*pTraits<Type>::one + && finalResidual_ < cmptMultiply(RelTolerance, initialResidual_) ) - // || (solverName == "symSolve" && iter == 0) ) { converged_ = true; @@ -71,38 +91,25 @@ bool Foam::lduMatrix::solverPerformance::checkConvergence } -bool Foam::lduMatrix::solverPerformance::checkSingularity +template<class Type> +void Foam::SolverPerformance<Type>::print ( - const scalar residual -) -{ - if (residual > VSMALL) - { - singular_ = false; - } - else - { - singular_ = true; - } - - return singular_; -} - - -void Foam::lduMatrix::solverPerformance::print() const + Ostream& os +) const { - if (debug) + for(direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++) { - Info<< solverName_ << ": Solving for " << fieldName_; + os << solverName_ << ": Solving for " + << word(fieldName_ + pTraits<Type>::componentNames[cmpt]); - if (singular()) + if (singular_[cmpt]) { - Info<< ": solution singularity" << endl; + os << ": solution singularity" << endl; } else { - Info<< ", Initial residual = " << initialResidual_ - << ", Final residual = " << finalResidual_ + os << ", Initial residual = " << component(initialResidual_, cmpt) + << ", Final residual = " << component(finalResidual_, cmpt) << ", No Iterations " << noIterations_ << endl; } @@ -110,9 +117,10 @@ void Foam::lduMatrix::solverPerformance::print() const } -bool Foam::lduMatrix::solverPerformance::operator!= +template<class Type> +bool Foam::SolverPerformance<Type>::operator!= ( - const lduMatrix::solverPerformance& sp + const SolverPerformance<Type>& sp ) const { return @@ -128,13 +136,14 @@ bool Foam::lduMatrix::solverPerformance::operator!= } -Foam::lduMatrix::solverPerformance Foam::max +template<class Type> +typename Foam::SolverPerformance<Type> Foam::max ( - const lduMatrix::solverPerformance& sp1, - const lduMatrix::solverPerformance& sp2 + const typename Foam::SolverPerformance<Type>& sp1, + const typename Foam::SolverPerformance<Type>& sp2 ) { - return lduMatrix::solverPerformance + return SolverPerformance<Type> ( sp1.solverName(), sp1.fieldName_, @@ -147,13 +156,14 @@ Foam::lduMatrix::solverPerformance Foam::max } +template<class Type> Foam::Istream& Foam::operator>> ( Istream& is, - Foam::lduMatrix::solverPerformance& sp + typename Foam::SolverPerformance<Type>& sp ) { - is.readBeginList("lduMatrix::solverPerformance"); + is.readBeginList("SolverPerformance<Type>"); is >> sp.solverName_ >> sp.fieldName_ >> sp.initialResidual_ @@ -161,16 +171,17 @@ Foam::Istream& Foam::operator>> >> sp.noIterations_ >> sp.converged_ >> sp.singular_; - is.readEndList("lduMatrix::solverPerformance"); + is.readEndList("SolverPerformance<Type>"); return is; } +template<class Type> Foam::Ostream& Foam::operator<< ( Ostream& os, - const Foam::lduMatrix::solverPerformance& sp + const typename Foam::SolverPerformance<Type>& sp ) { os << token::BEGIN_LIST diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/SolverPerformance.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/SolverPerformance.H new file mode 100644 index 0000000000000000000000000000000000000000..d39ecb10a80edf07b7afc15004eaad701cd440da --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/SolverPerformance.H @@ -0,0 +1,292 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::SolverPerformance + +Description + SolverPerformance is a general matrix class in which the coefficients are + stored as three arrays, one for the upper triangle, one for the + lower triangle and a third for the diagonal. + +SourceFiles + SolverPerformance.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SolverPerformance_H +#define SolverPerformance_H + +#include "word.H" +#include "FixedList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of friend functions and operators + +template<class Type> +class SolverPerformance; + +template<class Type> +SolverPerformance<Type> max +( + const SolverPerformance<Type>&, + const SolverPerformance<Type>& +); + +template<class Type> +Istream& operator>> +( + Istream&, + SolverPerformance<Type>& +); + +template<class Type> +Ostream& operator<< +( + Ostream&, + const SolverPerformance<Type>& +); + + + +/*---------------------------------------------------------------------------*\ + Class SolverPerformance Declaration +\*---------------------------------------------------------------------------*/ + +//- Class returned by the solver +// containing performance statistics +template<class Type> +class SolverPerformance +{ + word solverName_; + word fieldName_; + Type initialResidual_; + Type finalResidual_; + label noIterations_; + bool converged_; + FixedList<bool, pTraits<Type>::nComponents> singular_; + + +public: + + // Static data + + // Declare name of the class and its debug switch + ClassName("SolverPerformance"); + + //- Large Type for the use in solvers + static const scalar great_; + + //- Small Type for the use in solvers + static const scalar small_; + + //- Very small Type for the use in solvers + static const scalar vsmall_; + + + // Constructors + + SolverPerformance() + : + initialResidual_(pTraits<Type>::zero), + finalResidual_(pTraits<Type>::zero), + noIterations_(0), + converged_(false), + singular_(false) + {} + + + SolverPerformance + ( + const word& solverName, + const word& fieldName, + const Type& iRes = pTraits<Type>::zero, + const Type& fRes = pTraits<Type>::zero, + const label nIter = 0, + const bool converged = false, + const bool singular = false + ) + : + solverName_(solverName), + fieldName_(fieldName), + initialResidual_(iRes), + finalResidual_(fRes), + noIterations_(nIter), + converged_(converged), + singular_(singular) + {} + + + // Member functions + + //- Return solver name + const word& solverName() const + { + return solverName_; + } + + //- Return solver name + word& solverName() + { + return solverName_; + } + + + //- Return field name + const word& fieldName() const + { + return fieldName_; + } + + + //- Return initial residual + const Type& initialResidual() const + { + return initialResidual_; + } + + //- Return initial residual + Type& initialResidual() + { + return initialResidual_; + } + + + //- Return final residual + const Type& finalResidual() const + { + return finalResidual_; + } + + //- Return final residual + Type& finalResidual() + { + return finalResidual_; + } + + + //- Return number of iterations + label nIterations() const + { + return noIterations_; + } + + //- Return number of iterations + label& nIterations() + { + return noIterations_; + } + + + //- Has the solver converged? + bool converged() const + { + return converged_; + } + + //- Is the matrix singular? + bool singular() const; + + //- Check, store and return convergence + bool checkConvergence + ( + const Type& tolerance, + const Type& relTolerance + ); + + //- Singularity test + bool checkSingularity(const Type& residual); + + //- Print summary of solver performance to the given stream + void print(Ostream& os) const; + + + // Member Operators + + bool operator!=(const SolverPerformance<Type>&) const; + + + // Friend functions + + //- Return the element-wise maximum of two SolverPerformance<Type>s + friend SolverPerformance<Type> max <Type> + ( + const SolverPerformance<Type>&, + const SolverPerformance<Type>& + ); + + + // Ostream Operator + + friend Istream& operator>> <Type> + ( + Istream&, + SolverPerformance<Type>& + ); + + friend Ostream& operator<< <Type> + ( + Ostream&, + const SolverPerformance<Type>& + ); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeSolverPerformance(Type) \ + \ +typedef Foam::SolverPerformance<Type> \ + solverPerformance##Type; \ + \ +defineNamedTemplateTypeNameAndDebug(solverPerformance##Type, 0); \ + \ +template<> \ +const scalar solverPerformance##Type::great_(1e20); \ + \ +template<> \ +const scalar solverPerformance##Type::small_(1e-20); \ + \ +template<> \ +const scalar solverPerformance##Type::vsmall_(VSMALL); \ + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "SolverPerformance.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/lduMatrices.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/lduMatrices.C new file mode 100644 index 0000000000000000000000000000000000000000..3861c5698bc918aa5530b94b956f9b166ceb867d --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/lduMatrices.C @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "LduMatrix.H" +#include "fieldTypes.H" + +namespace Foam +{ + makeLduMatrix(scalar, scalar, scalar); + makeLduMatrix(vector, scalar, scalar); + makeLduMatrix(sphericalTensor, scalar, scalar); + makeLduMatrix(symmTensor, scalar, scalar); + makeLduMatrix(tensor, scalar, scalar); +}; + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/solverPerformance.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/solverPerformance.C new file mode 100644 index 0000000000000000000000000000000000000000..5bac12c784c9fd02909584a03377bdd30281c781 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/solverPerformance.C @@ -0,0 +1,39 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "solverPerformance.H" +#include "fieldTypes.H" + +namespace Foam +{ + makeSolverPerformance(scalar); + makeSolverPerformance(vector); + makeSolverPerformance(sphericalTensor); + makeSolverPerformance(symmTensor); + makeSolverPerformance(tensor); +}; + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/solverPerformance.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/solverPerformance.H new file mode 100644 index 0000000000000000000000000000000000000000..139ab128b1c2a8db3ed883c57a3549e82a4b6e63 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/solverPerformance.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Typedef + Foam::solverPerformance + +Description + SolverPerformance instantiated for a scalar + +SourceFiles + solverPerformance.C + +\*---------------------------------------------------------------------------*/ + +#ifndef solverPerformance_H +#define solverPerformance_H + +#include "SolverPerformance.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + typedef SolverPerformance<scalar> solverPerformance; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DILUPreconditioner/TDILUPreconditioner.C b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DILUPreconditioner/TDILUPreconditioner.C new file mode 100644 index 0000000000000000000000000000000000000000..99fdc9cb1f6c0a9ce1db6f141a36ac4fc8af2c75 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DILUPreconditioner/TDILUPreconditioner.C @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "TDILUPreconditioner.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::TDILUPreconditioner<Type, DType, LUType>::TDILUPreconditioner +( + const typename LduMatrix<Type, DType, LUType>::solver& sol, + const dictionary& +) +: + LduMatrix<Type, DType, LUType>::preconditioner(sol), + rD_(sol.matrix().diag()) +{ + calcInvD(rD_, sol.matrix()); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::TDILUPreconditioner<Type, DType, LUType>::calcInvD +( + Field<DType>& rD, + const LduMatrix<Type, DType, LUType>& matrix +) +{ + DType* __restrict__ rDPtr = rD.begin(); + + const label* const __restrict__ uPtr = matrix.lduAddr().upperAddr().begin(); + const label* const __restrict__ lPtr = matrix.lduAddr().lowerAddr().begin(); + + const LUType* const __restrict__ upperPtr = matrix.upper().begin(); + const LUType* const __restrict__ lowerPtr = matrix.lower().begin(); + + register label nFaces = matrix.upper().size(); + for (register label face=0; face<nFaces; face++) + { + rDPtr[uPtr[face]] -= + dot(dot(upperPtr[face], lowerPtr[face]), inv(rDPtr[lPtr[face]])); + } + + + // Calculate the reciprocal of the preconditioned diagonal + register label nCells = rD.size(); + + for (register label cell=0; cell<nCells; cell++) + { + rDPtr[cell] = inv(rDPtr[cell]); + } +} + + +template<class Type, class DType, class LUType> +void Foam::TDILUPreconditioner<Type, DType, LUType>::precondition +( + Field<Type>& wA, + const Field<Type>& rA +) const +{ + Type* __restrict__ wAPtr = wA.begin(); + const Type* __restrict__ rAPtr = rA.begin(); + const DType* __restrict__ rDPtr = rD_.begin(); + + const label* const __restrict__ uPtr = + this->solver_.matrix().lduAddr().upperAddr().begin(); + const label* const __restrict__ lPtr = + this->solver_.matrix().lduAddr().lowerAddr().begin(); + const label* const __restrict__ losortPtr = + this->solver_.matrix().lduAddr().losortAddr().begin(); + + const LUType* const __restrict__ upperPtr = + this->solver_.matrix().upper().begin(); + const LUType* const __restrict__ lowerPtr = + this->solver_.matrix().lower().begin(); + + register label nCells = wA.size(); + register label nFaces = this->solver_.matrix().upper().size(); + register label nFacesM1 = nFaces - 1; + + for (register label cell=0; cell<nCells; cell++) + { + wAPtr[cell] = dot(rDPtr[cell], rAPtr[cell]); + } + + + register label sface; + + for (register label face=0; face<nFaces; face++) + { + sface = losortPtr[face]; + wAPtr[uPtr[sface]] -= + dot(rDPtr[uPtr[sface]], dot(lowerPtr[sface], wAPtr[lPtr[sface]])); + } + + for (register label face=nFacesM1; face>=0; face--) + { + wAPtr[lPtr[face]] -= + dot(rDPtr[lPtr[face]], dot(upperPtr[face], wAPtr[uPtr[face]])); + } +} + + +template<class Type, class DType, class LUType> +void Foam::TDILUPreconditioner<Type, DType, LUType>::preconditionT +( + Field<Type>& wT, + const Field<Type>& rT +) const +{ + Type* __restrict__ wTPtr = wT.begin(); + const Type* __restrict__ rTPtr = rT.begin(); + const DType* __restrict__ rDPtr = rD_.begin(); + + const label* const __restrict__ uPtr = + this->solver_.matrix().lduAddr().upperAddr().begin(); + const label* const __restrict__ lPtr = + this->solver_.matrix().lduAddr().lowerAddr().begin(); + const label* const __restrict__ losortPtr = + this->solver_.matrix().lduAddr().losortAddr().begin(); + + const LUType* const __restrict__ upperPtr = + this->solver_.matrix().upper().begin(); + const LUType* const __restrict__ lowerPtr = + this->solver_.matrix().lower().begin(); + + register label nCells = wT.size(); + register label nFaces = this->solver_.matrix().upper().size(); + register label nFacesM1 = nFaces - 1; + + for (register label cell=0; cell<nCells; cell++) + { + wTPtr[cell] = dot(rDPtr[cell], rTPtr[cell]); + } + + for (register label face=0; face<nFaces; face++) + { + wTPtr[uPtr[face]] -= + dot(rDPtr[uPtr[face]], dot(upperPtr[face], wTPtr[lPtr[face]])); + } + + + register label sface; + + for (register label face=nFacesM1; face>=0; face--) + { + sface = losortPtr[face]; + wTPtr[lPtr[sface]] -= + dot(rDPtr[lPtr[sface]], dot(lowerPtr[sface], wTPtr[uPtr[sface]])); + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DILUPreconditioner/TDILUPreconditioner.H b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DILUPreconditioner/TDILUPreconditioner.H new file mode 100644 index 0000000000000000000000000000000000000000..da46f8185813c0c3a0fcfae4641688effea45ec0 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DILUPreconditioner/TDILUPreconditioner.H @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::TDILUPreconditioner + +Description + Simplified diagonal-based incomplete LU preconditioner for asymmetric + matrices. + + The inverse (reciprocal for scalar) of the preconditioned diagonal is + calculated and stored. + +SourceFiles + TDILUPreconditioner.C + +\*---------------------------------------------------------------------------*/ + +#ifndef TDILUPreconditioner_H +#define TDILUPreconditioner_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class TDILUPreconditioner Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class TDILUPreconditioner +: + public LduMatrix<Type, DType, LUType>::preconditioner +{ + // Private data + + //- The inverse (reciprocal for scalar) preconditioned diagonal + Field<DType> rD_; + + +public: + + //- Runtime type information + TypeName("DILU"); + + + // Constructors + + //- Construct from matrix components and preconditioner data dictionary + TDILUPreconditioner + ( + const typename LduMatrix<Type, DType, LUType>::solver& sol, + const dictionary& preconditionerDict + ); + + + // Destructor + + virtual ~TDILUPreconditioner() + {} + + + // Member Functions + + //- Calculate the reciprocal of the preconditioned diagonal + static void calcInvD + ( + Field<DType>& rD, + const LduMatrix<Type, DType, LUType>& matrix + ); + + //- Return wA the preconditioned form of residual rA + virtual void precondition + ( + Field<Type>& wA, + const Field<Type>& rA + ) const; + + //- Return wT the transpose-matrix preconditioned form of + // residual rT. + virtual void preconditionT + ( + Field<Type>& wT, + const Field<Type>& rT + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "TDILUPreconditioner.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DiagonalPreconditioner/DiagonalPreconditioner.C b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DiagonalPreconditioner/DiagonalPreconditioner.C new file mode 100644 index 0000000000000000000000000000000000000000..077704aee78720b7b577429a32274a49fcebf320 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DiagonalPreconditioner/DiagonalPreconditioner.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "DiagonalPreconditioner.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::DiagonalPreconditioner<Type, DType, LUType>::DiagonalPreconditioner +( + const typename LduMatrix<Type, DType, LUType>::solver& sol, + const dictionary& +) +: + LduMatrix<Type, DType, LUType>::preconditioner(sol), + rD(sol.matrix().diag().size()) +{ + DType* __restrict__ rDPtr = rD.begin(); + const DType* __restrict__ DPtr = this->solver_.matrix().diag().begin(); + + register label nCells = rD.size(); + + // Generate inverse (reciprocal for scalar) diagonal + for (register label cell=0; cell<nCells; cell++) + { + rDPtr[cell] = inv(DPtr[cell]); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::DiagonalPreconditioner<Type, DType, LUType>::read(const dictionary&) +{} + + +template<class Type, class DType, class LUType> +void Foam::DiagonalPreconditioner<Type, DType, LUType>::precondition +( + Field<Type>& wA, + const Field<Type>& rA +) const +{ + Type* __restrict__ wAPtr = wA.begin(); + const Type* __restrict__ rAPtr = rA.begin(); + const DType* __restrict__ rDPtr = rD.begin(); + + register label nCells = wA.size(); + + for (register label cell=0; cell<nCells; cell++) + { + wAPtr[cell] = dot(rDPtr[cell], rAPtr[cell]); + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DiagonalPreconditioner/DiagonalPreconditioner.H b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DiagonalPreconditioner/DiagonalPreconditioner.H new file mode 100644 index 0000000000000000000000000000000000000000..93eca754e0846637c8e564e853e1f6ddf30fed11 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/DiagonalPreconditioner/DiagonalPreconditioner.H @@ -0,0 +1,134 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::DiagonalPreconditioner + +Description + Diagonal preconditioner for both symmetric and asymmetric matrices. + + The inverse (reciprocal for scalar) of the diagonal is calculated and + stored. + +SourceFiles + DiagonalPreconditioner.C + +\*---------------------------------------------------------------------------*/ + +#ifndef DiagonalPreconditioner_H +#define DiagonalPreconditioner_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class DiagonalPreconditioner Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class DiagonalPreconditioner +: + public LduMatrix<Type, DType, LUType>::preconditioner +{ + // Private data + + //- The inverse (reciprocal for scalar) diagonal + Field<DType> rD; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + DiagonalPreconditioner(const DiagonalPreconditioner&); + + //- Disallow default bitwise assignment + void operator=(const DiagonalPreconditioner&); + + +public: + + //- Runtime type information + TypeName("diagonal"); + + + // Constructors + + //- Construct from matrix components and preconditioner data dictionary + DiagonalPreconditioner + ( + const typename LduMatrix<Type, DType, LUType>::solver& sol, + const dictionary& preconditionerDict + ); + + + // Destructor + + virtual ~DiagonalPreconditioner() + {} + + + // Member Functions + + //- Read and reset the preconditioner parameters from the given + // dictionary + virtual void read(const dictionary& preconditionerDict); + + //- Return wA the preconditioned form of residual rA + virtual void precondition + ( + Field<Type>& wA, + const Field<Type>& rA + ) const; + + //- Return wT the transpose-matrix preconditioned form of + // residual rT. + virtual void preconditionT + ( + Field<Type>& wT, + const Field<Type>& rT + ) const + { + return(precondition(wT, rT)); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "DiagonalPreconditioner.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Preconditioners/NoPreconditioner/NoPreconditioner.C b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/NoPreconditioner/NoPreconditioner.C new file mode 100644 index 0000000000000000000000000000000000000000..160ad8f2feb923b2b11b42d2d494c69f41e9481b --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/NoPreconditioner/NoPreconditioner.C @@ -0,0 +1,59 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "NoPreconditioner.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::NoPreconditioner<Type, DType, LUType>::NoPreconditioner +( + const typename LduMatrix<Type, DType, LUType>::solver& sol, + const dictionary& +) +: + LduMatrix<Type, DType, LUType>::preconditioner(sol) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::NoPreconditioner<Type, DType, LUType>::read(const dictionary&) +{} + + +template<class Type, class DType, class LUType> +void Foam::NoPreconditioner<Type, DType, LUType>::precondition +( + Field<Type>& wA, + const Field<Type>& rA +) const +{ + wA = rA; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Preconditioners/NoPreconditioner/NoPreconditioner.H b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/NoPreconditioner/NoPreconditioner.H new file mode 100644 index 0000000000000000000000000000000000000000..bf8b10d24b03dda4faa925b964484939c91d6dfb --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/NoPreconditioner/NoPreconditioner.H @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::NoPreconditioner + +Description + Null preconditioner for both symmetric and asymmetric matrices. + +SourceFiles + NoPreconditioner.C + +\*---------------------------------------------------------------------------*/ + +#ifndef NoPreconditioner_H +#define NoPreconditioner_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class NoPreconditioner Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class NoPreconditioner +: + public LduMatrix<Type, DType, LUType>::preconditioner +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + NoPreconditioner(const NoPreconditioner&); + + //- Disallow default bitwise assignment + void operator=(const NoPreconditioner&); + + +public: + + //- Runtime type information + TypeName("none"); + + + // Constructors + + //- Construct from matrix components and preconditioner data dictionary + NoPreconditioner + ( + const typename LduMatrix<Type, DType, LUType>::solver& sol, + const dictionary& preconditionerDict + ); + + + // Destructor + + virtual ~NoPreconditioner() + {} + + + // Member Functions + + //- Read and reset the preconditioner parameters from the given + // dictionary + virtual void read(const dictionary& preconditionerDict); + + //- Return wA the preconditioned form of residual rA + virtual void precondition + ( + Field<Type>& wA, + const Field<Type>& rA + ) const; + + //- Return wT the transpose-matrix preconditioned form of + // residual rT. + virtual void preconditionT + ( + Field<Type>& wT, + const Field<Type>& rT + ) const + { + return(precondition(wT, rT)); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "NoPreconditioner.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Preconditioners/lduPreconditioners.C b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/lduPreconditioners.C new file mode 100644 index 0000000000000000000000000000000000000000..95f1483658ea502afa8cda23a20c870d98ab72f1 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Preconditioners/lduPreconditioners.C @@ -0,0 +1,54 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "NoPreconditioner.H" +#include "DiagonalPreconditioner.H" +#include "TDILUPreconditioner.H" +#include "fieldTypes.H" + +#define makeLduPreconditioners(Type, DType, LUType) \ + \ + makeLduPreconditioner(NoPreconditioner, Type, DType, LUType); \ + makeLduSymPreconditioner(NoPreconditioner, Type, DType, LUType); \ + makeLduAsymPreconditioner(NoPreconditioner, Type, DType, LUType); \ + \ + makeLduPreconditioner(DiagonalPreconditioner, Type, DType, LUType); \ + makeLduSymPreconditioner(DiagonalPreconditioner, Type, DType, LUType); \ + makeLduAsymPreconditioner(DiagonalPreconditioner, Type, DType, LUType); \ + \ + makeLduPreconditioner(TDILUPreconditioner, Type, DType, LUType); \ + makeLduAsymPreconditioner(TDILUPreconditioner, Type, DType, LUType); + +namespace Foam +{ + makeLduPreconditioners(scalar, scalar, scalar); + makeLduPreconditioners(vector, scalar, scalar); + makeLduPreconditioners(sphericalTensor, scalar, scalar); + makeLduPreconditioners(symmTensor, scalar, scalar); + makeLduPreconditioners(tensor, scalar, scalar); +}; + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.C b/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.C new file mode 100644 index 0000000000000000000000000000000000000000..6d945da0bb5c9729b6f42ff1d0089e1c348b8cdb --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.C @@ -0,0 +1,167 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "TGaussSeidelSmoother.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::TGaussSeidelSmoother<Type, DType, LUType>::TGaussSeidelSmoother +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix +) +: + LduMatrix<Type, DType, LUType>::smoother + ( + fieldName, + matrix + ), + rD_(matrix.diag().size()) +{ + register const label nCells = matrix.diag().size(); + register const DType* const __restrict__ diagPtr = matrix.diag().begin(); + register DType* __restrict__ rDPtr = rD_.begin(); + + for (register label cellI=0; cellI<nCells; cellI++) + { + rDPtr[cellI] = inv(diagPtr[cellI]); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::TGaussSeidelSmoother<Type, DType, LUType>::smooth +( + const word& fieldName_, + Field<Type>& psi, + const LduMatrix<Type, DType, LUType>& matrix_, + const Field<DType>& rD_, + const label nSweeps +) +{ + register Type* __restrict__ psiPtr = psi.begin(); + + register const label nCells = psi.size(); + + Field<Type> bPrime(nCells); + register Type* __restrict__ bPrimePtr = bPrime.begin(); + + register const DType* const __restrict__ rDPtr = rD_.begin(); + + register const LUType* const __restrict__ upperPtr = + matrix_.upper().begin(); + + register const LUType* const __restrict__ lowerPtr = + matrix_.lower().begin(); + + register const label* const __restrict__ uPtr = + matrix_.lduAddr().upperAddr().begin(); + + register const label* const __restrict__ ownStartPtr = + matrix_.lduAddr().ownerStartAddr().begin(); + + + // Parallel boundary initialisation. The parallel boundary is treated + // as an effective jacobi interface in the boundary. + // Note: there is a change of sign in the coupled + // interface update to add the contibution to the r.h.s. + + FieldField<Field, LUType> mBouCoeffs(matrix_.interfacesUpper().size()); + + forAll(mBouCoeffs, patchi) + { + if (matrix_.interfaces().set(patchi)) + { + mBouCoeffs.set(patchi, -matrix_.interfacesUpper()[patchi]); + } + } + + for (label sweep=0; sweep<nSweeps; sweep++) + { + bPrime = matrix_.source(); + + matrix_.initMatrixInterfaces + ( + mBouCoeffs, + psi, + bPrime + ); + + matrix_.updateMatrixInterfaces + ( + mBouCoeffs, + psi, + bPrime + ); + + Type curPsi; + register label fStart; + register label fEnd = ownStartPtr[0]; + + for (register label cellI=0; cellI<nCells; cellI++) + { + // Start and end of this row + fStart = fEnd; + fEnd = ownStartPtr[cellI + 1]; + + // Get the accumulated neighbour side + curPsi = bPrimePtr[cellI]; + + // Accumulate the owner product side + for (register label curFace=fStart; curFace<fEnd; curFace++) + { + curPsi -= dot(upperPtr[curFace], psiPtr[uPtr[curFace]]); + } + + // Finish current psi + curPsi = dot(rDPtr[cellI], curPsi); + + // Distribute the neighbour side using current psi + for (register label curFace=fStart; curFace<fEnd; curFace++) + { + bPrimePtr[uPtr[curFace]] -= dot(lowerPtr[curFace], curPsi); + } + + psiPtr[cellI] = curPsi; + } + } +} + + +template<class Type, class DType, class LUType> +void Foam::TGaussSeidelSmoother<Type, DType, LUType>::smooth +( + Field<Type>& psi, + const label nSweeps +) const +{ + smooth(this->fieldName_, psi, this->matrix_, rD_, nSweeps); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.H b/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.H new file mode 100644 index 0000000000000000000000000000000000000000..2627592989ac3c5464056f836a74e3f586da56fc --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.H @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::TGaussSeidelSmoother + +Description + Foam::TGaussSeidelSmoother + +SourceFiles + TGaussSeidelSmoother.C + +\*---------------------------------------------------------------------------*/ + +#ifndef TGaussSeidelSmoother_H +#define TGaussSeidelSmoother_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class TGaussSeidelSmoother Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class TGaussSeidelSmoother +: + public LduMatrix<Type, DType, LUType>::smoother +{ + // Private data + + //- The inverse (reciprocal for scalars) diagonal + Field<DType> rD_; + + +public: + + //- Runtime type information + TypeName("GaussSeidel"); + + + // Constructors + + //- Construct from components + TGaussSeidelSmoother + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix + ); + + + // Member Functions + + //- Smooth for the given number of sweeps + static void smooth + ( + const word& fieldName, + Field<Type>& psi, + const LduMatrix<Type, DType, LUType>& matrix, + const Field<DType>& rD, + const label nSweeps + ); + + + //- Smooth the solution for a given number of sweeps + virtual void smooth + ( + Field<Type>& psi, + const label nSweeps + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "TGaussSeidelSmoother.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Smoothers/lduSmoothers.C b/src/OpenFOAM/matrices/LduMatrix/Smoothers/lduSmoothers.C new file mode 100644 index 0000000000000000000000000000000000000000..c40b0673f8c2e20f8a7978b6d39f741975b083c3 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Smoothers/lduSmoothers.C @@ -0,0 +1,45 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "TGaussSeidelSmoother.H" +#include "fieldTypes.H" + +#define makeLduSmoothers(Type, DType, LUType) \ + \ + makeLduSmoother(TGaussSeidelSmoother, Type, DType, LUType); \ + makeLduSymSmoother(TGaussSeidelSmoother, Type, DType, LUType); \ + makeLduAsymSmoother(TGaussSeidelSmoother, Type, DType, LUType); + +namespace Foam +{ + makeLduSmoothers(scalar, scalar, scalar); + makeLduSmoothers(vector, scalar, scalar); + makeLduSmoothers(sphericalTensor, scalar, scalar); + makeLduSmoothers(symmTensor, scalar, scalar); + makeLduSmoothers(tensor, scalar, scalar); +}; + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/DiagonalSolver/DiagonalSolver.C b/src/OpenFOAM/matrices/LduMatrix/Solvers/DiagonalSolver/DiagonalSolver.C new file mode 100644 index 0000000000000000000000000000000000000000..adbe9113a271c750af850a9443baf3190840d232 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/DiagonalSolver/DiagonalSolver.C @@ -0,0 +1,79 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "DiagonalSolver.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::DiagonalSolver<Type, DType, LUType>::DiagonalSolver +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict +) +: + LduMatrix<Type, DType, LUType>::solver + ( + fieldName, + matrix, + solverDict + ) +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::DiagonalSolver<Type, DType, LUType>::read +( + const dictionary& +) +{} + + +template<class Type, class DType, class LUType> +Foam::SolverPerformance<Type> +Foam::DiagonalSolver<Type, DType, LUType>::solve +( + Field<Type>& psi +) const +{ + psi = this->matrix_.source()/this->matrix_.diag(); + + return SolverPerformance<Type> + ( + typeName, + this->fieldName_, + pTraits<Type>::zero, + pTraits<Type>::zero, + 0, + true, + false + ); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/DiagonalSolver/DiagonalSolver.H b/src/OpenFOAM/matrices/LduMatrix/Solvers/DiagonalSolver/DiagonalSolver.H new file mode 100644 index 0000000000000000000000000000000000000000..b9dc537c08afaf1ea2a771046842f84dc776aa56 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/DiagonalSolver/DiagonalSolver.H @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::DiagonalSolver + +Description + Foam::DiagonalSolver + +SourceFiles + DiagonalSolver.C + +\*---------------------------------------------------------------------------*/ + +#ifndef DiagonalSolver_H +#define DiagonalSolver_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class DiagonalSolver Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class DiagonalSolver +: + public LduMatrix<Type, DType, LUType>::solver +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + DiagonalSolver(const DiagonalSolver&); + + //- Disallow default bitwise assignment + void operator=(const DiagonalSolver&); + + +public: + + //- Runtime type information + TypeName("diagonal"); + + + // Constructors + + //- Construct from matrix + DiagonalSolver + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ); + + + // Member Functions + + //- Read and reset the solver parameters from the given dictionary + void read(const dictionary& solverDict); + + //- Solve the matrix with this solver + virtual SolverPerformance<Type> solve(Field<Type>& psi) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "DiagonalSolver.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCCCG/PBiCCCG.C b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCCCG/PBiCCCG.C new file mode 100644 index 0000000000000000000000000000000000000000..7ee6da05dcf6bd6c733164fe77e85773b9296469 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCCCG/PBiCCCG.C @@ -0,0 +1,194 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "PBiCCCG.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::PBiCCCG<Type, DType, LUType>::PBiCCCG +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict +) +: + LduMatrix<Type, DType, LUType>::solver + ( + fieldName, + matrix, + solverDict + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::SolverPerformance<Type> +Foam::PBiCCCG<Type, DType, LUType>::solve +( + Field<Type>& psi +) const +{ + word preconditionerName(this->controlDict_.lookup("preconditioner")); + + // --- Setup class containing solver performance data + SolverPerformance<Type> solverPerf + ( + preconditionerName + typeName, + this->fieldName_ + ); + + register label nCells = psi.size(); + + Type* __restrict__ psiPtr = psi.begin(); + + Field<Type> pA(nCells); + Type* __restrict__ pAPtr = pA.begin(); + + Field<Type> pT(nCells, pTraits<Type>::zero); + Type* __restrict__ pTPtr = pT.begin(); + + Field<Type> wA(nCells); + Type* __restrict__ wAPtr = wA.begin(); + + Field<Type> wT(nCells); + Type* __restrict__ wTPtr = wT.begin(); + + scalar wArT = 1e15; //this->matrix_.great_; + scalar wArTold = wArT; + + // --- Calculate A.psi and T.psi + this->matrix_.Amul(wA, psi); + this->matrix_.Tmul(wT, psi); + + // --- Calculate initial residual and transpose residual fields + Field<Type> rA(this->matrix_.source() - wA); + Field<Type> rT(this->matrix_.source() - wT); + Type* __restrict__ rAPtr = rA.begin(); + Type* __restrict__ rTPtr = rT.begin(); + + // --- Calculate normalisation factor + Type normFactor = this->normFactor(psi, wA, pA); + + if (LduMatrix<Type, DType, LUType>::debug >= 2) + { + Info<< " Normalisation factor = " << normFactor << endl; + } + + // --- Calculate normalised residual norm + solverPerf.initialResidual() = cmptDivide(gSumCmptMag(rA), normFactor); + solverPerf.finalResidual() = solverPerf.initialResidual(); + + // --- Check convergence, solve if not converged + if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + { + // --- Select and construct the preconditioner + autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> + preconPtr = LduMatrix<Type, DType, LUType>::preconditioner::New + ( + *this, + this->controlDict_ + ); + + // --- Solver iteration + do + { + // --- Store previous wArT + wArTold = wArT; + + // --- Precondition residuals + preconPtr->precondition(wA, rA); + preconPtr->preconditionT(wT, rT); + + // --- Update search directions: + wArT = gSumProd(wA, rT); + + if (solverPerf.nIterations() == 0) + { + for (register label cell=0; cell<nCells; cell++) + { + pAPtr[cell] = wAPtr[cell]; + pTPtr[cell] = wTPtr[cell]; + } + } + else + { + scalar beta = wArT/wArTold; + + for (register label cell=0; cell<nCells; cell++) + { + pAPtr[cell] = wAPtr[cell] + (beta* pAPtr[cell]); + pTPtr[cell] = wTPtr[cell] + (beta* pTPtr[cell]); + } + } + + + // --- Update preconditioned residuals + this->matrix_.Amul(wA, pA); + this->matrix_.Tmul(wT, pT); + + scalar wApT = gSumProd(wA, pT); + + // --- Test for singularity + if + ( + solverPerf.checkSingularity + ( + cmptDivide(pTraits<Type>::one*mag(wApT), normFactor) + ) + ) + { + break; + } + + + // --- Update solution and residual: + + scalar alpha = wArT/wApT; + + for (register label cell=0; cell<nCells; cell++) + { + psiPtr[cell] += (alpha* pAPtr[cell]); + rAPtr[cell] -= (alpha* wAPtr[cell]); + rTPtr[cell] -= (alpha* wTPtr[cell]); + } + + solverPerf.finalResidual() = + cmptDivide(gSumCmptMag(rA), normFactor); + + } while + ( + solverPerf.nIterations()++ < this->maxIter_ + && !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + ); + } + + return solverPerf; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCCCG/PBiCCCG.H b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCCCG/PBiCCCG.H new file mode 100644 index 0000000000000000000000000000000000000000..39c0e56d44768d12e13879c872c6a97035db9fe9 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCCCG/PBiCCCG.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::PBiCCCG + +Description + Preconditioned bi-conjugate gradient solver for asymmetric lduMatrices + using a run-time selectable preconditiioner. + +SourceFiles + PBiCCCG.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PBiCCCG_H +#define PBiCCCG_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PBiCCCG Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class PBiCCCG +: + public LduMatrix<Type, DType, LUType>::solver +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + PBiCCCG(const PBiCCCG&); + + //- Disallow default bitwise assignment + void operator=(const PBiCCCG&); + + +public: + + //- Runtime type information + TypeName("PBiCCCG"); + + + // Constructors + + //- Construct from matrix components and solver data dictionary + PBiCCCG + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ); + + + // Destructor + + virtual ~PBiCCCG() + {} + + + // Member Functions + + //- Solve the matrix with this solver + virtual SolverPerformance<Type> solve(Field<Type>& psi) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "PBiCCCG.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCICG/PBiCICG.C b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCICG/PBiCICG.C new file mode 100644 index 0000000000000000000000000000000000000000..260daedbf0e11c88a2004b7d53a4130b8c3587c6 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCICG/PBiCICG.C @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "PBiCICG.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::PBiCICG<Type, DType, LUType>::PBiCICG +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict +) +: + LduMatrix<Type, DType, LUType>::solver + ( + fieldName, + matrix, + solverDict + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::SolverPerformance<Type> +Foam::PBiCICG<Type, DType, LUType>::solve(Field<Type>& psi) const +{ + word preconditionerName(this->controlDict_.lookup("preconditioner")); + + // --- Setup class containing solver performance data + SolverPerformance<Type> solverPerf + ( + preconditionerName + typeName, + this->fieldName_ + ); + + register label nCells = psi.size(); + + Type* __restrict__ psiPtr = psi.begin(); + + Field<Type> pA(nCells); + Type* __restrict__ pAPtr = pA.begin(); + + Field<Type> pT(nCells, pTraits<Type>::zero); + Type* __restrict__ pTPtr = pT.begin(); + + Field<Type> wA(nCells); + Type* __restrict__ wAPtr = wA.begin(); + + Field<Type> wT(nCells); + Type* __restrict__ wTPtr = wT.begin(); + + Type wArT = solverPerf.great_*pTraits<Type>::one; + Type wArTold = wArT; + + // --- Calculate A.psi and T.psi + this->matrix_.Amul(wA, psi); + this->matrix_.Tmul(wT, psi); + + // --- Calculate initial residual and transpose residual fields + Field<Type> rA(this->matrix_.source() - wA); + Field<Type> rT(this->matrix_.source() - wT); + Type* __restrict__ rAPtr = rA.begin(); + Type* __restrict__ rTPtr = rT.begin(); + + // --- Calculate normalisation factor + Type normFactor = this->normFactor(psi, wA, pA); + + if (LduMatrix<Type, DType, LUType>::debug >= 2) + { + Info<< " Normalisation factor = " << normFactor << endl; + } + + // --- Calculate normalised residual norm + solverPerf.initialResidual() = cmptDivide(gSumCmptMag(rA), normFactor); + solverPerf.finalResidual() = solverPerf.initialResidual(); + + // --- Check convergence, solve if not converged + if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + { + // --- Select and construct the preconditioner + autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> + preconPtr = LduMatrix<Type, DType, LUType>::preconditioner::New + ( + *this, + this->controlDict_ + ); + + // --- Solver iteration + do + { + // --- Store previous wArT + wArTold = wArT; + + // --- Precondition residuals + preconPtr->precondition(wA, rA); + preconPtr->preconditionT(wT, rT); + + // --- Update search directions: + wArT = gSumCmptProd(wA, rT); + + if (solverPerf.nIterations() == 0) + { + for (register label cell=0; cell<nCells; cell++) + { + pAPtr[cell] = wAPtr[cell]; + pTPtr[cell] = wTPtr[cell]; + } + } + else + { + Type beta = cmptDivide + ( + wArT, + stabilise(wArTold, solverPerf.vsmall_) + ); + + for (register label cell=0; cell<nCells; cell++) + { + pAPtr[cell] = wAPtr[cell] + cmptMultiply(beta, pAPtr[cell]); + pTPtr[cell] = wTPtr[cell] + cmptMultiply(beta, pTPtr[cell]); + } + } + + + // --- Update preconditioned residuals + this->matrix_.Amul(wA, pA); + this->matrix_.Tmul(wT, pT); + + Type wApT = gSumCmptProd(wA, pT); + + // --- Test for singularity + if + ( + solverPerf.checkSingularity + ( + cmptDivide(cmptMag(wApT), normFactor) + ) + ) + { + break; + } + + + // --- Update solution and residual: + + Type alpha = cmptDivide + ( + wArT, + stabilise(wApT, solverPerf.vsmall_) + ); + + for (register label cell=0; cell<nCells; cell++) + { + psiPtr[cell] += cmptMultiply(alpha, pAPtr[cell]); + rAPtr[cell] -= cmptMultiply(alpha, wAPtr[cell]); + rTPtr[cell] -= cmptMultiply(alpha, wTPtr[cell]); + } + + solverPerf.finalResidual() = + cmptDivide(gSumCmptMag(rA), normFactor); + + } while + ( + solverPerf.nIterations()++ < this->maxIter_ + && !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + ); + } + + return solverPerf; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCICG/PBiCICG.H b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCICG/PBiCICG.H new file mode 100644 index 0000000000000000000000000000000000000000..1265af2aac4b6197e9c7e2d7d0038ccb846a4a5a --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/PBiCICG/PBiCICG.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::PBiCICG + +Description + Preconditioned bi-conjugate gradient solver for asymmetric lduMatrices + using a run-time selectable preconditiioner. + +SourceFiles + PBiCICG.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PBiCICG_H +#define PBiCICG_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PBiCICG Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class PBiCICG +: + public LduMatrix<Type, DType, LUType>::solver +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + PBiCICG(const PBiCICG&); + + //- Disallow default bitwise assignment + void operator=(const PBiCICG&); + + +public: + + //- Runtime type information + TypeName("PBiCICG"); + + + // Constructors + + //- Construct from matrix components and solver data dictionary + PBiCICG + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ); + + + // Destructor + + virtual ~PBiCICG() + {} + + + // Member Functions + + //- Solve the matrix with this solver + virtual SolverPerformance<Type> solve(Field<Type>& psi) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "PBiCICG.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/PCICG/PCICG.C b/src/OpenFOAM/matrices/LduMatrix/Solvers/PCICG/PCICG.C new file mode 100644 index 0000000000000000000000000000000000000000..cc8f1d1c72b1eb0398f6c35dd3775409150e7f1c --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/PCICG/PCICG.C @@ -0,0 +1,186 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "PCICG.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::PCICG<Type, DType, LUType>::PCICG +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict +) +: + LduMatrix<Type, DType, LUType>::solver + ( + fieldName, + matrix, + solverDict + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +typename Foam::SolverPerformance<Type> +Foam::PCICG<Type, DType, LUType>::solve(Field<Type>& psi) const +{ + word preconditionerName(this->controlDict_.lookup("preconditioner")); + + // --- Setup class containing solver performance data + SolverPerformance<Type> solverPerf + ( + preconditionerName + typeName, + this->fieldName_ + ); + + register label nCells = psi.size(); + + Type* __restrict__ psiPtr = psi.begin(); + + Field<Type> pA(nCells); + Type* __restrict__ pAPtr = pA.begin(); + + Field<Type> wA(nCells); + Type* __restrict__ wAPtr = wA.begin(); + + Type wArA = solverPerf.great_*pTraits<Type>::one; + Type wArAold = wArA; + + // --- Calculate A.psi + this->matrix_.Amul(wA, psi); + + // --- Calculate initial residual field + Field<Type> rA(this->matrix_.source() - wA); + Type* __restrict__ rAPtr = rA.begin(); + + // --- Calculate normalisation factor + Type normFactor = this->normFactor(psi, wA, pA); + + if (LduMatrix<Type, DType, LUType>::debug >= 2) + { + Info<< " Normalisation factor = " << normFactor << endl; + } + + // --- Calculate normalised residual norm + solverPerf.initialResidual() = cmptDivide(gSumCmptMag(rA), normFactor); + solverPerf.finalResidual() = solverPerf.initialResidual(); + + // --- Check convergence, solve if not converged + if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + { + // --- Select and construct the preconditioner + autoPtr<typename LduMatrix<Type, DType, LUType>::preconditioner> + preconPtr = LduMatrix<Type, DType, LUType>::preconditioner::New + ( + *this, + this->controlDict_ + ); + + // --- Solver iteration + do + { + // --- Store previous wArA + wArAold = wArA; + + // --- Precondition residual + preconPtr->precondition(wA, rA); + + // --- Update search directions: + wArA = gSumCmptProd(wA, rA); + + if (solverPerf.nIterations() == 0) + { + for (register label cell=0; cell<nCells; cell++) + { + pAPtr[cell] = wAPtr[cell]; + } + } + else + { + Type beta = cmptDivide + ( + wArA, + stabilise(wArAold, solverPerf.vsmall_) + ); + + for (register label cell=0; cell<nCells; cell++) + { + pAPtr[cell] = wAPtr[cell] + cmptMultiply(beta, pAPtr[cell]); + } + } + + + // --- Update preconditioned residual + this->matrix_.Amul(wA, pA); + + Type wApA = gSumCmptProd(wA, pA); + + + // --- Test for singularity + if + ( + solverPerf.checkSingularity + ( + cmptDivide(cmptMag(wApA), normFactor) + ) + ) + { + break; + } + + + // --- Update solution and residual: + + Type alpha = cmptDivide + ( + wArA, + stabilise(wApA, solverPerf.vsmall_) + ); + + for (register label cell=0; cell<nCells; cell++) + { + psiPtr[cell] += cmptMultiply(alpha, pAPtr[cell]); + rAPtr[cell] -= cmptMultiply(alpha, wAPtr[cell]); + } + + solverPerf.finalResidual() = + cmptDivide(gSumCmptMag(rA), normFactor); + + } while + ( + solverPerf.nIterations()++ < this->maxIter_ + && !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + ); + } + + return solverPerf; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/PCICG/PCICG.H b/src/OpenFOAM/matrices/LduMatrix/Solvers/PCICG/PCICG.H new file mode 100644 index 0000000000000000000000000000000000000000..cafeb7f61d3a79ae55861e4dea79b68942f83c38 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/PCICG/PCICG.H @@ -0,0 +1,108 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::PCICG + +Description + Preconditioned conjugate gradient solver for symmetric lduMatrices + using a run-time selectable preconditiioner. + +SourceFiles + PCICG.C + +\*---------------------------------------------------------------------------*/ + +#ifndef PCICG_H +#define PCICG_H + +#include "LduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PCICG Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class PCICG +: + public LduMatrix<Type, DType, LUType>::solver +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + PCICG(const PCICG&); + + //- Disallow default bitwise assignment + void operator=(const PCICG&); + + +public: + + //- Runtime type information + TypeName("PCICG"); + + + // Constructors + + //- Construct from matrix components and solver data dictionary + PCICG + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ); + + + // Destructor + + virtual ~PCICG() + {} + + + // Member Functions + + //- Solve the matrix with this solver + virtual SolverPerformance<Type> solve(Field<Type>& psi) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "PCICG.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/SmoothSolver/SmoothSolver.C b/src/OpenFOAM/matrices/LduMatrix/Solvers/SmoothSolver/SmoothSolver.C new file mode 100644 index 0000000000000000000000000000000000000000..9cf5c81223b71386ed7f40a0737045a30766a57d --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/SmoothSolver/SmoothSolver.C @@ -0,0 +1,153 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "SmoothSolver.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +Foam::SmoothSolver<Type, DType, LUType>::SmoothSolver +( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict +) +: + LduMatrix<Type, DType, LUType>::solver + ( + fieldName, + matrix, + solverDict + ), + nSweeps_(1) +{ + readControls(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type, class DType, class LUType> +void Foam::SmoothSolver<Type, DType, LUType>::readControls() +{ + LduMatrix<Type, DType, LUType>::solver::readControls(); + this->readControl(this->controlDict_, nSweeps_, "nSweeps"); +} + + +template<class Type, class DType, class LUType> +Foam::SolverPerformance<Type> +Foam::SmoothSolver<Type, DType, LUType>::solve(Field<Type>& psi) const +{ + // --- Setup class containing solver performance data + SolverPerformance<Type> solverPerf + ( + typeName, + this->fieldName_ + ); + + // If the nSweeps_ is negative do a fixed number of sweeps + if (nSweeps_ < 0) + { + autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> + smootherPtr = LduMatrix<Type, DType, LUType>::smoother::New + ( + this->fieldName_, + this->matrix_, + this->controlDict_ + ); + + smootherPtr->smooth(psi, -nSweeps_); + + solverPerf.nIterations() -= nSweeps_; + } + else + { + Type normFactor = pTraits<Type>::zero; + + { + Field<Type> Apsi(psi.size()); + Field<Type> temp(psi.size()); + + // Calculate A.psi + this->matrix_.Amul(Apsi, psi); + + // Calculate normalisation factor + normFactor = this->normFactor(psi, Apsi, temp); + + // Calculate residual magnitude + solverPerf.initialResidual() = cmptDivide + ( + gSumCmptMag(this->matrix_.source() - Apsi), + normFactor + ); + solverPerf.finalResidual() = solverPerf.initialResidual(); + } + + if (LduMatrix<Type, DType, LUType>::debug >= 2) + { + Info<< " Normalisation factor = " << normFactor << endl; + } + + + // Check convergence, solve if not converged + if (!solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + { + autoPtr<typename LduMatrix<Type, DType, LUType>::smoother> + smootherPtr = LduMatrix<Type, DType, LUType>::smoother::New + ( + this->fieldName_, + this->matrix_, + this->controlDict_ + ); + + // Smoothing loop + do + { + smootherPtr->smooth + ( + psi, + nSweeps_ + ); + + // Calculate the residual to check convergence + solverPerf.finalResidual() = cmptDivide + ( + gSumCmptMag(this->matrix_.residual(psi)), + normFactor + ); + } while + ( + (solverPerf.nIterations() += nSweeps_) < this->maxIter_ + && !(solverPerf.checkConvergence(this->tolerance_, this->relTol_)) + ); + } + } + + return solverPerf; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/SmoothSolver/SmoothSolver.H b/src/OpenFOAM/matrices/LduMatrix/Solvers/SmoothSolver/SmoothSolver.H new file mode 100644 index 0000000000000000000000000000000000000000..54db11be8c569bc80530e486f9b7cada29806ff8 --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/SmoothSolver/SmoothSolver.H @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::SmoothSolver + +Description + Iterative solver for symmetric and assymetric matrices which uses a + run-time selected smoother e.g. GaussSeidel to converge the solution to + the required tolerance. To improve efficiency, the residual is evaluated + after every nSweeps smoothing iterations. + +SourceFiles + SmoothSolver.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SmoothSolver_H +#define SmoothSolver_H + +#include "lduMatrix.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class SmoothSolver Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type, class DType, class LUType> +class SmoothSolver +: + public LduMatrix<Type, DType, LUType>::solver +{ + +protected: + + // Protected data + + //- Number of sweeps before the evaluation of residual + label nSweeps_; + + //- Read the control parameters from the controlDict_ + virtual void readControls(); + + +public: + + //- Runtime type information + TypeName("SmoothSolver"); + + + // Constructors + + //- Construct from matrix components and solver data dictionary + SmoothSolver + ( + const word& fieldName, + const LduMatrix<Type, DType, LUType>& matrix, + const dictionary& solverDict + ); + + + // Member Functions + + //- Solve the matrix with this solver + virtual SolverPerformance<Type> solve(Field<Type>& psi) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "SmoothSolver.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/LduMatrix/Solvers/lduSolvers.C b/src/OpenFOAM/matrices/LduMatrix/Solvers/lduSolvers.C new file mode 100644 index 0000000000000000000000000000000000000000..6e36e525b8044482dfd5a135c863af8226853b2a --- /dev/null +++ b/src/OpenFOAM/matrices/LduMatrix/Solvers/lduSolvers.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "PCICG.H" +#include "PBiCCCG.H" +#include "PBiCICG.H" +#include "SmoothSolver.H" +#include "fieldTypes.H" + +#define makeLduSolvers(Type, DType, LUType) \ + \ + makeLduSolver(DiagonalSolver, Type, DType, LUType); \ + makeLduSymSolver(DiagonalSolver, Type, DType, LUType); \ + makeLduAsymSolver(DiagonalSolver, Type, DType, LUType); \ + \ + makeLduSolver(PCICG, Type, DType, LUType); \ + makeLduSymSolver(PCICG, Type, DType, LUType); \ + \ + makeLduSolver(PBiCCCG, Type, DType, LUType); \ + makeLduAsymSolver(PBiCCCG, Type, DType, LUType); \ + \ + makeLduSolver(PBiCICG, Type, DType, LUType); \ + makeLduAsymSolver(PBiCICG, Type, DType, LUType); \ + \ + makeLduSolver(SmoothSolver, Type, DType, LUType); \ + makeLduSymSolver(SmoothSolver, Type, DType, LUType); \ + makeLduAsymSolver(SmoothSolver, Type, DType, LUType); + +namespace Foam +{ + makeLduSolvers(scalar, scalar, scalar); + makeLduSolvers(vector, scalar, scalar); + makeLduSolvers(sphericalTensor, scalar, scalar); + makeLduSolvers(symmTensor, scalar, scalar); + makeLduSolvers(tensor, scalar, scalar); +}; + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H index 86bdcd045e4bcfff751fa9ec1b8071d20fec2761..5ff1f3eff81bb719b1c1f12687557e7a93a89602 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/cyclicLduInterfaceField/cyclicLduInterfaceField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -84,10 +84,14 @@ public: virtual int rank() const = 0; - //- Transform given patch internal field + //- Transform given patch field + template<class Type> + void transformCoupleField(Field<Type>& f) const; + + //- Transform given patch component field void transformCoupleField ( - scalarField& psiInternal, + scalarField& f, const direction cmpt ) const; }; @@ -97,6 +101,30 @@ public: } // End namespace Foam +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "tensorField.H" + +template<class Type> +void Foam::cyclicLduInterfaceField::transformCoupleField +( + Field<Type>& f +) const +{ + if (doTransform()) + { + if (forwardT().size() == 1) + { + transform(f, forwardT()[0], f); + } + else + { + transform(f, forwardT(), f); + } + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H index b8180a2b3ec086d043fc52e4c1d590f5bbd0ef87..45ad3f0dcad680588863a877f04870dcd0748953 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceField.H @@ -73,6 +73,7 @@ class lduInterfaceField //- Disallow default bitwise assignment void operator=(const lduInterfaceField&); + public: //- Runtime type information @@ -112,18 +113,6 @@ public: // Coupled interface matrix update - //- Initialise neighbour matrix update - virtual void initInterfaceMatrixUpdate - ( - const scalarField&, - scalarField&, - const lduMatrix&, - const scalarField&, - const direction, - const Pstream::commsTypes commsType - ) const - {} - //- Whether matrix has been updated bool updatedMatrix() const { @@ -142,12 +131,22 @@ public: return true; } + //- Initialise neighbour matrix update + virtual void initInterfaceMatrixUpdate + ( + scalarField&, + const scalarField&, + const scalarField&, + const direction, + const Pstream::commsTypes commsType + ) const + {} + //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField&, scalarField&, - const lduMatrix&, + const scalarField&, const scalarField&, const direction, const Pstream::commsTypes commsType diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H index b5111933558b9d441cfeaa2d375f0cfff2132e8d..a5b9066b828c90120951c4dd6b65f1f2ad477d00 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/processorLduInterfaceField/processorLduInterfaceField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -87,6 +87,10 @@ public: virtual int rank() const = 0; + //- Transform given patch field + template<class Type> + void transformCoupleField(Field<Type>& f) const; + //- Transform given patch component field void transformCoupleField ( @@ -100,6 +104,30 @@ public: } // End namespace Foam +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "tensorField.H" + +template<class Type> +void Foam::processorLduInterfaceField::transformCoupleField +( + Field<Type>& f +) const +{ + if (doTransform()) + { + if (forwardT().size() == 1) + { + transform(f, forwardT()[0], f); + } + else + { + transform(f, forwardT(), f); + } + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C index 6fb1b68d0ac816674a0494e73bacb77866d952a6..16dd1a41881b1473634a842772148519571abbe2 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,9 +30,6 @@ License defineTypeNameAndDebug(Foam::lduMatrix, 1); -const Foam::scalar Foam::lduMatrix::great_ = 1.0e+20; -const Foam::scalar Foam::lduMatrix::small_ = 1.0e-20; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index dc9583fc0b87116c00e2dfd7610c47b2665f7f32..ec5d7a89d5df3f7ea81406e1f2e2cf0ff78acf93 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,6 +57,7 @@ SourceFiles #include "typeInfo.H" #include "autoPtr.H" #include "runTimeSelectionTables.H" +#include "solverPerformance.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -86,165 +87,6 @@ class lduMatrix public: - //- Class returned by the solver, containing performance statistics - class solverPerformance - { - word solverName_; - word fieldName_; - scalar initialResidual_; - scalar finalResidual_; - label noIterations_; - bool converged_; - bool singular_; - - - public: - - // Constructors - - //- Construct null - solverPerformance() - : - initialResidual_(0), - finalResidual_(0), - noIterations_(0), - converged_(false), - singular_(false) - {} - - //- Construct from components - solverPerformance - ( - const word& solverName, - const word& fieldName, - const scalar iRes = 0, - const scalar fRes = 0, - const label nIter = 0, - const bool converged = false, - const bool singular = false - ) - : - solverName_(solverName), - fieldName_(fieldName), - initialResidual_(iRes), - finalResidual_(fRes), - noIterations_(nIter), - converged_(converged), - singular_(singular) - {} - - //- Construct from Istream - solverPerformance(Istream&); - - - // Member functions - - //- Return solver name - const word& solverName() const - { - return solverName_; - } - - //- Return solver name - word& solverName() - { - return solverName_; - } - - - //- Return field name - const word& fieldName() const - { - return fieldName_; - } - - - //- Return initial residual - scalar initialResidual() const - { - return initialResidual_; - } - - //- Return initial residual - scalar& initialResidual() - { - return initialResidual_; - } - - - //- Return final residual - scalar finalResidual() const - { - return finalResidual_; - } - - //- Return final residual - scalar& finalResidual() - { - return finalResidual_; - } - - - //- Return number of iterations - label nIterations() const - { - return noIterations_; - } - - //- Return number of iterations - label& nIterations() - { - return noIterations_; - } - - - //- Has the solver converged? - bool converged() const - { - return converged_; - } - - //- Is the matrix singular? - bool singular() const - { - return singular_; - } - - //- Convergence test - bool checkConvergence - ( - const scalar tolerance, - const scalar relTolerance - ); - - //- Singularity test - bool checkSingularity(const scalar residual); - - //- Print summary of solver performance - void print() const; - - // Member Operators - - bool operator!=(const solverPerformance&) const; - - - // Friend functions - - //- Return the element-wise maximum of two solverPerformances - friend solverPerformance max - ( - const solverPerformance&, - const solverPerformance& - ); - - - // Ostream Operator - - friend Istream& operator>>(Istream&, solverPerformance&); - friend Ostream& operator<<(Ostream&, const solverPerformance&); - }; - - //- Abstract base-class for lduMatrix solvers class solver { @@ -669,12 +511,6 @@ public: // Declare name of the class and its debug switch ClassName("lduMatrix"); - //- Large scalar for the use in solvers - static const scalar great_; - - //- Small scalar for the use in solvers - static const scalar small_; - // Constructors diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C index 0381db1b89f836177634d26f044fd9e4621aee65..bedb55529eeef8ed05289d11343adece8b0d28f4 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -188,10 +188,12 @@ Foam::scalar Foam::lduMatrix::solver::normFactor matrix_.sumA(tmpField, interfaceBouCoeffs_, interfaces_); tmpField *= gAverage(psi); - return gSum(mag(Apsi - tmpField) + mag(source - tmpField)) + matrix_.small_; + return + gSum(mag(Apsi - tmpField) + mag(source - tmpField)) + + solverPerformance::small_; // At convergence this simpler method is equivalent to the above - // return 2*gSumMag(source) + matrix_.small_; + // return 2*gSumMag(source) + solverPerformance::small_; } diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C index 62d00b7626c7c04929f6f69bc18e6562e92dea0f..bf48d3852b8c23e8f47dac63a5ff3dacc1ae2c69 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C @@ -48,9 +48,8 @@ void Foam::lduMatrix::initMatrixInterfaces { interfaces[interfaceI].initInterfaceMatrixUpdate ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::defaultCommsType @@ -75,9 +74,8 @@ void Foam::lduMatrix::initMatrixInterfaces { interfaces[interfaceI].initInterfaceMatrixUpdate ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::blocking @@ -112,9 +110,8 @@ void Foam::lduMatrix::updateMatrixInterfaces { interfaces[interfaceI].updateInterfaceMatrix ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::defaultCommsType @@ -141,9 +138,8 @@ void Foam::lduMatrix::updateMatrixInterfaces { interfaces[interfaceI].updateInterfaceMatrix ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::defaultCommsType @@ -193,9 +189,8 @@ void Foam::lduMatrix::updateMatrixInterfaces { interfaces[interfaceI].updateInterfaceMatrix ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::defaultCommsType @@ -218,9 +213,8 @@ void Foam::lduMatrix::updateMatrixInterfaces { interfaces[interfaceI].initInterfaceMatrixUpdate ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::scheduled @@ -230,9 +224,8 @@ void Foam::lduMatrix::updateMatrixInterfaces { interfaces[interfaceI].updateInterfaceMatrix ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::scheduled @@ -254,9 +247,8 @@ void Foam::lduMatrix::updateMatrixInterfaces { interfaces[interfaceI].updateInterfaceMatrix ( - psiif, result, - *this, + psiif, coupleCoeffs[interfaceI], cmpt, Pstream::blocking diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H index 27094885e6fcdc9405eed78bce0b63eeaa639bc6..273d2c75b2171803ea82f515dfb84bb1d09d3534 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -229,7 +229,7 @@ public: // Member Functions //- Solve - virtual lduMatrix::solverPerformance solve + virtual solverPerformance solve ( scalarField& psi, const scalarField& source, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C index e0574e5895390b27160cd59e26afb7fc5595fcfb..248c421f2e347dbf4a20cd3316a3c8395412b255 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/GAMGSolverSolve.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::lduMatrix::solverPerformance Foam::GAMGSolver::solve +Foam::solverPerformance Foam::GAMGSolver::solve ( scalarField& psi, const scalarField& source, @@ -38,7 +38,7 @@ Foam::lduMatrix::solverPerformance Foam::GAMGSolver::solve ) const { // Setup class containing solver performance data - lduMatrix::solverPerformance solverPerf(typeName, fieldName_); + solverPerformance solverPerf(typeName, fieldName_); // Calculate A.psi used to calculate the initial residual scalarField Apsi(psi.size()); @@ -103,7 +103,7 @@ Foam::lduMatrix::solverPerformance Foam::GAMGSolver::solve if (debug >= 2) { - solverPerf.print(); + solverPerf.print(Info); } } while ( @@ -429,7 +429,7 @@ void Foam::GAMGSolver::solveCoarsestLevel { const label coarsestLevel = matrixLevels_.size() - 1; coarsestCorrField = 0; - lduMatrix::solverPerformance coarseSolverPerf; + solverPerformance coarseSolverPerf; if (matrixLevels_[coarsestLevel].asymmetric()) { @@ -468,7 +468,7 @@ void Foam::GAMGSolver::solveCoarsestLevel if (debug >= 2) { - coarseSolverPerf.print(); + coarseSolverPerf.print(Info); } } } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C index eb7e39b3d424026977b976c18313540ca3b08558..c3a44bf160b3184528f6a0ca4dee4f847ba27888 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,9 +72,8 @@ Foam::cyclicGAMGInterfaceField::~cyclicGAMGInterfaceField() void Foam::cyclicGAMGInterfaceField::updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H index 5edb1a58afe655937df1eb8f5c4e07bc438e9855..29677f0c5031a07b25a3a95f2182aa72f11f2877 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -105,20 +105,6 @@ public: } - // Interface matrix update - - //- Update result field based on interface functionality - virtual void updateInterfaceMatrix - ( - const scalarField& psiInternal, - scalarField& result, - const lduMatrix&, - const scalarField& coeffs, - const direction cmpt, - const Pstream::commsTypes commsType - ) const; - - //- Cyclic interface functions //- Does the interface field perform the transfromation @@ -144,6 +130,19 @@ public: { return rank_; } + + + // Interface matrix update + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + scalarField& result, + const scalarField& psiInternal, + const scalarField& coeffs, + const direction cmpt, + const Pstream::commsTypes commsType + ) const; }; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.C index d5e7cab4e2c202f7a3b7079f245507b610338700..c0b1d8927da93f4a079940e5c8bdf271995c9b52 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,49 +59,4 @@ Foam::processorCyclicGAMGInterfaceField::~processorCyclicGAMGInterfaceField() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -//void Foam::processorCyclicGAMGInterfaceField::initInterfaceMatrixUpdate -//( -// const scalarField& psiInternal, -// scalarField&, -// const lduMatrix&, -// const scalarField&, -// const direction, -// const Pstream::commsTypes commsType -//) const -//{ -// procInterface_.compressedSend -// ( -// commsType, -// procInterface_.interfaceInternalField(psiInternal)() -// ); -//} -// -// -//void Foam::processorCyclicGAMGInterfaceField::updateInterfaceMatrix -//( -// const scalarField&, -// scalarField& result, -// const lduMatrix&, -// const scalarField& coeffs, -// const direction cmpt, -// const Pstream::commsTypes commsType -//) const -//{ -// scalarField pnf -// ( -// procInterface_.compressedReceive<scalar>(commsType, coeffs.size()) -// ); -// transformCoupleField(pnf, cmpt); -// -// const labelUList& faceCells = procInterface_.faceCells(); -// -// forAll(faceCells, elemI) -// { -// result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; -// } -//} - - // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.H index a9c48b5b4b4cabae569c7db6b57fd79bd75d2f5b..55e6471b46aab121834afe3389fdaa11711ff7ba 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorCyclicGAMGInterfaceField/processorCyclicGAMGInterfaceField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,18 +50,6 @@ class processorCyclicGAMGInterfaceField : public processorGAMGInterfaceField { - // Private data - -// //- Local reference cast into the processor interface -// const processorCyclicGAMGInterface& procInterface_; -// -// //- Is the transform required -// bool doTransform_; -// -// //- Rank of component for transformation -// int rank_; -// - // Private Member Functions //- Disallow default bitwise copy construct @@ -93,75 +81,6 @@ public: // Destructor virtual ~processorCyclicGAMGInterfaceField(); - - - // Member Functions - -// // Access -// -// //- Return size -// label size() const -// { -// return procInterface_.size(); -// } -// -// -// // Interface matrix update -// -// //- Initialise neighbour matrix update -// virtual void initInterfaceMatrixUpdate -// ( -// const scalarField& psiInternal, -// scalarField& result, -// const lduMatrix& m, -// const scalarField& coeffs, -// const direction cmpt, -// const Pstream::commsTypes commsType -// ) const; -// -// //- Update result field based on interface functionality -// virtual void updateInterfaceMatrix -// ( -// const scalarField& psiInternal, -// scalarField& result, -// const lduMatrix&, -// const scalarField& coeffs, -// const direction cmpt, -// const Pstream::commsTypes commsType -// ) const; -// -// -// //- Processor interface functions -// -// //- Return processor number -// virtual int myProcNo() const -// { -// return procInterface_.myProcNo(); -// } -// -// //- Return neigbour processor number -// virtual int neighbProcNo() const -// { -// return procInterface_.neighbProcNo(); -// } -// -// //- Does the interface field perform the transfromation -// virtual bool doTransform() const -// { -// return doTransform_; -// } -// -// //- Return face transformation tensor -// virtual const tensorField& forwardT() const -// { -// return procInterface_.forwardT(); -// } -// -// //- Return rank of component for transform -// virtual int rank() const -// { -// return rank_; -// } }; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C index b8fa744ff6b0673f1174fee7fc22bb43ca95eccd..184630bb49f5c35fc868bf5e632864431e2d245a 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C @@ -72,9 +72,8 @@ Foam::processorGAMGInterfaceField::~processorGAMGInterfaceField() void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate ( - const scalarField& psiInternal, scalarField&, - const lduMatrix&, + const scalarField& psiInternal, const scalarField&, const direction, const Pstream::commsTypes commsType @@ -117,9 +116,8 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate void Foam::processorGAMGInterfaceField::updateInterfaceMatrix ( - const scalarField&, scalarField& result, - const lduMatrix&, + const scalarField&, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H index 48d64baacf369908a2bec65f6cc88fabe2b669aa..c64f0738ee4df01c29019deebb9971a33454ca75 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H @@ -126,9 +126,8 @@ public: //- Initialise neighbour matrix update virtual void initInterfaceMatrixUpdate ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix& m, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType @@ -137,9 +136,8 @@ public: //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C index b553bab048c522c514f4bb9c1f06d5c2234c5873..8f224f85e743fa19ef06184b0dfa9e812d85e830 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,7 +62,7 @@ Foam::PBiCG::PBiCG // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::lduMatrix::solverPerformance Foam::PBiCG::solve +Foam::solverPerformance Foam::PBiCG::solve ( scalarField& psi, const scalarField& source, @@ -70,7 +70,7 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve ) const { // --- Setup class containing solver performance data - lduMatrix::solverPerformance solverPerf + solverPerformance solverPerf ( lduMatrix::preconditioner::getName(controlDict_) + typeName, fieldName_ @@ -92,7 +92,7 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve scalarField wT(nCells); scalar* __restrict__ wTPtr = wT.begin(); - scalar wArT = matrix_.great_; + scalar wArT = solverPerf.great_; scalar wArTold = wArT; // --- Calculate A.psi and T.psi @@ -167,9 +167,11 @@ Foam::lduMatrix::solverPerformance Foam::PBiCG::solve scalar wApT = gSumProd(wA, pT); - // --- Test for singularity - if (solverPerf.checkSingularity(mag(wApT)/normFactor)) break; + if (solverPerf.checkSingularity(mag(wApT)/normFactor)) + { + break; + } // --- Update solution and residual: diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H index 7479f75cc5533ea0e12f8509bfdc3d4edeac6678..fda7d7d314d895c938ef360111d0bf505ff6eaff 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PBiCG/PBiCG.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,7 +88,7 @@ public: // Member Functions //- Solve the matrix with this solver - virtual lduMatrix::solverPerformance solve + virtual solverPerformance solve ( scalarField& psi, const scalarField& source, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C index 37233afb719aee9470dad7bc9fcc767862212141..b4a06ec8a3df10db2a9c074c27e319b8f10be584 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,7 +62,7 @@ Foam::PCG::PCG // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::lduMatrix::solverPerformance Foam::PCG::solve +Foam::solverPerformance Foam::PCG::solve ( scalarField& psi, const scalarField& source, @@ -70,7 +70,7 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve ) const { // --- Setup class containing solver performance data - lduMatrix::solverPerformance solverPerf + solverPerformance solverPerf ( lduMatrix::preconditioner::getName(controlDict_) + typeName, fieldName_ @@ -86,7 +86,7 @@ Foam::lduMatrix::solverPerformance Foam::PCG::solve scalarField wA(nCells); scalar* __restrict__ wAPtr = wA.begin(); - scalar wArA = matrix_.great_; + scalar wArA = solverPerf.great_; scalar wArAold = wArA; // --- Calculate A.psi diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H index 7aca6131848fc743c9890a5f8ca676a861ec0146..74b3abd17c8fecbc05fd9e77cb8ba4e9be5465b4 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/PCG/PCG.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -88,7 +88,7 @@ public: // Member Functions //- Solve the matrix with this solver - virtual lduMatrix::solverPerformance solve + virtual solverPerformance solve ( scalarField& psi, const scalarField& source, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C index fd03af39e7a6b3c1d1d710d3b4807780a6e85713..73e386f5eddbf34cdafc8cd4b35be1ef7e539c87 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,7 +56,7 @@ Foam::diagonalSolver::diagonalSolver // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Foam::lduMatrix::solverPerformance Foam::diagonalSolver::solve +Foam::solverPerformance Foam::diagonalSolver::solve ( scalarField& psi, const scalarField& source, @@ -65,7 +65,7 @@ Foam::lduMatrix::solverPerformance Foam::diagonalSolver::solve { psi = source/matrix_.diag(); - return lduMatrix::solverPerformance + return solverPerformance ( typeName, fieldName_, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H index 1d67155e8cbe3e51d90fe9944285ad037c743a42..85908b33496b8a0bf45612c47248a6aa23b85f4b 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/diagonalSolver/diagonalSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -86,7 +86,7 @@ public: {} //- Solve the matrix with this solver - lduMatrix::solverPerformance solve + solverPerformance solve ( scalarField& psi, const scalarField& source, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C index 05597a3b66b6780f90ef1f1975503665573155bb..4287eb56999feeb249a9d3dfe544b4323669124d 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -74,7 +74,7 @@ void Foam::smoothSolver::readControls() } -Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve +Foam::solverPerformance Foam::smoothSolver::solve ( scalarField& psi, const scalarField& source, @@ -82,7 +82,7 @@ Foam::lduMatrix::solverPerformance Foam::smoothSolver::solve ) const { // Setup class containing solver performance data - lduMatrix::solverPerformance solverPerf(typeName, fieldName_); + solverPerformance solverPerf(typeName, fieldName_); // If the nSweeps_ is negative do a fixed number of sweeps if (nSweeps_ < 0) diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H index ec62305803c2aba27c9cdd186d68ea3d3e60bbd2..2009768401218f28214dc3b42925f0ba1fd9bef8 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/smoothSolver/smoothSolver.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -92,7 +92,7 @@ public: // Member Functions //- Solve the matrix with this solver - virtual lduMatrix::solverPerformance solve + virtual solverPerformance solve ( scalarField& psi, const scalarField& source, diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index 50eb2fb96c1296769e72726270cf27cb0f147c60..0b770b7daa3d1cd9e2c61665a5dbd552d9f3944e 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -130,6 +130,7 @@ Foam::solution::solution obr, ( obr.readOpt() == IOobject::MUST_READ + || obr.readOpt() == IOobject::READ_IF_PRESENT ? IOobject::MUST_READ_IF_MODIFIED : obr.readOpt() ), @@ -148,6 +149,7 @@ Foam::solution::solution ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED + || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) ) { read(solutionDict()); diff --git a/src/OpenFOAM/meshes/data/data.C b/src/OpenFOAM/meshes/data/data.C index 7540482cfe17a741a7b4bcb487a72b6d2246e036..02366479aa7bbc4c4a3c5bf1dbba6abab703e55d 100644 --- a/src/OpenFOAM/meshes/data/data.C +++ b/src/OpenFOAM/meshes/data/data.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ License #include "data.H" #include "Time.H" -#include "lduMatrix.H" +#include "solverPerformance.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -63,12 +63,12 @@ const Foam::dictionary& Foam::data::solverPerformanceDict() const void Foam::data::setSolverPerformance ( const word& name, - const lduMatrix::solverPerformance& sp + const solverPerformance& sp ) const { dictionary& dict = const_cast<dictionary&>(solverPerformanceDict()); - List<lduMatrix::solverPerformance> perfs; + List<solverPerformance> perfs; if (prevTimeIndex_ != this->time().timeIndex()) { @@ -90,7 +90,7 @@ void Foam::data::setSolverPerformance void Foam::data::setSolverPerformance ( - const lduMatrix::solverPerformance& sp + const solverPerformance& sp ) const { setSolverPerformance(sp.fieldName(), sp); diff --git a/src/OpenFOAM/meshes/data/data.H b/src/OpenFOAM/meshes/data/data.H index 31ce391acbac39c9c0d8be84926f36684029787a..e4fd40fb6a1041efb036ce4ab3112770828bb996 100644 --- a/src/OpenFOAM/meshes/data/data.H +++ b/src/OpenFOAM/meshes/data/data.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,7 +39,7 @@ SourceFiles #define data_H #include "IOdictionary.H" -#include "lduMatrix.H" +#include "solverPerformance.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -94,13 +94,13 @@ public: void setSolverPerformance ( const word& name, - const lduMatrix::solverPerformance& + const solverPerformance& ) const; //- Add/set the solverPerformance entry, using its fieldName void setSolverPerformance ( - const lduMatrix::solverPerformance& + const solverPerformance& ) const; }; diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C index 3ccbdd4043253af2c64bb1e7370d63c012d030a1..2122b282d7ff537630b9410f3c5bfcd22c2aa42c 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalMeshData.C @@ -44,7 +44,7 @@ License defineTypeNameAndDebug(Foam::globalMeshData, 0); // Geometric matching tolerance. Factor of mesh bounding box. -const Foam::scalar Foam::globalMeshData::matchTol_ = 1E-8; +const Foam::scalar Foam::globalMeshData::matchTol_ = 1e-8; namespace Foam { diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index ab13b344440ac5b6fe3648b4559dd4ba104eb103..d5670fa33147ce4cc0915be6a832d57c280a5c0e 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -132,6 +132,84 @@ Foam::polyBoundaryMesh::polyBoundaryMesh {} +Foam::polyBoundaryMesh::polyBoundaryMesh +( + const IOobject& io, + const polyMesh& pm, + const polyPatchList& ppl +) +: + polyPatchList(), + regIOobject(io), + mesh_(pm) +{ + if + ( + (this->readOpt() == IOobject::READ_IF_PRESENT && this->headerOk()) + || this->readOpt() == IOobject::MUST_READ + || this->readOpt() == IOobject::MUST_READ_IF_MODIFIED + ) + { + + if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) + { + WarningIn + ( + "polyBoundaryMesh::polyBoundaryMesh\n" + "(\n" + " const IOobject&,\n" + " const polyMesh&\n" + " const polyPatchList&\n" + ")" + ) << "Specified IOobject::MUST_READ_IF_MODIFIED but class" + << " does not support automatic rereading." + << endl; + } + + polyPatchList& patches = *this; + + // Read polyPatchList + Istream& is = readStream(typeName); + + PtrList<entry> patchEntries(is); + patches.setSize(patchEntries.size()); + + forAll(patches, patchI) + { + patches.set + ( + patchI, + polyPatch::New + ( + patchEntries[patchI].keyword(), + patchEntries[patchI].dict(), + patchI, + *this + ) + ); + } + + // Check state of IOstream + is.check + ( + "polyBoundaryMesh::polyBoundaryMesh" + "(const IOobject&, const polyMesh&, const polyPatchList&)" + ); + + close(); + } + else + { + polyPatchList& patches = *this; + patches.setSize(ppl.size()); + forAll (patches, patchI) + { + patches.set(patchI, ppl[patchI].clone(*this).ptr()); + } + } +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::polyBoundaryMesh::~polyBoundaryMesh() diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 62d6f4a5e1e8b6d2013dcc459cc3c657caf61c61..999b3815bf52ff26671e5086a21b2123dd2ca31d 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -119,6 +119,14 @@ public: const label size ); + //- Construct given polyPatchList + polyBoundaryMesh + ( + const IOobject&, + const polyMesh&, + const polyPatchList& + ); + //- Destructor ~polyBoundaryMesh(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index 8877cdafcfc38b98f6851040fb9159c5b87ace3f..e8bf1fc6b294bb2efed2150832fa08583bb0116f 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -338,7 +338,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::AUTO_WRITE ), points @@ -351,7 +351,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::AUTO_WRITE ), faces @@ -364,7 +364,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::AUTO_WRITE ), owner @@ -377,7 +377,7 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::AUTO_WRITE ), neighbour @@ -391,11 +391,11 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::AUTO_WRITE ), *this, - 0 + polyPatchList() ), bounds_(points_, syncPar), geometricD_(Vector<label>::zero), @@ -410,11 +410,11 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::NO_WRITE ), *this, - 0 + PtrList<pointZone>() ), faceZones_ ( @@ -424,11 +424,11 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::NO_WRITE ), *this, - 0 + PtrList<faceZone>() ), cellZones_ ( @@ -438,11 +438,11 @@ Foam::polyMesh::polyMesh instance(), meshSubDir, *this, - IOobject::NO_READ, + io.readOpt(), IOobject::NO_WRITE ), *this, - 0 + PtrList<cellZone>() ), globalMeshDataPtr_(NULL), moving_(false), @@ -893,7 +893,7 @@ Foam::polyMesh::cellTree() const Random rndGen(261782); - overallBb = overallBb.extend(rndGen, 1E-4); + overallBb = overallBb.extend(rndGen, 1e-4); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C index ca7155704d10ba81522681a8d644ee249f7de1a1..523cb99b0ba71ae270a59e3e53aafb1416f5d2b3 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/basic/coupled/coupledPolyPatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,7 @@ namespace Foam { defineTypeNameAndDebug(coupledPolyPatch, 0); - const scalar coupledPolyPatch::defaultMatchTol_ = 1E-4; + const scalar coupledPolyPatch::defaultMatchTol_ = 1e-4; template<> const char* NamedEnum<coupledPolyPatch::transformType, 4>::names[] = diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C index 2497592ee88ecf3f587330312f30f56ae41b1a04..33e17117c460f755e423d61dd0ffc31e3acfc113 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C @@ -162,6 +162,32 @@ Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh {} +template<class ZoneType, class MeshType> +Foam::ZoneMesh<ZoneType, MeshType>::ZoneMesh +( + const IOobject& io , + const MeshType& mesh, + const PtrList<ZoneType>& pzm +) +: + PtrList<ZoneType>(), + regIOobject(io), + mesh_(mesh), + zoneMapPtr_(NULL) +{ + ZoneMesh<ZoneType, MeshType>(io, mesh); + + if (this->size() == 0) + { + PtrList<ZoneType>& zones = *this; + zones.setSize(pzm.size()); + forAll (zones, zoneI) + { + zones.set(zoneI, pzm[zoneI].clone(*this).ptr()); + } + } +} + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class ZoneType, class MeshType> diff --git a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H index 08ef19b4fcc8bd3bfd3b92d6af0aa7bf04648170..96868c359aae803f0bee18df5d4bf5a8d76af5c6 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.H @@ -106,6 +106,15 @@ public: const label size ); + //- Construct given a PtrList + ZoneMesh + ( + const IOobject&, + const MeshType&, + const PtrList<ZoneType>& + ); + + //- Destructor ~ZoneMesh(); diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetPoints.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetPoints.H index 2e1ecf288dcc38a5c52986e3edbbc057f1fef8be..cb42d33d4b149ac912233fbf2f5cec479f8b9d25 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetPoints.H +++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetPoints.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2012-2012 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H index 14e6eb1fb58b22e1755fc9f4ff1003d77a9397fa..bcc3aee956b34f1e3dba5dbe9632f31f11714e74 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSV.H @@ -32,12 +32,13 @@ Description <entryName> csvFile; csvFileCoeffs { - hasHeaderLine true; - refColumn 0; // reference column index - componentColumns (1 2 3); // component column indices - separator ","; // optional (defaults to ",") - fileName "fileXYZ"; // name of csv data file - outOfBounds clamp; // optional out-of-bounds handling + hasHeaderLine true; + refColumn 0; // reference column index + componentColumns (1 2 3); // component column indices + separator ","; // optional (defaults to ",") + fileName "fileXYZ"; // name of csv data file + outOfBounds clamp; // optional out-of-bounds handling + interpolationScheme linear; // optional interpolation scheme } \endverbatim diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C index c977618e2a79ab5c9223e6e17bcd0903eab0c36a..e59c5ec898d3427c074141e7404c7d71dcb9937d 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.C @@ -26,6 +26,29 @@ License #include "TableBase.H" #include "Time.H" +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +template<class Type> +const Foam::interpolationWeights& Foam::TableBase<Type>::interpolator() const +{ + if (interpolatorPtr_.empty()) + { + // Re-work table into linear list + tableSamples_.setSize(table_.size()); + forAll(table_, i) + { + tableSamples_[i] = table_[i].first(); + } + interpolatorPtr_ = interpolationWeights::New + ( + interpolationScheme_, + tableSamples_ + ); + } + return interpolatorPtr_(); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class Type> @@ -39,6 +62,10 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict) dict.lookupOrDefault<word>("outOfBounds", "clamp") ) ), + interpolationScheme_ + ( + dict.lookupOrDefault<word>("interpolationScheme", "linear") + ), table_(), dimensions_(dimless) {} @@ -49,8 +76,11 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl) : name_(tbl.name_), boundsHandling_(tbl.boundsHandling_), + interpolationScheme_(tbl.interpolationScheme_), table_(tbl.table_), - dimensions_(tbl.dimensions_) + dimensions_(tbl.dimensions_), + tableSamples_(tbl.tableSamples_), + interpolatorPtr_(tbl.interpolatorPtr_) {} @@ -307,6 +337,9 @@ void Foam::TableBase<Type>::convertTimeBase(const Time& t) scalar value = table_[i].first(); table_[i].first() = t.userTimeToTime(value); } + + tableSamples_.clear(); + interpolatorPtr_.clear(); } @@ -325,88 +358,104 @@ Type Foam::TableBase<Type>::value(const scalar x) const return table_.last().second(); } - // Find i such that x(i) < xDash < x(i+1) - label i = 0; - while ((table_[i+1].first() < xDash) && (i+1 < table_.size())) + // Use interpolator + interpolator().valueWeights(x, currentIndices_, currentWeights_); + + Type t = currentWeights_[0]*table_[currentIndices_[0]].second(); + for (label i = 1; i < currentIndices_.size(); i++) { - i++; + t += currentWeights_[i]*table_[currentIndices_[i]].second(); } - -Info << - (xDash - table_[i].first())/(table_[i+1].first() - table_[i].first()) - * (table_[i+1].second() - table_[i].second()) - + table_[i].second() << endl; - - // Linear interpolation to find value - return Type - ( - (xDash - table_[i].first())/(table_[i+1].first() - table_[i].first()) - * (table_[i+1].second() - table_[i].second()) - + table_[i].second() - ); + return t; + + //// Find i such that x(i) < xDash < x(i+1) + //label i = 0; + //while ((table_[i+1].first() < xDash) && (i+1 < table_.size())) + //{ + // i++; + //} + // + //// Linear interpolation to find value + //return Type + //( + // (xDash - table_[i].first())/(table_[i+1].first() - table_[i].first()) + // * (table_[i+1].second() - table_[i].second()) + // + table_[i].second() + //); } template<class Type> Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const { - // Initialise return value - Type sum = pTraits<Type>::zero; - - // Return zero if out of bounds - if ((x1 > table_.last().first()) || (x2 < table_[0].first())) - { - return sum; - } - - // Find next index greater than x1 - label id1 = 0; - while ((table_[id1].first() < x1) && (id1 < table_.size())) - { - id1++; - } + // Use interpolator + interpolator().integrationWeights(x1, x2, currentIndices_, currentWeights_); - // Find next index less than x2 - label id2 = table_.size() - 1; - while ((table_[id2].first() > x2) && (id2 >= 1)) + Type sum = currentWeights_[0]*table_[currentIndices_[0]].second(); + for (label i = 1; i < currentIndices_.size(); i++) { - id2--; + sum += currentWeights_[i]*table_[currentIndices_[i]].second(); } + return sum; - if ((id1 - id2) == 1) - { - // x1 and x2 lie within 1 interval - sum = 0.5*(value(x1) + value(x2))*(x2 - x1); - } - else - { - // x1 and x2 cross multiple intervals - - // Integrate table body - for (label i=id1; i<id2; i++) - { - sum += - (table_[i].second() + table_[i+1].second()) - * (table_[i+1].first() - table_[i].first()); - } - sum *= 0.5; - - // Add table ends (partial segments) - if (id1 > 0) - { - sum += 0.5 - * (value(x1) + table_[id1].second()) - * (table_[id1].first() - x1); - } - if (id2 < table_.size() - 1) - { - sum += 0.5 - * (table_[id2].second() + value(x2)) - * (x2 - table_[id2].first()); - } - } - return sum; + //// Initialise return value + //Type sum = pTraits<Type>::zero; + // + //// Return zero if out of bounds + //if ((x1 > table_.last().first()) || (x2 < table_[0].first())) + //{ + // return sum; + //} + // + //// Find next index greater than x1 + //label id1 = 0; + //while ((table_[id1].first() < x1) && (id1 < table_.size())) + //{ + // id1++; + //} + // + //// Find next index less than x2 + //label id2 = table_.size() - 1; + //while ((table_[id2].first() > x2) && (id2 >= 1)) + //{ + // id2--; + //} + // + //if ((id1 - id2) == 1) + //{ + // // x1 and x2 lie within 1 interval + // sum = 0.5*(value(x1) + value(x2))*(x2 - x1); + //} + //else + //{ + // // x1 and x2 cross multiple intervals + // + // // Integrate table body + // for (label i=id1; i<id2; i++) + // { + // sum += + // (table_[i].second() + table_[i+1].second()) + // * (table_[i+1].first() - table_[i].first()); + // } + // sum *= 0.5; + // + // // Add table ends (partial segments) + // if (id1 > 0) + // { + // sum += 0.5 + // * (value(x1) + table_[id1].second()) + // * (table_[id1].first() - x1); + // } + // if (id2 < table_.size() - 1) + // { + // sum += 0.5 + // * (table_[id2].second() + value(x2)) + // * (x2 - table_[id2].first()); + // } + //} + // + //return sum; } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H index 15164b3d903819ebd1a79f25980548238e02e039..ce4c3d2287960883c8f2cc63457d871467dacd0b 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBase.H @@ -38,6 +38,7 @@ SourceFiles #include "DataEntry.H" #include "Tuple2.H" #include "dimensionSet.H" +#include "interpolationWeights.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -80,10 +81,13 @@ protected: // Protected data //- Table name - word name_; + const word name_; //- Enumeration for handling out-of-bound values - boundsHandling boundsHandling_; + const boundsHandling boundsHandling_; + + //- Interpolation type + const word interpolationScheme_; //- Table data List<Tuple2<scalar, Type> > table_; @@ -91,9 +95,24 @@ protected: //- The dimension set dimensionSet dimensions_; + //- Extracted values + mutable scalarField tableSamples_; + + //- Interpolator method + mutable autoPtr<interpolationWeights> interpolatorPtr_; + + //- Cached indices and weights + mutable labelList currentIndices_; + + mutable scalarField currentWeights_; + // Protected Member Functions + + //- Return (demand driven) interpolator + const interpolationWeights& interpolator() const; + //- Disallow default bitwise assignment void operator=(const TableBase<Type>&); diff --git a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C index 667ac72be23b8cab68a69f3df477e78e3d525ece..10d79420f794565f88c1fe22b1c059e12f518176 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/Table/TableBaseIO.C @@ -73,6 +73,11 @@ void Foam::TableBase<Type>::writeEntries(Ostream& os) const os.writeKeyword("outOfBounds") << boundsHandlingToWord(boundsHandling_) << token::END_STATEMENT << nl; } + if (interpolationScheme_ != "linear") + { + os.writeKeyword("interpolationScheme") << interpolationScheme_ + << token::END_STATEMENT << nl; + } } diff --git a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C index 5323ac6a859f4590094fe249825b6ec3e63df771..15fe8b57a265ef270198339197f9656200261ee6 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.C @@ -45,6 +45,15 @@ Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict) fileName expandedFile(fName_); IFstream is(expandedFile.expand()); + if (!is.good()) + { + FatalIOErrorIn + ( + "TableFile<Type>::TableFile(const word&, const dictionary&)", + is + ) << "Cannot open file." << exit(FatalIOError); + } + is >> this->table_; TableBase<Type>::check(); diff --git a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H index f167c211561dc64c0a627a3fee9db7701be1869e..7948ac6ee666be3cb506a1adb2944a2a2c8d28d2 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H +++ b/src/OpenFOAM/primitives/functions/DataEntry/TableFile/TableFile.H @@ -31,9 +31,10 @@ Description <entryName> tableFile; tableFileCoeffs { - dimensions [0 0 1 0 0]; // optional dimensions - fileName dataFile; // name of data file - outOfBounds clamp; // optional out-of-bounds handling + dimensions [0 0 1 0 0]; // optional dimensions + fileName dataFile; // name of data file + outOfBounds clamp; // optional out-of-bounds handling + interpolationScheme linear; // optional interpolation method } \endverbatim diff --git a/src/OpenFOAM/primitives/ops/ops.H b/src/OpenFOAM/primitives/ops/ops.H index c68face927b32e2e25a0f6bd25bc8145007e308e..66d793084962f6706f6bf5eb20abc7c3a64f215a 100644 --- a/src/OpenFOAM/primitives/ops/ops.H +++ b/src/OpenFOAM/primitives/ops/ops.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -142,6 +142,10 @@ Op(minMod, minMod(x, y)) Op(and, x && y) Op(or, x || y) Op(eqEq, x == y) +Op(less, x < y) +Op(lessEq, x <= y) +Op(greater, x > y) +Op(greaterEq, x >= y) #undef Op diff --git a/src/combustionModels/FSD/FSD.H b/src/combustionModels/FSD/FSD.H index 0a132d04fe2139bd9a558114d9cba94ef155a231..e5c396329a964b49e1144138d8ae939c38453f5a 100644 --- a/src/combustionModels/FSD/FSD.H +++ b/src/combustionModels/FSD/FSD.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,7 +48,7 @@ Description release. If the turbulent fluctuation of the mixture fraction at the sub-grid level - is large (>1E-04) then a beta pdf is used for filtering. + is large (>1e-04) then a beta pdf is used for filtering. At the moment the flame area combustion model is only fit to work in a LES frame work. In RAS the subgrid fluctiuation has to be solved by an extra diff --git a/src/dynamicMesh/Make/files b/src/dynamicMesh/Make/files index 02e9ad7ce4c6ea9c7eb9f7298a791cd592221d35..d7310029a7e568fb83edda0d8719c0821948f257 100644 --- a/src/dynamicMesh/Make/files +++ b/src/dynamicMesh/Make/files @@ -37,6 +37,7 @@ polyTopoChange/polyTopoChange/removePoints.C polyTopoChange/polyTopoChange/combineFaces.C polyTopoChange/polyTopoChange/localPointRegion.C polyTopoChange/polyTopoChange/duplicatePoints.C +polyTopoChange/polyTopoChange/tetDecomposer.C slidingInterface/slidingInterface.C slidingInterface/slidingInterfaceProjectPoints.C @@ -86,4 +87,9 @@ motionSmoother/polyMeshGeometry/polyMeshGeometry.C motionSolver/motionSolver.C +createShellMesh/createShellMesh.C + +extrudePatchMesh/extrudePatchMesh.C + + LIB = $(FOAM_LIBBIN)/libdynamicMesh diff --git a/src/dynamicMesh/Make/options b/src/dynamicMesh/Make/options index f168589eadd90b24f582a8154b7f741a30d8303b..0757c296783738fafdd35fc63fafb035a5fc1500 100644 --- a/src/dynamicMesh/Make/options +++ b/src/dynamicMesh/Make/options @@ -1,8 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/triSurface/lnInclude + -I$(LIB_SRC)/triSurface/lnInclude \ + -I$(LIB_SRC)/mesh/extrudeModel/lnInclude LIB_LIBS = \ -lfiniteVolume \ - -ltriSurface + -ltriSurface \ + -lextrudeModel diff --git a/src/dynamicMesh/boundaryMesh/boundaryMesh.C b/src/dynamicMesh/boundaryMesh/boundaryMesh.C index 96906926cb497cc234b20d9678c21d0ff750180a..51be127dd7108068e68c055ea2ed60d6bff1c2bd 100644 --- a/src/dynamicMesh/boundaryMesh/boundaryMesh.C +++ b/src/dynamicMesh/boundaryMesh/boundaryMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,7 +43,7 @@ defineTypeNameAndDebug(Foam::boundaryMesh, 0); const Foam::vector Foam::boundaryMesh::splitNormal_(3, 2, 1); // Distance to face tolerance for getNearest -const Foam::scalar Foam::boundaryMesh::distanceTol_ = 1E-2; +const Foam::scalar Foam::boundaryMesh::distanceTol_ = 1e-2; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -871,11 +871,11 @@ Foam::labelList Foam::boundaryMesh::getNearest { scalar sign = mesh().faceNormals()[bFaceI] & splitNormal_; - if (sign > -1E-5) + if (sign > -1e-5) { rightFaces.append(bFaceI); } - if (sign < 1E-5) + if (sign < 1e-5) { leftFaces.append(bFaceI); } @@ -909,7 +909,7 @@ Foam::labelList Foam::boundaryMesh::getNearest // Extend domain slightly (also makes it 3D if was 2D) // Note asymmetry to avoid having faces align with octree cubes. - scalar tol = 1E-6 * overallBb.avgDim(); + scalar tol = 1e-6 * overallBb.avgDim(); point& bbMin = overallBb.min(); bbMin.x() -= tol; diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/Make/files b/src/dynamicMesh/createShellMesh/Make/files similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/Make/files rename to src/dynamicMesh/createShellMesh/Make/files diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/Make/options b/src/dynamicMesh/createShellMesh/Make/options similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/Make/options rename to src/dynamicMesh/createShellMesh/Make/options diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.C b/src/dynamicMesh/createShellMesh/createShellMesh.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.C rename to src/dynamicMesh/createShellMesh/createShellMesh.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.H b/src/dynamicMesh/createShellMesh/createShellMesh.H similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeToRegionMesh/createShellMesh/createShellMesh.H rename to src/dynamicMesh/createShellMesh/createShellMesh.H diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..4730621e081e93662c14aa3787687c0409da2055 --- /dev/null +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C @@ -0,0 +1,283 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "extrudePatchMesh.H" + +#include "createShellMesh.H" +#include "polyTopoChange.H" +#include "wallPolyPatch.H" +#include "emptyPolyPatch.H" +#include "wedgePolyPatch.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(extrudePatchMesh, 0); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +extrudePatchMesh::extrudePatchMesh +( + const fvMesh& mesh, + const fvPatch& patch, + const dictionary& dict +) +: + fvMesh + ( + IOobject + ( + dict.lookup("region"), + mesh.facesInstance(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + true + ), + xferCopy(pointField()), + xferCopy(faceList()), + xferCopy(labelList()), + xferCopy(labelList()), + false + ), + extrudedPatch_(patch.patch()) +{ + if (this->boundaryMesh().size() == 0) + { + bool columnCells = readBool(dict.lookup("columnCells")); + + PackedBoolList nonManifoldEdge(extrudedPatch_.nEdges()); + for (label edgeI = 0; edgeI < extrudedPatch_.nInternalEdges(); edgeI++) + { + if (columnCells) + { + nonManifoldEdge[edgeI] = true; + } + } + + autoPtr<extrudeModel> model_(extrudeModel::New(dict)); + + faceList pointGlobalRegions; + faceList pointLocalRegions; + labelList localToGlobalRegion; + + const primitiveFacePatch pp + ( + extrudedPatch_, extrudedPatch_.points() + ); + + createShellMesh::calcPointRegions + ( + this->globalData(), + pp, + nonManifoldEdge, + false, + + pointGlobalRegions, + pointLocalRegions, + localToGlobalRegion + ); + + + // Per local region an originating point + labelList localRegionPoints(localToGlobalRegion.size()); + forAll(pointLocalRegions, faceI) + { + const face& f = extrudedPatch_.localFaces()[faceI]; + const face& pRegions = pointLocalRegions[faceI]; + forAll(pRegions, fp) + { + localRegionPoints[pRegions[fp]] = f[fp]; + } + } + + // Calculate region normals by reducing local region normals + pointField localRegionNormals(localToGlobalRegion.size()); + { + pointField localSum(localToGlobalRegion.size(), vector::zero); + + forAll(pointLocalRegions, faceI) + { + const face& pRegions = pointLocalRegions[faceI]; + forAll(pRegions, fp) + { + label localRegionI = pRegions[fp]; + localSum[localRegionI] += + extrudedPatch_.faceNormals()[faceI]; + } + } + + Map<point> globalSum(2*localToGlobalRegion.size()); + + forAll(localSum, localRegionI) + { + label globalRegionI = localToGlobalRegion[localRegionI]; + globalSum.insert(globalRegionI, localSum[localRegionI]); + } + + // Reduce + Pstream::mapCombineGather(globalSum, plusEqOp<point>()); + Pstream::mapCombineScatter(globalSum); + + forAll(localToGlobalRegion, localRegionI) + { + label globalRegionI = localToGlobalRegion[localRegionI]; + localRegionNormals[localRegionI] = globalSum[globalRegionI]; + } + localRegionNormals /= mag(localRegionNormals); + } + + + // Per local region an extrusion direction + vectorField firstDisp(localToGlobalRegion.size()); + forAll(firstDisp, regionI) + { + //const point& regionPt = regionCentres[regionI]; + const point& regionPt = extrudedPatch_.points() + [ + extrudedPatch_.meshPoints() + [ + localRegionPoints[regionI] + ] + ]; + const vector& n = localRegionNormals[regionI]; + firstDisp[regionI] = model_()(regionPt, n, 1) - regionPt; + } + + + // Extrude engine + createShellMesh extruder + ( + pp, + pointLocalRegions, + localRegionPoints + ); + + List<polyPatch*> regionPatches(3); + List<word> patchNames(regionPatches.size()); + List<word> patchTypes(regionPatches.size()); + PtrList<dictionary> dicts(regionPatches.size()); + + forAll (dicts, patchI) + { + if (!dicts.set(patchI)) + { + dicts.set(patchI, new dictionary()); + } + } + + dicts[bottomPatchID] = dict.subDict("bottomCoeffs"); + dicts[sidePatchID] = dict.subDict("sideCoeffs"); + dicts[topPatchID] = dict.subDict("topCoeffs"); + + forAll (dicts, patchI) + { + dicts[patchI].lookup("name") >> patchNames[patchI]; + dicts[patchI].lookup("type") >> patchTypes[patchI]; + } + + forAll (regionPatches, patchI) + { + dictionary& patchDict = dicts[patchI]; + patchDict.set("nFaces", 0); + patchDict.set("startFace", 0); + + regionPatches[patchI] = polyPatch::New + ( + patchNames[patchI], + patchDict, + patchI, + mesh.boundaryMesh() + ).ptr(); + + } + + this->clearOut(); + this->removeFvBoundary(); + this->addFvPatches(regionPatches, true); + + + // At this point we have a valid mesh with 3 patches and zero cells. + // Determine: + // - per face the top and bottom patch (topPatchID, bottomPatchID) + // - per edge, per face on edge the side patch (edgePatches) + labelListList edgePatches(extrudedPatch_.nEdges()); + forAll(edgePatches, edgeI) + { + const labelList& eFaces = extrudedPatch_.edgeFaces()[edgeI]; + + if (eFaces.size() != 2 || nonManifoldEdge[edgeI]) + { + edgePatches[edgeI].setSize(eFaces.size(), sidePatchID); + } + } + + polyTopoChange meshMod(regionPatches.size()); + + extruder.setRefinement + ( + firstDisp, // first displacement + model_().expansionRatio(), + model_().nLayers(), // nLayers + labelList(extrudedPatch_.size(), topPatchID), + labelList(extrudedPatch_.size(), bottomPatchID), + edgePatches, + meshMod + ); + + autoPtr<mapPolyMesh> map = meshMod.changeMesh + ( + *this, // mesh to change + false // inflate + ); + + // Update numbering on extruder. + extruder.updateMesh(map); + + this->setInstance(this->thisDb().time().constant()); + this->write(); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +extrudePatchMesh::~extrudePatchMesh() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H new file mode 100644 index 0000000000000000000000000000000000000000..b960988e20e2f9b5f4f9ec4422f4b157ed81bc2e --- /dev/null +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2012 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 <http://www.gnu.org/licenses/>. + +Class + extrudePatchMesh + +Description + Mesh at a patch created on the fly. The following entried should be used + on the field boundary dictionary: + + // New Shell mesh data + + region "regionMesh"; + extrudeModel linearNormal; + linearNormalCoeffs + { + thickness 40e-6; + } + nLayers 50; + expansionRatio 1; + columnCells true; + + // Patch information + bottomCoeffs + { + name "bottom"; + type mappedWall; + sampleMode nearestPatchFace; + samplePatch fixedWalls; + offsetMode uniform; + offset (0 0 0); + } + + topCoeffs + { + name "top"; + type patch; + } + + sideCoeffs + { + name "side"; + type empty; + } + +\*---------------------------------------------------------------------------*/ + +#ifndef extrudePatchMesh_H +#define extrudePatchMesh_H + +#include "extrudeModel.H" +#include "autoPtr.H" + +#include "fvMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + +/*---------------------------------------------------------------------------*\ + Class extrudePatchMesh Declaration +\*---------------------------------------------------------------------------*/ + +class extrudePatchMesh +: + public fvMesh +{ + +private: + + // Private data + + //- Enumeration of patch IDs + enum patchID + { + bottomPatchID, + topPatchID, + sidePatchID + }; + + //- Const reference to the patch from which this mesh is extruded + const polyPatch& extrudedPatch_; + + +public: + + //- Runtime type information + TypeName("extrudePatchMesh"); + + + // Constructors + + //- Construct from mesh, patch and dictionary + extrudePatchMesh + ( + const fvMesh&, + const fvPatch&, + const dictionary& + ); + + + //- Destructor + virtual ~extrudePatchMesh(); + + + // Member functions + + + // Access functions + + //- Return region mesh + const fvMesh& regionMesh() const + { + return *this; + } + + //- Return bottom patch + const polyPatch& bottomPatch() const + { + return this->boundaryMesh()[bottomPatchID]; + } + + //- Return top patch + const polyPatch& topPatch() const + { + return this->boundaryMesh()[topPatchID]; + } + + //- Return sides patch + const polyPatch& sidesPatch() const + { + return this->boundaryMesh()[sidePatchID]; + } + + //- Return extruded patch + const polyPatch& extrudedPatch() const + { + return extrudedPatch_; + } + +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // + diff --git a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C index 394ca197ed4d17a7fc0d1e88f3342b6b0d075822..2b1310ab9136de27c39cbaef404b47b2443b2227 100644 --- a/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C +++ b/src/dynamicMesh/meshCut/cellLooper/geomCellLooper.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,7 +39,7 @@ License // Extension factor of edges to make sure we catch intersections through // edge endpoints -const Foam::scalar Foam::geomCellLooper::pointEqualTol_ = 1E-3; +const Foam::scalar Foam::geomCellLooper::pointEqualTol_ = 1e-3; // Snap cuts through edges onto edge endpoints. Fraction of edge length. diff --git a/src/dynamicMesh/meshCut/directions/directions.C b/src/dynamicMesh/meshCut/directions/directions.C index e35a8c0efd4a21828be54f66b2b2191541501c92..35170e9007fe94543c89c7fbbac55540101d2ae5 100644 --- a/src/dynamicMesh/meshCut/directions/directions.C +++ b/src/dynamicMesh/meshCut/directions/directions.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -125,7 +125,7 @@ void Foam::directions::check2D { if (correct2DPtr) { - if (mag(correct2DPtr->planeNormal() & vec) > 1E-6) + if (mag(correct2DPtr->planeNormal() & vec) > 1e-6) { FatalErrorIn("check2D") << "Specified vector " << vec << "is not normal to plane defined in dynamicMeshDict." diff --git a/src/dynamicMesh/motionSmoother/motionSmoother.C b/src/dynamicMesh/motionSmoother/motionSmoother.C index 6542432aea4e224f371ef0db1d78fb145a98435d..fa9c2f1baa20a3501d8433efc87e90709afcc39c 100644 --- a/src/dynamicMesh/motionSmoother/motionSmoother.C +++ b/src/dynamicMesh/motionSmoother/motionSmoother.C @@ -283,7 +283,7 @@ Foam::tmp<Foam::scalarField> Foam::motionSmoother::calcEdgeWeights forAll(edges, edgeI) { - wght[edgeI] = min(GREAT, 1.0/edges[edgeI].mag(points)); + wght[edgeI] = 1.0/(edges[edgeI].mag(points)+SMALL); } return twght; } @@ -900,7 +900,7 @@ Foam::tmp<Foam::scalarField> Foam::motionSmoother::movePoints { Pout<< "motionSmoother::movePoints : testing sync of newPoints." << endl; - testSyncPositions(newPoints, 1E-6*mesh_.bounds().mag()); + testSyncPositions(newPoints, 1e-6*mesh_.bounds().mag()); } // Move actual mesh points. Make sure to delete tetBasePtIs so it @@ -1051,7 +1051,7 @@ bool Foam::motionSmoother::scaleMesh totalDisplacement, maxMagEqOp(), vector::zero, // null value - 1E-6*mesh_.bounds().mag() + 1e-6*mesh_.bounds().mag() ); } diff --git a/src/dynamicMesh/perfectInterface/perfectInterface.C b/src/dynamicMesh/perfectInterface/perfectInterface.C index bbc9b6199ada25980df518ee016db25b8e6f8d28..36df8808912381503dbe2804671d09a0f2a4b5bd 100644 --- a/src/dynamicMesh/perfectInterface/perfectInterface.C +++ b/src/dynamicMesh/perfectInterface/perfectInterface.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,7 +54,7 @@ namespace Foam // Tolerance used as fraction of minimum edge length. -const Foam::scalar Foam::perfectInterface::tol_ = 1E-3; +const Foam::scalar Foam::perfectInterface::tol_ = 1e-3; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index 01d0103a64650e74bf9634485cecdf2cf4b0e9bc..8de21e2f0857e45672a341838908334e47b9e3bf 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,7 +36,7 @@ License defineTypeNameAndDebug(Foam::faceCoupleInfo, 0); -const Foam::scalar Foam::faceCoupleInfo::angleTol_ = 1E-3; +const Foam::scalar Foam::faceCoupleInfo::angleTol_ = 1e-3; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -1014,7 +1014,7 @@ void Foam::faceCoupleInfo::findSlavesCoveringMaster mesh0, bndFaces // boundary faces only ), - overallBb.extend(rndGen, 1E-4), // overall search domain + overallBb.extend(rndGen, 1e-4), // overall search domain 8, // maxLevel 10, // leafsize 3.0 // duplicity diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C index b1e928e96b594dab033e5cf4df0bdb547b0c9926..8f579fc4f75594966599a460833abf7ae0b329d1 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/faceCollapser.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -277,7 +277,7 @@ void Foam::faceCollapser::setRefinement if (w <= dist[fpMin1]) { // Offset. - w = dist[fpMin1] + 1E-6*(dist[fpB] - dist[fpA]); + w = dist[fpMin1] + 1e-6*(dist[fpB] - dist[fpA]); point newPoint ( @@ -330,7 +330,7 @@ void Foam::faceCollapser::setRefinement if (w <= dist[fpMin1]) { // Offset. - w = dist[fpMin1] + 1E-6*(dist[fpB] - dist[fpA]); + w = dist[fpMin1] + 1e-6*(dist[fpB] - dist[fpA]); point newPoint ( diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C index b577a171779f4f1643ea5116ed9c70d7f2cdd553..827913a1c129e97a45871b7086e86e695737c633 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C @@ -4452,7 +4452,7 @@ void Foam::hexRef8::distribute(const mapDistributePolyMesh& map) void Foam::hexRef8::checkMesh() const { - const scalar smallDim = 1E-6 * mesh_.bounds().mag(); + const scalar smallDim = 1e-6 * mesh_.bounds().mag(); if (debug) { diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 9000380aa10ab4a13b8f71ec44744b49ac6f3921..b9b7bde14bc478de7c86d7d5b17cc758767ba494 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -3394,11 +3394,13 @@ Foam::autoPtr<Foam::mapPolyMesh> Foam::polyTopoChange::makeMesh // Create the mesh // ~~~~~~~~~~~~~~~ + IOobject noReadIO(io); + noReadIO.readOpt() = IOobject::NO_READ; newMeshPtr.reset ( new fvMesh ( - io, + noReadIO, xferMove(newPoints), faces_.xfer(), faceOwner_.xfer(), diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C new file mode 100644 index 0000000000000000000000000000000000000000..bdbd851527f9ef90334029cb0b4e489c0c89482e --- /dev/null +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.C @@ -0,0 +1,713 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "tetDecomposer.H" +#include "meshTools.H" +#include "polyMesh.H" +#include "polyTopoChange.H" +#include "mapPolyMesh.H" +#include "OFstream.H" +#include "EdgeMap.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::tetDecomposer, 0); + +namespace Foam +{ + template<> + const char* NamedEnum<tetDecomposer::decompositionType, 2>::names[] = + { + "faceCentre", + "faceDiagonal" + }; + + const NamedEnum<tetDecomposer::decompositionType, 2> + tetDecomposer::decompositionTypeNames; +} + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::tetDecomposer::modifyFace +( + polyTopoChange& meshMod, + const face& f, + const label faceI, + const label own, + const label nei, + const label patchI, + const label zoneI, + const bool zoneFlip +) const +{ + // First usage of face. Modify. + if (nei == -1 || own < nei) + { + meshMod.modifyFace + ( + f, // modified face + faceI, // label of face + own, // owner + nei, // neighbour + false, // face flip + patchI, // patch for face + zoneI, // zone for face + zoneFlip // face flip in zone + ); + } + else + { + meshMod.modifyFace + ( + f.reverseFace(), // modified face + faceI, // label of face + nei, // owner + own, // neighbour + true, // face flip + patchI, // patch for face + zoneI, // zone for face + !zoneFlip // face flip in zone + ); + } +} + + +void Foam::tetDecomposer::addFace +( + polyTopoChange& meshMod, + const face& f, + const label own, + const label nei, + const label masterPointID, + const label masterEdgeID, + const label masterFaceID, + const label patchI, + const label zoneI, + const bool zoneFlip +) const +{ + // Second or more usage of face. Add. + if (nei == -1 || own < nei) + { + meshMod.addFace + ( + f, // modified face + own, // owner + nei, // neighbour + masterPointID, // master point + masterEdgeID, // master edge + masterFaceID, // master face + false, // face flip + patchI, // patch for face + zoneI, // zone for face + zoneFlip // face flip in zone + ); + } + else + { + meshMod.addFace + ( + f.reverseFace(), // modified face + nei, // owner + own, // neighbour + masterPointID, // master point + masterEdgeID, // master edge + masterFaceID, // master face + true, // face flip + patchI, // patch for face + zoneI, // zone for face + !zoneFlip // face flip in zone + ); + } +} + + +// Work out triangle index given the starting vertex in the face +Foam::label Foam::tetDecomposer::triIndex(const label faceI, const label fp) +const +{ + const face& f = mesh_.faces()[faceI]; + const label fp0 = mesh_.tetBasePtIs()[faceI]; + + // Work out triangle index on this face + label thisTriI; + if (fp == fp0) + { + thisTriI = 0; + } + else if (fp == f.rcIndex(fp0)) + { + thisTriI = f.size()-3; + } + else + { + thisTriI = (fp-fp0-1) % (f.size()-2); + } + return thisTriI; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::tetDecomposer::tetDecomposer(const polyMesh& mesh) +: + mesh_(mesh) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::tetDecomposer::setRefinement +( + const decompositionType decomposeType, + polyTopoChange& meshMod +) +{ + cellToPoint_.setSize(mesh_.nCells()); + forAll(mesh_.cellCentres(), cellI) + { + // Any point on the cell + label masterPointI = mesh_.faces()[mesh_.cells()[cellI][0]][0]; + + cellToPoint_[cellI] = meshMod.addPoint + ( + mesh_.cellCentres()[cellI], + masterPointI, + -1, + true + ); + } + + + // Add face centre points + if (decomposeType == FACECENTRETETS) + { + faceToPoint_.setSize(mesh_.nFaces()); + forAll(mesh_.faceCentres(), faceI) + { + // Any point on the face + const label masterPointI = mesh_.faces()[faceI][0]; + + faceToPoint_[faceI] = meshMod.addPoint + ( + mesh_.faceCentres()[faceI], + masterPointI, + -1, + true + ); + } + } + + + // Per face, per point (faceCentre) or triangle (faceDiag) the added cell + faceOwnerCells_.setSize(mesh_.nFaces()); + faceNeighbourCells_.setSize(mesh_.nFaces()); + + if (decomposeType == FACECENTRETETS) + { + forAll(faceOwnerCells_, faceI) + { + const face& f = mesh_.faces()[faceI]; + faceOwnerCells_[faceI].setSize(f.size(), -1); + faceNeighbourCells_[faceI].setSize(f.size(), -1); + } + } + else + { + // Force construction of diagonal decomposition + (void)mesh_.tetBasePtIs(); + + forAll(faceOwnerCells_, faceI) + { + const face& f = mesh_.faces()[faceI]; + faceOwnerCells_[faceI].setSize(f.size()-2, -1); + faceNeighbourCells_[faceI].setSize(f.size()-2, -1); + } + } + + + forAll(mesh_.cells(), cellI) + { + const cell& cFaces = mesh_.cells()[cellI]; + + EdgeMap<label> edgeToFace(8*cFaces.size()); + + forAll(cFaces, cFaceI) + { + label faceI = cFaces[cFaceI]; + const face& f = mesh_.faces()[faceI]; + + // Get reference to either owner or neighbour + labelList& added = + ( + (mesh_.faceOwner()[faceI] == cellI) + ? faceOwnerCells_[faceI] + : faceNeighbourCells_[faceI] + ); + + if (decomposeType == FACECENTRETETS) + { + forAll(f, fp) + { + if (cFaceI == 0 && fp == 0) + { + // Reuse cell itself + added[fp] = cellI; + } + else + { + added[fp] = meshMod.addCell + ( + -1, // masterPoint + -1, // masterEdge + -1, // masterFace + cellI, // masterCell + mesh_.cellZones().whichZone(cellI) + ); + } + } + } + else + { + for (label triI = 0; triI < f.size()-2; triI++) + { + if (cFaceI == 0 && triI == 0) + { + // Reuse cell itself + added[triI] = cellI; + } + else + { + added[triI] = meshMod.addCell + ( + -1, // masterPoint + -1, // masterEdge + -1, // masterFace + cellI, // masterCell + mesh_.cellZones().whichZone(cellI) + ); + } + } + } + } + } + + + + // Add triangle faces + face triangle(3); + + forAll(mesh_.faces(), faceI) + { + label own = mesh_.faceOwner()[faceI]; + const labelList& addedOwn = faceOwnerCells_[faceI]; + const labelList& addedNei = faceNeighbourCells_[faceI]; + const face& f = mesh_.faces()[faceI]; + + label patchI = -1; + if (faceI >= mesh_.nInternalFaces()) + { + patchI = mesh_.boundaryMesh().whichPatch(faceI); + } + + label zoneI = mesh_.faceZones().whichZone(faceI); + bool zoneFlip = false; + if (zoneI != -1) + { + const faceZone& fz = mesh_.faceZones()[zoneI]; + zoneFlip = fz.flipMap()[fz.whichFace(faceI)]; + } + + + if (decomposeType == FACECENTRETETS) + { + forAll(f, fp) + { + // 1. Front triangle (decomposition of face itself) + // (between owner and neighbour cell) + { + triangle[0] = f[fp]; + triangle[1] = f[f.fcIndex(fp)]; + triangle[2] = faceToPoint_[faceI]; + + if (fp == 0) + { + modifyFace + ( + meshMod, + triangle, + faceI, + addedOwn[fp], + addedNei[fp], + patchI, + zoneI, + zoneFlip + ); + } + else + { + addFace + ( + meshMod, + triangle, + addedOwn[fp], + addedNei[fp], + -1, //point + -1, //edge + faceI, //face + patchI, + zoneI, + zoneFlip + ); + } + } + + + // 2. Within owner cell - to cell centre + { + label newOwn = addedOwn[f.rcIndex(fp)]; + label newNei = addedOwn[fp]; + + triangle[0] = f[fp]; + triangle[1] = cellToPoint_[own]; + triangle[2] = faceToPoint_[faceI]; + + addFace + ( + meshMod, + triangle, + newOwn, + newNei, + f[fp], //point + -1, //edge + -1, //face + -1, //patchI + zoneI, + zoneFlip + ); + } + // 2b. Within neighbour cell - to cell centre + if (faceI < mesh_.nInternalFaces()) + { + label newOwn = addedNei[f.rcIndex(fp)]; + label newNei = addedNei[fp]; + + triangle[0] = f[fp]; + triangle[1] = faceToPoint_[faceI]; + triangle[2] = cellToPoint_[mesh_.faceNeighbour()[faceI]]; + + addFace + ( + meshMod, + triangle, + newOwn, + newNei, + f[fp], //point + -1, //edge + -1, //face + -1, //patchI + zoneI, + zoneFlip + ); + } + } + } + else + { + label fp0 = mesh_.tetBasePtIs()[faceI]; + label fp = f.fcIndex(fp0); + + for (label triI = 0; triI < f.size()-2; triI++) + { + label nextTri = triI+1; + if (nextTri >= f.size()-2) + { + nextTri -= f.size()-2; + } + label nextFp = f.fcIndex(fp); + + + // Triangle triI consisiting of f[fp0], f[fp], f[nextFp] + + + // 1. Front triangle (decomposition of face itself) + // (between owner and neighbour cell) + { + triangle[0] = f[fp0]; + triangle[1] = f[fp]; + triangle[2] = f[nextFp]; + + if (triI == 0) + { + modifyFace + ( + meshMod, + triangle, + faceI, + addedOwn[triI], + addedNei[triI], + patchI, + zoneI, + zoneFlip + ); + } + else + { + addFace + ( + meshMod, + triangle, + addedOwn[triI], + addedNei[triI], + -1, //point + -1, //edge + faceI, //face + patchI, + zoneI, + zoneFlip + ); + } + } + + + // 2. Within owner cell - diagonal to cell centre + if (triI < f.size()-3) + { + label newOwn = addedOwn[triI]; + label newNei = addedOwn[nextTri]; + + triangle[0] = f[fp0]; + triangle[1] = f[nextFp]; + triangle[2] = cellToPoint_[own]; + + addFace + ( + meshMod, + triangle, + newOwn, + newNei, + f[fp], //point + -1, //edge + -1, //face + -1, //patchI + zoneI, + zoneFlip + ); + + // 2b. Within neighbour cell - to cell centre + if (faceI < mesh_.nInternalFaces()) + { + label newOwn = addedNei[triI]; + label newNei = addedNei[nextTri]; + + triangle[0] = f[nextFp]; + triangle[1] = f[fp0]; + triangle[2] = + cellToPoint_[mesh_.faceNeighbour()[faceI]]; + + addFace + ( + meshMod, + triangle, + newOwn, + newNei, + f[fp], //point + -1, //edge + -1, //face + -1, //patchI + zoneI, + zoneFlip + ); + } + } + + + fp = nextFp; + } + } + } + + + + // Add triangles for all edges. + EdgeMap<label> edgeToFace; + + forAll(mesh_.cells(), cellI) + { + const cell& cFaces = mesh_.cells()[cellI]; + + edgeToFace.clear(); + + forAll(cFaces, cFaceI) + { + label faceI = cFaces[cFaceI]; + + label zoneI = mesh_.faceZones().whichZone(faceI); + bool zoneFlip = false; + if (zoneI != -1) + { + const faceZone& fz = mesh_.faceZones()[zoneI]; + zoneFlip = fz.flipMap()[fz.whichFace(faceI)]; + } + + const face& f = mesh_.faces()[faceI]; + //const labelList& fEdges = mesh_.faceEdges()[faceI]; + forAll(f, fp) + { + label p0 = f[fp]; + label p1 = f[f.fcIndex(fp)]; + const edge e(p0, p1); + + EdgeMap<label>::const_iterator edgeFnd = edgeToFace.find(e); + if (edgeFnd == edgeToFace.end()) + { + edgeToFace.insert(e, faceI); + } + else + { + // Found the other face on the edge. + label otherFaceI = edgeFnd(); + const face& otherF = mesh_.faces()[otherFaceI]; + + // Found the other face on the edge. Note that since + // we are looping in the same order the tets added for + // otherFaceI will be before those of faceI + + label otherFp = findIndex(otherF, p0); + if (otherF.nextLabel(otherFp) == p1) + { + // ok. otherFp is first vertex of edge. + } + else if (otherF.prevLabel(otherFp) == p1) + { + otherFp = otherF.rcIndex(otherFp); + } + else + { + FatalErrorIn("tetDecomposer::setRefinement(..)") + << "problem." << abort(FatalError); + } + + + // Triangle from edge to cell centre + if (mesh_.faceOwner()[faceI] == cellI) + { + triangle[0] = p0; + triangle[1] = p1; + triangle[2] = cellToPoint_[cellI]; + } + else + { + triangle[0] = p1; + triangle[1] = p0; + triangle[2] = cellToPoint_[cellI]; + } + + // Determine tets on either side + label thisTet, otherTet; + + if (decomposeType == FACECENTRETETS) + { + if (mesh_.faceOwner()[faceI] == cellI) + { + thisTet = faceOwnerCells_[faceI][fp]; + } + else + { + thisTet = faceNeighbourCells_[faceI][fp]; + } + + if (mesh_.faceOwner()[otherFaceI] == cellI) + { + otherTet = faceOwnerCells_[otherFaceI][otherFp]; + } + else + { + otherTet = + faceNeighbourCells_[otherFaceI][otherFp]; + } + } + else + { + label thisTriI = triIndex(faceI, fp); + if (mesh_.faceOwner()[faceI] == cellI) + { + thisTet = faceOwnerCells_[faceI][thisTriI]; + } + else + { + thisTet = faceNeighbourCells_[faceI][thisTriI]; + } + + label otherTriI = triIndex(otherFaceI, otherFp); + if (mesh_.faceOwner()[otherFaceI] == cellI) + { + otherTet = faceOwnerCells_[otherFaceI][otherTriI]; + } + else + { + otherTet = + faceNeighbourCells_[otherFaceI][otherTriI]; + } + } + + + addFace + ( + meshMod, + triangle, + otherTet, + thisTet, + -1, //masterPoint + -1, //fEdges[fp], //masterEdge + faceI, //masterFace + -1, //patchI + zoneI, + zoneFlip + ); + } + } + } + } +} + + +void Foam::tetDecomposer::updateMesh(const mapPolyMesh& map) +{ + inplaceRenumber(map.reversePointMap(), cellToPoint_); + inplaceRenumber(map.reversePointMap(), faceToPoint_); + + forAll(faceOwnerCells_, faceI) + { + inplaceRenumber(map.reverseCellMap(), faceOwnerCells_[faceI]); + } + forAll(faceNeighbourCells_, faceI) + { + inplaceRenumber(map.reverseCellMap(), faceNeighbourCells_[faceI]); + } +} + + +// ************************************************************************* // diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.H new file mode 100644 index 0000000000000000000000000000000000000000..8485f3cd8db94890c8d87c6891fb23149a040128 --- /dev/null +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/tetDecomposer.H @@ -0,0 +1,198 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + tetDecomposer + +Description + Decomposes polyMesh into tets. + +SourceFiles + tetDecomposer.C + +\*---------------------------------------------------------------------------*/ + +#ifndef tetDecomposer_H +#define tetDecomposer_H + +#include "DynamicList.H" +#include "PackedBoolList.H" +#include "boolList.H" +#include "typeInfo.H" +#include "NamedEnum.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class polyMesh; +class polyTopoChange; +class face; +class mapPolyMesh; + +/*---------------------------------------------------------------------------*\ + Class tetDecomposer Declaration +\*---------------------------------------------------------------------------*/ + +class tetDecomposer +{ +public: + + // Public data types + + enum decompositionType + { + FACECENTRETETS, // tet decomposition using facectr and cellctr + FACEDIAGTETS // tet decomposition using face diag and cellctr + }; + static const NamedEnum<decompositionType, 2> decompositionTypeNames; + +private: + + // Private data + + const polyMesh& mesh_; + + //- From cell to tet point + labelList cellToPoint_; + + //- From face to tet point + labelList faceToPoint_; + + + // Per face, per point (faceCentre) or triangle (faceDiag) + // the added tet on the owner side + labelListList faceOwnerCells_; + + // Per face, per point (faceCentre) or triangle (faceDiag) + // the added tet on the neighbour side + labelListList faceNeighbourCells_; + + // Private Member Functions + + //- Modify a face + void modifyFace + ( + polyTopoChange& meshMod, + const face& f, + const label faceI, + const label own, + const label nei, + const label patchI, + const label zoneI, + const bool zoneFlip + ) const; + + //- Add a face + void addFace + ( + polyTopoChange& meshMod, + const face& f, + const label own, + const label nei, + const label masterPointID, + const label masterEdgeID, + const label masterFaceID, + const label patchI, + const label zoneI, + const bool zoneFlip + ) const; + + //- Work out triangle index given the starting vertex in the face + label triIndex(const label faceI, const label fp) const; + + //- Disallow default bitwise copy construct + tetDecomposer(const tetDecomposer&); + + //- Disallow default bitwise assignment + void operator=(const tetDecomposer&); + + +public: + + //- Runtime type information + ClassName("tetDecomposer"); + + + // Constructors + + //- Construct from mesh + tetDecomposer(const polyMesh&); + + + // Member Functions + + // Access + + //- From cell to tet point + const labelList& cellToPoint() const + { + return cellToPoint_; + } + + //- From face to tet point + const labelList& faceToPoint() const + { + return faceToPoint_; + } + + + //- Per face, per point (faceCentre) or triangle (faceDiag) + // the added tet on the owner side + const labelListList& faceOwnerCells() const + { + return faceOwnerCells_; + } + + //- Per face, per point (faceCentre) or triangle (faceDiag) + // the added tet on the neighbour side + const labelListList& faceNeighbourCells() const + { + return faceNeighbourCells_; + } + + + // Edit + + //- Insert all changes into meshMod to convert the polyMesh into + // tets. + void setRefinement + ( + const decompositionType decomposeType, + polyTopoChange& meshMod + ); + + //- Force recalculation of locally stored data on topological change + void updateMesh(const mapPolyMesh&); +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C index cd0ac4fc9474e60af31e08256a39487060b22396..aa046d6ec6028aefd0b407f07824491ac823e33e 100644 --- a/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C +++ b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -923,7 +923,7 @@ Foam::extendedFeatureEdgeMesh::pointTree() const // geometry there are less face/edge aligned items. treeBoundBox bb ( - treeBoundBox(points()).extend(rndGen, 1E-4) + treeBoundBox(points()).extend(rndGen, 1e-4) ); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); @@ -963,7 +963,7 @@ Foam::extendedFeatureEdgeMesh::edgeTree() const // geometry there are less face/edge aligned items. treeBoundBox bb ( - treeBoundBox(points()).extend(rndGen, 1E-4) + treeBoundBox(points()).extend(rndGen, 1e-4) ); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); @@ -1007,7 +1007,7 @@ Foam::extendedFeatureEdgeMesh::edgeTreesByType() const // geometry there are less face/edge aligned items. treeBoundBox bb ( - treeBoundBox(points()).extend(rndGen, 1E-4) + treeBoundBox(points()).extend(rndGen, 1e-4) ); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index c7e7453b1f5ad23fb696f3bf8dc1d2deaf3ff7df..3691354d0bce17a25fe23fc7d03206b80910225a 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -107,7 +107,6 @@ $(constraintFvPatchFields)/nonuniformTransformCyclic/nonuniformTransformCyclicFv $(constraintFvPatchFields)/processor/processorFvPatchFields.C $(constraintFvPatchFields)/processor/processorFvPatchScalarField.C $(constraintFvPatchFields)/processorCyclic/processorCyclicFvPatchFields.C -$(constraintFvPatchFields)/processorCyclic/processorCyclicFvPatchScalarField.C $(constraintFvPatchFields)/symmetry/symmetryFvPatchFields.C $(constraintFvPatchFields)/wedge/wedgeFvPatchFields.C $(constraintFvPatchFields)/wedge/wedgeFvPatchScalarField.C diff --git a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C index 4cd984f0ccc59999e923e9214516db3f18cc238b..2c89cc4cae0a0eb08e80800de12ca2a12b3d1a43 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/pimpleControl/pimpleControl.C @@ -70,7 +70,7 @@ bool Foam::pimpleControl::criteriaSatisfied() const label fieldI = applyToField(variableName); if (fieldI != -1) { - const List<lduMatrix::solverPerformance> sp(iter().stream()); + const List<solverPerformance> sp(iter().stream()); const scalar residual = sp.last().initialResidual(); checked = true; diff --git a/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C b/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C index b944f38b8f4a17eff3705a96389462a8f71e0e4d..27557eac3c6b3a736f252992eb6525b86fafc26e 100644 --- a/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C +++ b/src/finiteVolume/cfdTools/general/solutionControl/simpleControl/simpleControl.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,7 +59,7 @@ bool Foam::simpleControl::criteriaSatisfied() const label fieldI = applyToField(variableName); if (fieldI != -1) { - const List<lduMatrix::solverPerformance> sp(iter().stream()); + const List<solverPerformance> sp(iter().stream()); const scalar residual = sp.first().initialResidual(); checked = true; diff --git a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.C index a5fa44e1d7c80723394cd606106aaaae87912008..895f3404799786cb817e53fac4f0632a800a08a8 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -39,7 +39,7 @@ coupledFvPatchField<Type>::coupledFvPatchField const DimensionedField<Type, volMesh>& iF ) : - lduInterfaceField(refCast<const lduInterface>(p)), + LduInterfaceField<Type>(refCast<const lduInterface>(p)), fvPatchField<Type>(p, iF) {} @@ -52,7 +52,7 @@ coupledFvPatchField<Type>::coupledFvPatchField const Field<Type>& f ) : - lduInterfaceField(refCast<const lduInterface>(p)), + LduInterfaceField<Type>(refCast<const lduInterface>(p)), fvPatchField<Type>(p, iF, f) {} @@ -66,7 +66,7 @@ coupledFvPatchField<Type>::coupledFvPatchField const fvPatchFieldMapper& mapper ) : - lduInterfaceField(refCast<const lduInterface>(p)), + LduInterfaceField<Type>(refCast<const lduInterface>(p)), fvPatchField<Type>(ptf, p, iF, mapper) {} @@ -79,7 +79,7 @@ coupledFvPatchField<Type>::coupledFvPatchField const dictionary& dict ) : - lduInterfaceField(refCast<const lduInterface>(p)), + LduInterfaceField<Type>(refCast<const lduInterface>(p)), fvPatchField<Type>(p, iF, dict) {} @@ -90,7 +90,7 @@ coupledFvPatchField<Type>::coupledFvPatchField const coupledFvPatchField<Type>& ptf ) : - lduInterfaceField(refCast<const lduInterface>(ptf.patch())), + LduInterfaceField<Type>(refCast<const lduInterface>(ptf.patch())), fvPatchField<Type>(ptf) {} @@ -102,7 +102,7 @@ coupledFvPatchField<Type>::coupledFvPatchField const DimensionedField<Type, volMesh>& iF ) : - lduInterfaceField(refCast<const lduInterface>(ptf.patch())), + LduInterfaceField<Type>(refCast<const lduInterface>(ptf.patch())), fvPatchField<Type>(ptf, iF) {} diff --git a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H index d5eb3baa2cc94fc514d49b160dc0454f50c6198a..8677c34ed3d1b3c9c869859ba9ff4e0c8172c3c0 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,7 +35,7 @@ SourceFiles #ifndef coupledFvPatchField_H #define coupledFvPatchField_H -#include "lduInterfaceField.H" +#include "LduInterfaceField.H" #include "fvPatchField.H" #include "coupledFvPatch.H" @@ -51,7 +51,7 @@ namespace Foam template<class Type> class coupledFvPatchField : - public lduInterfaceField, + public LduInterfaceField<Type>, public fvPatchField<Type> { @@ -178,14 +178,23 @@ public: //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction, const Pstream::commsTypes commsType ) const = 0; + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field<Type>&, + const Field<Type>&, + const scalarField&, + const Pstream::commsTypes commsType + ) const = 0; + + //- Write virtual void write(Ostream&) const; }; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C index 8dac56c64f4dbac5267ff0cee1338a559f0427b8..0e23db6c3cd89ecee2399de4b4b675447160338a 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -191,26 +191,47 @@ const template<class Type> void cyclicFvPatchField<Type>::updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes ) const { - scalarField pnf(this->size()); - const labelUList& nbrFaceCells = cyclicPatch().cyclicPatch().neighbPatch().faceCells(); - forAll(pnf, facei) + scalarField pnf(psiInternal, nbrFaceCells); + + // Transform according to the transformation tensors + transformCoupleField(pnf, cmpt); + + // Multiply the field by coefficients and add into the result + const labelUList& faceCells = cyclicPatch_.faceCells(); + + forAll(faceCells, elemI) { - pnf[facei] = psiInternal[nbrFaceCells[facei]]; + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; } +} + + +template<class Type> +void cyclicFvPatchField<Type>::updateInterfaceMatrix +( + Field<Type>& result, + const Field<Type>& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes +) const +{ + const labelUList& nbrFaceCells = + cyclicPatch().cyclicPatch().neighbPatch().faceCells(); + + Field<Type> pnf(psiInternal, nbrFaceCells); // Transform according to the transformation tensors - transformCoupleField(pnf, cmpt); + transformCoupleField(pnf); // Multiply the field by coefficients and add into the result const labelUList& faceCells = cyclicPatch_.faceCells(); diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H index b2e82a9d43697f5b79e95d7af4d365453d45bf23..c3ba07477d954b3e40903d8b1c9e7b5588e11215 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -159,14 +159,22 @@ public: //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType ) const; + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field<Type>& result, + const Field<Type>& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes commsType + ) const; + // Cyclic coupled interface functions diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index 0eeb351cd4b301f527f171969993095467ecb326..fc48848757305d1bc1a184548f018c4f0db04fc6 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -202,9 +202,8 @@ Foam::cyclicAMIFvPatchField<Type>::neighbourPatchField() const template<class Type> void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes @@ -230,6 +229,35 @@ void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix } +template<class Type> +void Foam::cyclicAMIFvPatchField<Type>::updateInterfaceMatrix +( + Field<Type>& result, + const Field<Type>& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes +) const +{ + const labelUList& nbrFaceCells = + cyclicAMIPatch_.cyclicAMIPatch().neighbPatch().faceCells(); + + Field<Type> pnf(psiInternal, nbrFaceCells); + + // Transform according to the transformation tensors + transformCoupleField(pnf); + + pnf = cyclicAMIPatch_.interpolate(pnf); + + // Multiply the field by coefficients and add into the result + const labelUList& faceCells = cyclicAMIPatch_.faceCells(); + + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } +} + + template<class Type> void Foam::cyclicAMIFvPatchField<Type>::write(Ostream& os) const { diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H index 2e05111cb688a48568ffb599da04f18e0c3bc660..933a865f3007c485066e1806e9e18ba3b4a373c7 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -160,14 +160,22 @@ public: //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType ) const; + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field<Type>&, + const Field<Type>&, + const scalarField&, + const Pstream::commsTypes commsType + ) const; + // Cyclic AMI coupled interface functions diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C index fba9fb922d2d4245aa86eb5ed6e81eadbcb270ea..193008daffc3aa07cba17a13113b16bb56f0144e 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -137,9 +137,8 @@ tmp<Field<Type> > jumpCyclicFvPatchField<Type>::patchNeighbourField() const template<class Type> void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes @@ -152,7 +151,7 @@ void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix if (&psiInternal == &this->internalField()) { - tmp<Field<scalar> > tjf = jump(); + tmp<Field<scalar> > tjf = jump()().component(cmpt); if (!this->cyclicPatch().owner()) { tjf = -tjf; @@ -184,6 +183,54 @@ void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix } +template<class Type> +void jumpCyclicFvPatchField<Type>::updateInterfaceMatrix +( + Field<Type>& result, + const Field<Type>& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes +) const +{ + Field<Type> pnf(this->size()); + + const labelUList& nbrFaceCells = + this->cyclicPatch().neighbFvPatch().faceCells(); + + if (&psiInternal == &this->internalField()) + { + tmp<Field<Type> > tjf = jump(); + if (!this->cyclicPatch().owner()) + { + tjf = -tjf; + } + const Field<Type>& jf = tjf(); + + forAll(*this, facei) + { + pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei]; + } + } + else + { + forAll(*this, facei) + { + pnf[facei] = psiInternal[nbrFaceCells[facei]]; + } + } + + // Transform according to the transformation tensors + this->transformCoupleField(pnf); + + // Multiply the field by coefficients and add into the result + const labelUList& faceCells = this->cyclicPatch().faceCells(); + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H index 867e07bedebf3a60cf0e543fa8c37d0c17611222..4c4f94bce6ef3643cc74fb768972aff857d2fc35 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -109,7 +109,7 @@ public: } //- Return the "jump" across the patch as a "half" field - virtual tmp<Field<scalar> > jump() const = 0; + virtual tmp<Field<Type> > jump() const = 0; // Evaluation functions @@ -120,13 +120,21 @@ public: //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType ) const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field<Type>&, + const Field<Type>&, + const scalarField&, + const Pstream::commsTypes commsType + ) const; }; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C index a44ea4cc5c9c4f789006e4134a673d201cb53077..c9fb2563c162c0ac19931865fa673addac20b5d5 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C @@ -45,6 +45,7 @@ processorFvPatchField<Type>::processorFvPatchField coupledFvPatchField<Type>(p, iF), procPatch_(refCast<const processorFvPatch>(p)), sendBuf_(0), + receiveBuf_(0), outstandingSendRequest_(-1), outstandingRecvRequest_(-1), scalarSendBuf_(0), @@ -63,6 +64,7 @@ processorFvPatchField<Type>::processorFvPatchField coupledFvPatchField<Type>(p, iF, f), procPatch_(refCast<const processorFvPatch>(p)), sendBuf_(0), + receiveBuf_(0), outstandingSendRequest_(-1), outstandingRecvRequest_(-1), scalarSendBuf_(0), @@ -83,6 +85,7 @@ processorFvPatchField<Type>::processorFvPatchField coupledFvPatchField<Type>(ptf, p, iF, mapper), procPatch_(refCast<const processorFvPatch>(p)), sendBuf_(0), + receiveBuf_(0), outstandingSendRequest_(-1), outstandingRecvRequest_(-1), scalarSendBuf_(0), @@ -126,6 +129,7 @@ processorFvPatchField<Type>::processorFvPatchField coupledFvPatchField<Type>(p, iF, dict), procPatch_(refCast<const processorFvPatch>(p)), sendBuf_(0), + receiveBuf_(0), outstandingSendRequest_(-1), outstandingRecvRequest_(-1), scalarSendBuf_(0), @@ -162,6 +166,7 @@ processorFvPatchField<Type>::processorFvPatchField coupledFvPatchField<Type>(ptf), procPatch_(refCast<const processorFvPatch>(ptf.patch())), sendBuf_(ptf.sendBuf_.xfer()), + receiveBuf_(ptf.receiveBuf_.xfer()), outstandingSendRequest_(-1), outstandingRecvRequest_(-1), scalarSendBuf_(ptf.scalarSendBuf_.xfer()), @@ -186,6 +191,7 @@ processorFvPatchField<Type>::processorFvPatchField coupledFvPatchField<Type>(ptf, iF), procPatch_(refCast<const processorFvPatch>(ptf.patch())), sendBuf_(0), + receiveBuf_(0), outstandingSendRequest_(-1), outstandingRecvRequest_(-1), scalarSendBuf_(0), @@ -311,9 +317,8 @@ tmp<Field<Type> > processorFvPatchField<Type>::snGrad() const template<class Type> void processorFvPatchField<Type>::initInterfaceMatrixUpdate ( - const scalarField& psiInternal, scalarField&, - const lduMatrix&, + const scalarField& psiInternal, const scalarField&, const direction, const Pstream::commsTypes commsType @@ -368,9 +373,8 @@ void processorFvPatchField<Type>::initInterfaceMatrixUpdate template<class Type> void processorFvPatchField<Type>::updateInterfaceMatrix ( - const scalarField&, scalarField& result, - const lduMatrix&, + const scalarField&, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType @@ -430,6 +434,124 @@ void processorFvPatchField<Type>::updateInterfaceMatrix } +template<class Type> +void processorFvPatchField<Type>::initInterfaceMatrixUpdate +( + Field<Type>&, + const Field<Type>& psiInternal, + const scalarField&, + const Pstream::commsTypes commsType +) const +{ + this->patch().patchInternalField(psiInternal, sendBuf_); + + if (commsType == Pstream::nonBlocking && !Pstream::floatTransfer) + { + // Fast path. + if (debug && !this->ready()) + { + FatalErrorIn + ( + "processorFvPatchField<Type>::initInterfaceMatrixUpdate(..)" + ) << "On patch " << procPatch_.name() + << " outstanding request." + << abort(FatalError); + } + + + receiveBuf_.setSize(sendBuf_.size()); + outstandingRecvRequest_ = UPstream::nRequests(); + IPstream::read + ( + Pstream::nonBlocking, + procPatch_.neighbProcNo(), + reinterpret_cast<char*>(receiveBuf_.begin()), + receiveBuf_.byteSize(), + procPatch_.tag() + ); + + outstandingSendRequest_ = UPstream::nRequests(); + OPstream::write + ( + Pstream::nonBlocking, + procPatch_.neighbProcNo(), + reinterpret_cast<const char*>(sendBuf_.begin()), + sendBuf_.byteSize(), + procPatch_.tag() + ); + } + else + { + procPatch_.compressedSend(commsType, sendBuf_); + } + + const_cast<processorFvPatchField<Type>&>(*this).updatedMatrix() = false; +} + + +template<class Type> +void processorFvPatchField<Type>::updateInterfaceMatrix +( + Field<Type>& result, + const Field<Type>&, + const scalarField& coeffs, + const Pstream::commsTypes commsType +) const +{ + if (this->updatedMatrix()) + { + return; + } + + const labelUList& faceCells = this->patch().faceCells(); + + if (commsType == Pstream::nonBlocking && !Pstream::floatTransfer) + { + // Fast path. + if + ( + outstandingRecvRequest_ >= 0 + && outstandingRecvRequest_ < Pstream::nRequests() + ) + { + UPstream::waitRequest(outstandingRecvRequest_); + } + // Recv finished so assume sending finished as well. + outstandingSendRequest_ = -1; + outstandingRecvRequest_ = -1; + + // Consume straight from receiveBuf_ + + // Transform according to the transformation tensor + transformCoupleField(receiveBuf_); + + // Multiply the field by coefficients and add into the result + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*receiveBuf_[elemI]; + } + } + else + { + Field<Type> pnf + ( + procPatch_.compressedReceive<Type>(commsType, this->size())() + ); + + // Transform according to the transformation tensor + transformCoupleField(pnf); + + // Multiply the field by coefficients and add into the result + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; + } + } + + const_cast<processorFvPatchField<Type>&>(*this).updatedMatrix() = true; +} + + template<class Type> bool processorFvPatchField<Type>::ready() const { diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H index 9541e80ea56a3f040837f5092cddee9e90320412..690a9dbe4fedee6794788121c74ff137891c969c 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H @@ -64,6 +64,9 @@ class processorFvPatchField //- Send buffer. mutable Field<Type> sendBuf_; + //- Receive buffer. + mutable Field<Type> receiveBuf_; + //- Outstanding request mutable label outstandingSendRequest_; @@ -184,31 +187,48 @@ public: //- Return patch-normal gradient virtual tmp<Field<Type> > snGrad() const; + //- Is all data available + virtual bool ready() const; + //- Initialise neighbour matrix update virtual void initInterfaceMatrixUpdate ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix& m, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType ) const; - //- Is all data available - virtual bool ready() const; - //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix& m, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType ) const; + //- Initialise neighbour matrix update + virtual void initInterfaceMatrixUpdate + ( + Field<Type>& result, + const Field<Type>& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes commsType + ) const; + + //- Update result field based on interface functionality + virtual void updateInterfaceMatrix + ( + Field<Type>& result, + const Field<Type>& psiInternal, + const scalarField& coeffs, + const Pstream::commsTypes commsType + ) const; + + //- Processor coupled interface functions //- Return processor number diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C index 6fbb2150029bbe35dbd3945cd86c6bd632502ce9..82dcf7ca36ef430b45e3b745db5ef4026788b38f 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C @@ -35,9 +35,8 @@ namespace Foam template<> void processorFvPatchField<scalar>::initInterfaceMatrixUpdate ( - const scalarField& psiInternal, scalarField&, - const lduMatrix&, + const scalarField& psiInternal, const scalarField&, const direction, const Pstream::commsTypes commsType @@ -92,9 +91,8 @@ void processorFvPatchField<scalar>::initInterfaceMatrixUpdate template<> void processorFvPatchField<scalar>::updateInterfaceMatrix ( - const scalarField&, scalarField& result, - const lduMatrix&, + const scalarField&, const scalarField& coeffs, const direction, const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H index 02443c511dd1ec65269a905302e00caddebdac9c..a8bbb24dcb5adf64d0beff05fb49cbe7f6a5ff66 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,9 +38,8 @@ namespace Foam template<> void processorFvPatchField<scalar>::initInterfaceMatrixUpdate ( - const scalarField&, scalarField&, - const lduMatrix&, + const scalarField&, const scalarField&, const direction, const Pstream::commsTypes commsType @@ -50,9 +49,8 @@ void processorFvPatchField<scalar>::initInterfaceMatrixUpdate template<> void processorFvPatchField<scalar>::updateInterfaceMatrix ( - const scalarField&, scalarField& result, - const lduMatrix&, + const scalarField&, const scalarField& coeffs, const direction, const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C index 7d049f6ad30be58530f9ab7956cc67ab5ef97f7d..d36da92ef362d3458dece311f13ccd69b26e2bcb 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -227,9 +227,8 @@ processorCyclicFvPatchField<Type>::~processorCyclicFvPatchField() //template<class Type> //void processorCyclicFvPatchField<Type>::initInterfaceMatrixUpdate //( -// const scalarField& psiInternal, // scalarField&, -// const lduMatrix&, +// const scalarField& psiInternal, // const scalarField&, // const direction, // const Pstream::commsTypes commsType @@ -246,9 +245,8 @@ processorCyclicFvPatchField<Type>::~processorCyclicFvPatchField() //template<class Type> //void processorCyclicFvPatchField<Type>::updateInterfaceMatrix //( -// const scalarField&, // scalarField& result, -// const lduMatrix&, +// const scalarField&, // const scalarField& coeffs, // const direction cmpt, // const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H index 6447c9e067ccdc54b564243243ea5cf02ea8dc9f..8de27ade3232e5033052e84d60ec8454c893a3c5 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -150,8 +150,6 @@ public: { return procPatch_.forwardT(); } - - }; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchFields.H b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchFields.H index 93bfe8a2f572e9ca302bbdc5527f22d4932c9f14..b07ba14b619bf42e50cf2e135d75bc6a4ffbd2ba 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchFields.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchFields.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -26,7 +26,7 @@ License #ifndef processorCyclicFvPatchFields_H #define processorCyclicFvPatchFields_H -#include "processorCyclicFvPatchScalarField.H" +#include "processorCyclicFvPatchField.H" #include "fieldTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index beeeb364468274924fb4d80f709dc10aefc50900..ebfc0a83862c78740a0e735f17082d17bfa1e2c5 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,9 +38,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ) : fixedGradientFvPatchScalarField(p, iF), - UName_("U"), + phiHbyAName_("phiHbyA"), phiName_("phi"), rhoName_("rho"), + DpName_("Dp"), adjoint_(false) {} @@ -54,9 +55,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ) : fixedGradientFvPatchScalarField(ptf, p, iF, mapper), - UName_(ptf.UName_), + phiHbyAName_(ptf.phiHbyAName_), phiName_(ptf.phiName_), rhoName_(ptf.rhoName_), + DpName_(ptf.rhoName_), adjoint_(ptf.adjoint_) {} @@ -69,10 +71,11 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ) : fixedGradientFvPatchScalarField(p, iF), - UName_(dict.lookupOrDefault<word>("U", "U")), + phiHbyAName_(dict.lookupOrDefault<word>("phiHbyA", "phiHbyA")), phiName_(dict.lookupOrDefault<word>("phi", "phi")), rhoName_(dict.lookupOrDefault<word>("rho", "rho")), - adjoint_(dict.lookup("adjoint")) + DpName_(dict.lookupOrDefault<word>("Dp", "Dp")), + adjoint_(dict.lookupOrDefault<Switch>("adjoint", false)) { if (dict.found("gradient")) { @@ -94,9 +97,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ) : fixedGradientFvPatchScalarField(wbppsf), - UName_(wbppsf.UName_), + phiHbyAName_(wbppsf.phiHbyAName_), phiName_(wbppsf.phiName_), rhoName_(wbppsf.rhoName_), + DpName_(wbppsf.DpName_), adjoint_(wbppsf.adjoint_) {} @@ -108,9 +112,10 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField ) : fixedGradientFvPatchScalarField(wbppsf, iF), - UName_(wbppsf.UName_), + phiHbyAName_(wbppsf.phiHbyAName_), phiName_(wbppsf.phiName_), rhoName_(wbppsf.rhoName_), + DpName_(wbppsf.DpName_), adjoint_(wbppsf.adjoint_) {} @@ -124,15 +129,19 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs() return; } - const fvPatchField<vector>& Up = - patch().lookupPatchField<volVectorField, vector>(UName_); + const surfaceScalarField& phiHbyA = + db().lookupObject<surfaceScalarField>(phiHbyAName_); const surfaceScalarField& phi = db().lookupObject<surfaceScalarField>(phiName_); + fvsPatchField<scalar> phiHbyAp = + patch().patchField<surfaceScalarField, scalar>(phiHbyA); + fvsPatchField<scalar> phip = patch().patchField<surfaceScalarField, scalar>(phi); + /* if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { const fvPatchField<scalar>& rhop = @@ -141,16 +150,38 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs() phip /= rhop; } - const fvPatchField<scalar>& rAp = - patch().lookupPatchField<volScalarField, scalar>("(1|A("+UName_+"))"); + if (phiHbyA.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField<scalar>& rhop = + patch().lookupPatchField<volScalarField, scalar>(rhoName_); + + phiHbyAp /= rhop; + } + */ + + const scalarField *DppPtr = NULL; + + if (db().foundObject<volScalarField>(DpName_)) + { + DppPtr = + &patch().lookupPatchField<volScalarField, scalar>(DpName_); + } + else if (db().foundObject<surfaceScalarField>(DpName_)) + { + const surfaceScalarField& Dp = + db().lookupObject<surfaceScalarField>(DpName_); + + DppPtr = + &patch().patchField<surfaceScalarField, scalar>(Dp); + } if (adjoint_) { - gradient() = ((patch().Sf() & Up) - phip)/patch().magSf()/rAp; + gradient() = (phip - phiHbyAp)/patch().magSf()/(*DppPtr); } else { - gradient() = (phip - (patch().Sf() & Up))/patch().magSf()/rAp; + gradient() = (phiHbyAp - phip)/patch().magSf()/(*DppPtr); } fixedGradientFvPatchScalarField::updateCoeffs(); @@ -160,9 +191,10 @@ void Foam::fixedFluxPressureFvPatchScalarField::updateCoeffs() void Foam::fixedFluxPressureFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent<word>(os, "U", "U", UName_); + writeEntryIfDifferent<word>(os, "phiHbyA", "phiHbyA", phiHbyAName_); writeEntryIfDifferent<word>(os, "phi", "phi", phiName_); writeEntryIfDifferent<word>(os, "rho", "rho", rhoName_); + writeEntryIfDifferent<word>(os, "Dp", "Dp", rhoName_); os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl; gradient().writeEntry("gradient", os); } diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H index bc0c4f9fb9121aa5964c0f129d4703f86daef51b..de8f837abdfc99fe4321722133f669ff424ec22e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,14 @@ Class Foam::fixedFluxPressureFvPatchScalarField Description - Foam::fixedFluxPressureFvPatchScalarField + Adjusts the pressure gradient such that the flux on the boundary is that + specified by the velocity boundary condition. + + The predicted flux to be compensated by the pressure gradient is evaluated + as (phi - phiHbyA), both of which are looked-up from the database as is + the pressure diffusivity Dp used to calculate the gradient. + + The names of the phi, phiHbyA and Dp fields may be optionally specified. SourceFiles fixedFluxPressureFvPatchScalarField.C @@ -54,8 +61,8 @@ class fixedFluxPressureFvPatchScalarField { // Private data - //- Name of the velocity field - word UName_; + //- Name of the predicted flux transporting the field + word phiHbyAName_; //- Name of the flux transporting the field word phiName_; @@ -64,6 +71,9 @@ class fixedFluxPressureFvPatchScalarField // if neccessary word rhoName_; + //- Name of the pressure diffusivity field + word DpName_; + //- Is the pressure adjoint, i.e. has the opposite sign Switch adjoint_; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C index aa847551553107ddac6fc66535bd8480685df124..644c8b161c06516a867f586e58ede435c1b28c46 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.C @@ -136,6 +136,7 @@ void Foam::multiphaseFixedFluxPressureFvPatchScalarField::updateCoeffs() fvsPatchField<scalar> phip = patch().patchField<surfaceScalarField, scalar>(phi); + /* if (phi.dimensions() == dimDensity*dimVelocity*dimArea) { const fvPatchField<scalar>& rhop = @@ -144,6 +145,15 @@ void Foam::multiphaseFixedFluxPressureFvPatchScalarField::updateCoeffs() phip /= rhop; } + if (phiHbyA.dimensions() == dimDensity*dimVelocity*dimArea) + { + const fvPatchField<scalar>& rhop = + patch().lookupPatchField<volScalarField, scalar>(rhoName_); + + phiHbyAp /= rhop; + } + */ + const fvsPatchField<scalar>& Dpp = patch().lookupPatchField<surfaceScalarField, scalar>("Dp"); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.H index a6e0d7df45402224c7d635ff3a9e9a76c4022692..57f01d78e6fea9c60abeb0aa163e77383ceb4735 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/multiphaseFixedFluxPressure/multiphaseFixedFluxPressureFvPatchScalarField.H @@ -25,7 +25,14 @@ Class Foam::multiphaseFixedFluxPressureFvPatchScalarField Description - Foam::multiphaseFixedFluxPressureFvPatchScalarField + Adjusts the pressure gradient such that the flux on the boundary is that + specified by the velocity boundary condition. + + The predicted flux to be compensated by the pressure gradient is evaluated + as (phi - phiHbyA), both of which are looked-up from the database as is + the pressure diffusivity Dp used to calculate the gradient. + + The names of the phi, phiHbyA and Dp fields may be optionally specified. SourceFiles multiphaseFixedFluxPressureFvPatchScalarField.C diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C index 61fb24ba77d505f1bd996c4bec52f4563978a259..2d31d3802f1630eef14cb1310a29fde1e80c39f0 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,12 +25,7 @@ License #include "timeVaryingMappedFixedValueFvPatchField.H" #include "Time.H" -#include "triSurfaceTools.H" -#include "triSurface.H" -#include "vector2D.H" -#include "OFstream.H" #include "AverageIOField.H" -#include "Random.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -51,9 +46,6 @@ timeVaryingMappedFixedValueFvPatchField fieldTableName_(iF.name()), setAverage_(false), perturb_(0), - referenceCS_(NULL), - nearestVertex_(0), - nearestVertexWeight_(0), sampleTimes_(0), startSampleTime_(-1), startSampledValues_(0), @@ -78,9 +70,7 @@ timeVaryingMappedFixedValueFvPatchField fieldTableName_(ptf.fieldTableName_), setAverage_(ptf.setAverage_), perturb_(ptf.perturb_), - referenceCS_(NULL), - nearestVertex_(0), - nearestVertexWeight_(0), + mapperPtr_(ptf.mapperPtr_), sampleTimes_(0), startSampleTime_(-1), startSampledValues_(0), @@ -103,10 +93,8 @@ timeVaryingMappedFixedValueFvPatchField fixedValueFvPatchField<Type>(p, iF), fieldTableName_(iF.name()), setAverage_(readBool(dict.lookup("setAverage"))), - perturb_(dict.lookupOrDefault("perturb", 1E-5)), - referenceCS_(NULL), - nearestVertex_(0), - nearestVertexWeight_(0), + perturb_(dict.lookupOrDefault("perturb", 1e-5)), + mapperPtr_(NULL), sampleTimes_(0), startSampleTime_(-1), startSampledValues_(0), @@ -139,9 +127,7 @@ timeVaryingMappedFixedValueFvPatchField fieldTableName_(ptf.fieldTableName_), setAverage_(ptf.setAverage_), perturb_(ptf.perturb_), - referenceCS_(ptf.referenceCS_), - nearestVertex_(ptf.nearestVertex_), - nearestVertexWeight_(ptf.nearestVertexWeight_), + mapperPtr_(ptf.mapperPtr_), sampleTimes_(ptf.sampleTimes_), startSampleTime_(ptf.startSampleTime_), startSampledValues_(ptf.startSampledValues_), @@ -165,9 +151,7 @@ timeVaryingMappedFixedValueFvPatchField fieldTableName_(ptf.fieldTableName_), setAverage_(ptf.setAverage_), perturb_(ptf.perturb_), - referenceCS_(ptf.referenceCS_), - nearestVertex_(ptf.nearestVertex_), - nearestVertexWeight_(ptf.nearestVertexWeight_), + mapperPtr_(ptf.mapperPtr_), sampleTimes_(ptf.sampleTimes_), startSampleTime_(ptf.startSampleTime_), startSampledValues_(ptf.startSampledValues_), @@ -192,6 +176,10 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::autoMap startSampledValues_.autoMap(m); endSampledValues_.autoMap(m); } + // Clear interpolator + mapperPtr_.clear(); + startSampleTime_ = -1; + endSampleTime_ = -1; } @@ -209,266 +197,90 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::rmap startSampledValues_.rmap(tiptf.startSampledValues_, addr); endSampledValues_.rmap(tiptf.endSampledValues_, addr); + + // Clear interpolator + mapperPtr_.clear(); + startSampleTime_ = -1; + endSampleTime_ = -1; } template<class Type> -void timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints() +void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable() { - // Read the sample points - - pointIOField samplePoints - ( - IOobject - ( - "points", - this->db().time().constant(), - "boundaryData"/this->patch().name(), - this->db(), - IOobject::MUST_READ, - IOobject::AUTO_WRITE, - false - ) - ); - - const fileName samplePointsFile = samplePoints.filePath(); - - if (debug) - { - Info<< "timeVaryingMappedFixedValueFvPatchField :" - << " Read " << samplePoints.size() << " sample points from " - << samplePointsFile << endl; - } - - // Determine coordinate system from samplePoints - - if (samplePoints.size() < 3) + // Initialise + if (mapperPtr_.empty()) { - FatalErrorIn + pointIOField samplePoints ( - "timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()" - ) << "Only " << samplePoints.size() << " points read from file " - << samplePoints.objectPath() << nl - << "Need at least three non-colinear samplePoints" - << " to be able to interpolate." - << "\n on patch " << this->patch().name() - << " of points " << samplePoints.name() - << " in file " << samplePoints.objectPath() - << exit(FatalError); - } - - const point& p0 = samplePoints[0]; - - // Find furthest away point - vector e1; - label index1 = -1; - scalar maxDist = -GREAT; - - for (label i = 1; i < samplePoints.size(); i++) - { - const vector d = samplePoints[i] - p0; - scalar magD = mag(d); - - if (magD > maxDist) - { - e1 = d/magD; - index1 = i; - maxDist = magD; - } - } - // Find point that is furthest away from line p0-p1 - const point& p1 = samplePoints[index1]; + IOobject + ( + "points", + this->db().time().constant(), + "boundaryData"/this->patch().name(), + this->db(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + false + ) + ); + + const fileName samplePointsFile = samplePoints.filePath(); - label index2 = -1; - maxDist = -GREAT; - for (label i = 1; i < samplePoints.size(); i++) - { - if (i != index1) + if (debug) { - const point& p2 = samplePoints[i]; - vector e2(p2 - p0); - e2 -= (e2&e1)*e1; - scalar magE2 = mag(e2); - - if (magE2 > maxDist) - { - index2 = i; - maxDist = magE2; - } + Info<< "timeVaryingMappedFixedValueFvPatchField :" + << " Read " << samplePoints.size() << " sample points from " + << samplePointsFile << endl; } - } - if (index2 == -1) - { - FatalErrorIn - ( - "timeVaryingMappedFixedValueFvPatchField<Type>::readSamplePoints()" - ) << "Cannot find points that make valid normal." << nl - << "Have so far points " << p0 << " and " << p1 - << "Need at least three sample points which are not in a line." - << "\n on patch " << this->patch().name() - << " of points " << samplePoints.name() - << " in file " << samplePoints.objectPath() - << exit(FatalError); - } - - vector n = e1^(samplePoints[index2]-p0); - n /= mag(n); - - if (debug) - { - Info<< "timeVaryingMappedFixedValueFvPatchField :" - << " Used points " << p0 << ' ' << samplePoints[index1] - << ' ' << samplePoints[index2] - << " to define coordinate system with normal " << n << endl; - } - - referenceCS_.reset - ( - new coordinateSystem - ( - "reference", - p0, // origin - n, // normal - e1 // 0-axis - ) - ); - - tmp<vectorField> tlocalVertices - ( - referenceCS().localPosition(samplePoints) - ); - vectorField& localVertices = tlocalVertices(); - - const boundBox bb(localVertices, true); - const point bbMid(bb.midpoint()); - - if (debug) - { - Info<< "timeVaryingMappedFixedValueFvPatchField :" - << " Perturbing points with " << perturb_ - << " fraction of a random position inside " << bb - << " to break any ties on regular meshes." - << nl << endl; - } - - Random rndGen(123456); - forAll(localVertices, i) - { - localVertices[i] += - perturb_ - *(rndGen.position(bb.min(), bb.max())-bbMid); - } - - // Determine triangulation - List<vector2D> localVertices2D(localVertices.size()); - forAll(localVertices, i) - { - localVertices2D[i][0] = localVertices[i][0]; - localVertices2D[i][1] = localVertices[i][1]; - } - - triSurface s(triSurfaceTools::delaunay2D(localVertices2D)); - tmp<pointField> tlocalFaceCentres - ( - referenceCS().localPosition + // Allocate the interpolator + mapperPtr_.reset ( - this->patch().patch().faceCentres() - ) - ); - const pointField& localFaceCentres = tlocalFaceCentres(); - - if (debug) - { - Pout<< "readSamplePoints :" - <<" Dumping triangulated surface to triangulation.stl" << endl; - s.write(this->db().time().path()/"triangulation.stl"); + new pointToPointPlanarInterpolation + ( + samplePoints, + this->patch().patch().faceCentres(), + perturb_ + ) + ); - OFstream str(this->db().time().path()/"localFaceCentres.obj"); - Pout<< "readSamplePoints :" - << " Dumping face centres to " << str.name() << endl; + // Read the times for which data is available + const fileName samplePointsDir = samplePointsFile.path(); + sampleTimes_ = Time::findTimes(samplePointsDir); - forAll(localFaceCentres, i) + if (debug) { - const point& p = localFaceCentres[i]; - str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl; + Info<< "timeVaryingMappedFixedValueFvPatchField : In directory " + << samplePointsDir << " found times " + << pointToPointPlanarInterpolation::timeNames(sampleTimes_) + << endl; } } - // Determine interpolation onto face centres. - triSurfaceTools::calcInterpolationWeights - ( - s, - localFaceCentres, // points to interpolate to - nearestVertex_, - nearestVertexWeight_ - ); - - - - // Read the times for which data is available - - const fileName samplePointsDir = samplePointsFile.path(); - - sampleTimes_ = Time::findTimes(samplePointsDir); - - if (debug) - { - Info<< "timeVaryingMappedFixedValueFvPatchField : In directory " - << samplePointsDir << " found times " << timeNames(sampleTimes_) - << endl; - } -} - - -template<class Type> -wordList timeVaryingMappedFixedValueFvPatchField<Type>::timeNames -( - const instantList& times -) -{ - wordList names(times.size()); - - forAll(times, i) - { - names[i] = times[i].name(); - } - return names; -} - -template<class Type> -void timeVaryingMappedFixedValueFvPatchField<Type>::findTime -( - const fileName& instance, - const fileName& local, - const scalar timeVal, - label& lo, - label& hi -) const -{ - lo = startSampleTime_; - hi = -1; + // Find current time in sampleTimes + label lo = -1; + label hi = -1; - for (label i = startSampleTime_+1; i < sampleTimes_.size(); i++) - { - if (sampleTimes_[i].value() > timeVal) - { - break; - } - else - { - lo = i; - } - } + bool foundTime = mapperPtr_().findTime + ( + sampleTimes_, + startSampleTime_, + this->db().time().value(), + lo, + hi + ); - if (lo == -1) + if (!foundTime) { - FatalErrorIn("findTime") - << "Cannot find starting sampling values for current time " - << timeVal << nl + FatalErrorIn + ( + "timeVaryingMappedFixedValueFvPatchField<Type>::checkTable" + ) << "Cannot find starting sampling values for current time " + << this->db().time().value() << nl << "Have sampling values for times " - << timeNames(sampleTimes_) << nl + << pointToPointPlanarInterpolation::timeNames(sampleTimes_) << nl << "In directory " << this->db().time().constant()/"boundaryData"/this->patch().name() << "\n on patch " << this->patch().name() @@ -476,52 +288,6 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::findTime << exit(FatalError); } - if (lo < sampleTimes_.size()-1) - { - hi = lo+1; - } - - - if (debug) - { - if (hi == -1) - { - Pout<< "findTime : Found time " << timeVal << " after" - << " index:" << lo << " time:" << sampleTimes_[lo].value() - << endl; - } - else - { - Pout<< "findTime : Found time " << timeVal << " inbetween" - << " index:" << lo << " time:" << sampleTimes_[lo].value() - << " and index:" << hi << " time:" << sampleTimes_[hi].value() - << endl; - } - } -} - - -template<class Type> -void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable() -{ - // Initialise - if (startSampleTime_ == -1 && endSampleTime_ == -1) - { - readSamplePoints(); - } - - // Find current time in sampleTimes - label lo = -1; - label hi = -1; - - findTime - ( - this->db().time().constant(), - "boundaryData"/this->patch().name(), - this->db().time().value(), - lo, - hi - ); // Update sampled data fields. @@ -573,7 +339,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable() ); startAverage_ = vals.average(); - startSampledValues_ = interpolate(vals); + startSampledValues_ = mapperPtr_().interpolate(vals); } } @@ -617,61 +383,22 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable() ) ); endAverage_ = vals.average(); - endSampledValues_ = interpolate(vals); + endSampledValues_ = mapperPtr_().interpolate(vals); } } } -template<class Type> -tmp<Field<Type> > timeVaryingMappedFixedValueFvPatchField<Type>::interpolate -( - const Field<Type>& sourceFld -) const -{ - tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size())); - Field<Type>& fld = tfld(); - - forAll(fld, i) - { - const FixedList<label, 3>& verts = nearestVertex_[i]; - const FixedList<scalar, 3>& w = nearestVertexWeight_[i]; - - if (verts[2] == -1) - { - if (verts[1] == -1) - { - // Use vertex0 only - fld[i] = sourceFld[verts[0]]; - } - else - { - // Use vertex 0,1 - fld[i] = - w[0]*sourceFld[verts[0]] - + w[1]*sourceFld[verts[1]]; - } - } - else - { - fld[i] = - w[0]*sourceFld[verts[0]] - + w[1]*sourceFld[verts[1]] - + w[2]*sourceFld[verts[2]]; - } - } - return tfld; -} - - template<class Type> void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs() { + if (this->updated()) { return; } + checkTable(); // Interpolate between the sampled data @@ -768,7 +495,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::write(Ostream& os) const { fvPatchField<Type>::write(os); os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; - os.writeKeyword("peturb") << perturb_ << token::END_STATEMENT << nl; + os.writeKeyword("perturb") << perturb_ << token::END_STATEMENT << nl; if (fieldTableName_ != this->dimensionedInternalField().name()) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H index e3ac11215495207ba2572e0a8f978434c7a913f8..82525ec49a090a37755530d52daa31b15a1fe673 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,7 +45,7 @@ Description // Maintain average to that of the supplied values setAverage false; - // Optional: change perturbation (default 1E-5) to avoid any ties + // Optional: change perturbation (default 1e-5) to avoid any ties // in triangulating regular geometries. //perturb 0.0; @@ -66,9 +66,9 @@ SourceFiles #define timeVaryingMappedFixedValueFvPatchField_H #include "fixedValueFvPatchFields.H" -#include "coordinateSystem.H" #include "FixedList.H" #include "instantList.H" +#include "pointToPointPlanarInterpolation.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,16 +95,8 @@ class timeVaryingMappedFixedValueFvPatchField //- Fraction of perturbation (fraction of bounding box) to add scalar perturb_; - //- Coordinate system - autoPtr<coordinateSystem> referenceCS_; - - //- Current interpolation addressing to face centres of underlying - // patch - List<FixedList<label, 3> > nearestVertex_; - - //- Current interpolation factors to face centres of underlying - // patch - List<FixedList<scalar, 3> > nearestVertexWeight_; + //- 2D interpolation + autoPtr<pointToPointPlanarInterpolation> mapperPtr_; //- List of boundaryData time directories instantList sampleTimes_; @@ -127,31 +119,6 @@ class timeVaryingMappedFixedValueFvPatchField //- If setAverage: end average value Type endAverage_; - - // Private Member Functions - - //- Get names of times - static wordList timeNames(const instantList&); - - //- Find times around current time - void findTime - ( - const fileName& instance, - const fileName& local, - const scalar timeVal, - label& lo, - label& hi - ) const; - - - //- Read boundary points and determine interpolation weights to patch - // faceCentres - void readSamplePoints(); - - //- Do actual interpolation using current weights - tmp<Field<Type> > interpolate(const Field<Type>&) const; - - public: //- Runtime type information @@ -224,12 +191,6 @@ public: // Access - //- Return the coordinateSystem - const coordinateSystem& referenceCS() const - { - return referenceCS_; - } - //- Return startSampledValues const Field<Type> startSampledValues() { diff --git a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C index 303eb42b80e4e0980ed6afec76deb165594fbd0d..bdbe5db09233115bcf33cc0a6ce7e0cf5263e608 100644 --- a/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C +++ b/src/finiteVolume/finiteVolume/fvSchemes/fvSchemes.C @@ -258,6 +258,7 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr) obr, ( obr.readOpt() == IOobject::MUST_READ + || obr.readOpt() == IOobject::READ_IF_PRESENT ? IOobject::MUST_READ_IF_MODIFIED : obr.readOpt() ), @@ -372,6 +373,7 @@ Foam::fvSchemes::fvSchemes(const objectRegistry& obr) ( readOpt() == IOobject::MUST_READ || readOpt() == IOobject::MUST_READ_IF_MODIFIED + || (readOpt() == IOobject::READ_IF_PRESENT && headerOk()) ) { read(schemesDict()); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index a69f7f5add6d6ee9c1d3a6c2ffd52f3da59873ad..3e65f5d1c23eeb60c89043ab10e6d127ea4d251a 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -1377,7 +1377,7 @@ void Foam::checkMethod template<class Type> -Foam::lduMatrix::solverPerformance Foam::solve +Foam::solverPerformance Foam::solve ( fvMatrix<Type>& fvm, const dictionary& solverControls @@ -1387,13 +1387,13 @@ Foam::lduMatrix::solverPerformance Foam::solve } template<class Type> -Foam::lduMatrix::solverPerformance Foam::solve +Foam::solverPerformance Foam::solve ( const tmp<fvMatrix<Type> >& tfvm, const dictionary& solverControls ) { - lduMatrix::solverPerformance solverPerf = + solverPerformance solverPerf = const_cast<fvMatrix<Type>&>(tfvm()).solve(solverControls); tfvm.clear(); @@ -1403,15 +1403,15 @@ Foam::lduMatrix::solverPerformance Foam::solve template<class Type> -Foam::lduMatrix::solverPerformance Foam::solve(fvMatrix<Type>& fvm) +Foam::solverPerformance Foam::solve(fvMatrix<Type>& fvm) { return fvm.solve(); } template<class Type> -Foam::lduMatrix::solverPerformance Foam::solve(const tmp<fvMatrix<Type> >& tfvm) +Foam::solverPerformance Foam::solve(const tmp<fvMatrix<Type> >& tfvm) { - lduMatrix::solverPerformance solverPerf = + solverPerformance solverPerf = const_cast<fvMatrix<Type>&>(tfvm()).solve(); tfvm.clear(); diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 25021653f3a3ba9fa4c259ab420cf7bf71def9bf..ce214e60c801e9af8346e4c5b7671476bc9045c4 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -142,7 +142,8 @@ class fvMatrix mutable GeometricField<Type, fvsPatchField, surfaceMesh> *faceFluxCorrectionPtr_; -protected: +// ***HGW for testing LduMatrix protected: +public: //- Declare friendship with the fvSolver class friend class fvSolver; @@ -238,11 +239,11 @@ public: //- Solve returning the solution statistics. // Use the given solver controls - lduMatrix::solverPerformance solve(const dictionary&); + solverPerformance solve(const dictionary&); //- Solve returning the solution statistics. // Solver controls read from fvSolution - lduMatrix::solverPerformance solve(); + solverPerformance solve(); }; @@ -386,13 +387,21 @@ public: // Solver controls read from fvSolution autoPtr<fvSolver> solver(); - //- Solve returning the solution statistics. + //- Solve segregated or coupled returning the solution statistics. + // Use the given solver controls + solverPerformance solve(const dictionary&); + + //- Solve segregated returning the solution statistics. + // Use the given solver controls + solverPerformance solveSegregated(const dictionary&); + + //- Solve coupled returning the solution statistics. // Use the given solver controls - lduMatrix::solverPerformance solve(const dictionary&); + solverPerformance solveCoupled(const dictionary&); //- Solve returning the solution statistics. // Solver controls read from fvSolution - lduMatrix::solverPerformance solve(); + solverPerformance solve(); //- Return the matrix residual tmp<Field<Type> > residual() const; @@ -541,14 +550,14 @@ void checkMethod //- Solve returning the solution statistics given convergence tolerance // Use the given solver controls template<class Type> -lduMatrix::solverPerformance solve(fvMatrix<Type>&, const dictionary&); +solverPerformance solve(fvMatrix<Type>&, const dictionary&); //- Solve returning the solution statistics given convergence tolerance, // deleting temporary matrix after solution. // Use the given solver controls template<class Type> -lduMatrix::solverPerformance solve +solverPerformance solve ( const tmp<fvMatrix<Type> >&, const dictionary& @@ -558,14 +567,14 @@ lduMatrix::solverPerformance solve //- Solve returning the solution statistics given convergence tolerance // Solver controls read fvSolution template<class Type> -lduMatrix::solverPerformance solve(fvMatrix<Type>&); +solverPerformance solve(fvMatrix<Type>&); //- Solve returning the solution statistics given convergence tolerance, // deleting temporary matrix after solution. // Solver controls read fvSolution template<class Type> -lduMatrix::solverPerformance solve(const tmp<fvMatrix<Type> >&); +solverPerformance solve(const tmp<fvMatrix<Type> >&); //- Return the correction form of the given matrix diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 675c794070ac0768f7f4b7163c925c8a40ed6489..0cd882fe5463391e6c22fa1715279e7563232e0c 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,6 +23,9 @@ License \*---------------------------------------------------------------------------*/ +#include "LduMatrix.H" +#include "diagTensorField.H" + // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> @@ -50,7 +53,7 @@ void Foam::fvMatrix<Type>::setComponentReference template<class Type> -Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve +Foam::solverPerformance Foam::fvMatrix<Type>::solve ( const dictionary& solverControls ) @@ -62,12 +65,51 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve << endl; } + word type(solverControls.lookupOrDefault<word>("type", "segregated")); + + if (type == "segregated") + { + return solveSegregated(solverControls); + } + else if (type == "coupled") + { + return solveCoupled(solverControls); + } + else + { + FatalIOErrorIn + ( + "fvMatrix<Type>::solve(const dictionary& solverControls)", + solverControls + ) << "Unknown type " << type + << "; currently supported solver types are segregated and coupled" + << exit(FatalIOError); + + return solverPerformance(); + } +} + + +template<class Type> +Foam::solverPerformance Foam::fvMatrix<Type>::solveSegregated +( + const dictionary& solverControls +) +{ + if (debug) + { + Info<< "fvMatrix<Type>::solveSegregated" + "(const dictionary& solverControls) : " + "solving fvMatrix<Type>" + << endl; + } + GeometricField<Type, fvPatchField, volMesh>& psi = const_cast<GeometricField<Type, fvPatchField, volMesh>&>(psi_); - lduMatrix::solverPerformance solverPerfVec + solverPerformance solverPerfVec ( - "fvMatrix<Type>::solve", + "fvMatrix<Type>::solveSegregated", psi.name() ); @@ -111,7 +153,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve ); lduInterfaceFieldPtrsList interfaces = - psi.boundaryField().interfaces(); + psi.boundaryField().scalarInterfaces(); // Use the initMatrixInterfaces and updateMatrixInterfaces to correct // bouCoeffsCmpt for the explicit part of the coupled boundary @@ -134,7 +176,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve cmpt ); - lduMatrix::solverPerformance solverPerf; + solverPerformance solverPerf; // Solver call solverPerf = lduMatrix::solver::New @@ -147,7 +189,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve solverControls )->solve(psiCmpt, sourceCmpt, cmpt); - solverPerf.print(); + solverPerf.print(Info); solverPerfVec = max(solverPerfVec, solverPerf); solverPerfVec.solverName() = solverPerf.solverName(); @@ -164,6 +206,62 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve } +template<class Type> +Foam::solverPerformance Foam::fvMatrix<Type>::solveCoupled +( + const dictionary& solverControls +) +{ + if (debug) + { + Info<< "fvMatrix<Type>::solveCoupled" + "(const dictionary& solverControls) : " + "solving fvMatrix<Type>" + << endl; + } + + GeometricField<Type, fvPatchField, volMesh>& psi = + const_cast<GeometricField<Type, fvPatchField, volMesh>&>(psi_); + + LduMatrix<Type, scalar, scalar> coupledMatrix(psi.mesh()); + coupledMatrix.diag() = diag(); + coupledMatrix.upper() = upper(); + coupledMatrix.lower() = lower(); + coupledMatrix.source() = source(); + + addBoundaryDiag(coupledMatrix.diag(), 0); + addBoundarySource(coupledMatrix.source(), false); + + coupledMatrix.interfaces() = psi.boundaryField().interfaces(); + coupledMatrix.interfacesUpper() = boundaryCoeffs().component(0); + coupledMatrix.interfacesLower() = internalCoeffs().component(0); + + autoPtr<typename LduMatrix<Type, scalar, scalar>::solver> + coupledMatrixSolver + ( + LduMatrix<Type, scalar, scalar>::solver::New + ( + psi.name(), + coupledMatrix, + solverControls + ) + ); + + SolverPerformance<Type> solverPerf + ( + coupledMatrixSolver->solve(psi) + ); + + solverPerf.print(Info); + + psi.correctBoundaryConditions(); + + // psi.mesh().setSolverPerformance(psi.name(), solverPerf); + + return solverPerformance(); +} + + template<class Type> Foam::autoPtr<typename Foam::fvMatrix<Type>::fvSolver> Foam::fvMatrix<Type>::solver() @@ -183,7 +281,7 @@ Foam::fvMatrix<Type>::solver() template<class Type> -Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve() +Foam::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve() { return solve ( @@ -200,7 +298,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::fvSolver::solve() template<class Type> -Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve() +Foam::solverPerformance Foam::fvMatrix<Type>::solve() { return solve ( @@ -245,7 +343,7 @@ Foam::tmp<Foam::Field<Type> > Foam::fvMatrix<Type>::residual() const psiCmpt, res.component(cmpt) - boundaryDiagCmpt*psiCmpt, bouCoeffsCmpt, - psi_.boundaryField().interfaces(), + psi_.boundaryField().scalarInterfaces(), cmpt ) ); diff --git a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C index 9b4b92af5131581c812d4786a5c87108383cc7f4..bd75991ca9cebca2d7031b0f04a5c022055e34ad 100644 --- a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C +++ b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,7 +80,7 @@ Foam::fvMatrix<Foam::scalar>::solver *this, boundaryCoeffs_, internalCoeffs_, - psi_.boundaryField().interfaces(), + psi_.boundaryField().scalarInterfaces(), solverControls ) ) @@ -93,7 +93,7 @@ Foam::fvMatrix<Foam::scalar>::solver template<> -Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve +Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve ( const dictionary& solverControls ) @@ -111,13 +111,13 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve // assign new solver controls solver_->read(solverControls); - lduMatrix::solverPerformance solverPerf = solver_->solve + solverPerformance solverPerf = solver_->solve ( psi.internalField(), totalSource ); - solverPerf.print(); + solverPerf.print(Info); fvMat_.diag() = saveDiag; @@ -130,14 +130,15 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve template<> -Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve +Foam::solverPerformance Foam::fvMatrix<Foam::scalar>::solveSegregated ( const dictionary& solverControls ) { if (debug) { - Info<< "fvMatrix<scalar>::solve(const dictionary& solverControls) : " + Info<< "fvMatrix<scalar>::solveSegregated" + "(const dictionary& solverControls) : " "solving fvMatrix<scalar>" << endl; } @@ -152,17 +153,17 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve addBoundarySource(totalSource, false); // Solver call - lduMatrix::solverPerformance solverPerf = lduMatrix::solver::New + solverPerformance solverPerf = lduMatrix::solver::New ( psi.name(), *this, boundaryCoeffs_, internalCoeffs_, - psi.boundaryField().interfaces(), + psi.boundaryField().scalarInterfaces(), solverControls )->solve(psi.internalField(), totalSource); - solverPerf.print(); + solverPerf.print(Info); diag() = saveDiag; @@ -187,7 +188,7 @@ Foam::tmp<Foam::scalarField> Foam::fvMatrix<Foam::scalar>::residual() const psi_.internalField(), source_ - boundaryDiag*psi_.internalField(), boundaryCoeffs_, - psi_.boundaryField().interfaces(), + psi_.boundaryField().scalarInterfaces(), 0 ) ); diff --git a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H index 072c9f2cd09e0de014046fb5dfa78b41546bd239..dc0d89db4d5a2bb5da4c87c588cfb6506c53ee5e 100644 --- a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H +++ b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -62,13 +62,13 @@ autoPtr<fvMatrix<scalar>::fvSolver> fvMatrix<scalar>::solver ); template<> -lduMatrix::solverPerformance fvMatrix<scalar>::fvSolver::solve +solverPerformance fvMatrix<scalar>::fvSolver::solve ( const dictionary& ); template<> -lduMatrix::solverPerformance fvMatrix<scalar>::solve +solverPerformance fvMatrix<scalar>::solveSegregated ( const dictionary& ); diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 98346e4c777b4acf0510d202dc092624845245d0..0889270894b03b7d3e63a27558fcbbd3b396f0be 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -295,7 +295,7 @@ Foam::fvMesh::fvMesh fvSchemes(static_cast<const objectRegistry&>(*this)), fvSolution(static_cast<const objectRegistry&>(*this)), data(static_cast<const objectRegistry&>(*this)), - boundary_(*this), + boundary_(*this, boundaryMesh()), lduPtr_(NULL), curTimeIndex_(time().timeIndex()), VPtr_(NULL), diff --git a/src/fvMotionSolver/Make/files b/src/fvMotionSolver/Make/files index bea2f1065699047d4470169b4a9b92cbb1e1e0c7..cdaf67e6afa5fe670d13d35b24faf34c2c619560 100644 --- a/src/fvMotionSolver/Make/files +++ b/src/fvMotionSolver/Make/files @@ -26,13 +26,20 @@ motionDiffusivity/manipulators/exponential/exponentialDiffusivity.C fvPatchFields/derived/cellMotion/cellMotionFvPatchFields.C fvPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementFvPatchFields.C -pointPatchFields/derived/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C -pointPatchFields/derived/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C - -pointPatchFields/derived/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C -pointPatchFields/derived/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C -pointPatchFields/derived/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C -pointPatchFields/derived/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C -pointPatchFields/derived/waveDisplacement/waveDisplacementPointPatchVectorField.C +derivedPoint = pointPatchFields/derived + +$(derivedPoint)/oscillatingVelocity/oscillatingVelocityPointPatchVectorField.C +$(derivedPoint)/angularOscillatingVelocity/angularOscillatingVelocityPointPatchVectorField.C + +$(derivedPoint)/oscillatingDisplacement/oscillatingDisplacementPointPatchVectorField.C +$(derivedPoint)/angularOscillatingDisplacement/angularOscillatingDisplacementPointPatchVectorField.C +$(derivedPoint)/surfaceSlipDisplacement/surfaceSlipDisplacementPointPatchVectorField.C +$(derivedPoint)/surfaceDisplacement/surfaceDisplacementPointPatchVectorField.C +$(derivedPoint)/waveDisplacement/waveDisplacementPointPatchVectorField.C + +$(derivedPoint)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.C +$(derivedPoint)/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C + + LIB = $(FOAM_LIBBIN)/libfvMotionSolvers diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C new file mode 100644 index 0000000000000000000000000000000000000000..1fa44b5d64c0c54c14453a7f49270a89f6081a4e --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.C @@ -0,0 +1,482 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "timeVaryingMappedFixedValuePointPatchField.H" +#include "Time.H" +#include "AverageIOField.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template<class Type> +Foam:: +timeVaryingMappedFixedValuePointPatchField<Type>:: +timeVaryingMappedFixedValuePointPatchField +( + const pointPatch& p, + const DimensionedField<Type, pointMesh>& iF +) +: + fixedValuePointPatchField<Type>(p, iF), + fieldTableName_(iF.name()), + setAverage_(false), + perturb_(0), + sampleTimes_(0), + startSampleTime_(-1), + startSampledValues_(0), + startAverage_(pTraits<Type>::zero), + endSampleTime_(-1), + endSampledValues_(0), + endAverage_(pTraits<Type>::zero) + +{} + + +template<class Type> +Foam:: +timeVaryingMappedFixedValuePointPatchField<Type>:: +timeVaryingMappedFixedValuePointPatchField +( + const timeVaryingMappedFixedValuePointPatchField<Type>& ptf, + const pointPatch& p, + const DimensionedField<Type, pointMesh>& iF, + const pointPatchFieldMapper& mapper +) +: + fixedValuePointPatchField<Type>(ptf, p, iF, mapper), + fieldTableName_(ptf.fieldTableName_), + setAverage_(ptf.setAverage_), + perturb_(ptf.perturb_), + mapperPtr_(ptf.mapperPtr_), + sampleTimes_(0), + startSampleTime_(-1), + startSampledValues_(0), + startAverage_(pTraits<Type>::zero), + endSampleTime_(-1), + endSampledValues_(0), + endAverage_(pTraits<Type>::zero) +{} + + +template<class Type> +Foam:: +timeVaryingMappedFixedValuePointPatchField<Type>:: +timeVaryingMappedFixedValuePointPatchField +( + const pointPatch& p, + const DimensionedField<Type, pointMesh>& iF, + const dictionary& dict +) +: + fixedValuePointPatchField<Type>(p, iF), + fieldTableName_(iF.name()), + setAverage_(readBool(dict.lookup("setAverage"))), + perturb_(dict.lookupOrDefault("perturb", 1e-5)), + mapperPtr_(NULL), + sampleTimes_(0), + startSampleTime_(-1), + startSampledValues_(0), + startAverage_(pTraits<Type>::zero), + endSampleTime_(-1), + endSampledValues_(0), + endAverage_(pTraits<Type>::zero) +{ + dict.readIfPresent("fieldTableName", fieldTableName_); + updateCoeffs(); +} + + +template<class Type> +Foam:: +timeVaryingMappedFixedValuePointPatchField<Type>:: +timeVaryingMappedFixedValuePointPatchField +( + const timeVaryingMappedFixedValuePointPatchField<Type>& ptf +) +: + fixedValuePointPatchField<Type>(ptf), + fieldTableName_(ptf.fieldTableName_), + setAverage_(ptf.setAverage_), + perturb_(ptf.perturb_), + mapperPtr_(ptf.mapperPtr_), + sampleTimes_(ptf.sampleTimes_), + startSampleTime_(ptf.startSampleTime_), + startSampledValues_(ptf.startSampledValues_), + startAverage_(ptf.startAverage_), + endSampleTime_(ptf.endSampleTime_), + endSampledValues_(ptf.endSampledValues_), + endAverage_(ptf.endAverage_) +{} + + +template<class Type> +Foam:: +timeVaryingMappedFixedValuePointPatchField<Type>:: +timeVaryingMappedFixedValuePointPatchField +( + const timeVaryingMappedFixedValuePointPatchField<Type>& ptf, + const DimensionedField<Type, pointMesh>& iF +) +: + fixedValuePointPatchField<Type>(ptf, iF), + fieldTableName_(ptf.fieldTableName_), + setAverage_(ptf.setAverage_), + perturb_(ptf.perturb_), + mapperPtr_(ptf.mapperPtr_), + sampleTimes_(ptf.sampleTimes_), + startSampleTime_(ptf.startSampleTime_), + startSampledValues_(ptf.startSampledValues_), + startAverage_(ptf.startAverage_), + endSampleTime_(ptf.endSampleTime_), + endSampledValues_(ptf.endSampledValues_), + endAverage_(ptf.endAverage_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::checkTable() +{ + // Initialise + if (startSampleTime_ == -1 && endSampleTime_ == -1) + { + const polyMesh& pMesh = this->patch().boundaryMesh().mesh()(); + + // Read the initial point position + pointField meshPts; + + if (pMesh.pointsInstance() == pMesh.facesInstance()) + { + meshPts = pointField(pMesh.points(), this->patch().meshPoints()); + } + else + { + // Load points from facesInstance + if (debug) + { + Info<< "Reloading points0 from " << pMesh.facesInstance() + << endl; + } + + pointIOField points0 + ( + IOobject + ( + "points", + pMesh.facesInstance(), + polyMesh::meshSubDir, + pMesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + meshPts = pointField(points0, this->patch().meshPoints()); + } + + pointIOField samplePoints + ( + IOobject + ( + "points", + this->db().time().constant(), + "boundaryData"/this->patch().name(), + this->db(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + false + ) + ); + + mapperPtr_.reset + ( + new pointToPointPlanarInterpolation + ( + samplePoints, + meshPts, + perturb_ + ) + ); + + // Read the times for which data is available + + const fileName samplePointsFile = samplePoints.filePath(); + const fileName samplePointsDir = samplePointsFile.path(); + sampleTimes_ = Time::findTimes(samplePointsDir); + + if (debug) + { + Info<< "timeVaryingMappedFixedValuePointPatchField : In directory " + << samplePointsDir << " found times " + << pointToPointPlanarInterpolation::timeNames(sampleTimes_) + << endl; + } + } + + // Find current time in sampleTimes + label lo = -1; + label hi = -1; + + bool foundTime = mapperPtr_().findTime + ( + sampleTimes_, + startSampleTime_, + this->db().time().value(), + lo, + hi + ); + + if (!foundTime) + { + FatalErrorIn + ( + "timeVaryingMappedFixedValuePointPatchField<Type>::checkTable" + ) << "Cannot find starting sampling values for current time " + << this->db().time().value() << nl + << "Have sampling values for times " + << pointToPointPlanarInterpolation::timeNames(sampleTimes_) << nl + << "In directory " + << this->db().time().constant()/"boundaryData"/this->patch().name() + << "\n on patch " << this->patch().name() + << " of field " << fieldTableName_ + << exit(FatalError); + } + + + // Update sampled data fields. + + if (lo != startSampleTime_) + { + startSampleTime_ = lo; + + if (startSampleTime_ == endSampleTime_) + { + // No need to reread since are end values + if (debug) + { + Pout<< "checkTable : Setting startValues to (already read) " + << "boundaryData" + /this->patch().name() + /sampleTimes_[startSampleTime_].name() + << endl; + } + startSampledValues_ = endSampledValues_; + startAverage_ = endAverage_; + } + else + { + if (debug) + { + Pout<< "checkTable : Reading startValues from " + << "boundaryData" + /this->patch().name() + /sampleTimes_[lo].name() + << endl; + } + + // Reread values and interpolate + AverageIOField<Type> vals + ( + IOobject + ( + fieldTableName_, + this->db().time().constant(), + "boundaryData" + /this->patch().name() + /sampleTimes_[startSampleTime_].name(), + this->db(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + false + ) + ); + + startAverage_ = vals.average(); + startSampledValues_ = mapperPtr_().interpolate(vals); + } + } + + if (hi != endSampleTime_) + { + endSampleTime_ = hi; + + if (endSampleTime_ == -1) + { + // endTime no longer valid. Might as well clear endValues. + if (debug) + { + Pout<< "checkTable : Clearing endValues" << endl; + } + endSampledValues_.clear(); + } + else + { + if (debug) + { + Pout<< "checkTable : Reading endValues from " + << "boundaryData" + /this->patch().name() + /sampleTimes_[endSampleTime_].name() + << endl; + } + // Reread values and interpolate + AverageIOField<Type> vals + ( + IOobject + ( + fieldTableName_, + this->db().time().constant(), + "boundaryData" + /this->patch().name() + /sampleTimes_[endSampleTime_].name(), + this->db(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE, + false + ) + ); + endAverage_ = vals.average(); + endSampledValues_ = mapperPtr_().interpolate(vals); + } + } +} + + +template<class Type> +void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + checkTable(); + + // Interpolate between the sampled data + + Type wantedAverage; + + if (endSampleTime_ == -1) + { + // only start value + if (debug) + { + Pout<< "updateCoeffs : Sampled, non-interpolated values" + << " from start time:" + << sampleTimes_[startSampleTime_].name() << nl; + } + + this->operator==(startSampledValues_); + wantedAverage = startAverage_; + } + else + { + scalar start = sampleTimes_[startSampleTime_].value(); + scalar end = sampleTimes_[endSampleTime_].value(); + + scalar s = (this->db().time().value()-start)/(end-start); + + if (debug) + { + Pout<< "updateCoeffs : Sampled, interpolated values" + << " between start time:" + << sampleTimes_[startSampleTime_].name() + << " and end time:" << sampleTimes_[endSampleTime_].name() + << " with weight:" << s << endl; + } + + this->operator==((1-s)*startSampledValues_ + s*endSampledValues_); + wantedAverage = (1-s)*startAverage_ + s*endAverage_; + } + + // Enforce average. Either by scaling (if scaling factor > 0.5) or by + // offsetting. + if (setAverage_) + { + const Field<Type>& fld = *this; + + Type averagePsi = gAverage(fld); + + if (debug) + { + Pout<< "updateCoeffs :" + << " actual average:" << averagePsi + << " wanted average:" << wantedAverage + << endl; + } + + if (mag(averagePsi) < VSMALL) + { + // Field too small to scale. Offset instead. + const Type offset = wantedAverage - averagePsi; + if (debug) + { + Pout<< "updateCoeffs :" + << " offsetting with:" << offset << endl; + } + this->operator==(fld+offset); + } + else + { + const scalar scale = mag(wantedAverage)/mag(averagePsi); + + if (debug) + { + Pout<< "updateCoeffs :" + << " scaling with:" << scale << endl; + } + this->operator==(scale*fld); + } + } + + if (debug) + { + Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this) + << " max:" << gMax(*this) << endl; + } + + fixedValuePointPatchField<Type>::updateCoeffs(); +} + + +template<class Type> +void Foam::timeVaryingMappedFixedValuePointPatchField<Type>::write +( + Ostream& os +) const +{ + fixedValuePointPatchField<Type>::write(os); + os.writeKeyword("setAverage") << setAverage_ << token::END_STATEMENT << nl; + os.writeKeyword("perturb") << perturb_ << token::END_STATEMENT << nl; + + if (fieldTableName_ != this->dimensionedInternalField().name()) + { + os.writeKeyword("fieldTableName") << fieldTableName_ + << token::END_STATEMENT << nl; + } +} + + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.H b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.H new file mode 100644 index 0000000000000000000000000000000000000000..108ec6786ee9b4a804ec0e5c1ebe0068f56ae538 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchField.H @@ -0,0 +1,195 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::timeVaryingMappedFixedValuePointPatchField + +Description + A time-varying form of a mapped fixed value boundary condition. + +See Also + Foam::timeVaryingMappedFixedValueFvPatchField + +SourceFiles + timeVaryingMappedFixedValuePointPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef timeVaryingMappedFixedValuePointPatchField_H +#define timeVaryingMappedFixedValuePointPatchField_H + +#include "fixedValuePointPatchField.H" +#include "instantList.H" +#include "pointToPointPlanarInterpolation.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class timeVaryingMappedFixedValuePointPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template<class Type> +class timeVaryingMappedFixedValuePointPatchField +: + public fixedValuePointPatchField<Type> +{ + // Private data + + //- Name of the field data table, defaults to the name of the field + word fieldTableName_; + + //- If true adjust the mapped field to maintain average value + bool setAverage_; + + //- Fraction of perturbation (fraction of bounding box) to add + scalar perturb_; + + //- 2D interpolation + autoPtr<pointToPointPlanarInterpolation> mapperPtr_; + + //- List of boundaryData time directories + instantList sampleTimes_; + + //- Current starting index in sampleTimes + label startSampleTime_; + + //- Interpolated values from startSampleTime + Field<Type> startSampledValues_; + + //- If setAverage: starting average value + Type startAverage_; + + //- Current end index in sampleTimes + label endSampleTime_; + + //- Interpolated values from endSampleTime + Field<Type> endSampledValues_; + + //- If setAverage: end average value + Type endAverage_; + + +public: + + //- Runtime type information + TypeName("timeVaryingMappedFixedValue"); + + + // Constructors + + //- Construct from patch and internal field + timeVaryingMappedFixedValuePointPatchField + ( + const pointPatch&, + const DimensionedField<Type, pointMesh>& + ); + + //- Construct from patch, internal field and dictionary + timeVaryingMappedFixedValuePointPatchField + ( + const pointPatch&, + const DimensionedField<Type, pointMesh>&, + const dictionary& + ); + + //- Construct by mapping given patch field onto a new patch + timeVaryingMappedFixedValuePointPatchField + ( + const timeVaryingMappedFixedValuePointPatchField<Type>&, + const pointPatch&, + const DimensionedField<Type, pointMesh>&, + const pointPatchFieldMapper& + ); + + //- Construct as copy + timeVaryingMappedFixedValuePointPatchField + ( + const timeVaryingMappedFixedValuePointPatchField<Type>& + ); + + //- Construct and return a clone + virtual autoPtr<pointPatchField<Type> > clone() const + { + return autoPtr<pointPatchField<Type> > + ( + new timeVaryingMappedFixedValuePointPatchField<Type>(*this) + ); + } + + //- Construct as copy setting internal field reference + timeVaryingMappedFixedValuePointPatchField + ( + const timeVaryingMappedFixedValuePointPatchField<Type>&, + const DimensionedField<Type, pointMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual autoPtr<pointPatchField<Type> > clone + ( + const DimensionedField<Type, pointMesh>& iF + ) const + { + return autoPtr<pointPatchField<Type> > + ( + new timeVaryingMappedFixedValuePointPatchField<Type>(*this, iF) + ); + } + + + // Member functions + + // Utility functions + + //- Find boundary data inbetween current time and interpolate + void checkTable(); + + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); + + + //- Write + virtual void write(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "timeVaryingMappedFixedValuePointPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.C b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.C new file mode 100644 index 0000000000000000000000000000000000000000..ed847ab52d32588863e1b34e5c52c57f823018f1 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "timeVaryingMappedFixedValuePointPatchFields.H" +#include "pointPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePointPatchFields(timeVaryingMappedFixedValue); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchScalarField.H b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.H similarity index 65% rename from src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchScalarField.H rename to src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.H index 6dbbb04559714c16018ebc6389cecaec37a904fa..ad06b48066912a0505c9c6256ad3ff15c08925bb 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processorCyclic/processorCyclicFvPatchScalarField.H +++ b/src/fvMotionSolver/pointPatchFields/derived/timeVaryingMappedFixedValue/timeVaryingMappedFixedValuePointPatchFields.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,49 +21,35 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. +InClass + Foam::timeVaryingMappedFixedValuePointPatchFields + +Description + +SourceFiles + timeVaryingMappedFixedValuePointPatchFields.C + \*---------------------------------------------------------------------------*/ -#ifndef processorCyclicFvPatchScalarField_H -#define processorCyclicFvPatchScalarField_H +#ifndef timeVaryingMappedFixedValuePointPatchFields_H +#define timeVaryingMappedFixedValuePointPatchFields_H -#include "processorCyclicFvPatchField.H" +#include "timeVaryingMappedFixedValuePointPatchField.H" +#include "fieldTypes.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -//template<> -//void processorCyclicFvPatchField<scalar>::initInterfaceMatrixUpdate -//( -// const scalarField&, -// scalarField&, -// const lduMatrix&, -// const scalarField&, -// const direction, -// const Pstream::commsTypes commsType -//) const; -// -// -//template<> -//void processorCyclicFvPatchField<scalar>::updateInterfaceMatrix -//( -// const scalarField&, -// scalarField& result, -// const lduMatrix&, -// const scalarField& coeffs, -// const direction, -// const Pstream::commsTypes commsType -//) const; +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +makePointPatchFieldTypedefs(timeVaryingMappedFixedValue); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C new file mode 100644 index 0000000000000000000000000000000000000000..21b5e74224fbf6fa79330dbbe9372195f92f9d9c --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C @@ -0,0 +1,291 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "uniformInterpolatedDisplacementPointPatchVectorField.H" +#include "pointPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "Time.H" +#include "polyMesh.H" +#include "interpolationWeights.H" +#include "uniformInterpolate.H" +#include "ReadFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +uniformInterpolatedDisplacementPointPatchVectorField:: +uniformInterpolatedDisplacementPointPatchVectorField +( + const pointPatch& p, + const DimensionedField<vector, pointMesh>& iF +) +: + fixedValuePointPatchField<vector>(p, iF) +{} + + +uniformInterpolatedDisplacementPointPatchVectorField:: +uniformInterpolatedDisplacementPointPatchVectorField +( + const pointPatch& p, + const DimensionedField<vector, pointMesh>& iF, + const dictionary& dict +) +: + fixedValuePointPatchField<vector>(p, iF, dict), + fieldName_(dict.lookup("fieldName")), + interpolationScheme_(dict.lookup("interpolationScheme")) +{ + const pointMesh& pMesh = this->dimensionedInternalField().mesh(); + + // Read time values + instantList allTimes = Time::findTimes(pMesh().time().path()); + + // Only keep those that contain the field + DynamicList<word> names(allTimes.size()); + DynamicList<scalar> values(allTimes.size()); + + forAll(allTimes, i) + { + IOobject io + ( + fieldName_, + allTimes[i].name(), + pMesh(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ); + if (io.headerOk()) + { + names.append(allTimes[i].name()); + values.append(allTimes[i].value()); + } + } + timeNames_.transfer(names); + timeVals_.transfer(values); + + Info<< type() << " : found " << fieldName_ << " for times " + << timeNames_ << endl; + + if (timeNames_.size() < 1) + { + FatalErrorIn + ( + "uniformInterpolatedDisplacementPointPatchVectorField::\n" + "uniformInterpolatedDisplacementPointPatchVectorField\n" + "(\n" + " const pointPatch&,\n" + " const DimensionedField<vector, pointMesh>&,\n" + " const dictionary&\n" + ")\n" + ) << "Did not find any times with " << fieldName_ + << exit(FatalError); + } + + + if (!dict.found("value")) + { + updateCoeffs(); + } +} + + +uniformInterpolatedDisplacementPointPatchVectorField:: +uniformInterpolatedDisplacementPointPatchVectorField +( + const uniformInterpolatedDisplacementPointPatchVectorField& ptf, + const pointPatch& p, + const DimensionedField<vector, pointMesh>& iF, + const pointPatchFieldMapper& mapper +) +: + fixedValuePointPatchField<vector>(ptf, p, iF, mapper), + fieldName_(ptf.fieldName_), + interpolationScheme_(ptf.interpolationScheme_), + timeNames_(ptf.timeNames_), + timeVals_(ptf.timeVals_), + interpolatorPtr_(ptf.interpolatorPtr_) +{} + + +uniformInterpolatedDisplacementPointPatchVectorField:: +uniformInterpolatedDisplacementPointPatchVectorField +( + const uniformInterpolatedDisplacementPointPatchVectorField& ptf, + const DimensionedField<vector, pointMesh>& iF +) +: + fixedValuePointPatchField<vector>(ptf, iF), + fieldName_(ptf.fieldName_), + interpolationScheme_(ptf.interpolationScheme_), + timeNames_(ptf.timeNames_), + timeVals_(ptf.timeVals_), + interpolatorPtr_(ptf.interpolatorPtr_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void uniformInterpolatedDisplacementPointPatchVectorField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + if (!interpolatorPtr_.valid()) + { + interpolatorPtr_ = interpolationWeights::New + ( + interpolationScheme_, + timeVals_ + ); + } + + const pointMesh& pMesh = this->dimensionedInternalField().mesh(); + const Time& t = pMesh().time(); + + // Update indices of times and weights + bool timesChanged = interpolatorPtr_->valueWeights + ( + t.timeOutputValue(), + currentIndices_, + currentWeights_ + ); + + const wordList currentTimeNames + ( + UIndirectList<word>(timeNames_, currentIndices_) + ); + + + // Load if necessary fields for this interpolation + if (timesChanged) + { + objectRegistry& fieldsCache = const_cast<objectRegistry&> + ( + pMesh.thisDb().subRegistry("fieldsCache", true) + ); + // Save old times so we now which ones have been loaded and need + // 'correctBoundaryConditions'. Bit messy. + HashSet<word> oldTimes(fieldsCache.toc()); + + ReadFields<pointVectorField> + ( + fieldName_, + pMesh, + currentTimeNames + ); + + forAllConstIter(objectRegistry, fieldsCache, fieldsCacheIter) + { + if (!oldTimes.found(fieldsCacheIter.key())) + { + // Newly loaded fields. Make sure the internal + // values are consistent with the boundary conditions. + // This is quite often not the case since these + // fields typically are constructed 'by hand' + + const objectRegistry& timeCache = dynamic_cast + < + const objectRegistry& + >(*fieldsCacheIter()); + + + pointVectorField& d = const_cast<pointVectorField&> + ( + timeCache.lookupObject<pointVectorField> + ( + fieldName_ + ) + ); + d.correctBoundaryConditions(); + } + } + } + + + // Interpolate the whole field + pointVectorField result + ( + uniformInterpolate<pointVectorField> + ( + IOobject + ( + word("uniformInterpolate(") + + this->dimensionedInternalField().name() + + ')', + pMesh.time().timeName(), + pMesh.thisDb(), + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + fieldName_, + currentTimeNames, + currentWeights_ + ) + ); + + + // Extract back from the internal field + this->operator== + ( + this->patchInternalField(result.dimensionedInternalField()) + ); + + fixedValuePointPatchField<vector>::updateCoeffs(); +} + + +void uniformInterpolatedDisplacementPointPatchVectorField::write(Ostream& os) +const +{ + pointPatchField<vector>::write(os); + os.writeKeyword("fieldName") + << fieldName_ << token::END_STATEMENT << nl; + os.writeKeyword("interpolationScheme") + << interpolationScheme_ << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePointPatchTypeField +( + pointPatchVectorField, + uniformInterpolatedDisplacementPointPatchVectorField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.H b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.H new file mode 100644 index 0000000000000000000000000000000000000000..bd1beb36ff6523c2dff32677a679c8938f4e8f21 --- /dev/null +++ b/src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.H @@ -0,0 +1,183 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::uniformInterpolatedDisplacementPointPatchVectorField + +Description + Interpolates pre-specified motion. + + Motion specified as pointVectorFields. E.g. + + walls + { + type uniformInterpolatedDisplacement; + value uniform (0 0 0); + fieldName wantedDisplacement; + interpolationScheme linear; + } + + This will scan the case for 'wantedDisplacement' pointVectorFields + and interpolate those in time (using 'linear' interpolation) to + obtain the current displacement. + The advantage of specifying displacement in this way is that it + automatically works through decomposePar. + +SourceFiles + uniformInterpolatedDisplacementPointPatchVectorField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef uniformInterpolatedDisplacementPointPatchVectorField_H +#define uniformInterpolatedDisplacementPointPatchVectorField_H + +#include "fixedValuePointPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class interpolationWeights; + +/*---------------------------------------------------------------------------*\ + Class uniformInterpolatedDisplacementPointPatchVectorField Declaration +\*---------------------------------------------------------------------------*/ + +class uniformInterpolatedDisplacementPointPatchVectorField +: + public fixedValuePointPatchField<vector> +{ + // Private data + + //- Name of displacement field + const word fieldName_; + + const word interpolationScheme_; + + //- Times with pre-specified displacement + wordList timeNames_; + + //- Times with pre-specified displacement + scalarField timeVals_; + + //- User-specified interpolator + autoPtr<interpolationWeights> interpolatorPtr_; + + + //- Cached interpolation times + labelList currentIndices_; + + //- Cached interpolation weights + scalarField currentWeights_; + +public: + + //- Runtime type information + TypeName("uniformInterpolatedDisplacement"); + + + // Constructors + + //- Construct from patch and internal field + uniformInterpolatedDisplacementPointPatchVectorField + ( + const pointPatch&, + const DimensionedField<vector, pointMesh>& + ); + + //- Construct from patch, internal field and dictionary + uniformInterpolatedDisplacementPointPatchVectorField + ( + const pointPatch&, + const DimensionedField<vector, pointMesh>&, + const dictionary& + ); + + //- Construct by mapping given patchField<vector> onto a new patch + uniformInterpolatedDisplacementPointPatchVectorField + ( + const uniformInterpolatedDisplacementPointPatchVectorField&, + const pointPatch&, + const DimensionedField<vector, pointMesh>&, + const pointPatchFieldMapper& + ); + + //- Construct and return a clone + virtual autoPtr<pointPatchField<vector> > clone() const + { + return autoPtr<pointPatchField<vector> > + ( + new uniformInterpolatedDisplacementPointPatchVectorField + ( + *this + ) + ); + } + + //- Construct as copy setting internal field reference + uniformInterpolatedDisplacementPointPatchVectorField + ( + const uniformInterpolatedDisplacementPointPatchVectorField&, + const DimensionedField<vector, pointMesh>& + ); + + //- Construct and return a clone setting internal field reference + virtual autoPtr<pointPatchField<vector> > clone + ( + const DimensionedField<vector, pointMesh>& iF + ) const + { + return autoPtr<pointPatchField<vector> > + ( + new uniformInterpolatedDisplacementPointPatchVectorField + ( + *this, + iF + ) + ); + } + + + // Member functions + + // Evaluation 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/src/mesh/Allwmake b/src/mesh/Allwmake index 712094055c7ab0be1d0b397d567e62be4b98e2a8..4653b1d3c4db8c78ca7b8af79e1399ae423d30fa 100755 --- a/src/mesh/Allwmake +++ b/src/mesh/Allwmake @@ -5,5 +5,6 @@ set -x wmake $makeType autoMesh wmake $makeType blockMesh +wmake $makeType extrudeModel # ----------------------------------------------------------------- end-of-file diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C index 2ebf0b140d29ad3d1d2b1384d9844362fdbe4413..6347d5dd16e65d359dd3eb2793857d0011fed803 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoSnapDriverFeature.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -1202,10 +1202,23 @@ void Foam::autoSnapDriver::featureAttractionUsingFeatureEdges // Reverse lookup : go through all edgeAttractors and find the // nearest point on pp + // Get search domain and extend it a bit + treeBoundBox bb(pp.localPoints()); + { + // Random number generator. Bit dodgy since not exactly random ;-) + Random rndGen(65431); + + // Slightly extended bb. Slightly off-centred just so on symmetric + // geometry there are less face/edge aligned items. + bb = bb.extend(rndGen, 1e-4); + bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + } + indexedOctree<treeDataPoint> ppTree ( treeDataPoint(pp.localPoints()), - treeBoundBox(pp.localPoints()), // overall search domain + bb, // overall search domain 8, // maxLevel 10, // leafsize 3.0 // duplicity diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C index e12394624b1e8200444b7c12704af81cf663241c..2890577c24b01fc80a96fc092a785248966a5dba 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinement.C @@ -1881,7 +1881,7 @@ void Foam::meshRefinement::distribute(const mapDistributePolyMesh& map) List<treeBoundBox> meshBb(1); treeBoundBox& bb = meshBb[0]; bb = treeBoundBox(mesh_.points()); - bb = bb.extend(rndGen, 1E-4); + bb = bb.extend(rndGen, 1e-4); // Distribute all geometry (so refinementSurfaces and shellSurfaces) searchableSurfaces& geometry = diff --git a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C index 076fd11e2fd4963e890f01df0188d31f9715858c..977f75dbd45b0551d2c43fa7f04ed3d9ea6d1002 100644 --- a/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C +++ b/src/mesh/autoMesh/autoHexMesh/meshRefinement/meshRefinementBaffles.C @@ -1073,7 +1073,7 @@ void Foam::meshRefinement::findCellZoneGeometric label nei = faceNeighbour[faceI]; const point& neiCc = cellCentres[nei]; // Perturbed cc - const vector d = 1E-4*(neiCc - ownCc); + const vector d = 1e-4*(neiCc - ownCc); candidatePoints[nCandidates++] = ownCc-d; candidatePoints[nCandidates++] = neiCc+d; } @@ -1081,7 +1081,7 @@ void Foam::meshRefinement::findCellZoneGeometric { const point& neiFc = mesh_.faceCentres()[faceI]; // Perturbed cc - const vector d = 1E-4*(neiFc - ownCc); + const vector d = 1e-4*(neiFc - ownCc); candidatePoints[nCandidates++] = ownCc-d; } } diff --git a/src/mesh/autoMesh/autoHexMesh/refinementFeatures/refinementFeatures.C b/src/mesh/autoMesh/autoHexMesh/refinementFeatures/refinementFeatures.C index 1c88348f99d2c1d3b49728af2afd1cd433f97328..56533c0b004eafbbb8ce3a7cc095fc8185446a89 100644 --- a/src/mesh/autoMesh/autoHexMesh/refinementFeatures/refinementFeatures.C +++ b/src/mesh/autoMesh/autoHexMesh/refinementFeatures/refinementFeatures.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -93,7 +93,7 @@ Foam::refinementFeatures::refinementFeatures // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. - bb = bb.extend(rndGen, 1E-4); + bb = bb.extend(rndGen, 1e-4); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/Make/files b/src/mesh/extrudeModel/Make/files similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/Make/files rename to src/mesh/extrudeModel/Make/files diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/Make/options b/src/mesh/extrudeModel/Make/options similarity index 74% rename from applications/utilities/mesh/generation/extrude/extrudeModel/Make/options rename to src/mesh/extrudeModel/Make/options index 1618ab57ec2d869d439de31fd8ead10e6f2b8ae2..eabd0b53a8ffd8a16a228d71ae038fac7e2ea6a2 100644 --- a/applications/utilities/mesh/generation/extrude/extrudeModel/Make/options +++ b/src/mesh/extrudeModel/Make/options @@ -3,5 +3,4 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicMesh/lnInclude LIB_LIBS = \ - -lmeshTools \ - -ldynamicMesh + -lmeshTools diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/extrudeModel/extrudeModel.C b/src/mesh/extrudeModel/extrudeModel/extrudeModel.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/extrudeModel/extrudeModel.C rename to src/mesh/extrudeModel/extrudeModel/extrudeModel.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/extrudeModel/extrudeModel.H b/src/mesh/extrudeModel/extrudeModel/extrudeModel.H similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/extrudeModel/extrudeModel.H rename to src/mesh/extrudeModel/extrudeModel/extrudeModel.H diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/extrudeModel/extrudeModelNew.C b/src/mesh/extrudeModel/extrudeModel/extrudeModelNew.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/extrudeModel/extrudeModelNew.C rename to src/mesh/extrudeModel/extrudeModel/extrudeModelNew.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/linearDirection/linearDirection.C b/src/mesh/extrudeModel/linearDirection/linearDirection.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/linearDirection/linearDirection.C rename to src/mesh/extrudeModel/linearDirection/linearDirection.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/linearDirection/linearDirection.H b/src/mesh/extrudeModel/linearDirection/linearDirection.H similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/linearDirection/linearDirection.H rename to src/mesh/extrudeModel/linearDirection/linearDirection.H diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/linearNormal/linearNormal.C b/src/mesh/extrudeModel/linearNormal/linearNormal.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/linearNormal/linearNormal.C rename to src/mesh/extrudeModel/linearNormal/linearNormal.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/linearNormal/linearNormal.H b/src/mesh/extrudeModel/linearNormal/linearNormal.H similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/linearNormal/linearNormal.H rename to src/mesh/extrudeModel/linearNormal/linearNormal.H diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/linearRadial/linearRadial.C b/src/mesh/extrudeModel/linearRadial/linearRadial.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/linearRadial/linearRadial.C rename to src/mesh/extrudeModel/linearRadial/linearRadial.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/linearRadial/linearRadial.H b/src/mesh/extrudeModel/linearRadial/linearRadial.H similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/linearRadial/linearRadial.H rename to src/mesh/extrudeModel/linearRadial/linearRadial.H diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/sigmaRadial/sigmaRadial.C b/src/mesh/extrudeModel/sigmaRadial/sigmaRadial.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/sigmaRadial/sigmaRadial.C rename to src/mesh/extrudeModel/sigmaRadial/sigmaRadial.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/sigmaRadial/sigmaRadial.H b/src/mesh/extrudeModel/sigmaRadial/sigmaRadial.H similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/sigmaRadial/sigmaRadial.H rename to src/mesh/extrudeModel/sigmaRadial/sigmaRadial.H diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/wedge/wedge.C b/src/mesh/extrudeModel/wedge/wedge.C similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/wedge/wedge.C rename to src/mesh/extrudeModel/wedge/wedge.C diff --git a/applications/utilities/mesh/generation/extrude/extrudeModel/wedge/wedge.H b/src/mesh/extrudeModel/wedge/wedge.H similarity index 100% rename from applications/utilities/mesh/generation/extrude/extrudeModel/wedge/wedge.H rename to src/mesh/extrudeModel/wedge/wedge.H diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C index a5624af4be3ec5bd9f69b1bb38887d0aa202dc27..abc7875db6e1aa520f0cb079490fcdd97bfca714 100644 --- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -72,9 +72,8 @@ Foam::cyclicAMIGAMGInterfaceField::~cyclicAMIGAMGInterfaceField() void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H index ae4ede91e108348198f57232883ac44e1927ea1b..cb22cd61b6a0dce0bc7b5dd13a14799690f0e137 100644 --- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -110,9 +110,8 @@ public: //- Update result field based on interface functionality virtual void updateInterfaceMatrix ( - const scalarField& psiInternal, scalarField& result, - const lduMatrix&, + const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, const Pstream::commsTypes commsType diff --git a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H index d34c04406b4ea2aa5ff151b0ca1889472acf06c3..533437df0806f6abde904b38b2ec1fe508ecbfa4 100644 --- a/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H +++ b/src/meshTools/AMIInterpolation/patches/cyclic/cyclicAMILduInterfaceField/cyclicAMILduInterfaceField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -83,6 +83,10 @@ public: virtual int rank() const = 0; + //- Transform given patch field + template<class Type> + void transformCoupleField(Field<Type>& f) const; + //- Transform given patch internal field void transformCoupleField ( @@ -96,6 +100,30 @@ public: } // End namespace Foam +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "tensorField.H" + +template<class Type> +void Foam::cyclicAMILduInterfaceField::transformCoupleField +( + Field<Type>& f +) const +{ + if (doTransform()) + { + if (forwardT().size() == 1) + { + transform(f, forwardT()[0], f); + } + else + { + transform(f, forwardT(), f); + } + } +} + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 5912ea12e423618bc998e964cc4061d4be829be4..3329c2b28d1115a290a7cc0b4b11537fadc7cd11 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -158,6 +158,7 @@ triSurface/triangleFuncs/triangleFuncs.C triSurface/surfaceFeatures/surfaceFeatures.C triSurface/triSurfaceTools/triSurfaceTools.C triSurface/triSurfaceTools/geompack/geompack.C +triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C twoDPointCorrector/twoDPointCorrector.C diff --git a/src/meshTools/cellClassification/cellClassification.C b/src/meshTools/cellClassification/cellClassification.C index 4a33b4321ed0596582c2cf12279af3a3fda5b40d..6fc2b15a97808e593d3ad037a7c56a78e4dc05ad 100644 --- a/src/meshTools/cellClassification/cellClassification.C +++ b/src/meshTools/cellClassification/cellClassification.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -146,7 +146,7 @@ Foam::boolList Foam::cellClassification::markFaces treeBoundBox allBb(mesh_.points()); // Extend domain slightly (also makes it 3D if was 2D) - scalar tol = 1E-6 * allBb.avgDim(); + scalar tol = 1e-6 * allBb.avgDim(); point& bbMin = allBb.min(); bbMin.x() -= tol; @@ -187,7 +187,7 @@ Foam::boolList Foam::cellClassification::markFaces vector edgeNormal(end - start); const scalar edgeMag = mag(edgeNormal); - const vector smallVec = 1E-9*edgeNormal; + const vector smallVec = 1e-9*edgeNormal; edgeNormal /= edgeMag+VSMALL; diff --git a/src/meshTools/indexedOctree/treeDataFace.C b/src/meshTools/indexedOctree/treeDataFace.C index daa968fd5c88fa8f7b96168a5b924ebafdc0c96a..ca928ab1c724851881ac9816b4b4a12b6f992c85 100644 --- a/src/meshTools/indexedOctree/treeDataFace.C +++ b/src/meshTools/indexedOctree/treeDataFace.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,7 +31,7 @@ License defineTypeNameAndDebug(Foam::treeDataFace, 0); -Foam::scalar Foam::treeDataFace::tolSqr = sqr(1E-6); +Foam::scalar Foam::treeDataFace::tolSqr = sqr(1e-6); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C index bc9c0d4287fe8fda00ac21d5c3185b0bc99dc555..6927cbaa509d59a87b4b16c9ac46c387d0de5b12 100644 --- a/src/meshTools/indexedOctree/treeDataPrimitivePatch.C +++ b/src/meshTools/indexedOctree/treeDataPrimitivePatch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -38,7 +38,7 @@ template > Foam::scalar Foam::treeDataPrimitivePatch<Face, FaceList, PointField, PointType>:: -tolSqr = sqr(1E-6); +tolSqr = sqr(1e-6); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C index 79db701887c9b6194e5f6b6002d8128319e04f59..73d64b40f3e8c346f47ef372c3d905d93ef5d86d 100644 --- a/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C +++ b/src/meshTools/mappedPatches/mappedPolyPatch/mappedPatchBase.C @@ -265,7 +265,7 @@ void Foam::mappedPatchBase::findSamples treeBoundBox(pp.points(), pp.meshPoints()).extend ( rndGen, - 1E-4 + 1e-4 ) ); patchBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/meshTools/meshSearch/meshSearch.C b/src/meshTools/meshSearch/meshSearch.C index ab0975a43c4eb9c6d63804bf94ce8d9ba0ee594a..95245155312322a31faa88cb4b5ace87b727bdb7 100644 --- a/src/meshTools/meshSearch/meshSearch.C +++ b/src/meshTools/meshSearch/meshSearch.C @@ -35,7 +35,7 @@ License defineTypeNameAndDebug(Foam::meshSearch, 0); -Foam::scalar Foam::meshSearch::tol_ = 1E-3; +Foam::scalar Foam::meshSearch::tol_ = 1e-3; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -567,7 +567,7 @@ const Foam::indexedOctree<Foam::treeDataFace>& Foam::meshSearch::boundaryTree() treeBoundBox& overallBb = overallBbPtr_(); // Extend slightly and make 3D - overallBb = overallBb.extend(rndGen, 1E-4); + overallBb = overallBb.extend(rndGen, 1e-4); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); } @@ -620,7 +620,7 @@ const treeBoundBox& overallBb = overallBbPtr_(); // Extend slightly and make 3D - overallBb = overallBb.extend(rndGen, 1E-4); + overallBb = overallBb.extend(rndGen, 1e-4); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); } diff --git a/src/meshTools/meshTools/meshTools.C b/src/meshTools/meshTools/meshTools.C index 03edfc3825c0a2678087ad2f36b8ddf1dbe5202d..2cb27c39c71786f0bdab06eecb9b7d59690e3013 100644 --- a/src/meshTools/meshTools/meshTools.C +++ b/src/meshTools/meshTools/meshTools.C @@ -215,6 +215,39 @@ void Foam::meshTools::writeOBJ } +void Foam::meshTools::writeOBJ +( + Ostream& os, + const point& p1, + const point& p2, + label& count +) +{ + os << "v" << ' ' << p1.x() << ' ' << p1.y() << ' ' << p1.z() << endl; + os << "v" << ' ' << p2.x() << ' ' << p2.y() << ' ' << p2.z() << endl; + + os << "l" << " " << (count + 1) << " " << (count + 2) << endl; + + count += 2; +} + + +void Foam::meshTools::writeOBJ +( + Ostream& os, + const point& p1, + const point& p2 +) +{ + os << "v" << ' ' << p1.x() << ' ' << p1.y() << ' ' << p1.z() << endl; + + os << "vn" + << ' ' << p2.x() - p1.x() + << ' ' << p2.y() - p1.y() + << ' ' << p2.z() - p1.z() << endl; +} + + void Foam::meshTools::writeOBJ ( Ostream& os, diff --git a/src/meshTools/meshTools/meshTools.H b/src/meshTools/meshTools/meshTools.H index 65dff1f3b6e731d4e5645bcfb347d75ee978859e..3db94a8e5a7d93b4a3cf4f93f55e7d1d734a813d 100644 --- a/src/meshTools/meshTools/meshTools.H +++ b/src/meshTools/meshTools/meshTools.H @@ -107,6 +107,24 @@ namespace meshTools const point& pt ); + //- Write obj representation of a line connecting two points + // Need to keep track of points that have been added. count starts at 0 + void writeOBJ + ( + Ostream& os, + const point& p1, + const point& p2, + label& count + ); + + //- Write obj representation of a point p1 with a vector from p1 to p2 + void writeOBJ + ( + Ostream& os, + const point& p1, + const point& p2 + ); + //- Write obj representation of faces subset void writeOBJ ( diff --git a/src/meshTools/searchableSurface/searchablePlate.C b/src/meshTools/searchableSurface/searchablePlate.C index 604afc6f28fa01a056bfce266b39b0e3bfe7b221..37404db05117444141a9a024425f66ad2816ac78 100644 --- a/src/meshTools/searchableSurface/searchablePlate.C +++ b/src/meshTools/searchableSurface/searchablePlate.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -185,8 +185,8 @@ Foam::pointIndexHit Foam::searchablePlate::findLine if (info.hit()) { treeBoundBox bb(origin_, origin_+span_); - bb.min()[normalDir_] -= 1E-6; - bb.max()[normalDir_] += 1E-6; + bb.min()[normalDir_] -= 1e-6; + bb.max()[normalDir_] += 1e-6; if (!bb.contains(info.hitPoint())) { diff --git a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C index dd74c17135079b95e806541231d5e9ffec3bcebc..93c95778b86d7b2f160bd289f328e5d4c222d294 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C +++ b/src/meshTools/searchableSurface/searchableSurfaceWithGaps.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -242,7 +242,7 @@ void Foam::searchableSurfaceWithGaps::findLine // test in pairs: only if both perturbations hit something // do we accept the hit. - const vectorField smallVec(1E-6*(compactEnd-compactStart)); + const vectorField smallVec(1e-6*(compactEnd-compactStart)); List<pointIndexHit> plusInfo; surface().findLine @@ -296,7 +296,7 @@ void Foam::searchableSurfaceWithGaps::findLine offset0.setSize(plusMissMap.size()); offset1.setSize(plusMissMap.size()); - const vectorField smallVec(1E-6*(compactEnd-compactStart)); + const vectorField smallVec(1e-6*(compactEnd-compactStart)); surface().findLine ( diff --git a/src/meshTools/searchableSurface/triSurfaceMesh.C b/src/meshTools/searchableSurface/triSurfaceMesh.C index 703d8153d13ff5fac98440f72f8c98c3350251e0..6bbfd229600591f6d9a937714606645e66507ae2 100644 --- a/src/meshTools/searchableSurface/triSurfaceMesh.C +++ b/src/meshTools/searchableSurface/triSurfaceMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -542,7 +542,7 @@ Foam::triSurfaceMesh::tree() const // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. - bb = bb.extend(rndGen, 1E-4); + bb = bb.extend(rndGen, 1e-4); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); @@ -594,7 +594,7 @@ Foam::triSurfaceMesh::edgeTree() const // Slightly extended bb. Slightly off-centred just so on symmetric // geometry there are less face/edge aligned items. - bb = bb.extend(rndGen, 1E-4); + bb = bb.extend(rndGen, 1e-4); bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C index 9830bd4e6f7fcbef94acd452c3a4944d2369aee6..394f796aa32a7ca608a8a4393adc8620c133ea1d 100644 --- a/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C +++ b/src/meshTools/triSurface/booleanOps/surfaceIntersection/surfaceIntersection.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -569,7 +569,7 @@ void Foam::surfaceIntersection::doCutEdges List<DynamicList<label> >& surfEdgeCuts ) { - scalar oldTol = intersection::setPlanarTol(1E-3); + scalar oldTol = intersection::setPlanarTol(1e-3); const pointField& surf1Pts = surf1.localPoints(); diff --git a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C index e72ed09c8d99eba4291c816d4716aadc7ba31970..28f6393b2c28b84d209dc10b1c3d0ce7ccb7b468 100644 --- a/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C +++ b/src/meshTools/triSurface/triSurfaceSearch/triSurfaceSearch.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -54,7 +54,7 @@ Foam::triSurfaceSearch::triSurfaceSearch(const triSurface& surface) treeBoundBox(surface_.points(), surface_.meshPoints()).extend ( rndGen, - 1E-4 + 1e-4 ) ); treeBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/meshTools/triSurface/triSurfaceTools/geompack/geompack.C b/src/meshTools/triSurface/triSurfaceTools/geompack/geompack.C index 1bcc5fd7b3f419df6dce9d52aec014e2e4e5ccfa..7298db6060b493f194e6bf759335882cba193339 100644 --- a/src/meshTools/triSurface/triSurfaceTools/geompack/geompack.C +++ b/src/meshTools/triSurface/triSurfaceTools/geompack/geompack.C @@ -1130,8 +1130,8 @@ int dtris2 ( int point_num, double point_xy[], int *tri_num, tri_vert[3*(i-1)+0] = m1; tri_vert[3*(i-1)+1] = m2; tri_vert[3*(i-1)+2] = m; - tri_nabe[3*(i-1)+0] = -3 * i; - tri_nabe[3*(i-1)+1] = i; + tri_nabe[3*(i-2)+0] = -3 * i; + tri_nabe[3*(i-2)+1] = i; tri_nabe[3*(i-1)+2] = i - 1; } diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C new file mode 100644 index 0000000000000000000000000000000000000000..c60be140affddc6c55d851763876fc3fad2da055 --- /dev/null +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C @@ -0,0 +1,322 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "pointToPointPlanarInterpolation.H" +#include "boundBox.H" +#include "Random.H" +#include "vector2D.H" +#include "triSurface.H" +#include "triSurfaceTools.H" +#include "OFstream.H" +#include "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::pointToPointPlanarInterpolation, 0); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +Foam::coordinateSystem +Foam::pointToPointPlanarInterpolation::calcCoordinateSystem +( + const pointField& points +) const +{ + if (points.size() < 3) + { + FatalErrorIn + ( + "pointToPointPlanarInterpolation::calcCoordinateSystem" + "(const pointField&)" + ) << "Only " << points.size() << " provided." << nl + << "Need at least three non-colinear points" + << " to be able to interpolate." + << exit(FatalError); + } + + const point& p0 = points[0]; + + // Find furthest away point + vector e1; + label index1 = -1; + scalar maxDist = -GREAT; + + for (label i = 1; i < points.size(); i++) + { + const vector d = points[i] - p0; + scalar magD = mag(d); + + if (magD > maxDist) + { + e1 = d/magD; + index1 = i; + maxDist = magD; + } + } + // Find point that is furthest away from line p0-p1 + const point& p1 = points[index1]; + + label index2 = -1; + maxDist = -GREAT; + for (label i = 1; i < points.size(); i++) + { + if (i != index1) + { + const point& p2 = points[i]; + vector e2(p2 - p0); + e2 -= (e2&e1)*e1; + scalar magE2 = mag(e2); + + if (magE2 > maxDist) + { + index2 = i; + maxDist = magE2; + } + } + } + if (index2 == -1) + { + FatalErrorIn + ( + "pointToPointPlanarInterpolation::calcCoordinateSystem" + "(const pointField&)" + ) << "Cannot find points that make valid normal." << nl + << "Have so far points " << p0 << " and " << p1 + << "Need at least three points which are not in a line." + << exit(FatalError); + } + + vector n = e1^(points[index2]-p0); + n /= mag(n); + + if (debug) + { + Info<< "pointToPointPlanarInterpolation::calcCoordinateSystem :" + << " Used points " << p0 << ' ' << points[index1] + << ' ' << points[index2] + << " to define coordinate system with normal " << n << endl; + } + + return coordinateSystem + ( + "reference", + p0, // origin + n, // normal + e1 // 0-axis + ); +} + + +void Foam::pointToPointPlanarInterpolation::calcWeights +( + const pointField& sourcePoints, + const pointField& destPoints +) +{ + tmp<vectorField> tlocalVertices + ( + referenceCS_.localPosition(sourcePoints) + ); + vectorField& localVertices = tlocalVertices(); + + const boundBox bb(localVertices, true); + const point bbMid(bb.midpoint()); + + if (debug) + { + Info<< "pointToPointPlanarInterpolation::readData :" + << " Perturbing points with " << perturb_ + << " fraction of a random position inside " << bb + << " to break any ties on regular meshes." + << nl << endl; + } + + Random rndGen(123456); + forAll(localVertices, i) + { + localVertices[i] += + perturb_ + *(rndGen.position(bb.min(), bb.max())-bbMid); + } + + // Determine triangulation + List<vector2D> localVertices2D(localVertices.size()); + forAll(localVertices, i) + { + localVertices2D[i][0] = localVertices[i][0]; + localVertices2D[i][1] = localVertices[i][1]; + } + + triSurface s(triSurfaceTools::delaunay2D(localVertices2D)); + + tmp<pointField> tlocalFaceCentres + ( + referenceCS_.localPosition + ( + destPoints + ) + ); + const pointField& localFaceCentres = tlocalFaceCentres(); + + if (debug) + { + Pout<< "pointToPointPlanarInterpolation::readData :" + <<" Dumping triangulated surface to triangulation.stl" << endl; + s.write("triangulation.stl"); + + OFstream str("localFaceCentres.obj"); + Pout<< "readSamplePoints :" + << " Dumping face centres to " << str.name() << endl; + + forAll(localFaceCentres, i) + { + const point& p = localFaceCentres[i]; + str<< "v " << p.x() << ' ' << p.y() << ' ' << p.z() << nl; + } + } + + // Determine interpolation onto face centres. + triSurfaceTools::calcInterpolationWeights + ( + s, + localFaceCentres, // points to interpolate to + nearestVertex_, + nearestVertexWeight_ + ); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation +( + const pointField& sourcePoints, + const pointField& destPoints, + const scalar perturb +) +: + perturb_(perturb), + referenceCS_(calcCoordinateSystem(sourcePoints)) + +{ + calcWeights(sourcePoints, destPoints); +} + + +Foam::pointToPointPlanarInterpolation::pointToPointPlanarInterpolation +( + const coordinateSystem& referenceCS, + const pointField& sourcePoints, + const pointField& destPoints, + const scalar perturb +) +: + perturb_(perturb), + referenceCS_(referenceCS) +{ + calcWeights(sourcePoints, destPoints); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::wordList Foam::pointToPointPlanarInterpolation::timeNames +( + const instantList& times +) +{ + wordList names(times.size()); + + forAll(times, i) + { + names[i] = times[i].name(); + } + return names; +} + + +bool Foam::pointToPointPlanarInterpolation::findTime +( + const instantList& times, + const label startSampleTime, + const scalar timeVal, + label& lo, + label& hi +) +{ + lo = startSampleTime; + hi = -1; + + for (label i = startSampleTime+1; i < times.size(); i++) + { + if (times[i].value() > timeVal) + { + break; + } + else + { + lo = i; + } + } + + if (lo == -1) + { + //FatalErrorIn("findTime(..)") + // << "Cannot find starting sampling values for current time " + // << timeVal << nl + // << "Have sampling values for times " + // << timeNames(times) << nl + // << exit(FatalError); + return false; + } + + if (lo < times.size()-1) + { + hi = lo+1; + } + + + if (debug) + { + if (hi == -1) + { + Pout<< "findTime : Found time " << timeVal << " after" + << " index:" << lo << " time:" << times[lo].value() + << endl; + } + else + { + Pout<< "findTime : Found time " << timeVal << " inbetween" + << " index:" << lo << " time:" << times[lo].value() + << " and index:" << hi << " time:" << times[hi].value() + << endl; + } + } + return true; +} + + +// ************************************************************************* // diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H new file mode 100644 index 0000000000000000000000000000000000000000..daec2e46880a4aad4b79988e4bce3282f052f685 --- /dev/null +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolation.H @@ -0,0 +1,164 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +Class + Foam::pointToPointPlanarInterpolation + +Description + Interpolates between two sets of unstructured points using 2D Delaunay + triangulation. Used in e.g. timeVaryingMapped bcs. + +SourceFiles + pointToPointPlanarInterpolation.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pointToPointPlanarInterpolation_H +#define pointToPointPlanarInterpolation_H + +#include "FixedList.H" +#include "coordinateSystem.H" +#include "instantList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class pointToPointPlanarInterpolation Declaration +\*---------------------------------------------------------------------------*/ + +class pointToPointPlanarInterpolation +{ + // Private data + + //- Perturbation factor + const scalar perturb_; + + //- Coordinate system + coordinateSystem referenceCS_; + + //- Current interpolation addressing to face centres of underlying + // patch + List<FixedList<label, 3> > nearestVertex_; + + //- Current interpolation factors to face centres of underlying + // patch + List<FixedList<scalar, 3> > nearestVertexWeight_; + + // Private Member Functions + + //- Calculate a local coordinate system from set of points + coordinateSystem calcCoordinateSystem(const pointField&) const; + + //- Calculate addressing and weights + void calcWeights + ( + const pointField& sourcePoints, + const pointField& destPoints + ); + +public: + + // Declare name of the class and its debug switch + ClassName("pointToPointPlanarInterpolation"); + + + // Constructors + + //- Construct from 3D locations. Determines local coordinate system + // from sourcePoints and maps onto that. + pointToPointPlanarInterpolation + ( + const pointField& sourcePoints, + const pointField& destPoints, + const scalar perturb + ); + + //- Construct from coordinate system and locations. + pointToPointPlanarInterpolation + ( + const coordinateSystem& referenceCS, + const pointField& sourcePoints, + const pointField& destPoints, + const scalar perturb + ); + + + // Member Functions + + //- Return the coordinateSystem + const coordinateSystem& referenceCS() const + { + return referenceCS_; + } + + // patch + const List<FixedList<label, 3> >& nearestVertex() const + { + return nearestVertex_; + } + + //- Current interpolation factors to face centres of underlying + // patch + const List<FixedList<scalar, 3> >& nearestVertexWeight() const + { + return nearestVertexWeight_; + } + + //- Helper: extract words of times + static wordList timeNames(const instantList&); + + //- Helper: find time. Return true if succesful. + static bool findTime + ( + const instantList& times, + const label startSampleTime, + const scalar timeVal, + label& lo, + label& hi + ); + + //- Interpolate from field on source points to dest points + template<class Type> + tmp<Field<Type> > interpolate(const Field<Type>& sourceFld) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "pointToPointPlanarInterpolationTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolationTemplates.C b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolationTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..9159a03eddecdc0faef4261314ac203c1f536b6d --- /dev/null +++ b/src/meshTools/triSurface/triSurfaceTools/pointToPointPlanarInterpolationTemplates.C @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2012 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 <http://www.gnu.org/licenses/>. + +\*---------------------------------------------------------------------------*/ + +#include "pointToPointPlanarInterpolation.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +Foam::tmp<Foam::Field<Type> > Foam::pointToPointPlanarInterpolation::interpolate +( + const Field<Type>& sourceFld +) const +{ + tmp<Field<Type> > tfld(new Field<Type>(nearestVertex_.size())); + Field<Type>& fld = tfld(); + + forAll(fld, i) + { + const FixedList<label, 3>& verts = nearestVertex_[i]; + const FixedList<scalar, 3>& w = nearestVertexWeight_[i]; + + if (verts[2] == -1) + { + if (verts[1] == -1) + { + // Use vertex0 only + fld[i] = sourceFld[verts[0]]; + } + else + { + // Use vertex 0,1 + fld[i] = + w[0]*sourceFld[verts[0]] + + w[1]*sourceFld[verts[1]]; + } + } + else + { + fld[i] = + w[0]*sourceFld[verts[0]] + + w[1]*sourceFld[verts[1]] + + w[2]*sourceFld[verts[2]]; + } + } + return tfld; +} + + +// ************************************************************************* // diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C index 022d6fb8218149404dcc72e150693fc36de1de53..96794adaac61ac79b8329b9e751d2bd2e9e9475e 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -870,7 +870,7 @@ Foam::surfaceLocation Foam::triSurfaceTools::cutEdge { d[i] /= norm; - if (mag(d[i]) < 1E-6) + if (mag(d[i]) < 1e-6) { d[i] = 0.0; } diff --git a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H index 2328aa8284fc5478c5358ca631834c32c1832a24..ede548fd8349bf34835c7d6db3dec111345f33d2 100644 --- a/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H +++ b/src/meshTools/triSurface/triSurfaceTools/triSurfaceTools.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,7 +25,7 @@ Class Foam::triSurfaceTools Description - A collection of tools for triSurfaceMesh + A collection of tools for triSurface. SourceFiles triSurfaceTools.C diff --git a/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C b/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C index 5380ad40bd589ab168de0fc4c4fb2afdfa1ad8be..1098dfd828353ec1896d34526f008afa897596d8 100644 --- a/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C +++ b/src/parallel/decompose/decompositionMethods/hierarchGeomDecomp/hierarchGeomDecomp.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -701,7 +701,7 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose label allSize = points.size(); reduce(allSize, sumOp<label>()); - const label sizeTol = max(1, label(1E-3*allSize/nProcessors_)); + const label sizeTol = max(1, label(1e-3*allSize/nProcessors_)); // Sort recursive sortComponent @@ -742,7 +742,7 @@ Foam::labelList Foam::hierarchGeomDecomp::decompose label allSize = points.size(); reduce(allSize, sumOp<label>()); - const label sizeTol = max(1, label(1E-3*allSize/nProcessors_)); + const label sizeTol = max(1, label(1e-3*allSize/nProcessors_)); // Sort recursive sortComponent diff --git a/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C b/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C index 33105892ce685436b15d5364686cb0746558fac5..58c74f4c4b55ce3f81a6ed3e8407d4bbe4d219e0 100644 --- a/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C +++ b/src/parallel/reconstruct/reconstruct/fvFieldReconstructorReconstructFields.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -377,18 +377,24 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField // take care of the face direction offset trick. // { - labelList curAddr(faceProcAddressing_[procI]); + const labelList& faceMap = faceProcAddressing_[procI]; - forAll(curAddr, addrI) + // Addressing into original field + labelList curAddr(faceMap.size()); + // Correctly oriented copy of internal field + Field<Type> procInternalField(procField.internalField()); + + forAll(faceMap, addrI) { - curAddr[addrI] -= 1; + curAddr[addrI] = mag(faceMap[addrI])-1; + if (faceMap[addrI] < 0) + { + procInternalField[addrI] = -procInternalField[addrI]; + } } - internalField.rmap - ( - procField.internalField(), - curAddr - ); + // Map + internalField.rmap(procInternalField, curAddr); } // Set the boundary patch values in the reconstructed field diff --git a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C index 99e9eb4a085508f719d8cc758d7fe3e7e31ea088..b89cf0e6503717bf7b56aed3af343adcba8c7ed0 100644 --- a/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C +++ b/src/postProcessing/functionObjects/field/wallBoundedStreamLine/wallBoundedParticle.C @@ -62,7 +62,7 @@ namespace Foam // // pointHit ph(ln.nearestDist(position())); // -// if (ph.distance() > 1E-6) +// if (ph.distance() > 1e-6) // { // FatalErrorIn // ( diff --git a/src/sampling/probes/patchProbes.C b/src/sampling/probes/patchProbes.C index 4d81b9a661ca9521e5e5d6dd9a46d961e664e087..b6792ea08cd35ba9befff7b07b9f6ead6c9c5508 100644 --- a/src/sampling/probes/patchProbes.C +++ b/src/sampling/probes/patchProbes.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -73,7 +73,7 @@ void Foam::patchProbes::findElements(const fvMesh& mesh) treeBoundBox overallBb(pp.points()); Random rndGen(123456); - overallBb = overallBb.extend(rndGen, 1E-4); + overallBb = overallBb.extend(rndGen, 1e-4); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/sampling/sampledSet/patchCloud/patchCloudSet.C b/src/sampling/sampledSet/patchCloud/patchCloudSet.C index 2d2317a087939f83631c97059bb9b5be3563cc40..f955769ca3ba6350044dc2d331553f4107d276da 100644 --- a/src/sampling/sampledSet/patchCloud/patchCloudSet.C +++ b/src/sampling/sampledSet/patchCloud/patchCloudSet.C @@ -94,7 +94,7 @@ void Foam::patchCloudSet::calcSamples // Not very random Random rndGen(123456); // Make bb asymetric just to avoid problems on symmetric meshes - bb = bb.extend(rndGen, 1E-4); + bb = bb.extend(rndGen, 1e-4); // Make sure bb is 3D. bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/sampling/sampledSet/patchSeed/patchSeedSet.C b/src/sampling/sampledSet/patchSeed/patchSeedSet.C index 0393b5a85a919cdd241086183b873822e384a953..d06dd95f4bda4cc778cbffe251e02faedb0370c0 100644 --- a/src/sampling/sampledSet/patchSeed/patchSeedSet.C +++ b/src/sampling/sampledSet/patchSeed/patchSeedSet.C @@ -149,7 +149,7 @@ void Foam::patchSeedSet::calcSamples const point& cc = mesh().cellCentres()[cellI]; samplingPts.append ( - info.hitPoint() + 1E-1*(cc-info.hitPoint()) + info.hitPoint() + 1e-1*(cc-info.hitPoint()) ); } else diff --git a/src/sampling/sampledSurface/isoSurface/isoSurface.H b/src/sampling/sampledSurface/isoSurface/isoSurface.H index 4f8741c39423937c12ba4e470b794b90d61eaa13..1406ede0e019263c3660f4b2bf98368af90871da 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurface.H +++ b/src/sampling/sampledSurface/isoSurface/isoSurface.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -407,7 +407,7 @@ public: const scalarField& pointIsoVals, const scalar iso, const bool regularise, - const scalar mergeTol = 1E-6 // fraction of bounding box + const scalar mergeTol = 1e-6 // fraction of bounding box ); diff --git a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.H b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.H index 9c3c2990c844dc28d3e5b7d24106924d8376da9d..8a0b75c1b097aaba6c689336a6b16d6666f527b6 100644 --- a/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.H +++ b/src/sampling/sampledSurface/isoSurface/isoSurfaceCell.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -336,7 +336,7 @@ public: const scalarField& pointValues, const scalar iso, const bool regularise, - const scalar mergeTol = 1E-6 // fraction of bounding box + const scalar mergeTol = 1e-6 // fraction of bounding box ); diff --git a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C index a970fb7c5f9754c89901992e8aa773e41db5ef8c..dd2a280a516c86a73ba3170f83d21b932ba67abb 100644 --- a/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C +++ b/src/sampling/sampledSurface/isoSurface/sampledIsoSurface.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -401,7 +401,7 @@ Foam::sampledIsoSurface::sampledIsoSurface sampledSurface(name, mesh, dict), isoField_(dict.lookup("isoField")), isoVal_(readScalar(dict.lookup("isoValue"))), - mergeTol_(dict.lookupOrDefault("mergeTol", 1E-6)), + mergeTol_(dict.lookupOrDefault("mergeTol", 1e-6)), regularise_(dict.lookupOrDefault("regularise", true)), average_(dict.lookupOrDefault("average", false)), zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()), diff --git a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C index f7681fc99661e00c6c10f9355f4cd6e711f90498..7da10d7a57db7ce97e6e7454106c6f444cbe696f 100644 --- a/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C +++ b/src/sampling/sampledSurface/sampledCuttingPlane/sampledCuttingPlane.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -262,7 +262,7 @@ Foam::sampledCuttingPlane::sampledCuttingPlane : sampledSurface(name, mesh, dict), plane_(dict), - mergeTol_(dict.lookupOrDefault("mergeTol", 1E-6)), + mergeTol_(dict.lookupOrDefault("mergeTol", 1e-6)), regularise_(dict.lookupOrDefault("regularise", true)), average_(dict.lookupOrDefault("average", false)), zoneID_(dict.lookupOrDefault("zone", word::null), mesh.cellZones()), diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C index 4c050ff485c7ca42eab6507566417fb549c00d37..60ec434b13278cc7273580e4b8572c68ba78b69f 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -109,7 +109,7 @@ Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const treeBoundBox overallBb(mesh().points()); Random rndGen(123456); - overallBb = overallBb.extend(rndGen, 1E-4); + overallBb = overallBb.extend(rndGen, 1e-4); overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.C b/src/surfMesh/MeshedSurface/MeshedSurface.C index ccf2b0c38254eba351d3a3f10b5113f591a151f2..aedaec8bcea7509f5aecac45c93c235a0c3aa5ef 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.C +++ b/src/surfMesh/MeshedSurface/MeshedSurface.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -656,6 +656,7 @@ bool Foam::MeshedSurface<Face>::stitchFaces << " faces" << endl; } faceLst.setSize(newFaceI); + faceMap.setSize(newFaceI); remapFaces(faceMap); } faceMap.clear(); diff --git a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C index 57acb8153366f45b4ac83f642d81fb380b58a811..02637c203a1de3474f2d59a7ebd761933b2f7733 100644 --- a/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiationModels/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -102,8 +102,10 @@ greyDiffusiveRadiationMixedFvPatchScalarField const scalarField& Tp = patch().lookupPatchField<volScalarField, scalar>(TName_); + //NOTE: Assumes emissivity = 1 as the solidThermo might + // not be constructed yet refValue() = - 4.0*physicoChemical::sigma.value()*pow4(Tp)*emissivity()/pi; + 4.0*physicoChemical::sigma.value()*pow4(Tp)/pi; refGrad() = 0.0; valueFraction() = 1.0; diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C index 43f1ca873386a4fef0863ec1eb946042354a28f8..4ec3ce72f85dc8b19a6392c4111eaf05b0247dfb 100644 --- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C +++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,8 +59,8 @@ Foam::twoPhaseMixture::twoPhaseMixture : transportModel(U, phi), - phase1Name_("phase1"), - phase2Name_("phase2"), + phase1Name_(found("phases") ? wordList(lookup("phases"))[0] : "phase1"), + phase2Name_(found("phases") ? wordList(lookup("phases"))[1] : "phase2"), nuModel1_ ( @@ -83,13 +83,24 @@ Foam::twoPhaseMixture::twoPhaseMixture ) ), - rho1_(nuModel1_->viscosityProperties().lookup("rho")), - rho2_(nuModel2_->viscosityProperties().lookup("rho")), + rho1_("rho", dimDensity, nuModel1_->viscosityProperties().lookup("rho")), + rho2_("rho", dimDensity, nuModel2_->viscosityProperties().lookup("rho")), U_(U), phi_(phi), - alpha1_(U_.db().lookupObject<const volScalarField> (alpha1Name)), + alpha1_ + ( + IOobject + ( + found("phases") ? word("alpha" + phase1Name_) : alpha1Name, + U_.time().timeName(), + U_.db(), + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + U_.mesh() + ), nu_ ( diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H index 5e5eaaf10b119fc09f383ca218a6cc1a2f1d0733..025d95f7011b609c3fd3bb0bc914216b74bdaeb4 100644 --- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H +++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,7 +69,7 @@ protected: const volVectorField& U_; const surfaceScalarField& phi_; - const volScalarField& alpha1_; + volScalarField alpha1_; volScalarField nu_; @@ -110,6 +110,18 @@ public: return phase2Name_; } + //- Return the phase-fraction of phase 1 + const volScalarField& alpha1() const + { + return alpha1_; + } + + //- Return the phase-fraction of phase 1 + volScalarField& alpha1() + { + return alpha1_; + } + //- Return const-access to phase1 viscosityModel const viscosityModel& nuModel1() const { diff --git a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C index bb00ae0dcc43d0f7ed65eff8317c0c6a9b8ceaa8..1d1fc36244c4205e417a5a70ca7190f8833d2ce3 100644 --- a/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C +++ b/src/transportModels/incompressible/viscosityModels/Newtonian/Newtonian.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,7 +50,7 @@ Foam::viscosityModels::Newtonian::Newtonian ) : viscosityModel(name, viscosityProperties, U, phi), - nu0_(viscosityProperties_.lookup("nu")), + nu0_("nu", dimensionSet(0, 2, -1, 0, 0), viscosityProperties_.lookup("nu")), nu_ ( IOobject diff --git a/src/triSurface/faceTriangulation/faceTriangulation.C b/src/triSurface/faceTriangulation/faceTriangulation.C index 3b9916562eea27c24cd6ea45875df535577f6634..ea4482a13c4154556f8f2ef036b13b7b53a6ecca 100644 --- a/src/triSurface/faceTriangulation/faceTriangulation.C +++ b/src/triSurface/faceTriangulation/faceTriangulation.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const Foam::scalar Foam::faceTriangulation::edgeRelTol = 1E-6; +const Foam::scalar Foam::faceTriangulation::edgeRelTol = 1e-6; // Edge to the right of face vertex i diff --git a/src/triSurface/triSurface/triSurface.C b/src/triSurface/triSurface/triSurface.C index 6ae73266eeb8c343e5651cdd6a5537c6c19111f1..1350653865ff03b4557c110307c2df1f7ba1605e 100644 --- a/src/triSurface/triSurface/triSurface.C +++ b/src/triSurface/triSurface/triSurface.C @@ -386,7 +386,7 @@ bool Foam::triSurface::read } else if (ext == "stlb") { - return readSTL(name); + return readSTLBINARY(name); } else if (ext == "gts") { diff --git a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C index c7c10d0ae933be5ba70426030959091eaeb8b421..0d27e370505b0022588b729711b0f1c88062e76f 100644 --- a/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C +++ b/src/turbulenceModels/compressible/RAS/LaunderSharmaKE/LaunderSharmaKE.C @@ -320,7 +320,6 @@ void LaunderSharmaKE::correct() C1_*G*epsilon_/k_ - fvm::SuSp(((2.0/3.0)*C1_ + C3_)*rho_*divU, epsilon_) - fvm::Sp(C2_*f2()*rho_*epsilon_/k_, epsilon_) - //+ 0.75*1.5*flameKproduction*epsilon_/k_ + E ); @@ -340,7 +339,6 @@ void LaunderSharmaKE::correct() == G - fvm::SuSp(2.0/3.0*rho_*divU, k_) - fvm::Sp(rho_*(epsilon_ + D)/k_, k_) - //+ flameKproduction ); kEqn().relax(); diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C index ff459f8006147357dd3c19a8be9c2e4a1278d113..d5943dda5e118d5b3158b4c64ba3da1220072f0c 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/atmBoundaryLayerInletVelocity/atmBoundaryLayerInletVelocityFvPatchVectorField.C @@ -174,7 +174,7 @@ void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs() void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - zGround_.writeEntry("z0", os) ; + z0_.writeEntry("z0", os) ; os.writeKeyword("n") << n_ << token::END_STATEMENT << nl; os.writeKeyword("z") diff --git a/tutorials/DNS/dnsFoam/boxTurb16/system/fvSchemes b/tutorials/DNS/dnsFoam/boxTurb16/system/fvSchemes index 1f665c977f903a240ba6eeaf9579ac44e5c2681d..21be868783efefebb220ba3e5cb6eda626c23672 100644 --- a/tutorials/DNS/dnsFoam/boxTurb16/system/fvSchemes +++ b/tutorials/DNS/dnsFoam/boxTurb16/system/fvSchemes @@ -37,7 +37,7 @@ laplacianSchemes { default none; laplacian(nu,U) Gauss linear corrected; - laplacian((1|A(U)),p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; } interpolationSchemes diff --git a/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/p_rgh b/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/p_rgh index 1e34387a33c4d5d115d2cb94d650067ee138c190..f0770e8bd9f126c2b835c19726d70b454ea2a2d4 100644 --- a/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/p_rgh +++ b/tutorials/combustion/fireFoam/les/oppositeBurningPanels/0/p_rgh @@ -23,7 +23,7 @@ boundaryField { ground { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } @@ -35,7 +35,7 @@ boundaryField burner { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } @@ -53,7 +53,7 @@ boundaryField "(region0_to.*)" { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } } diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/p_rgh b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/p_rgh index 54e8cbeb298e8c45907959cbddbb524af49a9a78..d941becc551742da4f35fe43749b8516e56d2499 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/p_rgh +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/0/p_rgh @@ -23,7 +23,7 @@ boundaryField { outlet { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } @@ -41,13 +41,13 @@ boundaryField base { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } inlet { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/p_rgh b/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/p_rgh index 7a8d6054f8b5d17a9ef31f3cafc8063aa642674f..420c10de474b2ae6866af082ef3acadff0ba3c7b 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/p_rgh +++ b/tutorials/combustion/fireFoam/les/smallPoolFire3D/0/p_rgh @@ -23,7 +23,7 @@ boundaryField { outlet { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } sides @@ -39,12 +39,12 @@ boundaryField } base { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } inlet { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } } diff --git a/tutorials/compressible/rhoCentralFoam/LadenburgJet60psi/constant/thermophysicalProperties b/tutorials/compressible/rhoCentralFoam/LadenburgJet60psi/constant/thermophysicalProperties index e6838dcf7a7354d2da69681dac755bd3035a2489..2ff1fabbda2edf3e9699a432e2513cbb8f716238 100644 --- a/tutorials/compressible/rhoCentralFoam/LadenburgJet60psi/constant/thermophysicalProperties +++ b/tutorials/compressible/rhoCentralFoam/LadenburgJet60psi/constant/thermophysicalProperties @@ -33,6 +33,7 @@ mixture { As 1.458e-06; Ts 110.4; + Pr 1; } } diff --git a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/constant/thermophysicalProperties b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/constant/thermophysicalProperties index a3c1437dc02e2aaf078c7b0810552f233670f1f4..1e8492f320fdbc4c7cabfa3aa45f80c9ef04e0f9 100644 --- a/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/constant/thermophysicalProperties +++ b/tutorials/compressible/rhoCentralFoam/biconic25-55Run35/constant/thermophysicalProperties @@ -15,8 +15,6 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -Pr 0.72; - thermoType ePsiThermo<pureMixture<sutherlandTransport<specieThermo<janafThermo<perfectGas>>>>>; mixture @@ -38,6 +36,7 @@ mixture { As 1.458e-06; Ts 110; + Pr 0.72; } } diff --git a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/0/p_rgh b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/0/p_rgh index 7dc56a62899ed9872805bbc12110ff75bfb8b634..b2d94f6866564315997e7d855bffedce38e5e164 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/0/p_rgh +++ b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/0/p_rgh @@ -22,21 +22,21 @@ boundaryField { floor { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } ceiling { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } fixedWalls { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } diff --git a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/system/fvSchemes index ceb6aa0497de57b031eebd7e7d296827e0e5de6e..b7ff9739c17c81c1e46ea0e1d50141d1230ec4b2 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantBoussinesqPimpleFoam/hotRoom/system/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(nuEff,U) Gauss linear uncorrected; - laplacian((1|A(U)),p_rgh) Gauss linear uncorrected; + laplacian(Dp,p_rgh) Gauss linear uncorrected; laplacian(kappaEff,T) Gauss linear uncorrected; laplacian(DkEff,k) Gauss linear uncorrected; laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/0/p_rgh b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/0/p_rgh index 7dc56a62899ed9872805bbc12110ff75bfb8b634..b2d94f6866564315997e7d855bffedce38e5e164 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/0/p_rgh +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/0/p_rgh @@ -22,21 +22,21 @@ boundaryField { floor { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } ceiling { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } fixedWalls { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/system/fvSchemes index 3fa205e5e36af2c69f6a162e8bba1367affff6b4..6fc42b1ca74d8432bc3222d4dab79fc56b92d787 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/hotRoom/system/fvSchemes @@ -39,7 +39,7 @@ laplacianSchemes { default none; laplacian(nuEff,U) Gauss linear corrected; - laplacian((1|A(U)),p_rgh) Gauss linear corrected; + laplacian(Dp,p_rgh) Gauss linear corrected; laplacian(kappaEff,T) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/0/p_rgh b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/0/p_rgh index 0ce8d85c2b156dbb4a70afd4143856cc9c4cc41e..eb39e94eab1eb3cfce6119022fd24a4eb499c102 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/0/p_rgh +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/0/p_rgh @@ -22,28 +22,28 @@ boundaryField { ground { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } igloo_region0 { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } twoFridgeFreezers_seal_0 { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } twoFridgeFreezers_herring_1 { - type buoyantPressure; + type fixedFluxPressure; rho rhok; value uniform 0; } diff --git a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/fvSchemes b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/fvSchemes index 364987d87f0f32a8119270fb9d54660b3af82c5e..b36bd5f8fcbd2378f485eef05e5ff10ec0f5aa8b 100644 --- a/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantBoussinesqSimpleFoam/iglooWithFridges/system/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(nuEff,U) Gauss linear limited 0.333; - laplacian((1|A(U)),p_rgh) Gauss linear limited 0.333; + laplacian(Dp,p_rgh) Gauss linear limited 0.333; laplacian(kappaEff,T) Gauss linear limited 0.333; laplacian(DkEff,k) Gauss linear limited 0.333; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.333; diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/0/p_rgh b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/0/p_rgh index c851c9391a2283b03c70557e4f1482ac666c91df..86029469114e191c8e6061f8f577c434af5349d8 100644 --- a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/0/p_rgh +++ b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/0/p_rgh @@ -22,19 +22,19 @@ boundaryField { floor { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } ceiling { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } fixedWalls { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } } diff --git a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/system/fvSchemes index 3a7b6154e54e9b0d16611a9b96e1fbb61d7c16e1..a6897b72d5203bc01d9d3ef325c0606a8b79f239 100644 --- a/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantPimpleFoam/hotRoom/system/fvSchemes @@ -42,7 +42,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear corrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected; + laplacian(Dp,p_rgh) Gauss linear corrected; laplacian(alphaEff,h) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/0/p_rgh b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/0/p_rgh index fcf8d57e51baf9fb540061ad7b11402602be99c4..15979d020e33ed2769512df863c4ccb772b6eeca 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/0/p_rgh +++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/0/p_rgh @@ -23,25 +23,25 @@ boundaryField { frontAndBack { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } topAndBottom { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } hot { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } cold { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } } diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/system/fvSchemes b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/system/fvSchemes index cdaadf4c3033d5adc9fab9187dfd125022a1d33a..599b1530bc87becb9c2a370a29e1f862763a5744 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantSimpleFoam/buoyantCavity/system/fvSchemes @@ -40,7 +40,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear orthogonal; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear orthogonal; + laplacian(Dp,p_rgh) Gauss linear orthogonal; laplacian(alphaEff,h) Gauss linear orthogonal; laplacian(DkEff,k) Gauss linear orthogonal; laplacian(DepsilonEff,epsilon) Gauss linear orthogonal; diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/p_rgh b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/p_rgh index 94fc0bd9f339981c6d0bf17cb33f9f0a7183be4e..8cb7d58cdf5374a02b7f54e8539a5e3bb28102b8 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/p_rgh +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/p_rgh @@ -23,22 +23,22 @@ boundaryField { floor { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } ceiling { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } inlet { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } outlet { - type buoyantPressure; + type fixedFluxPressure; value $internalField; } fixedWalls diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/fvSchemes b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/fvSchemes index 02edc9816b94775af20c1716ecad09bf6ab7f8b9..46f978cc82b4be057ce6ea6e09b616c27cbf12c2 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/fvSchemes @@ -40,7 +40,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear uncorrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear uncorrected; + laplacian(Dp,p_rgh) Gauss linear uncorrected; laplacian(alphaEff,h) Gauss linear uncorrected; laplacian(DkEff,k) Gauss linear uncorrected; laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p_rgh b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p_rgh index c851c9391a2283b03c70557e4f1482ac666c91df..86029469114e191c8e6061f8f577c434af5349d8 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p_rgh +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/0/p_rgh @@ -22,19 +22,19 @@ boundaryField { floor { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } ceiling { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } fixedWalls { - type buoyantPressure; + type fixedFluxPressure; value uniform 1e5; } } diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes index f0019f66909410c050c47880c88b649476777274..991a5277f6e9ba1bdaff130ed0beee8c1d75ddfb 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantSimpleFoam/hotRoom/system/fvSchemes @@ -42,7 +42,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear uncorrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear uncorrected; + laplacian(Dp,p_rgh) Gauss linear uncorrected; laplacian(alphaEff,h) Gauss linear uncorrected; laplacian(DkEff,k) Gauss linear uncorrected; laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; diff --git a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/p_rgh b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/p_rgh index 5b0b64b9761eb0a2c4745e49c0755bfc23698501..b8deb5e5951a0cdbd637f101ab6283b1a5b051b3 100644 --- a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/p_rgh +++ b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/0/p_rgh @@ -22,25 +22,25 @@ boundaryField { floor { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } ceiling { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } fixedWalls { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } box { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } } diff --git a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/system/fvSchemes b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/system/fvSchemes index 572a6207d2280e9135103318008b254328051db3..3b6deefb697ca2d9996d39bb948132404efc138c 100644 --- a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoom/system/fvSchemes @@ -42,7 +42,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear corrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected; + laplacian(Dp,p_rgh) Gauss linear corrected; laplacian(alphaEff,h) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; diff --git a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/p_rgh b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/p_rgh index 5b0b64b9761eb0a2c4745e49c0755bfc23698501..b8deb5e5951a0cdbd637f101ab6283b1a5b051b3 100644 --- a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/p_rgh +++ b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/0/p_rgh @@ -22,25 +22,25 @@ boundaryField { floor { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } ceiling { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } fixedWalls { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } box { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } } diff --git a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/system/fvSchemes b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/system/fvSchemes index 3cbd11840882a2c5ceeca7760d7932ee1f771620..817fe7274b45e93858f680d4dd2de0884c4e9190 100644 --- a/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/system/fvSchemes +++ b/tutorials/heatTransfer/buoyantSimpleRadiationFoam/hotRadiationRoomFvDOM/system/fvSchemes @@ -43,7 +43,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear corrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected; + laplacian(Dp,p_rgh) Gauss linear corrected; laplacian(alphaEff,h) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/bottomAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/bottomAir/fvSchemes index e4be18c50c4cc9746d7d7568943cb8d899c6aa07..148fdb45eb91d90c8679f8e76413aa09cb96917b 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/bottomAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/bottomAir/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear limited 0.333; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear limited 0.333; + laplacian(Dp,p_rgh) Gauss linear limited 0.333; laplacian(alphaEff,h) Gauss linear limited 0.333; laplacian(DkEff,k) Gauss linear limited 0.333; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.333; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/topAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/topAir/fvSchemes index 865dfd9f993d8329406c98c469be9cf3e9d7695c..5694ac1f59bb24ecf0f2ef153d1d7b3c4c1d61a8 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/topAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionHeater/system/topAir/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear limited 0.333; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear limited 0.333; + laplacian(Dp,p_rgh) Gauss linear limited 0.333; laplacian(alphaEff,h) Gauss linear limited 0.333; laplacian(DkEff,k) Gauss linear limited 0.333; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.333; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/bottomWater/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/bottomWater/fvSchemes index 865dfd9f993d8329406c98c469be9cf3e9d7695c..5694ac1f59bb24ecf0f2ef153d1d7b3c4c1d61a8 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/bottomWater/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/bottomWater/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear limited 0.333; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear limited 0.333; + laplacian(Dp,p_rgh) Gauss linear limited 0.333; laplacian(alphaEff,h) Gauss linear limited 0.333; laplacian(DkEff,k) Gauss linear limited 0.333; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.333; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/topAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/topAir/fvSchemes index 865dfd9f993d8329406c98c469be9cf3e9d7695c..5694ac1f59bb24ecf0f2ef153d1d7b3c4c1d61a8 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/topAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/multiRegionLiquidHeater/system/topAir/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear limited 0.333; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear limited 0.333; + laplacian(Dp,p_rgh) Gauss linear limited 0.333; laplacian(alphaEff,h) Gauss linear limited 0.333; laplacian(DkEff,k) Gauss linear limited 0.333; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.333; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/bottomAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/bottomAir/fvSchemes index 865dfd9f993d8329406c98c469be9cf3e9d7695c..5694ac1f59bb24ecf0f2ef153d1d7b3c4c1d61a8 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/bottomAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/bottomAir/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear limited 0.333; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear limited 0.333; + laplacian(Dp,p_rgh) Gauss linear limited 0.333; laplacian(alphaEff,h) Gauss linear limited 0.333; laplacian(DkEff,k) Gauss linear limited 0.333; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.333; diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/topAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/topAir/fvSchemes index 865dfd9f993d8329406c98c469be9cf3e9d7695c..5694ac1f59bb24ecf0f2ef153d1d7b3c4c1d61a8 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/topAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionFoam/snappyMultiRegionHeater/system/topAir/fvSchemes @@ -41,7 +41,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear limited 0.333; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear limited 0.333; + laplacian(Dp,p_rgh) Gauss linear limited 0.333; laplacian(alphaEff,h) Gauss linear limited 0.333; laplacian(DkEff,k) Gauss linear limited 0.333; laplacian(DepsilonEff,epsilon) Gauss linear limited 0.333; diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/bottomAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/bottomAir/fvSchemes index 17ab97ec96f710289707b41e5dff527729aaa89c..09a66a2658baa460e70388dc986fc78c6a2381a7 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/bottomAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/bottomAir/fvSchemes @@ -42,7 +42,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear uncorrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear uncorrected; + laplacian(Dp,p_rgh) Gauss linear uncorrected; laplacian(alphaEff,h) Gauss linear uncorrected; laplacian(DkEff,k) Gauss linear uncorrected; laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/topAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/topAir/fvSchemes index cf4192a4ded2621c7ce0c8a8decb8856148af637..9b8eac50b508961960c847c3930d658aeaf483df 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/topAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeater/system/topAir/fvSchemes @@ -42,7 +42,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear uncorrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear uncorrected; + laplacian(Dp,p_rgh) Gauss linear uncorrected; laplacian(alphaEff,h) Gauss linear uncorrected; laplacian(DkEff,k) Gauss linear uncorrected; laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/changeDictionaryDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/changeDictionaryDict index 7fc53289cc8fba7129b758ef806409660e87cc7c..f08a1ebff825d2d924506dbf969acd6e7f9b68f0 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/changeDictionaryDict +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/changeDictionaryDict @@ -174,7 +174,6 @@ dictionaryReplacement type greyDiffusiveRadiation; T T; emissivityMode lookup; - Qro uniform 0; emissivity uniform 1.0; value uniform 0; } @@ -184,7 +183,6 @@ dictionaryReplacement type greyDiffusiveRadiation; T T; emissivityMode solidThermo; - Qro uniform 0; value uniform 0; } } diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSchemes index 7f3767d179336695ed70bb0a9ab904eff005998b..ca25b1d27ca7656c874002aa7e936abb3fdba428 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/bottomAir/fvSchemes @@ -43,7 +43,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear uncorrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear uncorrected; + laplacian(Dp,p_rgh) Gauss linear uncorrected; laplacian(alphaEff,h) Gauss linear uncorrected; laplacian(DkEff,k) Gauss linear uncorrected; laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/changeDictionaryDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/changeDictionaryDict index 6647732e8f732cfaaeedd68505b671e43f29d830..4c78380972a483f8db32196a70ba41df408f3cf1 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/changeDictionaryDict +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/changeDictionaryDict @@ -221,7 +221,6 @@ dictionaryReplacement type greyDiffusiveRadiation; T T; emissivityMode lookup; - Qro uniform 0; emissivity uniform 1.0; value uniform 0; } @@ -231,7 +230,6 @@ dictionaryReplacement type greyDiffusiveRadiation; T T; emissivityMode solidThermo; - Qro uniform 0; value uniform 0; } } diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSchemes b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSchemes index 7f3767d179336695ed70bb0a9ab904eff005998b..ca25b1d27ca7656c874002aa7e936abb3fdba428 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSchemes +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/multiRegionHeaterRadiation/system/topAir/fvSchemes @@ -43,7 +43,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear uncorrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear uncorrected; + laplacian(Dp,p_rgh) Gauss linear uncorrected; laplacian(alphaEff,h) Gauss linear uncorrected; laplacian(DkEff,k) Gauss linear uncorrected; laplacian(DepsilonEff,epsilon) Gauss linear uncorrected; diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre index 917bec1fac7b9664fcd34e306763162932e3beea..472c03a6f7034d02b4e0b8a4f01bba629dc6de59 100755 --- a/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre +++ b/tutorials/incompressible/pimpleDyMFoam/propeller/Allrun.pre @@ -12,21 +12,7 @@ cp $FOAM_TUTORIALS/resources/geometry/propellerTip.obj.gz constant/triSurface/ runApplication blockMesh -surfaces=" - innerCylinder - innerCylinderSmall - outerCylinder - propellerTip - propellerStem1 - propellerStem2 - propellerStem3 -" - -for s in $surfaces; do - runApplication surfaceFeatureExtract -includedAngle 150 -minElem 10 \ - constant/triSurface/$s.obj $s - mv log.surfaceFeatureExtract log.surfaceFeatureExtract.$s -done +runApplication surfaceFeatureExtract runApplication snappyHexMesh -overwrite # force removal of fields generated by snappy diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/system/surfaceFeatureExtractDict b/tutorials/incompressible/pimpleDyMFoam/propeller/system/surfaceFeatureExtractDict new file mode 100644 index 0000000000000000000000000000000000000000..b6333ec29b5db96f3fea61aa36c514cfe3a24344 --- /dev/null +++ b/tutorials/incompressible/pimpleDyMFoam/propeller/system/surfaceFeatureExtractDict @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object surfaceFeatureExtractDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +innerCylinder.obj +{ + #include "surfaceFeatureExtractDictDefaults" +} + + +innerCylinderSmall.obj +{ + #include "surfaceFeatureExtractDictDefaults" +} + + +outerCylinder.obj +{ + #include "surfaceFeatureExtractDictDefaults" +} + + +propellerStem1.obj +{ + #include "surfaceFeatureExtractDictDefaults" +} + + +propellerStem2.obj +{ + #include "surfaceFeatureExtractDictDefaults" +} + + +propellerStem3.obj +{ + #include "surfaceFeatureExtractDictDefaults" +} + + +propellerTip.obj +{ + #include "surfaceFeatureExtractDictDefaults" +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/pimpleDyMFoam/propeller/system/surfaceFeatureExtractDictDefaults b/tutorials/incompressible/pimpleDyMFoam/propeller/system/surfaceFeatureExtractDictDefaults new file mode 100644 index 0000000000000000000000000000000000000000..52258ae69251d62c223ced2f827f90a1f628f2f6 --- /dev/null +++ b/tutorials/incompressible/pimpleDyMFoam/propeller/system/surfaceFeatureExtractDictDefaults @@ -0,0 +1,17 @@ +// How to obtain raw features (extractFromFile || extractFromSurface) +extractionMethod extractFromSurface; + +extractFromSurfaceCoeffs +{ + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 150; +} + +trimFeatures +{ + // Remove features with fewer than the specified number of edges + minElem 10; +} diff --git a/tutorials/incompressible/pimpleFoam/TJunctionFan/0/epsilon b/tutorials/incompressible/pimpleFoam/TJunctionFan/0/epsilon index 7448f8e544548bb3719b444e775f5ad494605d58..b972d9f1d292f64130a687183d44cabe99c71cbb 100644 --- a/tutorials/incompressible/pimpleFoam/TJunctionFan/0/epsilon +++ b/tutorials/incompressible/pimpleFoam/TJunctionFan/0/epsilon @@ -27,19 +27,19 @@ boundaryField mixingLength 0.01; phi phi; k k; - value $internalField; + value uniform 200; } outlet1 { type inletOutlet; - inletValue $internalField; - value $internalField; + inletValue uniform 200; + value uniform 200; } outlet2 { type inletOutlet; - inletValue $internalField; - value $internalField; + inletValue uniform 200; + value uniform 200; } baffles { @@ -47,7 +47,7 @@ boundaryField Cmu 0.09; kappa 0.41; E 9.8; - value $internalField; + value uniform 0; } fan_half0 { @@ -63,7 +63,7 @@ boundaryField Cmu 0.09; kappa 0.41; E 9.8; - value $internalField; + value uniform 200; } } diff --git a/tutorials/incompressible/pimpleFoam/TJunctionFan/0/k b/tutorials/incompressible/pimpleFoam/TJunctionFan/0/k index 9684d73a5581f7dcf1b1e7c883a0b7c4268d7861..a58acefeab74e73cab3a532e784204d01c3683d5 100644 --- a/tutorials/incompressible/pimpleFoam/TJunctionFan/0/k +++ b/tutorials/incompressible/pimpleFoam/TJunctionFan/0/k @@ -27,24 +27,24 @@ boundaryField intensity 0.05; U U; phi phi; - value $internalField; + value uniform 0.375; } outlet1 { type inletOutlet; - inletValue $internalField; - value $internalField; + inletValue uniform 0.375; + value uniform 0.375; } outlet2 { type inletOutlet; - inletValue $internalField; - value $internalField; + inletValue uniform 0.375; + value uniform 0.375; } baffles { type kqRWallFunction; - value $internalField; + value uniform 0; } fan_half0 { @@ -57,7 +57,7 @@ boundaryField defaultFaces { type kqRWallFunction; - value $internalField; + value uniform 0.375; } } diff --git a/tutorials/incompressible/pimpleFoam/TJunctionFan/0/p b/tutorials/incompressible/pimpleFoam/TJunctionFan/0/p index dd968b84c5f088ea8391927d419f7c2fc625eacb..16a8bb50eddb376e9a4d3efbbf94db59b3126a2b 100644 --- a/tutorials/incompressible/pimpleFoam/TJunctionFan/0/p +++ b/tutorials/incompressible/pimpleFoam/TJunctionFan/0/p @@ -29,10 +29,13 @@ boundaryField gamma 1; p0 40; pressure table - ( - (0 10) - (1 40) - ); + +2 +( +(0 10) +(1 40) +) +; value uniform 40; } outlet1 @@ -54,7 +57,14 @@ boundaryField type fan; patchType cyclic; jump uniform 0; - f 2(100 -0.1); + jumpTable polynomial + +2 +( +(100 0) +(-0.1 1) +) +; value uniform 0; } fan_half1 @@ -62,7 +72,6 @@ boundaryField type fan; patchType cyclic; jump uniform 0; - f 2(100 -0.1); value uniform 0; } defaultFaces diff --git a/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allclean b/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allclean index 213da0de109463e68173277f9235bc6c5077a544..a25fd5e1c4ebf83bd5a8b6afb5eab93ed8f7bceb 100755 --- a/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allclean +++ b/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allclean @@ -5,6 +5,5 @@ cd ${0%/*} || exit 1 # run from this directory . $WM_PROJECT_DIR/bin/tools/CleanFunctions cleanCase -rm -rf 0/polyMesh # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allrun b/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allrun index 84cff2e93401b0173649153b31af9f8af003c006..fd85f49a951d0ded2fad152f116e272f97164bad 100755 --- a/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allrun +++ b/tutorials/incompressible/pimpleFoam/elipsekkLOmega/Allrun @@ -10,17 +10,14 @@ application=`getApplication` runApplication blockMesh transformPoints -scale '(1.6666 1 1)' -cp system/changeDictionaryDict.X system/changeDictionaryDict -runApplication changeDictionary -instance system -runApplication mirrorMesh +runApplication changeDictionary -instance system -dict system/changeDictionaryDict.X +runApplication mirrorMesh -overwrite rm log.mirrorMesh rm log.changeDictionary -cp system/changeDictionaryDict.Y system/changeDictionaryDict -runApplication changeDictionary -instance system +runApplication changeDictionary -instance system -dict system/changeDictionaryDict.Y -runApplication mirrorMesh -cp -rf 0/polyMesh constant/ +runApplication mirrorMesh -overwrite runApplication topoSet runApplication createPatch -overwrite diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/0.org/p_rgh b/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/0.org/p_rgh index 61d9570ec5bc6fca095b15121c8ef736c311bd6c..99be8758e28097d60213fbafa52d0f6294d6544f 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/0.org/p_rgh +++ b/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/0.org/p_rgh @@ -23,11 +23,11 @@ boundaryField { "(sides|frontAndBack)" { - type buoyantPressure; + type fixedFluxPressure; } region0_to_wallFilmRegion_wallFilmFaces { - type buoyantPressure; + type fixedFluxPressure; } } diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/p_rgh b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/p_rgh index 5ab863aeccf8f9efbde8f6088dbc5f9a882ee2d7..df06f47fd0da72a24bd0edc94d00274ef8e54505 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/p_rgh +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/0.org/p_rgh @@ -23,12 +23,12 @@ boundaryField { walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } wallFilm { - type buoyantPressure; + type fixedFluxPressure; value uniform 100000; } } diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/rivuletPanel/0.org/p_rgh b/tutorials/lagrangian/reactingParcelFilmFoam/rivuletPanel/0.org/p_rgh index 09857d680529cd430584112f2921072e2a5903f2..7333dfae9b2fd7a7022875ce94221883feecbcce 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/rivuletPanel/0.org/p_rgh +++ b/tutorials/lagrangian/reactingParcelFilmFoam/rivuletPanel/0.org/p_rgh @@ -23,19 +23,19 @@ boundaryField { inlet { - type buoyantPressure; + type fixedFluxPressure; } outlet { - type buoyantPressure; + type fixedFluxPressure; } sides { - type buoyantPressure; + type fixedFluxPressure; } region0_to_wallFilmRegion_wallFilmFaces { - type buoyantPressure; + type fixedFluxPressure; } } diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/0.org/p_rgh b/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/0.org/p_rgh index f30165dfb783231954d96aa6a1a988ef633e7c5b..840f0d21be7d0fa8f26873011284147f559a960d 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/0.org/p_rgh +++ b/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/0.org/p_rgh @@ -23,11 +23,11 @@ boundaryField { sides { - type buoyantPressure; + type fixedFluxPressure; } region0_to_wallFilmRegion_wallFilmFaces { - type buoyantPressure; + type fixedFluxPressure; } } diff --git a/tutorials/mesh/cvMesh/flange/Allrun b/tutorials/mesh/cvMesh/flange/Allrun index d4e853bb3f471c82fed754dc1518b996dee79423..dcbbfb47d41692c7e12c8aa3cb009f6e482def5d 100755 --- a/tutorials/mesh/cvMesh/flange/Allrun +++ b/tutorials/mesh/cvMesh/flange/Allrun @@ -8,7 +8,7 @@ cd ${0%/*} || exit 1 # run from this directory nProc=`grep numberOfSubdomains system/decomposeParDict \ | sed s/"numberOfSubdomains *\(.*\);"/"\1"/` -runApplication surfaceFeatureExtract constant/triSurface/flange.obj flange -includedAngle 155 +runApplication surfaceFeatureExtract # Create tight-fitting background mesh runApplication blockMesh diff --git a/tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict b/tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict index a4c24aa610ba75314acd08a4d37251e509b6e7e9..ca6dfb9e7c63e9f6dc8098bbdd5a778249797660 100644 --- a/tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict +++ b/tutorials/mesh/cvMesh/flange/system/surfaceFeatureExtractDict @@ -30,9 +30,6 @@ flange.obj // Write options - // Write .eMesh file (for snappyHexMesh) - writeFeatureEdgeMesh no; - // Write features to obj format for postprocessing writeObj yes; } diff --git a/tutorials/mesh/cvMesh/simpleShapes/Allrun b/tutorials/mesh/cvMesh/simpleShapes/Allrun index 5de37ba56944f816c5d8b546b98b48bcaabcfa98..f1259d32d27f3acd46796fd6c2afac3c00cf10ae 100755 --- a/tutorials/mesh/cvMesh/simpleShapes/Allrun +++ b/tutorials/mesh/cvMesh/simpleShapes/Allrun @@ -30,15 +30,11 @@ surfaceOrient \ constant/triSurface/domain_clean_orient.stl > log.surfaceOrient.domain 2>&1 -runApplication surfaceFeatureExtract \ - constant/triSurface/coneAndSphere_clean_orient.obj \ - coneAndSphere -includedAngle 125 +runApplication surfaceFeatureExtract mv log.surfaceFeatureExtract log.surfaceFeatureExtract.coneAndSphere_clean unset FOAM_SIGFPE -runApplication surfaceFeatureExtract \ - constant/triSurface/domain_clean_orient.stl \ - domain -includedAngle 125 +runApplication surfaceFeatureExtract mv log.surfaceFeatureExtract log.surfaceFeatureExtract.domain # Generate aligned points (in constant/internalDelaunayVertices) and a diff --git a/tutorials/mesh/cvMesh/simpleShapes/system/surfaceFeatureExtractDict b/tutorials/mesh/cvMesh/simpleShapes/system/surfaceFeatureExtractDict new file mode 100644 index 0000000000000000000000000000000000000000..850a4ea41f48c278271672540d2f1eff0dd60b03 --- /dev/null +++ b/tutorials/mesh/cvMesh/simpleShapes/system/surfaceFeatureExtractDict @@ -0,0 +1,57 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object surfaceFeatureExtractDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +coneAndSphere_clean_orient.obj +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 125; + } + + // Write options + + // Write features to obj format for postprocessing + writeObj no; +} + + +domain_clean_orient.stl +{ + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 125; + } + + // Write options + + // Write features to obj format for postprocessing + writeObj no; +} + + +// ************************************************************************* // diff --git a/tutorials/mesh/snappyHexMesh/flange/Allrun b/tutorials/mesh/snappyHexMesh/flange/Allrun index 5d808c1f55ab682080943fdd51db7f218f7dee6c..365020d19d52b7c3652ba808d37bc7660ad72916 100755 --- a/tutorials/mesh/snappyHexMesh/flange/Allrun +++ b/tutorials/mesh/snappyHexMesh/flange/Allrun @@ -6,5 +6,5 @@ cp $FOAM_TUTORIALS/resources/geometry/flange.stl.gz constant/triSurface/ runApplication blockMesh -runApplication surfaceFeatureExtract -includedAngle 150 -writeObj constant/triSurface/flange.stl flange +runApplication surfaceFeatureExtract runApplication snappyHexMesh -overwrite diff --git a/tutorials/mesh/snappyHexMesh/flange/system/surfaceFeatureExtractDict b/tutorials/mesh/snappyHexMesh/flange/system/surfaceFeatureExtractDict new file mode 100644 index 0000000000000000000000000000000000000000..21384ba40c4b2d283b37fd3b7afcc0ffaa5fb760 --- /dev/null +++ b/tutorials/mesh/snappyHexMesh/flange/system/surfaceFeatureExtractDict @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object surfaceFeatureExtractDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +flange.stl +{ + // How to obtain raw features (extractFromFile || extractFromSurface) + extractionMethod extractFromSurface; + + extractFromSurfaceCoeffs + { + // Mark edges whose adjacent surface normals are at an angle less + // than includedAngle as features + // - 0 : selects no edges + // - 180: selects all edges + includedAngle 150; + } + + // Write options + + // Write features to obj format for postprocessing + writeObj yes; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/LTSInterFoam/wigleyHull/0/p_rgh b/tutorials/multiphase/LTSInterFoam/wigleyHull/0/p_rgh index 54e73a08ae51b2c75a153ba8266ecfe5641a04ea..2b4915fe5c6ec12273419990fe4a76274d4eeb1f 100644 --- a/tutorials/multiphase/LTSInterFoam/wigleyHull/0/p_rgh +++ b/tutorials/multiphase/LTSInterFoam/wigleyHull/0/p_rgh @@ -22,7 +22,7 @@ boundaryField { inlet { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } @@ -50,7 +50,7 @@ boundaryField hull_wall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/bubbleFoam/bubbleColumn/0.org/p b/tutorials/multiphase/bubbleFoam/bubbleColumn/0.org/p index 07744fc101cb1476f9d39dda5aba58c3cd8a13e6..536747ce3f16ca8751dfc977d88a95cb3a6faad8 100644 --- a/tutorials/multiphase/bubbleFoam/bubbleColumn/0.org/p +++ b/tutorials/multiphase/bubbleFoam/bubbleColumn/0.org/p @@ -22,7 +22,8 @@ boundaryField { inlet { - type zeroGradient; + type fixedFluxPressure; + value uniform 0; } outlet @@ -33,7 +34,7 @@ boundaryField walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/bubbleFoam/bubbleColumn/0/p b/tutorials/multiphase/bubbleFoam/bubbleColumn/0/p index 709bf07cefe0ee7a5eb1168d91d6fd810ead81e5..5fffa73a19c7bb4636820cdc2558cd1f43b0429d 100644 --- a/tutorials/multiphase/bubbleFoam/bubbleColumn/0/p +++ b/tutorials/multiphase/bubbleFoam/bubbleColumn/0/p @@ -1901,7 +1901,8 @@ boundaryField { inlet { - type zeroGradient; + type fixedFluxPressure; + value uniform 0; } outlet @@ -1912,7 +1913,7 @@ boundaryField walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/bubbleFoam/bubbleColumn/system/fvSchemes b/tutorials/multiphase/bubbleFoam/bubbleColumn/system/fvSchemes index 9e465b42626b91d9c8ea1c723119e11c224b50da..0779f1ea22142fea4f0c473c6e11fe2be822c587 100644 --- a/tutorials/multiphase/bubbleFoam/bubbleColumn/system/fvSchemes +++ b/tutorials/multiphase/bubbleFoam/bubbleColumn/system/fvSchemes @@ -42,7 +42,7 @@ laplacianSchemes default none; laplacian(nuEff1,U1) Gauss linear corrected; laplacian(nuEff2,U2) Gauss linear corrected; - laplacian((rho*(1|A(U))),p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; } interpolationSchemes diff --git a/tutorials/multiphase/cavitatingFoam/les/throttle/system/fvSchemes b/tutorials/multiphase/cavitatingFoam/les/throttle/system/fvSchemes index 4dd3e2bcc8832e21b0372730d027c9ad89382500..0c8bf54bb5147c6e3efe5a0212ddbf9d31f23449 100644 --- a/tutorials/multiphase/cavitatingFoam/les/throttle/system/fvSchemes +++ b/tutorials/multiphase/cavitatingFoam/les/throttle/system/fvSchemes @@ -43,7 +43,7 @@ laplacianSchemes default none; laplacian(nuf,rhoU) Gauss linear corrected; laplacian(muEff,U) Gauss linear corrected; - laplacian(rAUf,p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(1,p) Gauss linear corrected; } diff --git a/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/fvSchemes b/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/fvSchemes index 4dd3e2bcc8832e21b0372730d027c9ad89382500..0c8bf54bb5147c6e3efe5a0212ddbf9d31f23449 100644 --- a/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/fvSchemes +++ b/tutorials/multiphase/cavitatingFoam/les/throttle3D/system/fvSchemes @@ -43,7 +43,7 @@ laplacianSchemes default none; laplacian(nuf,rhoU) Gauss linear corrected; laplacian(muEff,U) Gauss linear corrected; - laplacian(rAUf,p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(1,p) Gauss linear corrected; } diff --git a/tutorials/multiphase/cavitatingFoam/ras/throttle/system/fvSchemes b/tutorials/multiphase/cavitatingFoam/ras/throttle/system/fvSchemes index 7134b5cb392707f3df724e601d244555786a6520..633e4a749e31ff2499e39cf4bc8b0ef6b26c2dae 100644 --- a/tutorials/multiphase/cavitatingFoam/ras/throttle/system/fvSchemes +++ b/tutorials/multiphase/cavitatingFoam/ras/throttle/system/fvSchemes @@ -44,7 +44,7 @@ laplacianSchemes default none; laplacian(nuf,rhoU) Gauss linear corrected; laplacian(muEff,U) Gauss linear corrected; - laplacian(rAUf,p) Gauss linear corrected; + laplacian(Dp,p) Gauss linear corrected; laplacian(DomegaEff,omega) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(1,p) Gauss linear corrected; diff --git a/tutorials/incompressible/pimpleFoam/elipsekkLOmega/constant/polyMesh/boundary b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/T.org similarity index 62% rename from tutorials/incompressible/pimpleFoam/elipsekkLOmega/constant/polyMesh/boundary rename to tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/T.org index ff3254a0cb60dfcc732d8651e9cc43f1738c5533..e5ac2eeb27e347dab629027bf93918e211179ee3 100644 --- a/tutorials/incompressible/pimpleFoam/elipsekkLOmega/constant/polyMesh/boundary +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/T.org @@ -9,38 +9,26 @@ FoamFile { version 2.0; format ascii; - class polyBoundaryMesh; - location "0/polyMesh"; - object boundary; + class volScalarField; + object alpha1; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -4 -( - outlet - { - type patch; - nFaces 320; - startFace 99370; - } - up - { - type symmetryPlane; - nFaces 380; - startFace 99690; - } - hole +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + walls { - type wall; - nFaces 560; - startFace 100070; + type zeroGradient; } - frontAndBack + + defaultFaces { type empty; - nFaces 100000; - startFace 100630; } -) +} // ************************************************************************* // diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/alpha1.org b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/alphawater.org similarity index 97% rename from tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/alpha1.org rename to tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/alphawater.org index b55820f9a97df868883d8e268380ca33634353c1..d90b720092af3d27f74cf6ca3cb23723735c73da 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/alpha1.org +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/0/alphawater.org @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class volScalarField; - object alpha1; + object alphawater; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allclean b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allclean index 1f81d5f86a1a82fe3da7c5866fa769511be561b4..d6e8dce5df4d6bb1480f3d9a86ae4abb36ea0fff 100755 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allclean +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allclean @@ -1,5 +1,6 @@ #!/bin/sh +cd ${0%/*} || exit 1 # run from this directory foamCleanTutorials cases rm -rf processor* -rm -rf 0/p_rgh 0/p_rgh.gz 0/alpha1 0/alpha1.gz +rm -rf 0/p_rgh.gz 0/alphawater.gz 0/T.gz diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allrun b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allrun index 5fd844dc716a76d9e1fd863c6095de60b8e1316c..76547516b77f0ec8beb17b5b56f9419008d1c5b2 100755 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allrun +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/Allrun @@ -8,8 +8,9 @@ cd ${0%/*} || exit 1 # run from this directory application=`getApplication` runApplication blockMesh -cp 0/alpha1.org 0/alpha1 +cp 0/alphawater.org 0/alphawater cp 0/p_rgh.org 0/p_rgh +cp 0/T.org 0/T runApplication setFields runApplication $application diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/polyMesh/blockMeshDict b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/polyMesh/blockMeshDict index 22d11441f9d1689de77c6f4166a669f5ad381151..9ed9a630b5557e768b1fe950ee9986c39ddd055a 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/polyMesh/blockMeshDict +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/polyMesh/blockMeshDict @@ -33,28 +33,20 @@ blocks hex (0 1 2 3 4 5 6 7) (80 160 1) simpleGrading (1 1 1) ); -boundary +patches ( - walls - { - type wall; - faces - ( - (3 7 6 2) - (0 4 7 3) - (2 6 5 1) - (1 5 4 0) - ); - } - frontAndBack - { - type empty; - faces - ( - (0 3 2 1) - (4 5 6 7) - ); - } + wall walls + ( + (3 7 6 2) + (0 4 7 3) + (2 6 5 1) + (1 5 4 0) + ) + empty frontAndBack + ( + (0 3 2 1) + (4 5 6 7) + ) ); // ************************************************************************* // diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/transportProperties b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/transportProperties index 67e66cd27d1df7d295302ee3b4f3744065d9a450..564df56f2083c586a247b9a7276aba1b90d3a4f2 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/transportProperties +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/constant/transportProperties @@ -15,22 +15,40 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -phase1 +phases (water air); + +water { transportModel Newtonian; - nu nu [ 0 2 -1 0 0 0 0 ] 1e-06; - rho rho [ 1 -3 0 0 0 0 0 ] 1000; - rho0 rho0 [ 1 -3 0 0 0 0 0 ] 1000; - psi psi [ 0 -2 2 0 0 ] 1e-05; + nu 1e-06; + rho 1000; + k 0; // 0.613; + Cv 4179; + + equationOfState + { + type perfectFluid; + + rho0 1000; + R 3000; + } } -phase2 +air { transportModel Newtonian; - nu nu [ 0 2 -1 0 0 0 0 ] 1.589e-05; - rho rho [ 1 -3 0 0 0 0 0 ] 1; - rho0 rho0 [ 1 -3 0 0 0 0 0 ] 0; - psi psi [ 0 -2 2 0 0 ] 1e-05; + nu 1.589e-05; + rho 1; + k 0; // 2.63e-2; + Cv 721; + + equationOfState + { + type perfectFluid; + + rho0 0; + R 287; + } } pMin pMin [ 1 -1 -2 0 0 0 0 ] 10000; diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/controlDict b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/controlDict index 4c225df9c72c71d81456de053cd258ddb2cd273a..933d1de45062eec659a907104ca20601a973af1f 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/controlDict +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/controlDict @@ -17,7 +17,7 @@ FoamFile application compressibleInterFoam; -startFrom latestTime; +startFrom startTime; startTime 0; diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSchemes b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSchemes index 5ab2bdc2fdd09ce6b17bba8d4eecc81f2422b925..c35af6cc4f1f5d6fee1dbd9232c03ad306fbbec1 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSchemes +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSchemes @@ -30,7 +30,9 @@ divSchemes div(rho*phi,U) Gauss upwind; div(phi,alpha) Gauss vanLeer; div(phirb,alpha) Gauss interfaceCompression 1; - div(phi,p_rgh) Gauss upwind; + div(phid1,p_rgh) Gauss upwind; + div(phid2,p_rgh) Gauss upwind; + div(rho*phi,T) Gauss upwind; div(phi,k) Gauss vanLeer; div((nuEff*dev(T(grad(U))))) Gauss linear; } @@ -55,7 +57,6 @@ fluxRequired default no; p_rgh; pcorr; - gamma; } diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution index 4a7f094cec58241b4f389580a662f5c8daaa0074..461897454640df6743233c416536bbb89b0fa6a0 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/fvSolution @@ -91,7 +91,7 @@ solvers nSweeps 1; } - "(k|B|nuTilda)" + "(T|k|B|nuTilda).*" { solver PBiCG; preconditioner DILU; diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/setFieldsDict b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/setFieldsDict index 37f90fd1d58d76574b98c9ce27c4685709e2d869..88198a4d2492d2a3aea2da05522422006700024a 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/setFieldsDict +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge2D/system/setFieldsDict @@ -17,8 +17,9 @@ FoamFile defaultFieldValues ( - volScalarFieldValue alpha1 1 + volScalarFieldValue alphawater 1 volScalarFieldValue p_rgh 1e5 + volScalarFieldValue T 300 ); regions @@ -29,8 +30,9 @@ regions radius 0.1; fieldValues ( - volScalarFieldValue alpha1 0 + volScalarFieldValue alphawater 0 volScalarFieldValue p_rgh 1e6 + volScalarFieldValue T 578 ); } boxToCell @@ -38,7 +40,7 @@ regions box (-10 1 -1) (10 10 1); fieldValues ( - volScalarFieldValue alpha1 0 + volScalarFieldValue alphawater 0 ); } ); diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/T.org b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/T.org new file mode 100644 index 0000000000000000000000000000000000000000..b40cb08478605737ff4cac5ebc6bf0cef6004ac7 --- /dev/null +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/T.org @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha1; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 300; + +boundaryField +{ + walls + { + type zeroGradient; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/alpha1.org b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/alphawater.org similarity index 97% rename from tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/alpha1.org rename to tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/alphawater.org index b15de21b75df681ebb13e3590211bf7adf8eaefa..62be61f403a247c589ce0dfd45bc84e54eaeb536 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/alpha1.org +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/0/alphawater.org @@ -10,7 +10,7 @@ FoamFile version 2.0; format ascii; class volScalarField; - object alpha1.org; + object alphawater; } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allclean b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allclean index 902055c7f72789a34d390cc9bea010bade61ab90..539c7721669d0975387894caa2ffcd81d6927fae 100755 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allclean +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allclean @@ -3,6 +3,6 @@ cd ${0%/*} || exit 1 # run from this directory foamCleanTutorials cases rm -rf processor* -rm -rf 0/p_rgh 0/p_rgh.gz 0/alpha1 0/alpha1.gz +rm -rf 0/p_rgh 0/p_rgh.gz 0/alphawater 0/alphawater.gz 0/T.gz # ----------------------------------------------------------------- end-of-file diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allrun b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allrun index ac00d007bcf311fc7c62e2b8e7a93ecb8d6850d3..0941ac4aa1aaff404b79022685eec6717e2ed8aa 100755 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allrun +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/Allrun @@ -8,8 +8,9 @@ cd ${0%/*} || exit 1 # run from this directory application=`getApplication` runApplication blockMesh -cp 0/alpha1.org 0/alpha1 +cp 0/alphawater.org 0/alphawater cp 0/p_rgh.org 0/p_rgh +cp 0/T.org 0/T runApplication setFields runApplication decomposePar runParallel $application 4 diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/constant/transportProperties b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/constant/transportProperties index 67e66cd27d1df7d295302ee3b4f3744065d9a450..564df56f2083c586a247b9a7276aba1b90d3a4f2 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/constant/transportProperties +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/constant/transportProperties @@ -15,22 +15,40 @@ FoamFile } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -phase1 +phases (water air); + +water { transportModel Newtonian; - nu nu [ 0 2 -1 0 0 0 0 ] 1e-06; - rho rho [ 1 -3 0 0 0 0 0 ] 1000; - rho0 rho0 [ 1 -3 0 0 0 0 0 ] 1000; - psi psi [ 0 -2 2 0 0 ] 1e-05; + nu 1e-06; + rho 1000; + k 0; // 0.613; + Cv 4179; + + equationOfState + { + type perfectFluid; + + rho0 1000; + R 3000; + } } -phase2 +air { transportModel Newtonian; - nu nu [ 0 2 -1 0 0 0 0 ] 1.589e-05; - rho rho [ 1 -3 0 0 0 0 0 ] 1; - rho0 rho0 [ 1 -3 0 0 0 0 0 ] 0; - psi psi [ 0 -2 2 0 0 ] 1e-05; + nu 1.589e-05; + rho 1; + k 0; // 2.63e-2; + Cv 721; + + equationOfState + { + type perfectFluid; + + rho0 0; + R 287; + } } pMin pMin [ 1 -1 -2 0 0 0 0 ] 10000; diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSchemes b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSchemes index 5ab2bdc2fdd09ce6b17bba8d4eecc81f2422b925..c35af6cc4f1f5d6fee1dbd9232c03ad306fbbec1 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSchemes +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSchemes @@ -30,7 +30,9 @@ divSchemes div(rho*phi,U) Gauss upwind; div(phi,alpha) Gauss vanLeer; div(phirb,alpha) Gauss interfaceCompression 1; - div(phi,p_rgh) Gauss upwind; + div(phid1,p_rgh) Gauss upwind; + div(phid2,p_rgh) Gauss upwind; + div(rho*phi,T) Gauss upwind; div(phi,k) Gauss vanLeer; div((nuEff*dev(T(grad(U))))) Gauss linear; } @@ -55,7 +57,6 @@ fluxRequired default no; p_rgh; pcorr; - gamma; } diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution index 4a7f094cec58241b4f389580a662f5c8daaa0074..461897454640df6743233c416536bbb89b0fa6a0 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/fvSolution @@ -91,7 +91,7 @@ solvers nSweeps 1; } - "(k|B|nuTilda)" + "(T|k|B|nuTilda).*" { solver PBiCG; preconditioner DILU; diff --git a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/setFieldsDict b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/setFieldsDict index 07f675b5de627181ee0d6160a1ddda90c59d6101..ec31deae034f52a0bcee92507698a43d1acd06de 100644 --- a/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/setFieldsDict +++ b/tutorials/multiphase/compressibleInterFoam/les/depthCharge3D/system/setFieldsDict @@ -17,8 +17,9 @@ FoamFile defaultFieldValues ( - volScalarFieldValue alpha1 1 + volScalarFieldValue alphawater 1 volScalarFieldValue p_rgh 1e5 + volScalarFieldValue T 300 ); regions @@ -29,8 +30,9 @@ regions radius 0.1; fieldValues ( - volScalarFieldValue alpha1 0 + volScalarFieldValue alphawater 0 volScalarFieldValue p_rgh 1e6 + volScalarFieldValue T 578 ); } boxToCell @@ -38,7 +40,7 @@ regions box (-10 1 -1) (10 10 1); fieldValues ( - volScalarFieldValue alpha1 0 + volScalarFieldValue alphawater 0 ); } ); diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p index 8f2ec50ff3a474e82d133f7b699115bf324249e3..ae2c14b7460e91d82d3717d540b6a9d33dc087e8 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/bubbleColumn/0/p @@ -22,7 +22,7 @@ boundaryField { inlet { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } outlet @@ -32,7 +32,7 @@ boundaryField } walls { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } } diff --git a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/0/p b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/0/p index 9c4de0da512d78d3fcd7499ef5621c328e3d56e0..72f221208d63bd2bb025e53a1aca041cb7c0c742 100644 --- a/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/0/p +++ b/tutorials/multiphase/compressibleTwoPhaseEulerFoam/mixerVessel2D/0/p @@ -22,13 +22,13 @@ boundaryField { rotor { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } stator { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } diff --git a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0.org/p_rgh b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0.org/p_rgh index e3f442956da4fbe4fe0ad93d72bdead2d0ade842..5c911a0345a594e93bda4ea5a00079c63723c8dc 100644 --- a/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0.org/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/damBreakWithObstacle/0.org/p_rgh @@ -22,13 +22,13 @@ boundaryField { walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } obstacle { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/p_rgh b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/p_rgh index 03c2b46b04460ab258396af7c20618722be05ea1..825a15d6dc99da40eadda49f7cb085281d7a3ec4 100644 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/p_rgh @@ -22,7 +22,7 @@ boundaryField { stationaryWalls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } atmosphere @@ -38,7 +38,7 @@ boundaryField } floatingObject { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/p_rgh b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/p_rgh index 6fd77ea86aebdfa2ea51e0c8e9d56327db65a4fa..5c0b4be6fd997364797adbf679d53bfbabe379d7 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D/0/p_rgh @@ -30,7 +30,7 @@ boundaryField } walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/0/p_rgh b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/0/p_rgh index 6fd77ea86aebdfa2ea51e0c8e9d56327db65a4fa..5c0b4be6fd997364797adbf679d53bfbabe379d7 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/0/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank2D3DoF/0/p_rgh @@ -30,7 +30,7 @@ boundaryField } walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/0/p_rgh b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/0/p_rgh index 1f97b19664ab01d8c9fd79ba09823507b0e87e9e..29202adadbe7d1acbcceb457c21c5d120c7dfe7f 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/0/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D/0/p_rgh @@ -22,7 +22,7 @@ boundaryField { walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/0/p_rgh b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/0/p_rgh index 1f97b19664ab01d8c9fd79ba09823507b0e87e9e..29202adadbe7d1acbcceb457c21c5d120c7dfe7f 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/0/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D3DoF/0/p_rgh @@ -22,7 +22,7 @@ boundaryField { walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/0/p_rgh b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/0/p_rgh index 1f97b19664ab01d8c9fd79ba09823507b0e87e9e..29202adadbe7d1acbcceb457c21c5d120c7dfe7f 100644 --- a/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/0/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/sloshingTank3D6DoF/0/p_rgh @@ -22,7 +22,7 @@ boundaryField { walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/0/p_rgh b/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/0/p_rgh index 1f97b19664ab01d8c9fd79ba09823507b0e87e9e..29202adadbe7d1acbcceb457c21c5d120c7dfe7f 100644 --- a/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/0/p_rgh +++ b/tutorials/multiphase/interDyMFoam/ras/testTubeMixer/0/p_rgh @@ -22,7 +22,7 @@ boundaryField { walls { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } } diff --git a/tutorials/multiphase/interFoam/laminar/capillaryRise/0/p_rgh b/tutorials/multiphase/interFoam/laminar/capillaryRise/0/p_rgh index 6914780a052838db58611901de22e358de6b1195..e574d0ac74aa2b472833684b5b25f1eb50076c54 100644 --- a/tutorials/multiphase/interFoam/laminar/capillaryRise/0/p_rgh +++ b/tutorials/multiphase/interFoam/laminar/capillaryRise/0/p_rgh @@ -35,7 +35,6 @@ boundaryField walls { type fixedFluxPressure; - adjoint no; } defaultFaces diff --git a/tutorials/multiphase/interFoam/laminar/capillaryRise/system/controlDict b/tutorials/multiphase/interFoam/laminar/capillaryRise/system/controlDict index 02e7599942b1ca1d11244cbe0c9888929075420d..64536780d08235e8fc74a30cad598a1aa943ada2 100644 --- a/tutorials/multiphase/interFoam/laminar/capillaryRise/system/controlDict +++ b/tutorials/multiphase/interFoam/laminar/capillaryRise/system/controlDict @@ -17,7 +17,7 @@ FoamFile application interFoam; -startFrom latestTime; +startFrom startTime; startTime 0; @@ -25,7 +25,7 @@ stopAt endTime; endTime 0.5; -deltaT 0.001; +deltaT 1e-5; writeControl adjustableRunTime; diff --git a/tutorials/multiphase/interFoam/laminar/damBreak/0/p_rgh b/tutorials/multiphase/interFoam/laminar/damBreak/0/p_rgh index 7ef84e282bacd00fe686b4129770ecb0a8819c1f..cfabea4db1c624bd7b28007c7e1c119856b1a412 100644 --- a/tutorials/multiphase/interFoam/laminar/damBreak/0/p_rgh +++ b/tutorials/multiphase/interFoam/laminar/damBreak/0/p_rgh @@ -22,19 +22,19 @@ boundaryField { leftWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } rightWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } lowerWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/interFoam/ras/damBreak/0/p_rgh b/tutorials/multiphase/interFoam/ras/damBreak/0/p_rgh index 7ef84e282bacd00fe686b4129770ecb0a8819c1f..cfabea4db1c624bd7b28007c7e1c119856b1a412 100644 --- a/tutorials/multiphase/interFoam/ras/damBreak/0/p_rgh +++ b/tutorials/multiphase/interFoam/ras/damBreak/0/p_rgh @@ -22,19 +22,19 @@ boundaryField { leftWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } rightWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } lowerWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/interFoam/ras/damBreakPorousBaffle/0/p_rgh b/tutorials/multiphase/interFoam/ras/damBreakPorousBaffle/0/p_rgh index 2b5d9fde975e5d8cf3706bbac886e25343a18234..c085da2cb601d8fefbe9daf36bd3be31cf44688d 100644 --- a/tutorials/multiphase/interFoam/ras/damBreakPorousBaffle/0/p_rgh +++ b/tutorials/multiphase/interFoam/ras/damBreakPorousBaffle/0/p_rgh @@ -23,19 +23,19 @@ boundaryField { leftWall { - type buoyantPressure; + type fixedFluxPressure; gradient uniform 0; value uniform 0; } rightWall { - type buoyantPressure; + type fixedFluxPressure; gradient uniform 0; value uniform 0; } lowerWall { - type buoyantPressure; + type fixedFluxPressure; gradient uniform 0; value uniform 0; } diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/p_rgh b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/p_rgh index 7ef84e282bacd00fe686b4129770ecb0a8819c1f..cfabea4db1c624bd7b28007c7e1c119856b1a412 100644 --- a/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/p_rgh +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/p_rgh @@ -22,19 +22,19 @@ boundaryField { leftWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } rightWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } lowerWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/0/p_rgh b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/0/p_rgh index f32544b279f7897112478db7e8b24cf48e042f4b..f2ef63d0be0ced1f66ff74471e1a87f72bc2a739 100644 --- a/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/0/p_rgh +++ b/tutorials/multiphase/interPhaseChangeFoam/cavitatingBullet/0/p_rgh @@ -39,7 +39,7 @@ boundaryField bullet { - type buoyantPressure; + type fixedFluxPressure; } } diff --git a/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/0/p b/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/0/p index 6fe844d27aafcb4ce1d92de1a206013e20cfe364..278db348b8d23f65b5c4c722224f9a40143ee86b 100644 --- a/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/0/p +++ b/tutorials/multiphase/multiphaseEulerFoam/bubbleColumn/0/p @@ -22,7 +22,7 @@ boundaryField { inlet { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } outlet diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/0.org/p b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/0.org/p index 7d12a339569a8ca8a9ef78453ef2963f94f5fba0..037f82d0b09721783dadd7f04dd0944e7dd8e6fa 100644 --- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/0.org/p +++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phase/0.org/p @@ -22,19 +22,19 @@ boundaryField { leftWall { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } rightWall { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } lowerWall { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/0.org/p b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/0.org/p index 7d12a339569a8ca8a9ef78453ef2963f94f5fba0..037f82d0b09721783dadd7f04dd0944e7dd8e6fa 100644 --- a/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/0.org/p +++ b/tutorials/multiphase/multiphaseEulerFoam/damBreak4phaseFine/0.org/p @@ -22,19 +22,19 @@ boundaryField { leftWall { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } rightWall { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } lowerWall { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/0/p b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/0/p index 75717ab2755c7adb1ce32c50f1026fa9fef03767..32d92ebc3637af3a1e125f0f79d738521aac9fd8 100644 --- a/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/0/p +++ b/tutorials/multiphase/multiphaseEulerFoam/mixerVessel2D/0/p @@ -22,13 +22,13 @@ boundaryField { rotor { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } stator { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/0.org/p_rgh b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/0.org/p_rgh index 7ef84e282bacd00fe686b4129770ecb0a8819c1f..cfabea4db1c624bd7b28007c7e1c119856b1a412 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/0.org/p_rgh +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phase/0.org/p_rgh @@ -22,19 +22,19 @@ boundaryField { leftWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } rightWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } lowerWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/0.org/p_rgh b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/0.org/p_rgh index 7ef84e282bacd00fe686b4129770ecb0a8819c1f..cfabea4db1c624bd7b28007c7e1c119856b1a412 100644 --- a/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/0.org/p_rgh +++ b/tutorials/multiphase/multiphaseInterFoam/laminar/damBreak4phaseFine/0.org/p_rgh @@ -22,19 +22,19 @@ boundaryField { leftWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } rightWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } lowerWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/settlingFoam/ras/dahl/0/p_rgh b/tutorials/multiphase/settlingFoam/ras/dahl/0/p_rgh index f289b34b7c0085f8c7ad0f446387070d8f758900..81c72d7f7a91b9bb4387eaa5ec75d11af4dfa047 100644 --- a/tutorials/multiphase/settlingFoam/ras/dahl/0/p_rgh +++ b/tutorials/multiphase/settlingFoam/ras/dahl/0/p_rgh @@ -22,7 +22,7 @@ boundaryField { inlet { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } @@ -34,19 +34,19 @@ boundaryField bottomWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } endWall { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } top { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/settlingFoam/ras/dahl/system/fvSchemes b/tutorials/multiphase/settlingFoam/ras/dahl/system/fvSchemes index bfdc69ada0aab5869e62fc38754ceafb53757b68..026c549f6cc9e8ba363e2f68bf3632b42f9d9c95 100644 --- a/tutorials/multiphase/settlingFoam/ras/dahl/system/fvSchemes +++ b/tutorials/multiphase/settlingFoam/ras/dahl/system/fvSchemes @@ -39,7 +39,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear corrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected; + laplacian(Dp,p_rgh) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; laplacian(mut,Alpha) Gauss linear corrected; diff --git a/tutorials/multiphase/settlingFoam/ras/tank3D/0/p_rgh b/tutorials/multiphase/settlingFoam/ras/tank3D/0/p_rgh index 75d1cda22d24218c818448a0c72e88aa1852327f..0e6a2c640f58aec3dcdbee1f366e27e6695e7efd 100644 --- a/tutorials/multiphase/settlingFoam/ras/tank3D/0/p_rgh +++ b/tutorials/multiphase/settlingFoam/ras/tank3D/0/p_rgh @@ -22,115 +22,115 @@ boundaryField { SYMP3 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } INLE1 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } OUTL9 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } OUTL10 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } OUTL11 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } OUTL12 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL6 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL8 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL61 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL62 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL63 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL64 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL65 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL66 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL67 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL68 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL69 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL7 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } WALL70 { - type buoyantPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/settlingFoam/ras/tank3D/system/fvSchemes b/tutorials/multiphase/settlingFoam/ras/tank3D/system/fvSchemes index 65b5f239efdf671cd1e905521e0a367f391dee7b..ffdb15771e3f39d065b66a255d0529a0aad5a82e 100644 --- a/tutorials/multiphase/settlingFoam/ras/tank3D/system/fvSchemes +++ b/tutorials/multiphase/settlingFoam/ras/tank3D/system/fvSchemes @@ -39,7 +39,7 @@ laplacianSchemes { default none; laplacian(muEff,U) Gauss linear corrected; - laplacian((rho*(1|A(U))),p_rgh) Gauss linear corrected; + laplacian(Dp,p_rgh) Gauss linear corrected; laplacian(DkEff,k) Gauss linear corrected; laplacian(DepsilonEff,epsilon) Gauss linear corrected; laplacian(mut,Alpha) Gauss linear corrected; diff --git a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/0.org/p_rgh b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/0.org/p_rgh index a9156248a7f0c07bd2d7d4bc0ce935b441d7a1cf..b61e0277ec8f8c8470f2596dfe9705b49ecca2b9 100644 --- a/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/0.org/p_rgh +++ b/tutorials/multiphase/twoLiquidMixingFoam/lockExchange/0.org/p_rgh @@ -23,19 +23,19 @@ boundaryField { left { - type buoyantPressure; + type fixedFluxPressure; } right { - type buoyantPressure; + type fixedFluxPressure; } bottom { - type buoyantPressure; + type fixedFluxPressure; } top { - type buoyantPressure; + type fixedFluxPressure; } frontBack { diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p b/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p index 63e3f73b31401551576637875edbbfd179238e84..e5e362d9581416422955cfda91f20e06e4e30c0b 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed/0/p @@ -22,7 +22,7 @@ boundaryField { bottom { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } @@ -34,7 +34,7 @@ boundaryField walls { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p b/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p index d8384de3d5ca030b0e0472dc0a8f3148e1f8f3e8..5b2c9cfa86f1a79371639e8ac1932bc0a602cb51 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p +++ b/tutorials/multiphase/twoPhaseEulerFoam/bed2/0/p @@ -22,7 +22,7 @@ boundaryField { walls { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } outlet @@ -32,7 +32,7 @@ boundaryField } inlet { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } frontAndBackPlanes diff --git a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p index db1aca2e2a4e704567622e7f4d8a094e0f2152d2..5fffa73a19c7bb4636820cdc2558cd1f43b0429d 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p +++ b/tutorials/multiphase/twoPhaseEulerFoam/bubbleColumn/0/p @@ -1901,7 +1901,7 @@ boundaryField { inlet { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } @@ -1913,7 +1913,7 @@ boundaryField walls { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value uniform 0; } diff --git a/tutorials/multiphase/twoPhaseEulerFoam/mixerVessel2D/0/p b/tutorials/multiphase/twoPhaseEulerFoam/mixerVessel2D/0/p index 75717ab2755c7adb1ce32c50f1026fa9fef03767..32d92ebc3637af3a1e125f0f79d738521aac9fd8 100644 --- a/tutorials/multiphase/twoPhaseEulerFoam/mixerVessel2D/0/p +++ b/tutorials/multiphase/twoPhaseEulerFoam/mixerVessel2D/0/p @@ -22,13 +22,13 @@ boundaryField { rotor { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } stator { - type multiphaseFixedFluxPressure; + type fixedFluxPressure; value $internalField; } diff --git a/wmake/rules/General/CGAL b/wmake/rules/General/CGAL index 126640dc0cf2f7e1c4dd84814e5fbe5526fd0add..cfb02d716abda593740b3b21149e67ac1ffa9803 100644 --- a/wmake/rules/General/CGAL +++ b/wmake/rules/General/CGAL @@ -7,6 +7,4 @@ CGAL_INC = \ CGAL_LIBS = \ -L$(MPFR_ARCH_PATH)/lib \ - -L$(BOOST_ARCH_PATH)/lib \ - -lmpfr \ - -lboost_thread + -L$(BOOST_ARCH_PATH)/lib diff --git a/wmake/rules/linux64Gcc47/c b/wmake/rules/linux64Gcc47/c new file mode 100644 index 0000000000000000000000000000000000000000..f4114be3143d1210ffea500a2b361008910abed0 --- /dev/null +++ b/wmake/rules/linux64Gcc47/c @@ -0,0 +1,16 @@ +.SUFFIXES: .c .h + +cWARN = -Wall + +cc = gcc -m64 + +include $(RULES)/c$(WM_COMPILE_OPTION) + +cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC + +ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $$SOURCE -o $@ + +LINK_LIBS = $(cDBUG) + +LINKLIBSO = $(cc) -shared +LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linux64Gcc47/c++ b/wmake/rules/linux64Gcc47/c++ new file mode 100644 index 0000000000000000000000000000000000000000..98b25ed1fea2a1baa0ad749c09a76bd877ea4a6d --- /dev/null +++ b/wmake/rules/linux64Gcc47/c++ @@ -0,0 +1,21 @@ +.SUFFIXES: .C .cxx .cc .cpp + +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast + +CC = g++ -m64 + +include $(RULES)/c++$(WM_COMPILE_OPTION) + +ptFLAGS = -DNoRepository -ftemplate-depth-100 + +c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC + +Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $$SOURCE -o $@ +cxxtoo = $(Ctoo) +cctoo = $(Ctoo) +cpptoo = $(Ctoo) + +LINK_LIBS = $(c++DBUG) + +LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linux64Gcc47/c++Debug b/wmake/rules/linux64Gcc47/c++Debug new file mode 100644 index 0000000000000000000000000000000000000000..19bdb9c3346fc7a69380dfedd6e7911fe220a965 --- /dev/null +++ b/wmake/rules/linux64Gcc47/c++Debug @@ -0,0 +1,2 @@ +c++DBUG = -ggdb3 -DFULLDEBUG +c++OPT = -O0 -fdefault-inline diff --git a/wmake/rules/linux64Gcc47/c++Opt b/wmake/rules/linux64Gcc47/c++Opt new file mode 100644 index 0000000000000000000000000000000000000000..2aedabd6280a3476bc58db13139a0a3aa579502b --- /dev/null +++ b/wmake/rules/linux64Gcc47/c++Opt @@ -0,0 +1,2 @@ +c++DBUG = +c++OPT = -O3 diff --git a/wmake/rules/linux64Gcc47/c++Prof b/wmake/rules/linux64Gcc47/c++Prof new file mode 100644 index 0000000000000000000000000000000000000000..3bda4dad55e898a8198f6e8bfe21e8d829d7230a --- /dev/null +++ b/wmake/rules/linux64Gcc47/c++Prof @@ -0,0 +1,2 @@ +c++DBUG = -pg +c++OPT = -O2 diff --git a/wmake/rules/linux64Gcc47/cDebug b/wmake/rules/linux64Gcc47/cDebug new file mode 100644 index 0000000000000000000000000000000000000000..72b638f458220e329d52b59e3566a3c807101f9d --- /dev/null +++ b/wmake/rules/linux64Gcc47/cDebug @@ -0,0 +1,2 @@ +cDBUG = -ggdb -DFULLDEBUG +cOPT = -O1 -fdefault-inline -finline-functions diff --git a/wmake/rules/linux64Gcc47/cOpt b/wmake/rules/linux64Gcc47/cOpt new file mode 100644 index 0000000000000000000000000000000000000000..17318709f1fa39e6bf89cbe87778bc6fa459de17 --- /dev/null +++ b/wmake/rules/linux64Gcc47/cOpt @@ -0,0 +1,2 @@ +cDBUG = +cOPT = -O3 diff --git a/wmake/rules/linux64Gcc47/cProf b/wmake/rules/linux64Gcc47/cProf new file mode 100644 index 0000000000000000000000000000000000000000..ca3ac9bf5f0cd61fe99e0f05fa1bd4bdf9fa6cf7 --- /dev/null +++ b/wmake/rules/linux64Gcc47/cProf @@ -0,0 +1,2 @@ +cDBUG = -pg +cOPT = -O2 diff --git a/wmake/rules/linux64Gcc47/general b/wmake/rules/linux64Gcc47/general new file mode 100644 index 0000000000000000000000000000000000000000..4a42b11b1ee6aebe596e3cd2e2633d9c70cb5e9a --- /dev/null +++ b/wmake/rules/linux64Gcc47/general @@ -0,0 +1,8 @@ +CPP = cpp -traditional-cpp + +PROJECT_LIBS = -l$(WM_PROJECT) -ldl + +include $(GENERAL_RULES)/standard + +include $(RULES)/c +include $(RULES)/c++ diff --git a/wmake/rules/linux64Gcc47/mplibHPMPI b/wmake/rules/linux64Gcc47/mplibHPMPI new file mode 100644 index 0000000000000000000000000000000000000000..574492a236a32f7d87d00bf0e3507a5ac8e54f55 --- /dev/null +++ b/wmake/rules/linux64Gcc47/mplibHPMPI @@ -0,0 +1,3 @@ +PFLAGS = +PINC = -I$(MPI_ARCH_PATH)/include -D_MPICC_H +PLIBS = -L$(MPI_ARCH_PATH)/lib/linux_amd64 -lmpi diff --git a/wmake/rules/linux64Gcc47/mplibINTELMPI b/wmake/rules/linux64Gcc47/mplibINTELMPI new file mode 100644 index 0000000000000000000000000000000000000000..cf80ec2eaf68d1c2f6adf208964b6490c4c8fd36 --- /dev/null +++ b/wmake/rules/linux64Gcc47/mplibINTELMPI @@ -0,0 +1,3 @@ +PFLAGS = -DMPICH_SKIP_MPICXX +PINC = -I$(MPI_ARCH_PATH)/include64 +PLIBS = -L$(MPI_ARCH_PATH)/lib64 -lmpi diff --git a/wmake/rules/linuxGcc47/c b/wmake/rules/linuxGcc47/c new file mode 100644 index 0000000000000000000000000000000000000000..d914fcd37d084b82a1833722d6ad7a0db3dd1c93 --- /dev/null +++ b/wmake/rules/linuxGcc47/c @@ -0,0 +1,16 @@ +.SUFFIXES: .c .h + +cWARN = -Wall + +cc = gcc -m32 + +include $(RULES)/c$(WM_COMPILE_OPTION) + +cFLAGS = $(GFLAGS) $(cWARN) $(cOPT) $(cDBUG) $(LIB_HEADER_DIRS) -fPIC + +ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $$SOURCE -o $@ + +LINK_LIBS = $(cDBUG) + +LINKLIBSO = $(cc) -shared +LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linuxGcc47/c++ b/wmake/rules/linuxGcc47/c++ new file mode 100644 index 0000000000000000000000000000000000000000..357f4106e10d7d1108a6713802e6f0d01cd8be9a --- /dev/null +++ b/wmake/rules/linuxGcc47/c++ @@ -0,0 +1,21 @@ +.SUFFIXES: .C .cxx .cc .cpp + +c++WARN = -Wall -Wextra -Wno-unused-parameter -Wold-style-cast + +CC = g++ -m32 + +include $(RULES)/c++$(WM_COMPILE_OPTION) + +ptFLAGS = -DNoRepository -ftemplate-depth-100 + +c++FLAGS = $(GFLAGS) $(c++WARN) $(c++OPT) $(c++DBUG) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC + +Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) -c $$SOURCE -o $@ +cxxtoo = $(Ctoo) +cctoo = $(Ctoo) +cpptoo = $(Ctoo) + +LINK_LIBS = $(c++DBUG) + +LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linuxGcc47/c++Debug b/wmake/rules/linuxGcc47/c++Debug new file mode 100644 index 0000000000000000000000000000000000000000..19bdb9c3346fc7a69380dfedd6e7911fe220a965 --- /dev/null +++ b/wmake/rules/linuxGcc47/c++Debug @@ -0,0 +1,2 @@ +c++DBUG = -ggdb3 -DFULLDEBUG +c++OPT = -O0 -fdefault-inline diff --git a/wmake/rules/linuxGcc47/c++Opt b/wmake/rules/linuxGcc47/c++Opt new file mode 100644 index 0000000000000000000000000000000000000000..2aedabd6280a3476bc58db13139a0a3aa579502b --- /dev/null +++ b/wmake/rules/linuxGcc47/c++Opt @@ -0,0 +1,2 @@ +c++DBUG = +c++OPT = -O3 diff --git a/wmake/rules/linuxGcc47/c++Prof b/wmake/rules/linuxGcc47/c++Prof new file mode 100644 index 0000000000000000000000000000000000000000..3bda4dad55e898a8198f6e8bfe21e8d829d7230a --- /dev/null +++ b/wmake/rules/linuxGcc47/c++Prof @@ -0,0 +1,2 @@ +c++DBUG = -pg +c++OPT = -O2 diff --git a/wmake/rules/linuxGcc47/cDebug b/wmake/rules/linuxGcc47/cDebug new file mode 100644 index 0000000000000000000000000000000000000000..72b638f458220e329d52b59e3566a3c807101f9d --- /dev/null +++ b/wmake/rules/linuxGcc47/cDebug @@ -0,0 +1,2 @@ +cDBUG = -ggdb -DFULLDEBUG +cOPT = -O1 -fdefault-inline -finline-functions diff --git a/wmake/rules/linuxGcc47/cOpt b/wmake/rules/linuxGcc47/cOpt new file mode 100644 index 0000000000000000000000000000000000000000..17318709f1fa39e6bf89cbe87778bc6fa459de17 --- /dev/null +++ b/wmake/rules/linuxGcc47/cOpt @@ -0,0 +1,2 @@ +cDBUG = +cOPT = -O3 diff --git a/wmake/rules/linuxGcc47/cProf b/wmake/rules/linuxGcc47/cProf new file mode 100644 index 0000000000000000000000000000000000000000..ca3ac9bf5f0cd61fe99e0f05fa1bd4bdf9fa6cf7 --- /dev/null +++ b/wmake/rules/linuxGcc47/cProf @@ -0,0 +1,2 @@ +cDBUG = -pg +cOPT = -O2 diff --git a/wmake/rules/linuxGcc47/general b/wmake/rules/linuxGcc47/general new file mode 100644 index 0000000000000000000000000000000000000000..4b051e6b9840df29cac2e8ced14c7d18b0b337d5 --- /dev/null +++ b/wmake/rules/linuxGcc47/general @@ -0,0 +1,9 @@ +CPP = cpp -traditional-cpp +LD = ld -melf_i386 + +PROJECT_LIBS = -l$(WM_PROJECT) -ldl + +include $(GENERAL_RULES)/standard + +include $(RULES)/c +include $(RULES)/c++ diff --git a/wmake/rules/linuxGcc47/mplibHPMPI b/wmake/rules/linuxGcc47/mplibHPMPI new file mode 100644 index 0000000000000000000000000000000000000000..8aff40632bd23af9607d63c4eb675a8de0cd287c --- /dev/null +++ b/wmake/rules/linuxGcc47/mplibHPMPI @@ -0,0 +1,3 @@ +PFLAGS = +PINC = -I$(MPI_ARCH_PATH)/include -D_MPICC_H +PLIBS = -L$(MPI_ARCH_PATH)/lib/linux_ia32 -lmpi