diff --git a/applications/solvers/combustion/dieselEngineFoam/createFields.H b/applications/solvers/combustion/dieselEngineFoam/createFields.H index 9d9229cc3c1dbed27219d4e53ff49af24f78767d..6987608006944b90c490be22152d5b893dc648b0 100644 --- a/applications/solvers/combustion/dieselEngineFoam/createFields.H +++ b/applications/solvers/combustion/dieselEngineFoam/createFields.H @@ -13,6 +13,14 @@ PtrList<volScalarField>& Y = composition.Y(); word inertSpecie(thermo.lookup("inertSpecie")); +if (!composition.contains(inertSpecie)) +{ + FatalErrorIn(args.executable()) + << "Specified inert specie '" << inertSpecie << "' not found in " + << "species list. Available species:" << composition.species() + << exit(FatalError); +} + volScalarField rho ( IOobject diff --git a/applications/solvers/incompressible/porousSimpleFoam/Make/files b/applications/solvers/incompressible/porousSimpleFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..e72f7ed78c75d9aec66277a58f9807aee0073d75 --- /dev/null +++ b/applications/solvers/incompressible/porousSimpleFoam/Make/files @@ -0,0 +1,3 @@ +porousSimpleFoam.C + +EXE = $(FOAM_APPBIN)/porousSimpleFoam diff --git a/applications/solvers/incompressible/porousSimpleFoam/Make/options b/applications/solvers/incompressible/porousSimpleFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..f490133ba67a4764a473d9a150b2b06f839a3790 --- /dev/null +++ b/applications/solvers/incompressible/porousSimpleFoam/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I../simpleFoam \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lincompressibleRASModels \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/incompressible/porousSimpleFoam/UEqn.H b/applications/solvers/incompressible/porousSimpleFoam/UEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..c1925c7708c8fb821515092efcc420b22f816ad1 --- /dev/null +++ b/applications/solvers/incompressible/porousSimpleFoam/UEqn.H @@ -0,0 +1,47 @@ + // Construct the Momentum equation + + tmp<fvVectorMatrix> UEqn + ( + fvm::div(phi, U) + - fvm::Sp(fvc::div(phi), U) + + turbulence->divDevReff(U) + ); + + UEqn().relax(); + + // Include the porous media resistance and solve the momentum equation + // either implicit in the tensorial resistance or transport using by + // including the spherical part of the resistance in the momentum diagonal + + tmp<volScalarField> trAU; + tmp<volTensorField> trTU; + + if (pressureImplicitPorosity) + { + tmp<volTensorField> tTU = tensor(I)*UEqn().A(); + pZones.addResistance(UEqn(), tTU()); + trTU = inv(tTU()); + trTU().rename("rAU"); + + volVectorField gradp = fvc::grad(p); + + for (int UCorr=0; UCorr<nUCorr; UCorr++) + { + U = trTU() & (UEqn().H() - gradp); + } + U.correctBoundaryConditions(); + } + else + { + pZones.addResistance(UEqn()); + + eqnResidual = solve + ( + UEqn() == -fvc::grad(p) + ). initialResidual(); + + maxResidual = max(eqnResidual, maxResidual); + + trAU = 1.0/UEqn().A(); + trAU().rename("rAU"); + } diff --git a/applications/solvers/incompressible/porousSimpleFoam/createFields.H b/applications/solvers/incompressible/porousSimpleFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..04d57d0571472ea1ee00c9a8ec1e24171eefe640 --- /dev/null +++ b/applications/solvers/incompressible/porousSimpleFoam/createFields.H @@ -0,0 +1,64 @@ + 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("SIMPLE"), pRefCell, pRefValue); + + + singlePhaseTransportModel laminarTransport(U, phi); + + autoPtr<incompressible::RASModel> turbulence + ( + incompressible::RASModel::New(U, phi, laminarTransport) + ); + + + porousZones pZones(mesh); + Switch pressureImplicitPorosity(false); + + int nUCorr = 0; + if (pZones.size()) + { + // nUCorrectors for pressureImplicitPorosity + if (mesh.solutionDict().subDict("SIMPLE").found("nUCorrectors")) + { + nUCorr = readInt + ( + mesh.solutionDict().subDict("SIMPLE").lookup("nUCorrectors") + ); + } + + if (nUCorr > 0) + { + pressureImplicitPorosity = true; + } + } diff --git a/applications/solvers/incompressible/porousSimpleFoam/pEqn.H b/applications/solvers/incompressible/porousSimpleFoam/pEqn.H new file mode 100644 index 0000000000000000000000000000000000000000..e6797cd8603b8032e1c901583b6ddb15992b7ddc --- /dev/null +++ b/applications/solvers/incompressible/porousSimpleFoam/pEqn.H @@ -0,0 +1,59 @@ +if (pressureImplicitPorosity) +{ + U = trTU()&UEqn().H(); +} +else +{ + U = trAU()*UEqn().H(); +} + +UEqn.clear(); +phi = fvc::interpolate(U) & mesh.Sf(); +adjustPhi(phi, U, p); + +for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) +{ + tmp<fvScalarMatrix> tpEqn; + + if (pressureImplicitPorosity) + { + tpEqn = (fvm::laplacian(trTU(), p) == fvc::div(phi)); + } + else + { + tpEqn = (fvm::laplacian(trAU(), p) == fvc::div(phi)); + } + + tpEqn().setReference(pRefCell, pRefValue); + // retain the residual from the first iteration + if (nonOrth == 0) + { + eqnResidual = tpEqn().solve().initialResidual(); + maxResidual = max(eqnResidual, maxResidual); + } + else + { + tpEqn().solve(); + } + + if (nonOrth == nNonOrthCorr) + { + phi -= tpEqn().flux(); + } +} + +#include "continuityErrs.H" + +// Explicitly relax pressure for momentum corrector +p.relax(); + +if (pressureImplicitPorosity) +{ + U -= trTU()&fvc::grad(p); +} +else +{ + U -= trAU()*fvc::grad(p); +} + +U.correctBoundaryConditions(); diff --git a/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C b/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..b78f1688fe9bacd942529d1edc031e7fce981eff --- /dev/null +++ b/applications/solvers/incompressible/porousSimpleFoam/porousSimpleFoam.C @@ -0,0 +1,85 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + porousSimpleFoam + +Description + Steady-state solver for incompressible, turbulent flow with + implicit or explicit porosity treatment + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "RASModel.H" +#include "porousZones.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +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 "readSIMPLEControls.H" + #include "initConvergenceCheck.H" + + p.storePrevIter(); + + // Pressure-velocity SIMPLE corrector + { + #include "UEqn.H" + #include "pEqn.H" + } + + turbulence->correct(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + + #include "convergenceCheck.H" + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/coalChemistryFoam/YEqn.H b/applications/solvers/lagrangian/coalChemistryFoam/YEqn.H index 5c84cfdb3f5eae620a53dd50b8a0d32e6abb1fac..abe03f60c0693786e07694888078dd8ae0e08a28 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/YEqn.H +++ b/applications/solvers/lagrangian/coalChemistryFoam/YEqn.H @@ -14,7 +14,7 @@ tmp<fv::convectionScheme<scalar> > mvConvection label inertIndex = -1; volScalarField Yt = 0.0*Y[0]; - for (label i=0; i<Y.size(); i++) + forAll(Y, i) { if (Y[i].name() != inertSpecie) { diff --git a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H index bba39fe8627d330b08eab8f586835fbe37449e39..14d6f6f2298d26096ed33aead5eb30fac51fe886 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/createFields.H +++ b/applications/solvers/lagrangian/coalChemistryFoam/createFields.H @@ -13,6 +13,14 @@ word inertSpecie(thermo.lookup("inertSpecie")); + if (!composition.contains(inertSpecie)) + { + FatalErrorIn(args.executable()) + << "Specified inert specie '" << inertSpecie << "' not found in " + << "species list. Available species:" << composition.species() + << exit(FatalError); + } + volScalarField& p = thermo.p(); volScalarField& h = thermo.h(); const volScalarField& T = thermo.T(); diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H index e802fdfe0d85929101f5e6723080b6666dfa2fb4..4e9c29815aaa0a96f1a017be68befcff7b154b59 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/YEqn.H @@ -15,7 +15,7 @@ tmp<fv::convectionScheme<scalar> > mvConvection label inertIndex = -1; volScalarField Yt = 0.0*Y[0]; - for (label i=0; i<Y.size(); i++) + forAll(Y, i) { if (Y[i].name() != inertSpecie) { diff --git a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H index a3054db0f5853192df84abadd77f6a3e3fed6687..3d6c5500ea9a3b3460eefb90c0abc4ead007f969 100644 --- a/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H +++ b/applications/solvers/lagrangian/porousExplicitSourceReactingParcelFoam/createFields.H @@ -13,6 +13,14 @@ word inertSpecie(thermo.lookup("inertSpecie")); + if (!composition.contains(inertSpecie)) + { + FatalErrorIn(args.executable()) + << "Specified inert specie '" << inertSpecie << "' not found in " + << "species list. Available species:" << composition.species() + << exit(FatalError); + } + volScalarField& p = thermo.p(); volScalarField& h = thermo.h(); const volScalarField& T = thermo.T(); diff --git a/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H b/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H index 5cf44cb09fef5500b0813c099abc57c433cee9cc..c687f2035ba3fb4bb6d48efcd631d052eb189fce 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/YEqn.H @@ -14,7 +14,7 @@ tmp<fv::convectionScheme<scalar> > mvConvection label inertIndex = -1; volScalarField Yt = 0.0*Y[0]; - for (label i=0; i<Y.size(); i++) + forAll(Y, i) { if (Y[i].name() != inertSpecie) { diff --git a/applications/solvers/lagrangian/reactingParcelFoam/createFields.H b/applications/solvers/lagrangian/reactingParcelFoam/createFields.H index ec820fa5e364dcc3a56781d08bf9ac2dc7925ad0..359599a61f4f1bf68362720d9d9e9e006a9fb2cc 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/createFields.H +++ b/applications/solvers/lagrangian/reactingParcelFoam/createFields.H @@ -13,6 +13,14 @@ word inertSpecie(thermo.lookup("inertSpecie")); + if (!composition.contains(inertSpecie)) + { + FatalErrorIn(args.executable()) + << "Specified inert specie '" << inertSpecie << "' not found in " + << "species list. Available species:" << composition.species() + << exit(FatalError); + } + volScalarField& p = thermo.p(); volScalarField& h = thermo.h(); const volScalarField& T = thermo.T(); diff --git a/applications/solvers/multiphase/interMixingFoam/Make/files b/applications/solvers/multiphase/interMixingFoam/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..488cd77e56dca265db6dab1b98933df8fe9ae72a --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/Make/files @@ -0,0 +1,6 @@ +incompressibleThreePhaseMixture/threePhaseMixture.C +threePhaseInterfaceProperties/threePhaseInterfaceProperties.C +interMixingFoam.C + +EXE = $(FOAM_APPBIN)/interMixingFoam + diff --git a/applications/solvers/multiphase/interMixingFoam/Make/options b/applications/solvers/multiphase/interMixingFoam/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..d8e4da2313e4343d0c6200c7fe9c7e8d2c090d48 --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/Make/options @@ -0,0 +1,17 @@ +INTERFOAM = $(FOAM_SOLVERS)/multiphase/interFoam + +EXE_INC = \ + -I$(INTERFOAM) \ + -IincompressibleThreePhaseMixture \ + -IthreePhaseInterfaceProperties \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/incompressible/turbulenceModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/transportModels + +EXE_LIBS = \ + -linterfaceProperties \ + -lincompressibleTransportModels \ + -lincompressibleRASModels \ + -lincompressibleLESModels \ + -lfiniteVolume diff --git a/applications/solvers/multiphase/interMixingFoam/alphaEqns.H b/applications/solvers/multiphase/interMixingFoam/alphaEqns.H new file mode 100644 index 0000000000000000000000000000000000000000..f9bad0a7058577487b0cb6e4fd7bb14f1e9ee24d --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/alphaEqns.H @@ -0,0 +1,164 @@ +{ + word alphaScheme("div(phi,alpha)"); + word alpharScheme("div(phirb,alpha)"); + + surfaceScalarField phir + ( + IOobject + ( + "phir", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + interface.cAlpha()*mag(phi/mesh.magSf())*interface.nHatf() + ); + + for (int gCorr=0; gCorr<nAlphaCorr; gCorr++) + { + // Create the limiter to be used for all phase-fractions + scalarField allLambda(mesh.nFaces(), 1.0); + + // Split the limiter into a surfaceScalarField + slicedSurfaceScalarField lambda + ( + IOobject + ( + "lambda", + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + mesh, + dimless, + allLambda + ); + + + // Create the complete convection flux for alpha1 + surfaceScalarField phiAlpha1 = + fvc::flux + ( + phi, + alpha1, + alphaScheme + ) + + fvc::flux + ( + -fvc::flux(-phir, alpha2, alpharScheme), + alpha1, + alpharScheme + ) + + fvc::flux + ( + -fvc::flux(-phir, alpha3, alpharScheme), + alpha1, + alpharScheme + ); + + // Create the bounded (upwind) flux for alpha1 + surfaceScalarField phiAlpha1BD = + upwind<scalar>(mesh, phi).flux(alpha1); + + // Calculate the flux correction for alpha1 + phiAlpha1 -= phiAlpha1BD; + + // Calculate the limiter for alpha1 + MULES::limiter + ( + allLambda, + oneField(), + alpha1, + phiAlpha1BD, + phiAlpha1, + zeroField(), + zeroField(), + 1, + 0, + 3 + ); + + // Create the complete flux for alpha2 + surfaceScalarField phiAlpha2 = + fvc::flux + ( + phi, + alpha2, + alphaScheme + ) + + fvc::flux + ( + -fvc::flux(phir, alpha1, alpharScheme), + alpha2, + alpharScheme + ); + + // Create the bounded (upwind) flux for alpha2 + surfaceScalarField phiAlpha2BD = + upwind<scalar>(mesh, phi).flux(alpha2); + + // Calculate the flux correction for alpha2 + phiAlpha2 -= phiAlpha2BD; + + // Further limit the limiter for alpha2 + MULES::limiter + ( + allLambda, + oneField(), + alpha2, + phiAlpha2BD, + phiAlpha2, + zeroField(), + zeroField(), + 1, + 0, + 3 + ); + + // Construct the limited fluxes + phiAlpha1 = phiAlpha1BD + lambda*phiAlpha1; + phiAlpha2 = phiAlpha2BD + lambda*phiAlpha2; + + // Solve for alpha1 + solve(fvm::ddt(alpha1) + fvc::div(phiAlpha1)); + + // Create the diffusion coefficients for alpha2<->alpha3 + volScalarField Dc23 = D23*max(alpha3, scalar(0))*pos(alpha2); + volScalarField Dc32 = D23*max(alpha2, scalar(0))*pos(alpha3); + + // Add the diffusive flux for alpha3->alpha2 + phiAlpha2 -= fvc::interpolate(Dc32)*mesh.magSf()*fvc::snGrad(alpha1); + + // Solve for alpha2 + fvScalarMatrix alpha2Eqn + ( + fvm::ddt(alpha2) + + fvc::div(phiAlpha2) + - fvm::laplacian(Dc23 + Dc32, alpha2) + ); + alpha2Eqn.solve(); + + // Construct the complete mass flux + rhoPhi = + phiAlpha1*(rho1 - rho3) + + (phiAlpha2 + alpha2Eqn.flux())*(rho2 - rho3) + + phi*rho3; + + alpha3 = 1.0 - alpha1 - alpha2; + } + + Info<< "Air phase volume fraction = " + << alpha1.weightedAverage(mesh.V()).value() + << " Min(alpha1) = " << min(alpha1).value() + << " Max(alpha1) = " << max(alpha1).value() + << endl; + + Info<< "Liquid phase volume fraction = " + << alpha2.weightedAverage(mesh.V()).value() + << " Min(alpha2) = " << min(alpha2).value() + << " Max(alpha2) = " << max(alpha2).value() + << endl; +} diff --git a/applications/solvers/multiphase/interMixingFoam/alphaEqnsSubCycle.H b/applications/solvers/multiphase/interMixingFoam/alphaEqnsSubCycle.H new file mode 100644 index 0000000000000000000000000000000000000000..765087a183baf3db62ec9b4dcf382d667b6209f3 --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/alphaEqnsSubCycle.H @@ -0,0 +1,43 @@ +label nAlphaCorr +( + readLabel(piso.lookup("nAlphaCorr")) +); + +label nAlphaSubCycles +( + readLabel(piso.lookup("nAlphaSubCycles")) +); + +if (nAlphaSubCycles > 1) +{ + surfaceScalarField rhoPhiSum = 0.0*rhoPhi; + dimensionedScalar totalDeltaT = runTime.deltaT(); + + for + ( + subCycle<volScalarField> alphaSubCycle(alpha1, nAlphaSubCycles); + !(++alphaSubCycle).end(); + ) + { +# include "alphaEqns.H" + rhoPhiSum += (runTime.deltaT()/totalDeltaT)*rhoPhi; + } + + rhoPhi = rhoPhiSum; +} +else +{ +# include "alphaEqns.H" +} + +interface.correct(); + +{ + volScalarField rhoNew = alpha1*rho1 + alpha2*rho2 + alpha3*rho3; + + //solve(fvm::ddt(rho) + fvc::div(rhoPhi)); + //Info<< "density error = " + // << max((mag(rho - rhoNew)/mag(rhoNew))().internalField()) << endl; + + rho == rhoNew; +} diff --git a/applications/solvers/multiphase/interMixingFoam/createFields.H b/applications/solvers/multiphase/interMixingFoam/createFields.H new file mode 100644 index 0000000000000000000000000000000000000000..9615e6c18645286de8cbdf87ba5c1a127b251236 --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/createFields.H @@ -0,0 +1,132 @@ + Info<< "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Reading field alpha1\n" << endl; + volScalarField alpha1 + ( + IOobject + ( + "alpha1", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + + Info<< "Reading field alpha2\n" << endl; + volScalarField alpha2 + ( + IOobject + ( + "alpha2", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + + Info<< "Reading field alpha3\n" << endl; + volScalarField alpha3 + ( + IOobject + ( + "alpha3", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + alpha3 == 1.0 - alpha1 - alpha2; + + + Info<< "Reading field U\n" << endl; + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + +# include "createPhi.H" + + threePhaseMixture threePhaseProperties(U, phi); + + const dimensionedScalar& rho1 = threePhaseProperties.rho1(); + const dimensionedScalar& rho2 = threePhaseProperties.rho2(); + const dimensionedScalar& rho3 = threePhaseProperties.rho3(); + + dimensionedScalar D23(threePhaseProperties.lookup("D23")); + + // Need to store rho for ddt(rho, U) + volScalarField rho + ( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT + ), + alpha1*rho1 + alpha2*rho2 + alpha3*rho3, + alpha1.boundaryField().types() + ); + rho.oldTime(); + + + // Mass flux + // Initialisation does not matter because rhoPhi is reset after the + // alpha solution before it is used in the U equation. + surfaceScalarField rhoPhi + ( + IOobject + ( + "rho*phi", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + rho1*phi + ); + + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell(p, mesh.solutionDict().subDict("PISO"), pRefCell, pRefValue); + + + // Construct interface from alpha distribution + threePhaseInterfaceProperties interface(threePhaseProperties); + + + // Construct incompressible turbulence model + autoPtr<incompressible::turbulenceModel> turbulence + ( + incompressible::turbulenceModel::New(U, phi, threePhaseProperties) + ); diff --git a/applications/solvers/multiphase/interMixingFoam/incompressibleThreePhaseMixture/threePhaseMixture.C b/applications/solvers/multiphase/interMixingFoam/incompressibleThreePhaseMixture/threePhaseMixture.C new file mode 100644 index 0000000000000000000000000000000000000000..f27e17923f952e5fafec44cf6536241071ad9743 --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/incompressibleThreePhaseMixture/threePhaseMixture.C @@ -0,0 +1,204 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + threePhaseMixture + +\*---------------------------------------------------------------------------*/ + +#include "threePhaseMixture.H" +#include "addToRunTimeSelectionTable.H" +#include "surfaceFields.H" +#include "fvc.H" + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +//- Calculate and return the laminar viscosity +void Foam::threePhaseMixture::calcNu() +{ + // Average kinematic viscosity calculated from dynamic viscosity + nu_ = mu()/(alpha1_*rho1_ + alpha2_*rho2_ + alpha3_*rho3_); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::threePhaseMixture::threePhaseMixture +( + const volVectorField& U, + const surfaceScalarField& phi +) +: + transportModel(U, phi), + + phase1Name_("phase1"), + phase2Name_("phase2"), + phase3Name_("phase3"), + + nuModel1_ + ( + viscosityModel::New + ( + "nu1", + subDict(phase1Name_), + U, + phi + ) + ), + nuModel2_ + ( + viscosityModel::New + ( + "nu2", + subDict(phase2Name_), + U, + phi + ) + ), + nuModel3_ + ( + viscosityModel::New + ( + "nu3", + subDict(phase2Name_), + U, + phi + ) + ), + + rho1_(nuModel1_->viscosityProperties().lookup("rho")), + rho2_(nuModel2_->viscosityProperties().lookup("rho")), + rho3_(nuModel3_->viscosityProperties().lookup("rho")), + + U_(U), + phi_(phi), + + alpha1_(U_.db().lookupObject<const volScalarField> ("alpha1")), + alpha2_(U_.db().lookupObject<const volScalarField> ("alpha2")), + alpha3_(U_.db().lookupObject<const volScalarField> ("alpha3")), + + nu_ + ( + IOobject + ( + "nu", + U_.time().timeName(), + U_.db() + ), + U_.mesh(), + dimensionedScalar("nu", dimensionSet(0, 2, -1, 0, 0), 0), + calculatedFvPatchScalarField::typeName + ) +{ + calcNu(); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::tmp<Foam::volScalarField> Foam::threePhaseMixture::mu() const +{ + return tmp<volScalarField> + ( + new volScalarField + ( + "mu", + alpha1_*rho1_*nuModel1_->nu() + + alpha2_*rho2_*nuModel2_->nu() + + alpha3_*rho3_*nuModel3_->nu() + ) + ); +} + + +Foam::tmp<Foam::surfaceScalarField> Foam::threePhaseMixture::muf() const +{ + surfaceScalarField alpha1f = fvc::interpolate(alpha1_); + surfaceScalarField alpha2f = fvc::interpolate(alpha2_); + surfaceScalarField alpha3f = fvc::interpolate(alpha3_); + + return tmp<surfaceScalarField> + ( + new surfaceScalarField + ( + "mu", + alpha1f*rho1_*fvc::interpolate(nuModel1_->nu()) + + alpha2f*rho2_*fvc::interpolate(nuModel2_->nu()) + + alpha3f*rho3_*fvc::interpolate(nuModel3_->nu()) + ) + ); +} + + +Foam::tmp<Foam::surfaceScalarField> Foam::threePhaseMixture::nuf() const +{ + surfaceScalarField alpha1f = fvc::interpolate(alpha1_); + surfaceScalarField alpha2f = fvc::interpolate(alpha2_); + surfaceScalarField alpha3f = fvc::interpolate(alpha3_); + + return tmp<surfaceScalarField> + ( + new surfaceScalarField + ( + "nu", + ( + alpha1f*rho1_*fvc::interpolate(nuModel1_->nu()) + + alpha2f*rho2_*fvc::interpolate(nuModel2_->nu()) + + alpha3f*rho3_*fvc::interpolate(nuModel3_->nu()) + )/(alpha1f*rho1_ + alpha2f*rho2_ + alpha3f*rho3_) + ) + ); +} + + +bool Foam::threePhaseMixture::read() +{ + if (transportModel::read()) + { + if + ( + nuModel1_().read(*this) + && nuModel2_().read(*this) + && nuModel3_().read(*this) + ) + { + nuModel1_->viscosityProperties().lookup("rho") >> rho1_; + nuModel2_->viscosityProperties().lookup("rho") >> rho2_; + nuModel3_->viscosityProperties().lookup("rho") >> rho3_; + + return true; + } + else + { + return false; + } + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/interMixingFoam/incompressibleThreePhaseMixture/threePhaseMixture.H b/applications/solvers/multiphase/interMixingFoam/incompressibleThreePhaseMixture/threePhaseMixture.H new file mode 100644 index 0000000000000000000000000000000000000000..2712b5d0cbfc18500f47c9b8db5661a5c0721fa6 --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/incompressibleThreePhaseMixture/threePhaseMixture.H @@ -0,0 +1,197 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + threePhaseMixture + +Description + +SourceFiles + threePhaseMixture.C + +\*---------------------------------------------------------------------------*/ + +#ifndef threePhaseMixture_H +#define threePhaseMixture_H + +#include "incompressible/transportModel/transportModel.H" +#include "incompressible/viscosityModels/viscosityModel/viscosityModel.H" +#include "dimensionedScalar.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class threePhaseMixture Declaration +\*---------------------------------------------------------------------------*/ + +class threePhaseMixture +: + public transportModel +{ + // Private data + + word phase1Name_; + word phase2Name_; + word phase3Name_; + + autoPtr<viscosityModel> nuModel1_; + autoPtr<viscosityModel> nuModel2_; + autoPtr<viscosityModel> nuModel3_; + + dimensionedScalar rho1_; + dimensionedScalar rho2_; + dimensionedScalar rho3_; + + const volVectorField& U_; + const surfaceScalarField& phi_; + + const volScalarField& alpha1_; + const volScalarField& alpha2_; + const volScalarField& alpha3_; + + volScalarField nu_; + + + // Private Member Functions + + //- Calculate and return the laminar viscosity + void calcNu(); + + +public: + + // Constructors + + //- Construct from components + threePhaseMixture + ( + const volVectorField& U, + const surfaceScalarField& phi + ); + + + // Destructor + + ~threePhaseMixture() + {} + + + // Member Functions + + //- Return const-access to phase1 viscosityModel + const viscosityModel& nuModel1() const + { + return nuModel1_(); + } + + //- Return const-access to phase2 viscosityModel + const viscosityModel& nuModel2() const + { + return nuModel2_(); + } + + //- Return const-access to phase3 viscosityModel + const viscosityModel& nuModel3() const + { + return nuModel3_(); + } + + //- Return const-access to phase1 density + const dimensionedScalar& rho1() const + { + return rho1_; + } + + //- Return const-access to phase2 density + const dimensionedScalar& rho2() const + { + return rho2_; + }; + + //- Return const-access to phase3 density + const dimensionedScalar& rho3() const + { + return rho3_; + }; + + const volScalarField& alpha1() const + { + return alpha1_; + } + + const volScalarField& alpha2() const + { + return alpha2_; + } + + const volScalarField& alpha3() const + { + return alpha3_; + } + + //- Return the velocity + const volVectorField& U() const + { + return U_; + } + + //- Return the dynamic laminar viscosity + tmp<volScalarField> mu() const; + + //- Return the face-interpolated dynamic laminar viscosity + tmp<surfaceScalarField> muf() const; + + //- Return the kinematic laminar viscosity + tmp<volScalarField> nu() const + { + return nu_; + } + + //- Return the face-interpolated dynamic laminar viscosity + tmp<surfaceScalarField> nuf() const; + + //- Correct the laminar viscosity + void correct() + { + calcNu(); + } + + //- Read base transportProperties dictionary + bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C b/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C new file mode 100644 index 0000000000000000000000000000000000000000..a18df8d12a59ee7d3914109374467a5a10e14a80 --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/interMixingFoam.C @@ -0,0 +1,102 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Application + interMixingFoam + +Description + Solver for 3 incompressible fluids, two of which are miscible, + using a VOF method to capture the interface. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "MULES.H" +#include "subCycle.H" +#include "threePhaseMixture.H" +#include "threePhaseInterfaceProperties.H" +#include "turbulenceModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readGravitationalAcceleration.H" + #include "readPISOControls.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "readTimeControls.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" + #include "correctPhi.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readPISOControls.H" + #include "readTimeControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + threePhaseProperties.correct(); + + #include "alphaEqnsSubCycle.H" + + #define twoPhaseProperties threePhaseProperties + #include "UEqn.H" + + // --- PISO loop + for (int corr=0; corr<nCorr; corr++) + { + #include "pEqn.H" + } + + #include "continuityErrs.H" + + turbulence->correct(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "\n end \n"; + + return(0); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C b/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C new file mode 100644 index 0000000000000000000000000000000000000000..1ab10bd74348be3faafce4e5db2b66c57c5f7a05 --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.C @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Application + threePhaseInterfaceProperties + +Description + Properties to aid interFoam : + 1. Correct the alpha boundary condition for dynamic contact angle. + 2. Calculate interface curvature. + +\*---------------------------------------------------------------------------*/ + +#include "threePhaseInterfaceProperties.H" +#include "alphaContactAngleFvPatchScalarField.H" +#include "mathematicalConstants.H" +#include "surfaceInterpolate.H" +#include "fvcDiv.H" +#include "fvcGrad.H" + +// * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * // + +const Foam::scalar Foam::threePhaseInterfaceProperties::convertToRad = + Foam::constant::mathematical::pi/180.0; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// Correction for the boundary condition on the unit normal nHat on +// walls to produce the correct contact angle. + +// The dynamic contact angle is calculated from the component of the +// velocity on the direction of the interface, parallel to the wall. + +void Foam::threePhaseInterfaceProperties::correctContactAngle +( + surfaceVectorField::GeometricBoundaryField& nHatb +) const +{ + const volScalarField::GeometricBoundaryField& alpha1 = + mixture_.alpha1().boundaryField(); + const volScalarField::GeometricBoundaryField& alpha2 = + mixture_.alpha2().boundaryField(); + const volScalarField::GeometricBoundaryField& alpha3 = + mixture_.alpha3().boundaryField(); + const volVectorField::GeometricBoundaryField& U = + mixture_.U().boundaryField(); + + const fvMesh& mesh = mixture_.U().mesh(); + const fvBoundaryMesh& boundary = mesh.boundary(); + + forAll(boundary, patchi) + { + if (isA<alphaContactAngleFvPatchScalarField>(alpha1[patchi])) + { + const alphaContactAngleFvPatchScalarField& a2cap = + refCast<const alphaContactAngleFvPatchScalarField> + (alpha2[patchi]); + + const alphaContactAngleFvPatchScalarField& a3cap = + refCast<const alphaContactAngleFvPatchScalarField> + (alpha3[patchi]); + + scalarField twoPhaseAlpha2 = max(a2cap, scalar(0)); + scalarField twoPhaseAlpha3 = max(a3cap, scalar(0)); + + scalarField sumTwoPhaseAlpha = + twoPhaseAlpha2 + twoPhaseAlpha3 + SMALL; + + twoPhaseAlpha2 /= sumTwoPhaseAlpha; + twoPhaseAlpha3 /= sumTwoPhaseAlpha; + + fvsPatchVectorField& nHatp = nHatb[patchi]; + + scalarField theta = + convertToRad + *( + twoPhaseAlpha2*(180 - a2cap.theta(U[patchi], nHatp)) + + twoPhaseAlpha3*(180 - a3cap.theta(U[patchi], nHatp)) + ); + + vectorField nf = boundary[patchi].nf(); + + // Reset nHatPatch to correspond to the contact angle + + scalarField a12 = nHatp & nf; + + scalarField b1 = cos(theta); + + scalarField b2(nHatp.size()); + + forAll(b2, facei) + { + b2[facei] = cos(acos(a12[facei]) - theta[facei]); + } + + scalarField det = 1.0 - a12*a12; + + scalarField a = (b1 - a12*b2)/det; + scalarField b = (b2 - a12*b1)/det; + + nHatp = a*nf + b*nHatp; + + nHatp /= (mag(nHatp) + deltaN_.value()); + } + } +} + + +void Foam::threePhaseInterfaceProperties::calculateK() +{ + const volScalarField& alpha1 = mixture_.alpha1(); + + const fvMesh& mesh = alpha1.mesh(); + const surfaceVectorField& Sf = mesh.Sf(); + + // Cell gradient of alpha + volVectorField gradAlpha = fvc::grad(alpha1); + + // Interpolated face-gradient of alpha + surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha); + + // Face unit interface normal + surfaceVectorField nHatfv = gradAlphaf/(mag(gradAlphaf) + deltaN_); + correctContactAngle(nHatfv.boundaryField()); + + // Face unit interface normal flux + nHatf_ = nHatfv & Sf; + + // Simple expression for curvature + K_ = -fvc::div(nHatf_); + + // Complex expression for curvature. + // Correction is formally zero but numerically non-zero. + //volVectorField nHat = gradAlpha/(mag(gradAlpha) + deltaN_); + //nHat.boundaryField() = nHatfv.boundaryField(); + //K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::threePhaseInterfaceProperties::threePhaseInterfaceProperties +( + const threePhaseMixture& mixture +) +: + mixture_(mixture), + cAlpha_ + ( + readScalar + ( + mixture.U().mesh().solutionDict().subDict("PISO").lookup("cAlpha") + ) + ), + sigma12_(mixture.lookup("sigma12")), + sigma13_(mixture.lookup("sigma13")), + + deltaN_ + ( + "deltaN", + 1e-8/pow(average(mixture.U().mesh().V()), 1.0/3.0) + ), + + nHatf_ + ( + ( + fvc::interpolate(fvc::grad(mixture.alpha1())) + /(mag(fvc::interpolate(fvc::grad(mixture.alpha1()))) + deltaN_) + ) & mixture.alpha1().mesh().Sf() + ), + + K_ + ( + IOobject + ( + "K", + mixture.alpha1().time().timeName(), + mixture.alpha1().mesh() + ), + -fvc::div(nHatf_) + ) +{ + calculateK(); +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.H b/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.H new file mode 100644 index 0000000000000000000000000000000000000000..3a402feeedf37ebda540220c8773b76b4cb4f6aa --- /dev/null +++ b/applications/solvers/multiphase/interMixingFoam/threePhaseInterfaceProperties/threePhaseInterfaceProperties.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Class + threePhaseInterfaceProperties + +Description + Properties to aid interFoam : + 1. Correct the alpha boundary condition for dynamic contact angle. + 2. Calculate interface curvature. + +SourceFiles + threePhaseInterfaceProperties.C + +\*---------------------------------------------------------------------------*/ + +#ifndef threePhaseInterfaceProperties_H +#define threePhaseInterfaceProperties_H + +#include "threePhaseMixture.H" +#include "surfaceFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class threePhaseInterfaceProperties Declaration +\*---------------------------------------------------------------------------*/ + +class threePhaseInterfaceProperties +{ + // Private data + + const threePhaseMixture& mixture_; + + //- Compression coefficient + scalar cAlpha_; + + //- Surface tension 1-2 + dimensionedScalar sigma12_; + + //- Surface tension 1-3 + dimensionedScalar sigma13_; + + //- Stabilisation for normalisation of the interface normal + const dimensionedScalar deltaN_; + + surfaceScalarField nHatf_; + volScalarField K_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct and assignment + threePhaseInterfaceProperties(const threePhaseInterfaceProperties&); + void operator=(const threePhaseInterfaceProperties&); + + //- Correction for the boundary condition on the unit normal nHat on + // walls to produce the correct contact dynamic angle + // calculated from the component of U parallel to the wall + void correctContactAngle + ( + surfaceVectorField::GeometricBoundaryField& nHat + ) const; + + //- Re-calculate the interface curvature + void calculateK(); + + +public: + + //- Conversion factor for degrees into radians + static const scalar convertToRad; + + + // Constructors + + //- Construct from volume fraction field alpha and IOdictionary + threePhaseInterfaceProperties(const threePhaseMixture& mixture); + + + // Member Functions + + scalar cAlpha() const + { + return cAlpha_; + } + + const dimensionedScalar& deltaN() const + { + return deltaN_; + } + + const surfaceScalarField& nHatf() const + { + return nHatf_; + } + + const volScalarField& K() const + { + return K_; + } + + tmp<volScalarField> sigma() const + { + volScalarField limitedAlpha2 = max(mixture_.alpha2(), scalar(0)); + volScalarField limitedAlpha3 = max(mixture_.alpha3(), scalar(0)); + + return + (limitedAlpha2*sigma12_ + limitedAlpha3*sigma13_) + /(limitedAlpha2 + limitedAlpha3 + SMALL); + } + + tmp<volScalarField> sigmaK() const + { + return sigma()*K_; + } + + void correct() + { + calculateK(); + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/test/BSpline/BSplineTest.C b/applications/test/BSpline/BSplineTest.C new file mode 100644 index 0000000000000000000000000000000000000000..91f3efad238cfa771d4ea97afd1bc3c25daa1f1d --- /dev/null +++ b/applications/test/BSpline/BSplineTest.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ +#include "argList.H" + +#include "vector.H" +#include "IFstream.H" +#include "BSpline.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + argList::noParallel(); + argList::validArgs.insert("file .. fileN"); + + argList args(argc, argv, false, true); + + forAll(args.additionalArgs(), argI) + { + const string& srcFile = args.additionalArgs()[argI]; + Info<< nl << "reading " << srcFile << nl; + IFstream ifs(srcFile); + + List<pointField> splinePointFields(ifs); + + forAll(splinePointFields, splineI) + { + Info<<"convert " << splinePointFields[splineI] << " to bspline" << endl; + + BSpline spl(splinePointFields[splineI], vector::zero, vector::zero); + + Info<< "1/2 = " << spl.position(0.5) << endl; + } + } + + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/BSpline/Make/files b/applications/test/BSpline/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..be66810067f2cdb25e5db68f7f137fdd296135ed --- /dev/null +++ b/applications/test/BSpline/Make/files @@ -0,0 +1,3 @@ +BSplineTest.C + +EXE = $(FOAM_USER_APPBIN)/BSplineTest diff --git a/applications/test/BSpline/Make/options b/applications/test/BSpline/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..1a366abf0ddd3cd00be342af4f142f166733cb55 --- /dev/null +++ b/applications/test/BSpline/Make/options @@ -0,0 +1,5 @@ +EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/mesh/blockMesh/lnInclude + +EXE_LIBS = -lblockMesh diff --git a/applications/test/BSpline/test-splines b/applications/test/BSpline/test-splines new file mode 100644 index 0000000000000000000000000000000000000000..f5c3a46ae4bd0c2d308801293e9f768f2458d092 --- /dev/null +++ b/applications/test/BSpline/test-splines @@ -0,0 +1,69 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +( + // Upper body longitudinal splines. + ( + (-0.22685 -0.01125166 0) // 7 + (-0.21685 -0.01340204 0) + (-0.20685 -0.01529684 0) + (-0.19685 -0.01694748 0) + (-0.18685 -0.01836538 0) + (-0.17685 -0.01956197 0) + (-0.16685 -0.02054868 0) + (-0.15685 -0.02133693 0) + (-0.14685 -0.02193816 0) + (-0.13685 -0.02236377 0) + (-0.12685 -0.02262521 0) + (-0.11685 -0.02273389 0) // 2 + ) + + ( + (-0.22685 0 0.01125166) // 8 + (-0.21685 0 0.01340204) + (-0.20685 0 0.01529684) + (-0.19685 0 0.01694748) + (-0.18685 0 0.01836538) + (-0.17685 0 0.01956197) + (-0.16685 0 0.02054868) + (-0.15685 0 0.02133693) + (-0.14685 0 0.02193816) + (-0.13685 0 0.02236377) + (-0.12685 0 0.02262521) + (-0.11685 0 0.02273389) // 3 + ) + + ( + (-0.22685 0.01125166 0) // 9 + (-0.21685 0.01340204 0) + (-0.20685 0.01529684 0) + (-0.19685 0.01694748 0) + (-0.18685 0.01836538 0) + (-0.17685 0.01956197 0) + (-0.16685 0.02054868 0) + (-0.15685 0.02133693 0) + (-0.14685 0.02193816 0) + (-0.13685 0.02236377 0) + (-0.12685 0.02262521 0) + (-0.11685 0.02273389 0) // 4 + ) + + ( + (-0.22685 0 -0.01125166) // 6 + (-0.21685 0 -0.01340204) + (-0.20685 0 -0.01529684) + (-0.19685 0 -0.01694748) + (-0.18685 0 -0.01836538) + (-0.17685 0 -0.01956197) + (-0.16685 0 -0.02054868) + (-0.15685 0 -0.02133693) + (-0.14685 0 -0.02193816) + (-0.13685 0 -0.02236377) + (-0.12685 0 -0.02262521) + (-0.11685 0 -0.02273389) // 1 + ) +); diff --git a/applications/test/CompactListList/CompactListListTest.C b/applications/test/CompactListList/CompactListListTest.C index 136b5f458375fc9bad625135fd8439919970c257..cd3270a169c6d953616b8e6cf6280fd90725af44 100644 --- a/applications/test/CompactListList/CompactListListTest.C +++ b/applications/test/CompactListList/CompactListListTest.C @@ -32,6 +32,9 @@ Description #include "CompactListList.H" #include "IOstreams.H" +#include "OStringStream.H" +#include "IStringStream.H" +#include "faceList.H" using namespace Foam; @@ -40,7 +43,29 @@ using namespace Foam; int main(int argc, char *argv[]) { - CompactListList<label> cll1; + { + // null construct + CompactListList<label> cll1; + Info<< "cll1:" << cll1 << endl; + + // Resize and assign row by row + labelList row0(2, 0); + labelList row1(3, 1); + + labelList rowSizes(2); + rowSizes[0] = row0.size(); + rowSizes[1] = row1.size(); + cll1.resize(rowSizes); + + cll1[0].assign(row0); //note: operator= will not work since UList + cll1[1].assign(row1); + Info<< "cll1:" << cll1 << endl; + + forAll(cll1.m(), i) + { + Info<< "i:" << i << " whichRow:" << cll1.whichRow(i) << endl; + } + } List<List<label> > lll(5); lll[0].setSize(3, 0); @@ -60,14 +85,21 @@ int main(int argc, char *argv[]) Info<< endl; + Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl; + cll2(2, 3) = 999; Info<< "cll2(2, 3) = " << cll2(2, 3) << nl << endl; - Info<< "cll2 as List<List<label > > " << List<List<label > >(cll2) << endl; + Info<< "cll2 as List<List<label > > " << cll2() + << endl; cll2.setSize(3); Info<< "cll2 = " << cll2 << endl; + cll2.setSize(0); + + Info<< "cll2 = " << cll2 << endl; + List<label> rowSizes(5); rowSizes[0] = 2; @@ -87,6 +119,39 @@ int main(int argc, char *argv[]) Info<< "cll3 = " << cll3 << endl; Info<< "cll4 = " << cll4 << endl; + + { + // IO + OStringStream ostr; + ostr << cll4; + + IStringStream istr(ostr.str()); + CompactListList<label> cll5(istr); + Info<< "cll5 = " << cll5 << endl; + } + { + // IO + cll4.clear(); + OStringStream ostr; + ostr << cll4; + + IStringStream istr(ostr.str()); + CompactListList<label> cll5(istr); + Info<< "cll5 = " << cll5 << endl; + } + + { + faceList fcs(2); + fcs[0] = face(labelList(1, 111)); + fcs[1] = face(labelList(2, 222)); + + CompactListList<label, face> compactFcs(fcs); + Info<< "comactFcs:" << compactFcs << endl; + + faceList fcs2 = compactFcs(); + Info<< "fcs2:" << fcs2 << endl; + } + return 0; } diff --git a/applications/test/HashTable/hashTableTest.C b/applications/test/HashTable/hashTableTest.C index 7e03a36f7dfd2cfc747a46a78cad6f3f6fc6f84c..d0eae872435e70d4c53c83645896fb8408005f95 100644 --- a/applications/test/HashTable/hashTableTest.C +++ b/applications/test/HashTable/hashTableTest.C @@ -40,6 +40,7 @@ using namespace Foam; int main() { HASHTABLE_CLASS<double> table1(13); + HASHTABLE_CLASS<double>::iterator iter; table1.insert("aaa", 1.0); table1.insert("aba", 2.0); @@ -52,8 +53,12 @@ int main() table1.insert("adx", 9.0); table1.insert("aec", 10.0); + // erase by key table1.erase("aaw"); - table1.erase("abs"); + + // erase by iterator + iter = table1.find("abs"); + table1.erase(iter); Info<< "\ntable1 toc: " << table1.toc() << endl; Info<< "\ntable1 sortedToc: " << table1.sortedToc() << endl; diff --git a/applications/test/HashTable3/Make/files b/applications/test/HashTable3/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..e8ec193ffa2e78cf5a570a32b4e3952096365d70 --- /dev/null +++ b/applications/test/HashTable3/Make/files @@ -0,0 +1,3 @@ +hashTableTest3.C + +EXE = $(FOAM_USER_APPBIN)/hashTableTest3 diff --git a/applications/test/HashTable3/Make/options b/applications/test/HashTable3/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..6a9e9810b3d5ce6684bdaf03143933480ff45e42 --- /dev/null +++ b/applications/test/HashTable3/Make/options @@ -0,0 +1,2 @@ +/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */ +/* EXE_LIBS = -lfiniteVolume */ diff --git a/applications/test/HashTable3/hashTableTest3.C b/applications/test/HashTable3/hashTableTest3.C new file mode 100644 index 0000000000000000000000000000000000000000..910e4f229052bc8c9305ea7b30d30a3907cbbfd0 --- /dev/null +++ b/applications/test/HashTable3/hashTableTest3.C @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + + Test speeds for some HashTable operations + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "HashTable.H" +#include "HashPtrTable.H" +#include "Map.H" +#include "StaticHashTable.H" +#include "HashTbl.H" +#include "cpuTime.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + const label nLoops = 30; + const label nBase = 100000; + const label nSize = nLoops * nBase; + + cpuTime timer; + + // ie, a + // Map<label> map(2 * nSize); + // HashTable<label, label, Hash<label> > map(2 * nSize); + // StaticHashTable<label, label, Hash<label> > map(2 * nSize); + HashTbl<label, label, Hash<label> > map(2 * nSize); + + Info<< "Constructed map of size: " << nSize + << " (size " << map.size() << " capacity " << map.capacity() << ") " + << " " << timer.cpuTimeIncrement() << " s\n\n"; + + for (label i = 0; i < nSize; i++) + { + map.insert(i, i); + } + Info<< "Inserted " << nSize << " elements" + << " (size " << map.size() << " capacity " << map.capacity() << ") " + << timer.cpuTimeIncrement() << " s\n"; + + label elemI = 0; + for (label iLoop = 0; iLoop < nLoops; iLoop++) + { + for (label i = 0; i < nBase; i++) + { + map.erase(elemI++); + } + + map.shrink(); + Info<< "loop " << iLoop << " - Erased " << nBase << " elements" + << " (size " << map.size() << " capacity " << map.capacity() << ") " + << timer.cpuTimeIncrement() << " s\n"; + } + + return 0; +} + +// ************************************************************************* // diff --git a/applications/test/globalIndex/Make/files b/applications/test/globalIndex/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..6d7dd88f145991084bea588c9cb7d1cab9924b63 --- /dev/null +++ b/applications/test/globalIndex/Make/files @@ -0,0 +1,4 @@ +globalIndex.C +globalIndexTest.C + +EXE = $(FOAM_USER_APPBIN)/globalIndexTest diff --git a/applications/test/globalIndex/Make/options b/applications/test/globalIndex/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..90f18e878fb879774c8cf332dfab8a0cb5e3eaa6 --- /dev/null +++ b/applications/test/globalIndex/Make/options @@ -0,0 +1 @@ +EXE_INC = /* -DFULLDEBUG -g -O0 */ diff --git a/applications/test/globalIndex/globalIndexTest.C b/applications/test/globalIndex/globalIndexTest.C new file mode 100644 index 0000000000000000000000000000000000000000..60650cd93af79ef07e2dcfdd5e7cf7de413329e1 --- /dev/null +++ b/applications/test/globalIndex/globalIndexTest.C @@ -0,0 +1,171 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + globalIndexTest + +Description + Simple demonstration and test application for the globalIndex class. + +\*---------------------------------------------------------------------------*/ + +#include "globalIndex.H" +#include "argList.H" +#include "Time.H" +#include "polyMesh.H" +#include "IOstreams.H" +#include "OStringStream.H" +#include "IStringStream.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ +# include "setRootCase.H" +# include "createTime.H" +# include "createPolyMesh.H" + + // Global numbering of cells (proc0 elements first, then proc1, etc.) + globalIndex globalNumbering(mesh.nCells()); + + if (globalNumbering.localSize() != mesh.nCells()) + { + FatalErrorIn(args.executable()) + << "Problem." << abort(FatalError); + } + + + if (!Pstream::parRun()) + { + WarningIn(args.executable()) + << "globalIndex class is only useful in parallel code." + << endl; + } + + // convert from local to global and back. + for (label cellI = 0; cellI < mesh.nCells(); cellI++) + { + // to global index + label globalCellI = globalNumbering.toGlobal(cellI); + + // and back + label procI = globalNumbering.whichProcID(globalCellI); + label localCellI = globalNumbering.toLocal(globalCellI); + + if (procI != Pstream::myProcNo() || localCellI != cellI) + { + FatalErrorIn(args.executable()) + << "Problem. cellI:" << cellI << " localCellI:" << localCellI + << " procI:" << procI << abort(FatalError); + } + + if (!globalNumbering.isLocal(globalCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. cellI:" << cellI << " globalCellI:" << globalCellI + << " not local" << abort(FatalError); + } + } + + + // Try whichProcID on a few borderline cases. + + if (mesh.nCells() < 1) + { + FatalErrorIn(args.executable()) + << "Test needs to be run on a case with at least one" + << " cell per processor." << abort(FatalError); + } + + if (Pstream::myProcNo() > 0) + { + // We already checked that toGlobal(0) maps back correctly to myProcNo + // so now check that the index one before maps to the previous processor + label prevProcCellI = globalNumbering.toGlobal(0)-1; + label procI = globalNumbering.whichProcID(prevProcCellI); + + if (procI != Pstream::myProcNo()-1) + { + FatalErrorIn(args.executable()) + << "Problem. global:" << prevProcCellI + << " expected on processor:" << Pstream::myProcNo()-1 + << " but is calculated to be on procI:" << procI + << abort(FatalError); + } + + if (globalNumbering.isLocal(prevProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << prevProcCellI + << " calculated as local" << abort(FatalError); + } + + if (!globalNumbering.isLocal(procI, prevProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << prevProcCellI + << " not calculated as local on processor:" << procI + << abort(FatalError); + } + } + + + if (Pstream::myProcNo() < Pstream::nProcs()-1) + { + label nextProcCellI = globalNumbering.toGlobal(mesh.nCells()-1)+1; + label procI = globalNumbering.whichProcID(nextProcCellI); + + if (procI != Pstream::myProcNo()+1) + { + FatalErrorIn(args.executable()) + << "Problem. global:" << nextProcCellI + << " expected on processor:" << Pstream::myProcNo()+1 + << " but is calculated to be on procI:" << procI + << abort(FatalError); + } + + if (globalNumbering.isLocal(nextProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << nextProcCellI + << " calculated as local" << abort(FatalError); + } + + if (!globalNumbering.isLocal(procI, nextProcCellI)) + { + FatalErrorIn(args.executable()) + << "Problem. globalCellI:" << nextProcCellI + << " not calculated as local on processor:" << procI + << abort(FatalError); + } + } + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/router/Gather/GatherBase.C b/applications/test/router/Gather/GatherBase.C index e171fd45c5454f45b41d43d438431296ba7b0d12..9950bc9753a4c3b174520c013869b60c7ce3ae84 100644 --- a/applications/test/router/Gather/GatherBase.C +++ b/applications/test/router/Gather/GatherBase.C @@ -22,13 +22,9 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "GatherBase.H" -#include "IPstream.H" -#include "OPstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C index 2ce7f8ba80c734caa456aba557739915f918c98f..51ae42fb25c6f7f6e22ef6886536396f4d37934e 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseEdges.C @@ -50,6 +50,7 @@ Description #include "mathematicalConstants.H" #include "PackedBoolList.H" #include "SortableList.H" +#include "unitConversion.H" using namespace Foam; @@ -467,7 +468,7 @@ int main(int argc, char *argv[]) scalar angle(readScalar(IStringStream(args.additionalArgs()[1])())); bool overwrite = args.optionFound("overwrite"); - scalar maxCos = Foam::cos(angle*180/constant::mathematical::pi); + scalar maxCos = Foam::cos(degToRad(angle)); Info<< "Merging:" << nl << " edges with length less than " << minLen << " meters" << nl diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C index 6a9d85ba301b115c2a4d02f1fa19895598e1a373..1776285e462db03cd31365ece6e603c9304e18eb 100644 --- a/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/ideasUnvToFoam.C @@ -208,12 +208,13 @@ void readPoints { hasWarned = true; - WarningIn + IOWarningIn ( "readPoints(IFstream&, label&, DynamicList<point>" - ", DynamicList<label>&)" + ", DynamicList<label>&)", + is ) << "Points not in order starting at point " << pointI - << " at line " << is.lineNumber() + //<< " at line " << is.lineNumber() //<< abort(FatalError); << endl; } @@ -429,47 +430,53 @@ void readPatches >> dofSet >> tempSet >> contactSet >> nFaces; is.getLine(line); - patchNames.append(string::validate<word>(line)); + word groupName = string::validate<word>(line); - Info<< "For facegroup " << group - << " named " << patchNames[patchNames.size()-1] + Info<< "For group " << group + << " named " << groupName << " trying to read " << nFaces << " patch face indices." << endl; - patchFaceIndices.append(labelList(0)); - labelList& faceIndices = patchFaceIndices[patchFaceIndices.size()-1]; - faceIndices.setSize(nFaces); - label faceI = 0; + labelList groupIndices(nFaces); + label groupType = -1; + nFaces = 0; - while (faceI < faceIndices.size()) + while (nFaces < groupIndices.size()) { is.getLine(line); IStringStream lineStr(line); // Read one (for last face) or two entries from line. label nRead = 2; - if (faceI == faceIndices.size()-1) + if (nFaces == groupIndices.size()-1) { nRead = 1; } for (label i = 0; i < nRead; i++) { - label typeCode, tag, nodeLeaf, component; + label tag, nodeLeaf, component; - lineStr >> typeCode >> tag >> nodeLeaf >> component; + lineStr >> groupType >> tag >> nodeLeaf >> component; - if (typeCode != 8) - { - FatalErrorIn("readPatches") - << "When reading patches expect Entity Type Code 8" - << nl << "At line " << is.lineNumber() - << exit(FatalError); - } - - faceIndices[faceI++] = tag; + groupIndices[nFaces++] = tag; } } + + + // Store + if (groupType == 8) + { + patchNames.append(groupName); + patchFaceIndices.append(groupIndices); + } + else + { + IOWarningIn("readPatches(..)", is) + << "When reading patches expect entity type code 8" + << nl << " Skipping group code " << groupType + << endl; + } } patchNames.shrink(); diff --git a/applications/utilities/mesh/conversion/ideasUnvToFoam/unv/mesh.unv b/applications/utilities/mesh/conversion/ideasUnvToFoam/unv/mesh.unv new file mode 100644 index 0000000000000000000000000000000000000000..650a447a0039930c17341726c5e9eae3775208d1 --- /dev/null +++ b/applications/utilities/mesh/conversion/ideasUnvToFoam/unv/mesh.unv @@ -0,0 +1,394 @@ + -1 + 2411 + 1 0 0 0 + 2.0000000000000000E+02 3.0000000000000000E+02 0.0000000000000000E+00 + 2 0 0 0 + 2.0000000000000000E+02 3.0000000000000000E+02 2.1000000000000000E+02 + 3 0 0 0 + 2.0000000000000000E+02 0.0000000000000000E+00 0.0000000000000000E+00 + 4 0 0 0 + 2.0000000000000000E+02 0.0000000000000000E+00 2.1000000000000000E+02 + 5 0 0 0 + 0.0000000000000000E+00 3.0000000000000000E+02 0.0000000000000000E+00 + 6 0 0 0 + 0.0000000000000000E+00 3.0000000000000000E+02 2.1000000000000000E+02 + 7 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 0.0000000000000000E+00 + 8 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 2.1000000000000000E+02 + 9 0 0 0 + 0.0000000000000000E+00 1.0020000000000000E+02 2.1000000000000000E+02 + 10 0 0 0 + 0.0000000000000000E+00 2.0009999999999999E+02 2.1000000000000000E+02 + 11 0 0 0 + 1.0000000000000000E+02 3.0000000000000000E+02 2.1000000000000000E+02 + 12 0 0 0 + 2.0000000000000000E+02 1.0020000000000000E+02 2.1000000000000000E+02 + 13 0 0 0 + 2.0000000000000000E+02 2.0009999999999999E+02 2.1000000000000000E+02 + 14 0 0 0 + 1.0000000000000000E+02 0.0000000000000000E+00 2.1000000000000000E+02 + 15 0 0 0 + 0.0000000000000000E+00 1.0020000000000000E+02 0.0000000000000000E+00 + 16 0 0 0 + 0.0000000000000000E+00 2.0009999999999999E+02 0.0000000000000000E+00 + 17 0 0 0 + 1.0000000000000000E+02 3.0000000000000000E+02 0.0000000000000000E+00 + 18 0 0 0 + 2.0000000000000000E+02 1.0020000000000000E+02 0.0000000000000000E+00 + 19 0 0 0 + 2.0000000000000000E+02 2.0009999999999999E+02 0.0000000000000000E+00 + 20 0 0 0 + 1.0000000000000000E+02 0.0000000000000000E+00 0.0000000000000000E+00 + 21 0 0 0 + 2.0000000000000000E+02 3.0000000000000000E+02 1.0500000000000000E+02 + 22 0 0 0 + 0.0000000000000000E+00 3.0000000000000000E+02 1.0500000000000000E+02 + 23 0 0 0 + 2.0000000000000000E+02 0.0000000000000000E+00 1.0500000000000000E+02 + 24 0 0 0 + 0.0000000000000000E+00 0.0000000000000000E+00 1.0500000000000000E+02 + 25 0 0 0 + 9.6161727574445891E+01 1.3290789499900029E+02 2.1000000000000000E+02 + 26 0 0 0 + 8.0082880863556014E+01 2.2412763570985578E+02 2.1000000000000000E+02 + 27 0 0 0 + 9.6161727574240444E+01 1.3290789499883087E+02 0.0000000000000000E+00 + 28 0 0 0 + 8.0082880863392205E+01 2.2412763570989483E+02 0.0000000000000000E+00 + 29 0 0 0 + 2.0000000000000000E+02 1.5011560268321134E+02 1.0500000000592973E+02 + 30 0 0 0 + 0.0000000000000000E+00 1.5011560299451648E+02 1.0499999963389952E+02 + 31 0 0 0 + 9.9094099553883055E+01 7.2457929267250009E+01 1.0499999994714025E+02 + -1 + -1 + 2412 + 1 11 2 1 7 2 + 0 0 0 + 9 8 + 2 11 2 1 7 2 + 0 0 0 + 10 9 + 3 11 2 1 7 2 + 0 0 0 + 6 10 + 4 11 2 1 7 2 + 0 0 0 + 11 6 + 5 11 2 1 7 2 + 0 0 0 + 2 11 + 6 11 2 1 7 2 + 0 0 0 + 4 12 + 7 11 2 1 7 2 + 0 0 0 + 12 13 + 8 11 2 1 7 2 + 0 0 0 + 13 2 + 9 11 2 1 7 2 + 0 0 0 + 8 14 + 10 11 2 1 7 2 + 0 0 0 + 14 4 + 11 11 2 1 7 2 + 0 0 0 + 7 15 + 12 11 2 1 7 2 + 0 0 0 + 15 16 + 13 11 2 1 7 2 + 0 0 0 + 16 5 + 14 11 2 1 7 2 + 0 0 0 + 5 17 + 15 11 2 1 7 2 + 0 0 0 + 17 1 + 16 11 2 1 7 2 + 0 0 0 + 18 3 + 17 11 2 1 7 2 + 0 0 0 + 19 18 + 18 11 2 1 7 2 + 0 0 0 + 1 19 + 19 11 2 1 7 2 + 0 0 0 + 20 7 + 20 11 2 1 7 2 + 0 0 0 + 3 20 + 21 11 2 1 7 2 + 0 0 0 + 21 1 + 22 11 2 1 7 2 + 0 0 0 + 2 21 + 23 11 2 1 7 2 + 0 0 0 + 5 22 + 24 11 2 1 7 2 + 0 0 0 + 22 6 + 25 11 2 1 7 2 + 0 0 0 + 3 23 + 26 11 2 1 7 2 + 0 0 0 + 23 4 + 27 11 2 1 7 2 + 0 0 0 + 24 7 + 28 11 2 1 7 2 + 0 0 0 + 8 24 + 29 41 2 1 7 3 + 9 8 14 + 30 41 2 1 7 3 + 10 9 25 + 31 41 2 1 7 3 + 6 10 26 + 32 41 2 1 7 3 + 11 6 26 + 33 41 2 1 7 3 + 10 25 26 + 34 41 2 1 7 3 + 2 11 13 + 35 41 2 1 7 3 + 4 12 14 + 36 41 2 1 7 3 + 12 13 25 + 37 41 2 1 7 3 + 14 12 25 + 38 41 2 1 7 3 + 9 14 25 + 39 41 2 1 7 3 + 13 11 26 + 40 41 2 1 7 3 + 13 26 25 + 41 41 2 1 7 3 + 7 15 20 + 42 41 2 1 7 3 + 15 16 27 + 43 41 2 1 7 3 + 16 5 28 + 44 41 2 1 7 3 + 27 16 28 + 45 41 2 1 7 3 + 5 17 28 + 46 41 2 1 7 3 + 17 1 19 + 47 41 2 1 7 3 + 18 3 20 + 48 41 2 1 7 3 + 19 18 27 + 49 41 2 1 7 3 + 18 20 27 + 50 41 2 1 7 3 + 20 15 27 + 51 41 2 1 7 3 + 17 19 28 + 52 41 2 1 7 3 + 28 19 27 + 53 41 2 1 7 3 + 17 5 22 + 54 41 2 1 7 3 + 1 17 21 + 55 41 2 1 7 3 + 2 21 11 + 56 41 2 1 7 3 + 6 11 22 + 57 41 2 1 7 3 + 22 11 21 + 58 41 2 1 7 3 + 22 21 17 + 59 41 2 1 7 3 + 7 20 24 + 60 41 2 1 7 3 + 20 3 23 + 61 41 2 1 7 3 + 23 4 14 + 62 41 2 1 7 3 + 14 8 24 + 63 41 2 1 7 3 + 14 24 23 + 64 41 2 1 7 3 + 20 23 24 + 65 41 2 1 7 3 + 23 3 18 + 66 41 2 1 7 3 + 4 23 12 + 67 41 2 1 7 3 + 13 12 29 + 68 41 2 1 7 3 + 2 13 21 + 69 41 2 1 7 3 + 22 16 30 + 70 41 2 1 7 3 + 13 29 21 + 71 41 2 1 7 3 + 1 21 19 + 72 41 2 1 7 3 + 12 23 29 + 73 41 2 1 7 3 + 18 19 29 + 74 41 2 1 7 3 + 23 18 29 + 75 41 2 1 7 3 + 15 24 30 + 76 41 2 1 7 3 + 29 19 21 + 77 41 2 1 7 3 + 7 24 15 + 78 41 2 1 7 3 + 24 8 9 + 79 41 2 1 7 3 + 9 10 30 + 80 41 2 1 7 3 + 10 6 22 + 81 41 2 1 7 3 + 30 10 22 + 82 41 2 1 7 3 + 16 15 30 + 83 41 2 1 7 3 + 22 5 16 + 84 41 2 1 7 3 + 24 9 30 + 85 111 2 1 7 4 + 21 28 22 17 + 86 111 2 1 7 4 + 31 18 29 23 + 87 111 2 1 7 4 + 31 29 18 27 + 88 111 2 1 7 4 + 29 21 26 13 + 89 111 2 1 7 4 + 29 25 26 30 + 90 111 2 1 7 4 + 26 28 29 30 + 91 111 2 1 7 4 + 16 28 5 22 + 92 111 2 1 7 4 + 30 25 10 9 + 93 111 2 1 7 4 + 16 30 15 27 + 94 111 2 1 7 4 + 26 25 10 30 + 95 111 2 1 7 4 + 21 28 26 22 + 96 111 2 1 7 4 + 31 20 18 23 + 97 111 2 1 7 4 + 27 28 16 30 + 98 111 2 1 7 4 + 18 27 29 19 + 99 111 2 1 7 4 + 21 22 26 11 + 100 111 2 1 7 4 + 23 4 12 14 + 101 111 2 1 7 4 + 31 25 29 30 + 102 111 2 1 7 4 + 31 18 20 27 + 103 111 2 1 7 4 + 21 11 26 13 + 104 111 2 1 7 4 + 22 28 5 17 + 105 111 2 1 7 4 + 2 11 21 13 + 106 111 2 1 7 4 + 29 25 12 13 + 107 111 2 1 7 4 + 30 28 16 22 + 108 111 2 1 7 4 + 31 24 20 23 + 109 111 2 1 7 4 + 26 28 30 22 + 110 111 2 1 7 4 + 21 17 19 28 + 111 111 2 1 7 4 + 15 24 31 30 + 112 111 2 1 7 4 + 31 9 30 24 + 113 111 2 1 7 4 + 15 30 31 27 + 114 111 2 1 7 4 + 8 14 24 9 + 115 111 2 1 7 4 + 26 22 10 6 + 116 111 2 1 7 4 + 31 25 12 29 + 117 111 2 1 7 4 + 31 29 12 23 + 118 111 2 1 7 4 + 31 30 9 25 + 119 111 2 1 7 4 + 21 1 19 17 + 120 111 2 1 7 4 + 29 19 27 28 + 121 111 2 1 7 4 + 10 22 26 30 + 122 111 2 1 7 4 + 29 28 26 21 + 123 111 2 1 7 4 + 7 20 15 24 + 124 111 2 1 7 4 + 11 22 26 6 + 125 111 2 1 7 4 + 29 28 27 30 + 126 111 2 1 7 4 + 31 23 12 14 + 127 111 2 1 7 4 + 26 25 29 13 + 128 111 2 1 7 4 + 15 27 31 20 + 129 111 2 1 7 4 + 21 19 29 28 + 130 111 2 1 7 4 + 18 3 23 20 + 131 111 2 1 7 4 + 15 20 31 24 + 132 111 2 1 7 4 + 27 31 29 30 + 133 111 2 1 7 4 + 31 14 9 24 + 134 111 2 1 7 4 + 31 9 14 25 + 135 111 2 1 7 4 + 31 14 12 25 + 136 111 2 1 7 4 + 31 23 14 24 + -1 + -1 + 2467 + 0 0 0 0 0 0 0 10 +outlet + 8 70 0 0 8 67 0 0 + 8 68 0 0 8 71 0 0 + 8 76 0 0 8 66 0 0 + 8 72 0 0 8 73 0 0 + 8 74 0 0 8 65 0 0 + 1 0 0 0 0 0 0 12 +inlet + 8 36 0 0 8 30 0 0 + 8 31 0 0 8 37 0 0 + 8 34 0 0 8 38 0 0 + 8 33 0 0 8 35 0 0 + 8 32 0 0 8 29 0 0 + 8 39 0 0 8 40 0 0 + 2 0 0 0 0 0 0 12 +nodes + 7 2 0 0 7 4 0 0 + 7 6 0 0 7 8 0 0 + 7 9 0 0 7 10 0 0 + 7 11 0 0 7 12 0 0 + 7 13 0 0 7 14 0 0 + 7 25 0 0 7 26 0 0 + -1 diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index 96fb76ffe2cfac58730616357f77cc71011c37f2..6caeffbd4ec7d53a8392460a635f4820c9740940 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -94,7 +94,8 @@ int main(int argc, char *argv[]) noFailedChecks += checkGeometry(mesh, allGeometry); - reduce(noFailedChecks, sumOp<label>()); + // Note: no reduction in noFailedChecks necessary since is + // counter of checks, not counter of failed cells,faces etc. if (noFailedChecks == 0) { @@ -112,8 +113,6 @@ int main(int argc, char *argv[]) label nFailedChecks = checkGeometry(mesh, allGeometry); - reduce(nFailedChecks, sumOp<label>()); - if (nFailedChecks) { Info<< "\nFailed " << nFailedChecks << " mesh checks.\n" diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index 3732c7e4ec1d9d17f5f55226666ba345b4a0e463..7b348015d40cf5147d80f8eb5868b398bf086c5c 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -283,11 +283,11 @@ void printHelp(Ostream& os) << " cellSet c0 list" << endl << endl << "Zones can be set using zoneSets from corresponding sets:" << endl - << " cellZoneSet c0Zone new setToZone c0" << endl - << " faceZoneSet f0Zone new setToZone f0" << endl + << " cellZoneSet c0Zone new setToCellZone c0" << endl + << " faceZoneSet f0Zone new setToFaceZone f0" << endl << endl << "or if orientation is important:" << endl - << " faceZoneSet f0Zone new setsToZone f0 c0" << endl + << " faceZoneSet f0Zone new setsToFaceZone f0 c0" << endl << endl << "ZoneSets can be manipulated using the general actions:" << endl << " list - prints the contents of the set" << endl diff --git a/applications/utilities/mesh/manipulation/singleCellMesh/Make/files b/applications/utilities/mesh/manipulation/singleCellMesh/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..db941393b0800179cca310b587885dab85390ac7 --- /dev/null +++ b/applications/utilities/mesh/manipulation/singleCellMesh/Make/files @@ -0,0 +1,3 @@ +singleCellMesh.C + +EXE = $(FOAM_APPBIN)/singleCellMesh diff --git a/applications/utilities/mesh/manipulation/singleCellMesh/Make/options b/applications/utilities/mesh/manipulation/singleCellMesh/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..89e52b6d520dc088e6516df08f0f521f188a6353 --- /dev/null +++ b/applications/utilities/mesh/manipulation/singleCellMesh/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume + diff --git a/applications/utilities/mesh/manipulation/singleCellMesh/singleCellMesh.C b/applications/utilities/mesh/manipulation/singleCellMesh/singleCellMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..fe1e2850b97cccd5304e6809d91b01649ee97a37 --- /dev/null +++ b/applications/utilities/mesh/manipulation/singleCellMesh/singleCellMesh.C @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + singleCellMesh + +Description + Removes all but one cells of the mesh. Used to generate mesh and fields + that can be used for boundary-only data. + Might easily result in illegal mesh though so only look at boundaries + in paraview. + +\*---------------------------------------------------------------------------*/ + + +#include "argList.H" +#include "fvMesh.H" +#include "volFields.H" +#include "Time.H" +#include "ReadFields.H" +#include "singleCellFvMesh.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class GeoField> +void interpolateFields +( + const singleCellFvMesh& scMesh, + const PtrList<GeoField>& flds +) +{ + forAll(flds, i) + { + tmp<GeoField> scFld = scMesh.interpolate(flds[i]); + GeoField* scFldPtr = scFld.ptr(); + scFldPtr->writeOpt() = IOobject::AUTO_WRITE; + scFldPtr->store(); + } +} + + +// Main program: + +int main(int argc, char *argv[]) +{ + Foam::argList::validOptions.insert("overwrite", ""); +# 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" + const word oldInstance = mesh.pointsInstance(); + + bool overwrite = args.optionFound("overwrite"); + + + // Read objects in time directory + IOobjectList objects(mesh, runTime.timeName()); + + // Read vol fields. + PtrList<volScalarField> vsFlds; + ReadFields(mesh, objects, vsFlds); + + PtrList<volVectorField> vvFlds; + ReadFields(mesh, objects, vvFlds); + + PtrList<volSphericalTensorField> vstFlds; + ReadFields(mesh, objects, vstFlds); + + PtrList<volSymmTensorField> vsymtFlds; + ReadFields(mesh, objects, vsymtFlds); + + PtrList<volTensorField> vtFlds; + ReadFields(mesh, objects, vtFlds); + + + if (!overwrite) + { + runTime++; + } + + // Create the mesh + singleCellFvMesh scMesh + ( + IOobject + ( + mesh.name(), + mesh.polyMesh::instance(), + runTime, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + + // Map and store the fields on the scMesh. + interpolateFields(scMesh, vsFlds); + interpolateFields(scMesh, vvFlds); + interpolateFields(scMesh, vstFlds); + interpolateFields(scMesh, vsymtFlds); + interpolateFields(scMesh, vtFlds); + + + // Write + Info<< "Writing mesh to time " << runTime.timeName() << endl; + scMesh.write(); + + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C index bc193810bd96c1c43fb4739cf734c5363a54a11f..de6d5c10e4ec187c3f0b6c1999772120e62be77a 100644 --- a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C +++ b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C @@ -163,10 +163,13 @@ int main(int argc, char *argv[]) // Addressing on faces only in mesh vertices. primitiveFacePatch fPatch ( - UIndirectList<face> + faceList ( - mesh.faces(), - faces + UIndirectList<face> + ( + mesh.faces(), + faces + ) ), mesh.points() ); diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Allwmake b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..5866aa8f371296d65d50ffd0b6454e745502bcb4 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Allwmake @@ -0,0 +1,6 @@ +#!/bin/sh + +if [ "$TEC_360_2009" ] +then + wmake +fi diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/files b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..270e84931b599af46bf3a9db82024e3202dd5006 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/files @@ -0,0 +1,5 @@ +tecplotWriter.C +vtkMesh.C +foamToTecplot360.C + +EXE = $(FOAM_APPBIN)/foamToTecplot360 diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..d03f44ae8cd509c3bcec9b62b2c7fc1ec3c31185 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/Make/options @@ -0,0 +1,14 @@ +EXE_INC = \ + -I$(TEC_360_2009)/include \ + /* -I../tecio/tecsrc/lnInclude/ */ \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + + +EXE_LIBS = \ + $(TEC_360_2009)/lib/tecio64.a \ + /* -L$(FOAM_USER_LIBBIN) -ltecio */ \ + -llagrangian \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C new file mode 100644 index 0000000000000000000000000000000000000000..d514609ff2ac93904ef354e35880f8d21b458831 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/foamToTecplot360.C @@ -0,0 +1,1362 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + foamToTecplot360 + +Description + Tecplot binary file format writer. + +Usage + + - foamToTecplot360 [OPTION] + + @param -fields \<fields\>\n + Convert selected fields only. For example, + @verbatim + -fields '( p T U )' + @endverbatim + The quoting is required to avoid shell expansions and to pass the + information as a single argument. + + @param -cellSet \<name\>\n + @param -faceSet \<name\>\n + Restrict conversion to the cellSet, faceSet. + + @param -nearCellValue \n + Output cell value on patches instead of patch value itself + + @param -noInternal \n + Do not generate file for mesh, only for patches + + @param -noPointValues \n + No pointFields + + @param -noFaceZones \n + No faceZones + + @param -excludePatches \<patchNames\>\n + Specify patches (wildcards) to exclude. For example, + @verbatim + -excludePatches '( inlet_1 inlet_2 "proc.*")' + @endverbatim + The quoting is required to avoid shell expansions and to pass the + information as a single argument. The double quotes denote a regular + expression. + +\*---------------------------------------------------------------------------*/ + +#include "pointMesh.H" +#include "volPointInterpolation.H" +#include "emptyPolyPatch.H" +#include "labelIOField.H" +#include "scalarIOField.H" +#include "sphericalTensorIOField.H" +#include "symmTensorIOField.H" +#include "tensorIOField.H" +#include "passiveParticleCloud.H" +#include "faceSet.H" +#include "stringListOps.H" +#include "wordRe.H" + +#include "vtkMesh.H" +#include "readFields.H" +#include "tecplotWriter.H" + +#include "TECIO.h" + +// Note: needs to be after TECIO to prevent Foam::Time conflicting with +// Xlib Time. +#include "fvCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class GeoField> +void print(const char* msg, Ostream& os, const PtrList<GeoField>& flds) +{ + if (flds.size()) + { + os << msg; + forAll(flds, i) + { + os<< ' ' << flds[i].name(); + } + os << endl; + } +} + + +void print(Ostream& os, const wordList& flds) +{ + forAll(flds, i) + { + os<< ' ' << flds[i]; + } + os << endl; +} + + +labelList getSelectedPatches +( + const polyBoundaryMesh& patches, + const List<wordRe>& excludePatches //HashSet<word>& excludePatches +) +{ + DynamicList<label> patchIDs(patches.size()); + + Info<< "Combining patches:" << endl; + + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + + if + ( + isType<emptyPolyPatch>(pp) + || (Pstream::parRun() && isType<processorPolyPatch>(pp)) + ) + { + Info<< " discarding empty/processor patch " << patchI + << " " << pp.name() << endl; + } + else if (findStrings(excludePatches, pp.name())) + { + Info<< " excluding patch " << patchI + << " " << pp.name() << endl; + } + else + { + patchIDs.append(patchI); + Info<< " patch " << patchI << " " << pp.name() << endl; + } + } + return patchIDs.shrink(); +} + + + + +// Main program: + +int main(int argc, char *argv[]) +{ + timeSelector::addOptions(); + +# include "addRegionOption.H" + + argList::validOptions.insert("fields", "fields"); + argList::validOptions.insert("cellSet", "cellSet name"); + argList::validOptions.insert("faceSet", "faceSet name"); + argList::validOptions.insert("nearCellValue",""); + argList::validOptions.insert("noInternal",""); + argList::validOptions.insert("noPointValues",""); + argList::validOptions.insert + ( + "excludePatches", + "patches (wildcards) to exclude" + ); + argList::validOptions.insert("noFaceZones",""); + +# include "setRootCase.H" +# include "createTime.H" + + bool doWriteInternal = !args.optionFound("noInternal"); + bool doFaceZones = !args.optionFound("noFaceZones"); + + bool nearCellValue = args.optionFound("nearCellValue"); + + if (nearCellValue) + { + WarningIn(args.executable()) + << "Using neighbouring cell value instead of patch value" + << nl << endl; + } + + bool noPointValues = args.optionFound("noPointValues"); + + if (noPointValues) + { + WarningIn(args.executable()) + << "Outputting cell values only" << nl << endl; + } + + List<wordRe> excludePatches; + if (args.optionFound("excludePatches")) + { + args.optionLookup("excludePatches")() >> excludePatches; + + Info<< "Not including patches " << excludePatches << nl << endl; + } + + word cellSetName; + string vtkName; + + if (args.optionFound("cellSet")) + { + cellSetName = args.option("cellSet"); + vtkName = cellSetName; + } + else if (Pstream::parRun()) + { + // Strip off leading casename, leaving just processor_DDD ending. + vtkName = runTime.caseName(); + + string::size_type i = vtkName.rfind("processor"); + + if (i != string::npos) + { + vtkName = vtkName.substr(i); + } + } + else + { + vtkName = runTime.caseName(); + } + + + instantList timeDirs = timeSelector::select0(runTime, args); + +# include "createNamedMesh.H" + + // TecplotData/ directory in the case + fileName fvPath(runTime.path()/"TecplotData-bin"); + // Directory of mesh (region0 gets filtered out) + fileName regionPrefix = ""; + + if (regionName != polyMesh::defaultRegion) + { + fvPath = fvPath/regionName; + regionPrefix = regionName; + } + + if (isDir(fvPath)) + { + if + ( + args.optionFound("time") + || args.optionFound("latestTime") + || cellSetName.size() + || regionName != polyMesh::defaultRegion + ) + { + Info<< "Keeping old files in " << fvPath << nl << endl; + } + else + { + Info<< "Deleting old VTK files in " << fvPath << nl << endl; + + rmDir(fvPath); + } + } + + mkDir(fvPath); + + + // mesh wrapper; does subsetting and decomposition + vtkMesh vMesh(mesh, cellSetName); + + forAll(timeDirs, timeI) + { + runTime.setTime(timeDirs[timeI], timeI); + + Info<< "Time: " << runTime.timeName() << endl; + + const word timeDesc = name(timeI); //name(runTime.timeIndex()); + + // Check for new polyMesh/ and update mesh, fvMeshSubset and cell + // decomposition. + polyMesh::readUpdateState meshState = vMesh.readUpdate(); + + const fvMesh& mesh = vMesh.mesh(); + + INTEGER4 nFaceNodes = 0; + forAll(mesh.faces(), faceI) + { + nFaceNodes += mesh.faces()[faceI].size(); + } + + + // Read all fields on the new mesh + // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // Search for list of objects for this time + IOobjectList objects(mesh, runTime.timeName()); + + HashSet<word> selectedFields; + if (args.optionFound("fields")) + { + args.optionLookup("fields")() >> selectedFields; + } + + // Construct the vol fields (on the original mesh if subsetted) + + PtrList<volScalarField> vsf; + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vsf); + print(" volScalarFields :", Info, vsf); + + PtrList<volVectorField> vvf; + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vvf); + print(" volVectorFields :", Info, vvf); + + PtrList<volSphericalTensorField> vSpheretf; + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSpheretf); + print(" volSphericalTensorFields :", Info, vSpheretf); + + PtrList<volSymmTensorField> vSymmtf; + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vSymmtf); + print(" volSymmTensorFields :", Info, vSymmtf); + + PtrList<volTensorField> vtf; + readFields(vMesh, vMesh.baseMesh(), objects, selectedFields, vtf); + print(" volTensorFields :", Info, vtf); + + + // Construct pointMesh only if nessecary since constructs edge + // addressing (expensive on polyhedral meshes) + if (noPointValues) + { + Info<< " pointScalarFields : switched off" + << " (\"-noPointValues\" option)\n"; + Info<< " pointVectorFields : switched off" + << " (\"-noPointValues\" option)\n"; + } + + PtrList<pointScalarField> psf; + PtrList<pointVectorField> pvf; + //PtrList<pointSphericalTensorField> pSpheretf; + //PtrList<pointSymmTensorField> pSymmtf; + //PtrList<pointTensorField> ptf; + + + if (!noPointValues) + { + //// Add interpolated volFields + //const volPointInterpolation& pInterp = volPointInterpolation::New + //( + // mesh + //); + // + //label nPsf = psf.size(); + //psf.setSize(nPsf+vsf.size()); + //forAll(vsf, i) + //{ + // Info<< "Interpolating " << vsf[i].name() << endl; + // tmp<pointScalarField> tvsf(pInterp.interpolate(vsf[i])); + // tvsf().rename(vsf[i].name() + "_point"); + // psf.set(nPsf, tvsf); + // nPsf++; + //} + // + //label nPvf = pvf.size(); + //pvf.setSize(vvf.size()); + //forAll(vvf, i) + //{ + // Info<< "Interpolating " << vvf[i].name() << endl; + // tmp<pointVectorField> tvvf(pInterp.interpolate(vvf[i])); + // tvvf().rename(vvf[i].name() + "_point"); + // pvf.set(nPvf, tvvf); + // nPvf++; + //} + + readFields + ( + vMesh, + pointMesh::New(vMesh.baseMesh()), + objects, + selectedFields, + psf + ); + print(" pointScalarFields :", Info, psf); + + readFields + ( + vMesh, + pointMesh::New(vMesh.baseMesh()), + objects, + selectedFields, + pvf + ); + print(" pointVectorFields :", Info, pvf); + + //readFields + //( + // vMesh, + // pointMesh::New(vMesh.baseMesh()), + // objects, + // selectedFields, + // pSpheretf + //); + //print(" pointSphericalTensorFields :", Info, pSpheretf); + // + //readFields + //( + // vMesh, + // pointMesh::New(vMesh.baseMesh()), + // objects, + // selectedFields, + // pSymmtf + //); + //print(" pointSymmTensorFields :", Info, pSymmtf); + // + //readFields + //( + // vMesh, + // pointMesh::New(vMesh.baseMesh()), + // objects, + // selectedFields, + // ptf + //); + //print(" pointTensorFields :", Info, ptf); + } + Info<< endl; + + + // Get field names + // ~~~~~~~~~~~~~~~ + + string varNames; + DynamicList<INTEGER4> varLocation; + + string cellVarNames; + DynamicList<INTEGER4> cellVarLocation; + + // volFields + tecplotWriter::getTecplotNames + ( + vsf, + ValueLocation_CellCentered, + varNames, + varLocation + ); + tecplotWriter::getTecplotNames + ( + vsf, + ValueLocation_CellCentered, + cellVarNames, + cellVarLocation + ); + + tecplotWriter::getTecplotNames + ( + vvf, + ValueLocation_CellCentered, + varNames, + varLocation + ); + tecplotWriter::getTecplotNames + ( + vvf, + ValueLocation_CellCentered, + cellVarNames, + cellVarLocation + ); + + tecplotWriter::getTecplotNames + ( + vSpheretf, + ValueLocation_CellCentered, + varNames, + varLocation + ); + tecplotWriter::getTecplotNames + ( + vSpheretf, + ValueLocation_CellCentered, + cellVarNames, + cellVarLocation + ); + + tecplotWriter::getTecplotNames + ( + vSymmtf, + ValueLocation_CellCentered, + varNames, + varLocation + ); + tecplotWriter::getTecplotNames + ( + vSymmtf, + ValueLocation_CellCentered, + cellVarNames, + cellVarLocation + ); + + tecplotWriter::getTecplotNames + ( + vtf, + ValueLocation_CellCentered, + varNames, + varLocation + ); + tecplotWriter::getTecplotNames + ( + vtf, + ValueLocation_CellCentered, + cellVarNames, + cellVarLocation + ); + + + + // pointFields + tecplotWriter::getTecplotNames + ( + psf, + ValueLocation_Nodal, + varNames, + varLocation + ); + + tecplotWriter::getTecplotNames + ( + pvf, + ValueLocation_Nodal, + varNames, + varLocation + ); + + // strandID (= some zone id) + INTEGER4 strandID = 1; + + + if (meshState != polyMesh::UNCHANGED) + { + if (doWriteInternal) + { + // Output mesh and fields + fileName vtkFileName + ( + fvPath/vtkName + + "_" + + timeDesc + + ".plt" + ); + + tecplotWriter writer(runTime); + + string allVarNames = string("X Y Z ") + varNames; + DynamicList<INTEGER4> allVarLocation; + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(varLocation); + + writer.writeInit + ( + runTime.caseName(), + allVarNames, + vtkFileName, + DataFileType_Full + ); + + writer.writePolyhedralZone + ( + mesh.name(), // regionName + strandID++, // strandID + mesh, + allVarLocation, + nFaceNodes + ); + + // Write coordinates + writer.writeField(mesh.points().component(0)()); + writer.writeField(mesh.points().component(1)()); + writer.writeField(mesh.points().component(2)()); + + // Write all fields + forAll(vsf, i) + { + writer.writeField(vsf[i]); + } + forAll(vvf, i) + { + writer.writeField(vvf[i]); + } + forAll(vSpheretf, i) + { + writer.writeField(vSpheretf[i]); + } + forAll(vSymmtf, i) + { + writer.writeField(vSymmtf[i]); + } + forAll(vtf, i) + { + writer.writeField(vtf[i]); + } + + forAll(psf, i) + { + writer.writeField(psf[i]); + } + forAll(pvf, i) + { + writer.writeField(pvf[i]); + } + + writer.writeConnectivity(mesh); + writer.writeEnd(); + } + } + else + { + if (doWriteInternal) + { + if (timeI == 0) + { + // Output static mesh only + fileName vtkFileName + ( + fvPath/vtkName + + "_grid_" + + timeDesc + + ".plt" + ); + + tecplotWriter writer(runTime); + + writer.writeInit + ( + runTime.caseName(), + "X Y Z", + vtkFileName, + DataFileType_Grid + ); + + writer.writePolyhedralZone + ( + mesh.name(), // regionName + 1, //strandID, // strandID + mesh, + List<INTEGER4>(3, ValueLocation_Nodal), + nFaceNodes + ); + + // Write coordinates + writer.writeField(mesh.points().component(0)()); + writer.writeField(mesh.points().component(1)()); + writer.writeField(mesh.points().component(2)()); + + writer.writeConnectivity(mesh); + writer.writeEnd(); + } + + // Output solution file + fileName vtkFileName + ( + fvPath/vtkName + + "_" + + timeDesc + + ".plt" + ); + + tecplotWriter writer(runTime); + + writer.writeInit + ( + runTime.caseName(), + varNames, + vtkFileName, + DataFileType_Solution + ); + + writer.writePolyhedralZone + ( + mesh.name(), // regionName + 1, //strandID, // strandID + mesh, + varLocation, + 0 + ); + + // Write all fields + forAll(vsf, i) + { + writer.writeField(vsf[i]); + } + forAll(vvf, i) + { + writer.writeField(vvf[i]); + } + forAll(vSpheretf, i) + { + writer.writeField(vSpheretf[i]); + } + forAll(vSymmtf, i) + { + writer.writeField(vSymmtf[i]); + } + forAll(vtf, i) + { + writer.writeField(vtf[i]); + } + + forAll(psf, i) + { + writer.writeField(psf[i]); + } + forAll(pvf, i) + { + writer.writeField(pvf[i]); + } + writer.writeEnd(); + } + } + + + //--------------------------------------------------------------------- + // + // Write faceSet + // + //--------------------------------------------------------------------- + + if (args.optionFound("faceSet")) + { + // Load the faceSet + word setName(args.option("faceSet")); + labelList faceLabels(faceSet(mesh, setName).toc()); + + // Filename as if patch with same name. + mkDir(fvPath/setName); + + fileName patchFileName + ( + fvPath/setName/setName + + "_" + + timeDesc + + ".plt" + ); + + Info<< " FaceSet : " << patchFileName << endl; + + tecplotWriter writer(runTime); + + string allVarNames = string("X Y Z ") + cellVarNames; + DynamicList<INTEGER4> allVarLocation; + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(cellVarLocation); + + writer.writeInit + ( + runTime.caseName(), + cellVarNames, + patchFileName, + DataFileType_Full + ); + + const indirectPrimitivePatch ipp + ( + IndirectList<face>(mesh.faces(), faceLabels), + mesh.points() + ); + + writer.writePolygonalZone + ( + setName, + 1, //strandID, + ipp, + allVarLocation + ); + + // Write coordinates + writer.writeField(ipp.localPoints().component(0)()); + writer.writeField(ipp.localPoints().component(1)()); + writer.writeField(ipp.localPoints().component(2)()); + + // Write all volfields + forAll(vsf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vsf[i])(), + faceLabels + )() + ); + } + forAll(vvf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vvf[i])(), + faceLabels + )() + ); + } + forAll(vSpheretf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vSpheretf[i])(), + faceLabels + )() + ); + } + forAll(vSymmtf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vSymmtf[i])(), + faceLabels + )() + ); + } + forAll(vtf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vtf[i])(), + faceLabels + )() + ); + } + writer.writeConnectivity(ipp); + + continue; + } + + + + //--------------------------------------------------------------------- + // + // Write patches as multi-zone file + // + //--------------------------------------------------------------------- + + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + + labelList patchIDs(getSelectedPatches(patches, excludePatches)); + + mkDir(fvPath/"boundaryMesh"); + + fileName patchFileName; + + if (vMesh.useSubMesh()) + { + patchFileName = + fvPath/"boundaryMesh"/cellSetName + + "_" + + timeDesc + + ".plt"; + } + else + { + patchFileName = + fvPath/"boundaryMesh"/"boundaryMesh" + + "_" + + timeDesc + + ".plt"; + } + + Info<< " Combined patches : " << patchFileName << endl; + + tecplotWriter writer(runTime); + + string allVarNames = string("X Y Z ") + varNames; + DynamicList<INTEGER4> allVarLocation; + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(varLocation); + + writer.writeInit + ( + runTime.caseName(), + allVarNames, + patchFileName, + DataFileType_Full + ); + + forAll(patchIDs, i) + { + label patchID = patchIDs[i]; + const polyPatch& pp = patches[patchID]; + INTEGER4 strandID = 1 + i; + + Info<< " Writing patch " << patchID << "\t" << pp.name() + << "\tstrand:" << strandID << nl << endl; + + const indirectPrimitivePatch ipp + ( + IndirectList<face>(pp, identity(pp.size())), + pp.points() + ); + + writer.writePolygonalZone + ( + pp.name(), + strandID, + ipp, + allVarLocation + ); + + // Write coordinates + writer.writeField(ipp.localPoints().component(0)()); + writer.writeField(ipp.localPoints().component(1)()); + writer.writeField(ipp.localPoints().component(2)()); + + // Write all fields + forAll(vsf, i) + { + writer.writeField + ( + writer.getPatchField + ( + nearCellValue, + vsf[i], + patchID + )() + ); + } + forAll(vvf, i) + { + writer.writeField + ( + writer.getPatchField + ( + nearCellValue, + vvf[i], + patchID + )() + ); + } + forAll(vSpheretf, i) + { + writer.writeField + ( + writer.getPatchField + ( + nearCellValue, + vSpheretf[i], + patchID + )() + ); + } + forAll(vSymmtf, i) + { + writer.writeField + ( + writer.getPatchField + ( + nearCellValue, + vSymmtf[i], + patchID + )() + ); + } + forAll(vtf, i) + { + writer.writeField + ( + writer.getPatchField + ( + nearCellValue, + vtf[i], + patchID + )() + ); + } + + forAll(psf, i) + { + writer.writeField + ( + psf[i].boundaryField()[patchID].patchInternalField()() + ); + } + forAll(pvf, i) + { + writer.writeField + ( + pvf[i].boundaryField()[patchID].patchInternalField()() + ); + } + + writer.writeConnectivity(ipp); + } + writer.writeEnd(); + + + + //--------------------------------------------------------------------- + // + // Write faceZones as multi-zone file + // + //--------------------------------------------------------------------- + + const faceZoneMesh& zones = mesh.faceZones(); + + if (doFaceZones && zones.size() > 0) + { + mkDir(fvPath/"faceZoneMesh"); + + fileName patchFileName; + + if (vMesh.useSubMesh()) + { + patchFileName = + fvPath/"faceZoneMesh"/cellSetName + + "_" + + timeDesc + + ".plt"; + } + else + { + patchFileName = + fvPath/"faceZoneMesh"/"faceZoneMesh" + + "_" + + timeDesc + + ".plt"; + } + + Info<< " FaceZone : " << patchFileName << endl; + + tecplotWriter writer(runTime); + + string allVarNames = string("X Y Z ") + cellVarNames; + DynamicList<INTEGER4> allVarLocation; + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(cellVarLocation); + + writer.writeInit + ( + runTime.caseName(), + cellVarNames, + patchFileName, + DataFileType_Full + ); + + forAll(zones, zoneI) + { + const faceZone& pp = zones[zoneI]; + + const indirectPrimitivePatch ipp + ( + IndirectList<face>(mesh.faces(), pp), + mesh.points() + ); + + writer.writePolygonalZone + ( + pp.name(), + 1+patchIDs.size()+zoneI, //strandID, + ipp, + allVarLocation + ); + + // Write coordinates + writer.writeField(ipp.localPoints().component(0)()); + writer.writeField(ipp.localPoints().component(1)()); + writer.writeField(ipp.localPoints().component(2)()); + + // Write all volfields + forAll(vsf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vsf[i])(), + pp + )() + ); + } + forAll(vvf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vvf[i])(), + pp + )() + ); + } + forAll(vSpheretf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vSpheretf[i])(), + pp + )() + ); + } + forAll(vSymmtf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vSymmtf[i])(), + pp + )() + ); + } + forAll(vtf, i) + { + writer.writeField + ( + writer.getFaceField + ( + fvc::interpolate(vtf[i])(), + pp + )() + ); + } + + writer.writeConnectivity(ipp); + } + } + + + + //--------------------------------------------------------------------- + // + // Write lagrangian data + // + //--------------------------------------------------------------------- + + fileNameList cloudDirs + ( + readDir + ( + runTime.timePath()/regionPrefix/cloud::prefix, + fileName::DIRECTORY + ) + ); + + forAll(cloudDirs, cloudI) + { + IOobjectList sprayObjs + ( + mesh, + runTime.timeName(), + cloud::prefix/cloudDirs[cloudI] + ); + + IOobject* positionsPtr = sprayObjs.lookup("positions"); + + if (positionsPtr) + { + mkDir(fvPath/cloud::prefix/cloudDirs[cloudI]); + + fileName lagrFileName + ( + fvPath/cloud::prefix/cloudDirs[cloudI]/cloudDirs[cloudI] + + "_" + timeDesc + ".plt" + ); + + Info<< " Lagrangian: " << lagrFileName << endl; + + wordList labelNames(sprayObjs.names(labelIOField::typeName)); + Info<< " labels :"; + print(Info, labelNames); + + wordList scalarNames(sprayObjs.names(scalarIOField::typeName)); + Info<< " scalars :"; + print(Info, scalarNames); + + wordList vectorNames(sprayObjs.names(vectorIOField::typeName)); + Info<< " vectors :"; + print(Info, vectorNames); + + wordList sphereNames + ( + sprayObjs.names + ( + sphericalTensorIOField::typeName + ) + ); + Info<< " spherical tensors :"; + print(Info, sphereNames); + + wordList symmNames + ( + sprayObjs.names + ( + symmTensorIOField::typeName + ) + ); + Info<< " symm tensors :"; + print(Info, symmNames); + + wordList tensorNames(sprayObjs.names(tensorIOField::typeName)); + Info<< " tensors :"; + print(Info, tensorNames); + + + // Load cloud positions + passiveParticleCloud parcels(mesh, cloudDirs[cloudI]); + + // Get positions as pointField + pointField positions(parcels.size()); + label n = 0; + forAllConstIter(passiveParticleCloud, parcels, elmnt) + { + positions[n++] = elmnt().position(); + } + + + string allVarNames = string("X Y Z"); + DynamicList<INTEGER4> allVarLocation; + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + allVarLocation.append(ValueLocation_Nodal); + + tecplotWriter::getTecplotNames<label> + ( + labelNames, + ValueLocation_Nodal, + allVarNames, + allVarLocation + ); + + tecplotWriter::getTecplotNames<scalar> + ( + scalarNames, + ValueLocation_Nodal, + allVarNames, + allVarLocation + ); + + tecplotWriter::getTecplotNames<vector> + ( + vectorNames, + ValueLocation_Nodal, + allVarNames, + allVarLocation + ); + + + tecplotWriter writer(runTime); + + writer.writeInit + ( + runTime.caseName(), + allVarNames, + lagrFileName, + DataFileType_Full + ); + + writer.writeOrderedZone + ( + cloudDirs[cloudI], + strandID, + parcels.size(), + allVarLocation + ); + + // Write coordinates + writer.writeField(positions.component(0)()); + writer.writeField(positions.component(1)()); + writer.writeField(positions.component(2)()); + + // labelFields + forAll(labelNames, i) + { + IOField<label> fld + ( + IOobject + ( + labelNames[i], + mesh.time().timeName(), + cloud::prefix/cloudDirs[cloudI], + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + + scalarField sfld(fld.size()); + forAll(fld, j) + { + sfld[j] = scalar(fld[j]); + } + writer.writeField(sfld); + } + // scalarFields + forAll(scalarNames, i) + { + IOField<scalar> fld + ( + IOobject + ( + scalarNames[i], + mesh.time().timeName(), + cloud::prefix/cloudDirs[cloudI], + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + writer.writeField(fld); + } + // vectorFields + forAll(vectorNames, i) + { + IOField<vector> fld + ( + IOobject + ( + vectorNames[i], + mesh.time().timeName(), + cloud::prefix/cloudDirs[cloudI], + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ) + ); + writer.writeField(fld); + } + + writer.writeEnd(); + } + } + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.C new file mode 100644 index 0000000000000000000000000000000000000000..46ddc9bf8cb116dca2364db32f05bb39e494b7c2 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.C @@ -0,0 +1,87 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "readFields.H" +#include "IOobjectList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // + +template<class GeoField> +void readFields +( + const vtkMesh& vMesh, + const typename GeoField::Mesh& mesh, + const IOobjectList& objects, + const HashSet<word>& selectedFields, + PtrList<GeoField>& fields +) +{ + // Search list of objects for volScalarFields + IOobjectList fieldObjects(objects.lookupClass(GeoField::typeName)); + + // Construct the vol scalar fields + label nFields = fields.size(); + fields.setSize(nFields + fieldObjects.size()); + + for + ( + IOobjectList::iterator iter = fieldObjects.begin(); + iter != fieldObjects.end(); + ++iter + ) + { + if (selectedFields.empty() || selectedFields.found(iter()->name())) + { + fields.set + ( + nFields, + vMesh.interpolate + ( + GeoField + ( + *iter(), + mesh + ) + ) + ); + nFields++; + } + } + + fields.setSize(nFields); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.H b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.H new file mode 100644 index 0000000000000000000000000000000000000000..aa9754c5483a8b8d8ff555fed09a8281b7fccd01 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/readFields.H @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +InClass + Foam::readFields + +Description + +SourceFiles + readFields.C + +\*---------------------------------------------------------------------------*/ + +#ifndef readFields_H +#define readFields_H + +#include "fvMesh.H" +#include "PtrList.H" +#include "IOobjectList.H" +#include "HashSet.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Read the fields and optionally subset and put on the pointer list +template<class GeoField> +void readFields +( + const vtkMesh& vMesh, + const typename GeoField::Mesh& mesh, + const IOobjectList& objects, + const HashSet<word>& selectedFields, + PtrList<GeoField>& fields +); + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "readFields.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C new file mode 100644 index 0000000000000000000000000000000000000000..47165d80a448adbec08991a0e7de239e1314a8cf --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.C @@ -0,0 +1,517 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "tecplotWriter.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::tecplotWriter::tecplotWriter(const Time& runTime) +: + runTime_(runTime) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::tecplotWriter::writeInit +( + const word& name, + const string& varNames, + const fileName& fName, + INTEGER4 tecplotFileType +) const +{ +Pout<< endl + << endl + << "Name:" << name + << " varNames:" << varNames + << " to file:" << fName + << " of type:" << tecplotFileType + << endl; + + INTEGER4 IsDouble = 0; //float + INTEGER4 Debug = 0; //nodebug + if + ( + !TECINI112 + ( + const_cast<char*>(name.c_str()), /* Data Set Title */ + const_cast<char*>(varNames.c_str()), /* Variable List */ + const_cast<char*>(fName.c_str()), /* File Name */ + const_cast<char*>(runTime_.path().c_str()), /* Scratch Directory */ + &tecplotFileType, + &Debug, + &IsDouble + ) + ) + { +// FatalErrorIn("tecplotWriter::writeInit(..) const") +// << "Error in TECINI112." << exit(FatalError); + } +} + + +void Foam::tecplotWriter::writePolyhedralZone +( + const word& zoneName, + const INTEGER4 strandID, + const fvMesh& mesh, + const List<INTEGER4>& varLocArray, + INTEGER4 nFaceNodes +) const +{ + /* Call TECZNE112 */ + INTEGER4 NumNodes = mesh.nPoints(); /* number of unique nodes */ + INTEGER4 NumElems = mesh.nCells(); /* number of elements */ + INTEGER4 NumFaces = mesh.nFaces(); /* number of unique faces */ + + INTEGER4 ICellMax = 0; /* Not Used, set to zero */ + INTEGER4 JCellMax = 0; /* Not Used, set to zero */ + INTEGER4 KCellMax = 0; /* Not Used, set to zero */ + + double SolTime = runTime_.value(); /* solution time */ + INTEGER4 StrandID = 1; /* static zone */ + INTEGER4 ParentZone = 0; /* no parent zone */ + + INTEGER4 IsBlock = 1; /* block format */ + + INTEGER4 NFConns = 0; /* not used for FEPolyhedron + * zones + */ + INTEGER4 FNMode = 0; /* not used for FEPolyhedron + * zones + */ +Pout<< "zoneName:" << zoneName + //<< " varLocArray:" << varLocArray + << " solTime:" << SolTime + << endl; + + + + INTEGER4 *PassiveVarArray = NULL; + INTEGER4 *VarShareArray = NULL; + INTEGER4 ShrConn = 0; + + INTEGER4 NumBConns = 0; /* No Boundary Connections */ + INTEGER4 NumBItems = 0; /* No Boundary Items */ + + INTEGER4 ZoneType = ZoneType_FEPolyhedron; + + if + ( + !TECZNE112 + ( + const_cast<char*>(zoneName.c_str()), + &ZoneType, + &NumNodes, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &StrandID, + &ParentZone, + &IsBlock, + &NFConns, + &FNMode, + &nFaceNodes, + &NumBConns, + &NumBItems, + PassiveVarArray, + const_cast<INTEGER4*>(varLocArray.begin()), + VarShareArray, + &ShrConn + ) + ) + { +// FatalErrorIn("tecplotWriter::writePolyhedralZone(..) const") +// << "Error in TECZNE112." << exit(FatalError); + } +} + + +void Foam::tecplotWriter::writePolygonalZone +( + const word& zoneName, + INTEGER4 strandID, + const indirectPrimitivePatch& pp, + const List<INTEGER4>& varLocArray +) const +{ + /* Call TECZNE112 */ + INTEGER4 NumNodes = pp.nPoints(); /* number of unique nodes */ + INTEGER4 NumElems = pp.size(); /* number of elements */ + INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */ + + INTEGER4 ICellMax = 0; /* Not Used, set to zero */ + INTEGER4 JCellMax = 0; /* Not Used, set to zero */ + INTEGER4 KCellMax = 0; /* Not Used, set to zero */ + + double SolTime = runTime_.value(); /* solution time */ + INTEGER4 ParentZone = 0; /* no parent zone */ + + INTEGER4 IsBlock = 1; /* block format */ + + INTEGER4 NFConns = 0; /* not used for FEPolyhedron + * zones + */ + INTEGER4 FNMode = 0; /* not used for FEPolyhedron + * zones + */ + INTEGER4 NumFaceNodes = 2*pp.nEdges(); + +Pout<< "zoneName:" << zoneName + << " strandID:" << strandID + //<< " varLocArray:" << varLocArray + << " solTime:" << SolTime + << endl; + + + INTEGER4 *PassiveVarArray = NULL; + INTEGER4 *VarShareArray = NULL; + INTEGER4 ShrConn = 0; + + INTEGER4 NumBConns = 0; /* No Boundary Connections */ + INTEGER4 NumBItems = 0; /* No Boundary Items */ + + INTEGER4 ZoneType = ZoneType_FEPolygon; + + if + ( + !TECZNE112 + ( + const_cast<char*>(zoneName.c_str()), + &ZoneType, + &NumNodes, + &NumElems, + &NumFaces, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &strandID, + &ParentZone, + &IsBlock, + &NFConns, + &FNMode, + &NumFaceNodes, + &NumBConns, + &NumBItems, + PassiveVarArray, + const_cast<INTEGER4*>(varLocArray.begin()), + VarShareArray, + &ShrConn + ) + ) + { +// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const") +// << "Error in TECZNE112." << exit(FatalError); + } +} + + +void Foam::tecplotWriter::writeOrderedZone +( + const word& zoneName, + INTEGER4 strandID, + const label n, + const List<INTEGER4>& varLocArray +) const +{ + /* Call TECZNE112 */ + INTEGER4 IMax = n; /* number of unique nodes */ + INTEGER4 JMax = 1; /* number of elements */ + INTEGER4 KMax = 1; /* number of unique faces */ + + INTEGER4 ICellMax = 0; /* Not Used, set to zero */ + INTEGER4 JCellMax = 0; /* Not Used, set to zero */ + INTEGER4 KCellMax = 0; /* Not Used, set to zero */ + + double SolTime = runTime_.value(); /* solution time */ + INTEGER4 ParentZone = 0; /* no parent zone */ + + INTEGER4 IsBlock = 1; /* block format */ + + INTEGER4 NFConns = 0; /* not used for FEPolyhedron + * zones + */ + INTEGER4 FNMode = 0; /* not used for FEPolyhedron + * zones + */ + INTEGER4 NumFaceNodes = 1; + INTEGER4 NumBConns = 1; /* No Boundary Connections */ + INTEGER4 NumBItems = 1; /* No Boundary Items */ + +Pout<< "zoneName:" << zoneName + << " strandID:" << strandID + //<< " varLocArray:" << varLocArray + << " solTime:" << SolTime + << endl; + + + INTEGER4 *PassiveVarArray = NULL; + INTEGER4 *VarShareArray = NULL; + INTEGER4 ShrConn = 0; + + + INTEGER4 ZoneType = ZoneType_Ordered; + + if + ( + !TECZNE112 + ( + const_cast<char*>(zoneName.c_str()), + &ZoneType, + &IMax, + &JMax, + &KMax, + &ICellMax, + &JCellMax, + &KCellMax, + &SolTime, + &strandID, + &ParentZone, + &IsBlock, + &NFConns, + &FNMode, + &NumFaceNodes, + &NumBConns, + &NumBItems, + PassiveVarArray, + const_cast<INTEGER4*>(varLocArray.begin()), + VarShareArray, + &ShrConn + ) + ) + { +// FatalErrorIn("tecplotWriter::writePolygonalZone(..) const") +// << "Error in TECZNE112." << exit(FatalError); + } +} + + +void Foam::tecplotWriter::writeConnectivity(const fvMesh& mesh) const +{ + List<INTEGER4> FaceNodeCounts(mesh.nFaces()); + + forAll(mesh.faces(), faceI) + { + const face& f = mesh.faces()[faceI]; + FaceNodeCounts[faceI] = INTEGER4(f.size()); + } + + + INTEGER4 nFaceNodes = 0; + forAll(mesh.faces(), faceI) + { + nFaceNodes += mesh.faces()[faceI].size(); + } + + + List<INTEGER4> FaceNodes(nFaceNodes); + label nodeI = 0; + forAll(mesh.faces(), faceI) + { + const face& f = mesh.faces()[faceI]; + forAll(f, fp) + { + FaceNodes[nodeI++] = INTEGER4(f[fp]+1); + } + } + + + List<INTEGER4> FaceLeftElems(mesh.nFaces()); + forAll(mesh.faceOwner(), faceI) + { + FaceLeftElems[faceI] = mesh.faceOwner()[faceI]+1; + } + + List<INTEGER4> FaceRightElems(mesh.nFaces()); + forAll(mesh.faceNeighbour(), faceI) + { + FaceRightElems[faceI] = mesh.faceNeighbour()[faceI]+1; + } + for + ( + label faceI = mesh.nInternalFaces(); + faceI < mesh.nFaces(); + faceI++ + ) + { + FaceRightElems[faceI] = 0; + } + + if + ( + !TECPOLY112 + ( + FaceNodeCounts.begin(), /* The face node counts array */ + FaceNodes.begin(), /* The face nodes array */ + FaceLeftElems.begin(), /* The left elements array */ + FaceRightElems.begin(), /* The right elements array */ + NULL, /* No boundary connection counts */ + NULL, /* No boundary connection elements */ + NULL /* No boundary connection zones */ + ) + ) + { +// FatalErrorIn("tecplotWriter::writeConnectivity(const fvMesh&) const") +// << "Error in TECPOLY112." << exit(FatalError); + } +} + + +void Foam::tecplotWriter::writeConnectivity +( + const indirectPrimitivePatch& pp +) const +{ + INTEGER4 NumFaces = pp.nEdges(); /* number of unique faces */ + INTEGER4 NumFaceNodes = 2*pp.nEdges(); + + // All faces (=edges) have 2 nodes + List<INTEGER4> FaceNodeCounts(NumFaces, 2); + + List<INTEGER4> FaceNodes(NumFaceNodes); + label nodeI = 0; + forAll(pp.edges(), edgeI) + { + edge e = pp.edges()[edgeI]; + if (e[0] > e[1]) + { + e = e.reverseEdge(); + } + + FaceNodes[nodeI++] = INTEGER4(e[0]+1); + FaceNodes[nodeI++] = INTEGER4(e[1]+1); + } + + /* Define the right and left elements of each face. + * + * The last step for writing out the polyhedral data is to + * define the right and left neighboring elements for each + * face. The neighboring elements can be determined using the + * right-hand rule. For each face, place your right-hand along + * the face which your fingers pointing the direction of + * incrementing node numbers (i.e. from node 1 to node 2). + * Your right thumb will point towards the right element; the + * element on the other side of your hand is the left element. + * + * The number zero is used to indicate that there isn't an + * element on that side of the face. + * + * Because of the way we numbered the nodes and faces, the + * right element for every face is the element itself + * (element 1) and the left element is "no-neighboring element" + * (element 0). + */ + + List<INTEGER4> FaceLeftElems(NumFaces); + List<INTEGER4> FaceRightElems(NumFaces); + + const labelListList& edgeFaces = pp.edgeFaces(); + forAll(edgeFaces, edgeI) + { + const labelList& eFaces = edgeFaces[edgeI]; + + if (eFaces.size() == 1) + { + FaceLeftElems[edgeI] = 0; + FaceRightElems[edgeI] = eFaces[0]+1; + } + else if (eFaces.size() == 2) + { + edge e = pp.edges()[edgeI]; + if (e[0] > e[1]) + { + e = e.reverseEdge(); + } + + const face& f0 = pp.localFaces()[eFaces[0]]; + + // The face that uses the vertices of e in increasing order + // is the left face. + + label fp = findIndex(f0, e[0]); + bool f0IsLeft = (f0.nextLabel(fp) == e[1]); + + if (f0IsLeft) + { + FaceLeftElems[edgeI] = eFaces[0]+1; + FaceRightElems[edgeI] = eFaces[1]+1; + } + else + { + FaceLeftElems[edgeI] = eFaces[1]+1; + FaceRightElems[edgeI] = eFaces[0]+1; + } + } + else + { + // non-manifold. Treat as if open. + FaceLeftElems[edgeI] = 0; + FaceRightElems[edgeI] = eFaces[0]+1; + } + } + + /* Write the face map (created above) using TECPOLY112. */ + if + ( + !TECPOLY112 + ( + FaceNodeCounts.begin(), /* The face node counts array */ + FaceNodes.begin(), /* The face nodes array */ + FaceLeftElems.begin(), /* The left elements array */ + FaceRightElems.begin(), /* The right elements array */ + NULL, /* No boundary connection counts */ + NULL, /* No boundary connection elements */ + NULL /* No boundary connection zones */ + ) + ) + { +// FatalErrorIn("tecplotWriter::writeConnectivity(..) const") +// << "Error in TECPOLY112." << exit(FatalError); + } +} + + +void Foam::tecplotWriter::writeEnd() const +{ +Pout<< "writeEnd" << endl; + + if (!TECEND112()) + { +// FatalErrorIn("tecplotWriter::writeEnd() const") +// << "Error in TECEND112." << exit(FatalError); + } + +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.H b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.H new file mode 100644 index 0000000000000000000000000000000000000000..d614fac20209009f2ba93ac8588085fdd50bdab2 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriter.H @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::tecplotWriter + +Description + Write binary tecplot files using tecio. + +SourceFiles + tecplotWriter.C + tecplotWriterTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef tecplotWriter_H +#define tecplotWriter_H + +#include "TECIO.h" +#include "Time.H" +#include "indirectPrimitivePatch.H" +#include "volFields.H" +#include "surfaceFields.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +class fvMesh; + +/*---------------------------------------------------------------------------*\ + Class tecplotWriter Declaration +\*---------------------------------------------------------------------------*/ + +class tecplotWriter +{ + const Time& runTime_; + +public: + + // Constructors + + //- Construct from components + tecplotWriter(const Time&); + + + // Member Functions + + void writeInit + ( + const word& name, + const string& varNames, + const fileName&, + INTEGER4 tecplotFileType + ) const; + + //- Write mesh as polyhedral zone + void writePolyhedralZone + ( + const word& zoneName, + const INTEGER4 strandID, + const fvMesh& mesh, + const List<INTEGER4>& varLocArray, + INTEGER4 nFaceNodes + ) const; + + //- Write surface as polygonal zone + void writePolygonalZone + ( + const word& zoneName, + const INTEGER4 strandID, + const indirectPrimitivePatch& pp, + const List<INTEGER4>& varLocArray + ) const; + + //- Write unordered data (or rather 1D ordered) + void writeOrderedZone + ( + const word& zoneName, + INTEGER4 strandID, + const label n, + const List<INTEGER4>& varLocArray + ) const; + + //- Write mesh + void writeConnectivity(const fvMesh& mesh) const; + + //- Write surface + void writeConnectivity(const indirectPrimitivePatch& pp) const; + + void writeEnd() const; + + //- Write generic Field + template<class Type> + void writeField(const Field<Type>& fld) const; + + + //- Get either fvPatchField or patchInternalField + template<class Type> + tmp<Field<Type> > getPatchField + ( + const bool nearCellValue, + const GeometricField<Type, fvPatchField, volMesh>& vfld, + const label patchI + ) const; + + //- Get mixed field: fvsPatchField for boundary faces and + // internalField for internal faces. + template<class Type> + tmp<Field<Type> > getFaceField + ( + const GeometricField<Type, fvsPatchField, surfaceMesh>&, + const labelList& faceLabels + ) const; + + template<class GeoField> + static wordList getNames(const PtrList<GeoField>&); + + template<class Type> + static void getTecplotNames + ( + const wordList& names, + const INTEGER4 loc, + string& varNames, + DynamicList<INTEGER4>& varLocation + ); + + template<class GeoField> + static void getTecplotNames + ( + const PtrList<GeoField>& flds, + const INTEGER4 loc, + string& varNames, + DynamicList<INTEGER4>& varLocation + ); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "tecplotWriterTemplates.C" +#endif + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriterTemplates.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriterTemplates.C new file mode 100644 index 0000000000000000000000000000000000000000..f337b20d380836f9f06d2634f19470c0c108a407 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/tecplotWriterTemplates.C @@ -0,0 +1,199 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "tecplotWriter.H" + +extern "C" +{ + #include "MASTER.h" + #include "GLOBAL.h" +} + +#include "fvc.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template<class Type> +void Foam::tecplotWriter::writeField(const Field<Type>& fld) const +{ + for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++) + { + scalarField cmptFld(fld.component(cmpt)); + + // Convert to float + Field<float> floats(cmptFld.size()); + forAll(cmptFld, i) + { + floats[i] = float(cmptFld[i]); + } + + INTEGER4 size = INTEGER4(floats.size()); + INTEGER4 IsDouble = 0; //float + + //Pout<< "Writing component:" << cmpt << " of size:" << size + // << " floats." << endl; + + if (!TECDAT112(&size, floats.begin(), &IsDouble)) + { +// FatalErrorIn("tecplotWriter::writeField(..) const") +// << "Error in TECDAT112." << exit(FatalError); + } + } +} + + +template<class Type> +Foam::tmp<Field<Type> > Foam::tecplotWriter::getPatchField +( + const bool nearCellValue, + const GeometricField<Type, fvPatchField, volMesh>& vfld, + const label patchI +) const +{ + if (nearCellValue) + { + return vfld.boundaryField()[patchI].patchInternalField(); + } + else + { + return vfld.boundaryField()[patchI]; + } +} + + +template<class Type> +Foam::tmp<Field<Type> > Foam::tecplotWriter::getFaceField +( + const GeometricField<Type, fvsPatchField, surfaceMesh>& sfld, + const labelList& faceLabels +) const +{ + const polyBoundaryMesh& patches = sfld.mesh().boundaryMesh(); + + tmp<Field<Type> > tfld(new Field<Type>(faceLabels.size())); + Field<Type>& fld = tfld(); + + forAll(faceLabels, i) + { + label faceI = faceLabels[i]; + + label patchI = patches.whichPatch(faceI); + + if (patchI == -1) + { + fld[i] = sfld[faceI]; + } + else + { + label localFaceI = faceI - patches[patchI].start(); + fld[i] = sfld.boundaryField()[patchI][localFaceI]; + } + } + + return tfld; +} + + +template<class GeoField> +Foam::wordList Foam::tecplotWriter::getNames +( + const PtrList<GeoField>& flds +) +{ + wordList names(flds.size()); + forAll(flds, i) + { + names[i] = flds[i].name(); + } + return names; +} + + +template<class Type> +void Foam::tecplotWriter::getTecplotNames +( + const wordList& names, + const INTEGER4 loc, + string& varNames, + DynamicList<INTEGER4>& varLocation +) +{ + forAll(names, i) + { + if (!varNames.empty()) + { + varNames += " "; + } + + label nCmpts = pTraits<Type>::nComponents; + + if (nCmpts == 1) + { + varNames += names[i]; + varLocation.append(loc); + } + else + { + for + ( + direction cmpt = 0; + cmpt < nCmpts; + cmpt++ + ) + { + string fldName = + (cmpt != 0 ? " " : string::null) + + names[i] + + "_" + + pTraits<Type>::componentNames[cmpt]; + varNames += fldName; + varLocation.append(loc); + } + } + } +} + + +template<class GeoField> +void Foam::tecplotWriter::getTecplotNames +( + const PtrList<GeoField>& flds, + const INTEGER4 loc, + string& varNames, + DynamicList<INTEGER4>& varLocation +) +{ + getTecplotNames<typename GeoField::value_type> + ( + getNames(flds), + loc, + varNames, + varLocation + ); +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.C b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..06ff1aa0cc8db19beba59d2801d1f2b84e3d1190 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.C @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "vtkMesh.H" +#include "fvMeshSubset.H" +#include "Time.H" +#include "cellSet.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::vtkMesh::vtkMesh +( + fvMesh& baseMesh, + const word& setName +) +: + baseMesh_(baseMesh), + subsetter_(baseMesh), + setName_(setName) +{ + if (setName.size()) + { + // Read cellSet using whole mesh + cellSet currentSet(baseMesh_, setName_); + + // Set current subset + subsetter_.setLargeCellSubset(currentSet); + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::polyMesh::readUpdateState Foam::vtkMesh::readUpdate() +{ + polyMesh::readUpdateState meshState = baseMesh_.readUpdate(); + + if (meshState != polyMesh::UNCHANGED) + { + // Note: since fvMeshSubset has no movePoints() functionality reconstruct + // the subset even if only movement. + +// topoPtr_.clear(); + + if (setName_.size()) + { + Info<< "Subsetting mesh based on cellSet " << setName_ << endl; + + // Read cellSet using whole mesh + cellSet currentSet(baseMesh_, setName_); + + subsetter_.setLargeCellSubset(currentSet); + } + } + + return meshState; +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.H b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.H new file mode 100644 index 0000000000000000000000000000000000000000..4f8d5625832262449d59c1108f09778242d1a675 --- /dev/null +++ b/applications/utilities/postProcessing/dataConversion/foamToTecplot360/vtkMesh.H @@ -0,0 +1,179 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::vtkMesh + +Description + Encapsulation of VTK mesh data. Holds mesh or meshsubset and + polyhedral-cell decomposition on it. + +SourceFiles + vtkMesh.C + +\*---------------------------------------------------------------------------*/ + +#ifndef vtkMesh_H +#define vtkMesh_H + +#include "fvMeshSubset.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class Time; + +/*---------------------------------------------------------------------------*\ + Class vtkMesh Declaration +\*---------------------------------------------------------------------------*/ + +class vtkMesh +{ + // Private data + + //- Reference to mesh + fvMesh& baseMesh_; + + //- Subsetting engine + sub-fvMesh + fvMeshSubset subsetter_; + + //- Current cellSet (or empty) + const word setName_; + +// //- Current decomposition of topology +// mutable autoPtr<vtkTopo> topoPtr_; + + + + // Private Member Functions + + //- Disallow default bitwise copy construct + vtkMesh(const vtkMesh&); + + //- Disallow default bitwise assignment + void operator=(const vtkMesh&); + + +public: + + // Constructors + + //- Construct from components + vtkMesh(fvMesh& baseMesh, const word& setName = ""); + + + // Member Functions + + // Access + + //- whole mesh + const fvMesh& baseMesh() const + { + return baseMesh_; + } + + const fvMeshSubset& subsetter() const + { + return subsetter_; + } + + //- Check if running subMesh + bool useSubMesh() const + { + return setName_.size(); + } + +// //- topology +// const vtkTopo& topo() const +// { +// if (topoPtr_.empty()) +// { +// topoPtr_.reset(new vtkTopo(mesh())); +// } +// return topoPtr_(); +// } + + //- Access either mesh or submesh + const fvMesh& mesh() const + { + if (useSubMesh()) + { + return subsetter_.subMesh(); + } + else + { + return baseMesh_; + } + } + +// //- Number of field cells +// label nFieldCells() const +// { +// return topo().vertLabels().size(); +// } +// +// //- Number of field points +// label nFieldPoints() const +// { +// return mesh().nPoints() + topo().addPointCellLabels().size(); +// } + + + // Edit + + //- Read mesh + polyMesh::readUpdateState readUpdate(); + + + //- Map volume field (does in fact do very little interpolation; + // just copied from fvMeshSubset) + template<class GeoField> + tmp<GeoField> interpolate(const GeoField& fld) const + { + if (useSubMesh()) + { + tmp<GeoField> subFld = subsetter_.interpolate(fld); + subFld().rename(fld.name()); + return subFld; + } + else + { + return fld; + } + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C index 0a854af9d07a97ec279d560a3ff4a5f573b67816..fee07515ee5f3fe5a42485abda83b3b639270237 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamToVTK.C @@ -83,12 +83,13 @@ Usage Combine all patches into a single file @param -excludePatches \<patchNames\>\n - Specify patches to exclude. For example, + Specify patches (wildcards) to exclude. For example, @verbatim - -excludePatches "( inlet_1 inlet_2 )" + -excludePatches '( inlet_1 inlet_2 "proc.*")' @endverbatim The quoting is required to avoid shell expansions and to pass the - information as a single argument. + information as a single argument. The double quotes denote a regular + expression. @param -useTimeName \n use the time index in the VTK file name instead of the time index @@ -140,6 +141,7 @@ Note #include "faceZoneMesh.H" #include "Cloud.H" #include "passiveParticle.H" +#include "stringListOps.H" #include "vtkMesh.H" #include "readFields.H" @@ -192,7 +194,7 @@ void print(Ostream& os, const wordList& flds) labelList getSelectedPatches ( const polyBoundaryMesh& patches, - const HashSet<word>& excludePatches + const List<wordRe>& excludePatches //HashSet<word>& excludePatches ) { DynamicList<label> patchIDs(patches.size()); @@ -205,14 +207,19 @@ labelList getSelectedPatches if ( - isA<emptyPolyPatch>(pp) - || (Pstream::parRun() && isA<processorPolyPatch>(pp)) + isType<emptyPolyPatch>(pp) + || (Pstream::parRun() && isType<processorPolyPatch>(pp)) ) { Info<< " discarding empty/processor patch " << patchI << " " << pp.name() << endl; } - else if (!excludePatches.found(pp.name())) + else if (findStrings(excludePatches, pp.name())) + { + Info<< " excluding patch " << patchI + << " " << pp.name() << endl; + } + else { patchIDs.append(patchI); Info<< " patch " << patchI << " " << pp.name() << endl; @@ -224,6 +231,8 @@ labelList getSelectedPatches + + // Main program: int main(int argc, char *argv[]) @@ -283,7 +292,7 @@ int main(int argc, char *argv[]) bool allPatches = args.optionFound("allPatches"); - HashSet<word> excludePatches; + List<wordRe> excludePatches; if (args.optionFound("excludePatches")) { args.optionLookup("excludePatches")() >> excludePatches; @@ -771,7 +780,7 @@ int main(int argc, char *argv[]) { const polyPatch& pp = patches[patchI]; - if (!excludePatches.found(pp.name())) + if (!findStrings(excludePatches, pp.name())) { mkDir(fvPath/pp.name()); diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C index f699e1758885154c2300776b304b1823e9530470..82a8df0ccacf826ebfc4c4eb3761306d586dc33a 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.C @@ -220,7 +220,7 @@ void Foam::writeFuns::writePointDataHeader } -void Foam::writeFuns::insert(const scalar& pt, DynamicList<floatScalar>& dest) +void Foam::writeFuns::insert(const scalar pt, DynamicList<floatScalar>& dest) { dest.append(float(pt)); } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H index cf7a4e992cdc3561f0446b4ea1026720567c9f93..c38bbda6693d6aef25157d49df1487823db7c7a0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/writeFuns.H @@ -86,7 +86,7 @@ public: // Convert to VTK and store - static void insert(const scalar&, DynamicList<floatScalar>&); + static void insert(const scalar, DynamicList<floatScalar>&); static void insert(const point&, DynamicList<floatScalar>&); static void insert(const sphericalTensor&, DynamicList<floatScalar>&); static void insert(const symmTensor&, DynamicList<floatScalar>&); diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/Allwmake similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/Allwmake rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/Allwmake diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/CMakeLists.txt similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/CMakeLists.txt rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/CMakeLists.txt diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.pvsm diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/Make/PVFoamReader.xml diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.pvsm.in diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.xml.in b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.xml.in similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReader.xml.in rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReader.xml.in diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/PVFoamReaderConfigure.h.in diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.cxx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.cxx similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.cxx rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.cxx diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.h b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.h similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamData.h rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamData.h diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.cxx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.cxx similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.cxx rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.cxx diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.h b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.h similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkFoamReader.h rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkFoamReader.h diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.cxx diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamSelectTimeSet.h diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.cxx diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/PVFoamReader/vtkPVFoamServerSelectTimeSet.h diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/files b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/files similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/files rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/files diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/options b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/options similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/Make/options rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/Make/options diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkDataArrayTemplateImplicit.txx b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkDataArrayTemplateImplicit.txx rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.C rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.C diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoam.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoam.H diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamAddFields.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddFields.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamAddFields.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddFields.H diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamAddInternalMesh.C b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddInternalMesh.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamAddInternalMesh.C rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddInternalMesh.C diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamAddPatch.C b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddPatch.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamAddPatch.C rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamAddPatch.C diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertFields.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertFields.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertFields.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertFields.H diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertPatchFaceField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchFaceField.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertPatchFaceField.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchFaceField.H diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertPatchPointField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchPointField.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertPatchPointField.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPatchPointField.H diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertPointField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPointField.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertPointField.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertPointField.H diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertVolField.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertVolField.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamConvertVolField.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamConvertVolField.H diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamInsertNextPoint.H b/applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamInsertNextPoint.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkFoamInsertNextPoint.H rename to applications/utilities/postProcessing/graphics/PV2Readers/PVFoamReader/vtkFoam/vtkFoamInsertNextPoint.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake deleted file mode 100755 index c7a80fc7fbb2bc05d26200f074d4cfaaaec60b51..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwmake +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # run from this directory -set -x - -if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] -then - case "$ParaView_VERSION" in - 3*) - wmake libso vtkPV3Foam - ( - cd PV3FoamReader - mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1 - cd Make/$WM_OPTIONS - cmake ../.. - make - ) - ;; - esac -fi - -# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/Allwmake b/applications/utilities/postProcessing/graphics/PV3Readers/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..94a47b132b18c99d59ad01214cf0ee5b0726c561 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/Allwmake @@ -0,0 +1,16 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] +then + case "$ParaView_VERSION" in + 3*) + wmake libso vtkPV3Readers + PV3blockMeshReader/Allwmake + PV3FoamReader/Allwmake + ;; + esac +fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwclean b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/Allwclean similarity index 67% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/Allwclean rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/Allwclean index 3fdbeae44cdc62199bcc1969d41b60a99574fac4..c5f41ab9da11f3dc5f09f81ef6cf6d58a5e67d09 100755 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/Allwclean +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/Allwclean @@ -2,6 +2,9 @@ cd ${0%/*} || exit 1 # run from this directory set -x +# deal with client/server vs combined plugins +rm -f $FOAM_LIBBIN/libPV3FoamReader* 2>/dev/null + rm -rf PV3FoamReader/Make wclean libso vtkPV3Foam diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/Allwmake b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..ef7b571102c42fdebede2a1262d7a693d9536638 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/Allwmake @@ -0,0 +1,21 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] +then + case "$ParaView_VERSION" in + 3*) + wmake libso vtkPV3Foam + ( + cd PV3FoamReader + mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1 + cd Make/$WM_OPTIONS + cmake ../.. + make + ) + ;; + esac +fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/CMakeLists.txt similarity index 59% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/CMakeLists.txt index 670b78c33d80f3f2e1db2e6f4ce3ac7e0f0551cf..ea50923e6a7528e5f987f7e5896211c864af6f2b 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/CMakeLists.txt +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/CMakeLists.txt @@ -7,7 +7,7 @@ # the pqReader.xml file contains xml defining readers with their # file extensions and descriptions. -cmake_minimum_required(VERSION 2.4) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) FIND_PACKAGE(ParaView REQUIRED) INCLUDE(${PARAVIEW_USE_FILE}) @@ -33,19 +33,46 @@ SET( "Single output directory for building all libraries." ) -# Build the server-side plugin + +# +# Defined combined plugin +# + +# Extend the auto-generated panel +QT4_WRAP_CPP(MOC_SRCS pqPV3FoamReaderPanel.h) + +ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS + CLASS_NAME pqPV3FoamReaderPanel + XML_NAME PV3FoamReader # name of SourceProxy in *SM.xml + XML_GROUP sources +) + ADD_PARAVIEW_PLUGIN( PV3FoamReader_SM "1.0" SERVER_MANAGER_XML PV3FoamReader_SM.xml SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx + GUI_INTERFACES ${IFACES} + GUI_SOURCES pqPV3FoamReaderPanel.cxx + ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} + GUI_RESOURCE_FILES PV3FoamReader.xml ) -# Build the client-side plugin -ADD_PARAVIEW_PLUGIN( - PV3FoamReader - "1.0" - GUI_RESOURCES PV3FoamReader.qrc -) +# # +# # Define the server-side portion of the reader plugin +# # +# ADD_PARAVIEW_PLUGIN( +# PV3FoamReader_SM "1.0" +# SERVER_MANAGER_XML PV3FoamReader_SM.xml +# SERVER_MANAGER_SOURCES vtkPV3FoamReader.cxx +# ) +# # +# # Define the client-side portion of the reader plugin +# # +# ADD_PARAVIEW_PLUGIN( +# PV3FoamReader "1.0" +# GUI_RESOURCES PV3FoamReader.qrc +# ) +# TARGET_LINK_LIBRARIES( PV3FoamReader_SM diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.qrc b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader.qrc similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.qrc rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader.qrc diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader.xml diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml similarity index 95% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml index a78bceb7d5495847af7734fe3e896d589fc639d5..8506772e5ce9b6a98c63fab60ebec6f40d74e9ef 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/PV3FoamReader_SM.xml @@ -16,6 +16,21 @@ </Documentation> </StringVectorProperty> + <!-- Cache Mesh check-box --> + <IntVectorProperty + name="UiCacheMesh" + command="SetCacheMesh" + number_of_elements="1" + is_internal="1" + default_values="1" + animateable="0"> + <BooleanDomain name="bool"/> + <Documentation> + Cache the fvMesh in memory. + </Documentation> + </IntVectorProperty> + + <!-- Send discrete time info to the animation panel --> <DoubleVectorProperty name="TimestepValues" @@ -72,10 +87,11 @@ <!-- Show Patch Names check-box --> <IntVectorProperty - name="ShowPatchNames" + name="UiShowPatchNames" command="SetShowPatchNames" number_of_elements="1" default_values="0" + is_internal="1" animateable="0"> <BooleanDomain name="bool"/> <Documentation> @@ -83,21 +99,7 @@ </Documentation> </IntVectorProperty> - <!-- Cache Mesh check-box --> - <IntVectorProperty - name="CacheMesh" - command="SetCacheMesh" - number_of_elements="1" - default_values="1" - animateable="0"> - <BooleanDomain name="bool"/> - <Documentation> - Cache the fvMesh in memory. - </Documentation> - </IntVectorProperty> - - - <!-- Update GUI check box --> + <!-- Force GUI update check box --> <IntVectorProperty name="UpdateGUI" command="SetUpdateGUI" @@ -204,6 +206,14 @@ </RequiredProperties> </ArraySelectionDomain> </StringVectorProperty> + + <Hints> + <Property name="FileName" show="0"/> + <Property name="UiCacheMesh" show="0"/> + <Property name="UiShowPatchNames" show="0"/> + </Hints> + + </SourceProxy> </ProxyGroup> </ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx new file mode 100644 index 0000000000000000000000000000000000000000..4f12089f45d71be3aa020764467268814bac681d --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.cxx @@ -0,0 +1,135 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "pqPV3FoamReaderPanel.h" + +// QT +#include <QGridLayout> +#include <QCheckBox> +#include <QLabel> +#include <QLayout> +#include <QString> +#include <QtDebug> + +// Paraview<->QT UI +#include "pqAnimationScene.h" +#include "pqApplicationCore.h" +#include "pqPipelineRepresentation.h" +#include "pqServerManagerModel.h" +#include "pqView.h" + +// Paraview Server Manager +#include "vtkSMDoubleVectorProperty.h" +#include "vtkSMIntVectorProperty.h" +#include "vtkSMProperty.h" +#include "vtkSMSourceProxy.h" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +pqPV3FoamReaderPanel::pqPV3FoamReaderPanel +( + pqProxy *proxy, + QWidget *p +) +: + pqAutoGeneratedObjectPanel(proxy, p), + sourceProxy_(vtkSMSourceProxy::SafeDownCast(this->proxy())) +{ + // create first sublayout (at top of the panel) + QGridLayout *sect1 = new QGridLayout(); + this->PanelLayout->addLayout(sect1, 0, 0, 1, -1); + + + // checkbox for caching mesh + CacheMesh_ = new QCheckBox("Cache Mesh"); + CacheMesh_->setChecked(true); + + // checkbox for caching mesh + ShowPatchNames_ = new QCheckBox("Show Patch Names"); + ShowPatchNames_->setChecked(false); + + connect + ( + CacheMesh_, + SIGNAL(stateChanged(int)), + this, + SLOT(CacheMeshToggled()) + ); + + connect + ( + ShowPatchNames_, + SIGNAL(stateChanged(int)), + this, + SLOT(ShowPatchNamesToggled()) + ); + + sect1->addWidget(CacheMesh_); + sect1->addWidget(ShowPatchNames_); + + + // immediate update on the Server Manager side + vtkSMIntVectorProperty::SafeDownCast + ( + sourceProxy_->GetProperty("UiCacheMesh") + )->SetImmediateUpdate(true); + vtkSMIntVectorProperty::SafeDownCast + ( + sourceProxy_->GetProperty("UiShowPatchNames") + )->SetImmediateUpdate(true); +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void pqPV3FoamReaderPanel::CacheMeshToggled() +{ + vtkSMIntVectorProperty::SafeDownCast + ( + sourceProxy_->GetProperty("UiCacheMesh") + )->SetElement(0, CacheMesh_->isChecked()); +} + + +void pqPV3FoamReaderPanel::ShowPatchNamesToggled() +{ + vtkSMIntVectorProperty::SafeDownCast + ( + sourceProxy_->GetProperty("UiShowPatchNames") + )->SetElement(0, ShowPatchNames_->isChecked()); + + // update the active view + if (this->view()) + { + this->view()->render(); + } + // OR: update all views + // pqApplicationCore::instance()->render(); +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h new file mode 100644 index 0000000000000000000000000000000000000000..fc4f5f9adad0b89b6f395a492632d1f24de18075 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/pqPV3FoamReaderPanel.h @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + pqPV3FoamReaderPanel + +Description + GUI modifications for the ParaView reader panel + + A custom panel for the PV3FoamReader. + +SourceFiles + pqPV3FoamReaderPanel.cxx + +\*---------------------------------------------------------------------------*/ +#ifndef pqPV3FoamReaderPanel_h +#define pqPV3FoamReaderPanel_h + +#include "pqAutoGeneratedObjectPanel.h" + +// Forward declaration of QT classes + +class QCheckBox; +class QLineEdit; +class QTimer; +class QToolButton; + +// Forward declaration of ParaView classes +class vtkSMSourceProxy; + + +/*---------------------------------------------------------------------------*\ + Class pqPV3FoamReaderPanel Declaration +\*---------------------------------------------------------------------------*/ + +class pqPV3FoamReaderPanel +: + public pqAutoGeneratedObjectPanel +{ + // Private data + Q_OBJECT; + typedef pqAutoGeneratedObjectPanel Superclass; + + //- Server Manager Source Proxy + vtkSMSourceProxy* sourceProxy_; + + //- CacheMesh checkbox + QCheckBox* CacheMesh_; + + //- Show Patch Names checkbox + QCheckBox* ShowPatchNames_; + +protected slots: + + void CacheMeshToggled(); + void ShowPatchNamesToggled(); + + +public: + + // Constructors + + //- Construct from components + pqPV3FoamReaderPanel(pqProxy*, QWidget*); + + + //- Destructor + // virtual ~pqPV3FoamReaderPanel(); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx similarity index 88% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx index 55964e95407a3d4bdf6ab2a03075efce68009515..32b01eb7958d8ff805c8fdeeea779d1a34b32cf1 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.cxx @@ -1,18 +1,28 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: $RCSfile: vtkPV3FoamReader.cxx,v $ - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ #include "vtkPV3FoamReader.h" #include "pqApplicationCore.h" @@ -33,10 +43,15 @@ // Foam includes #include "vtkPV3Foam.H" +#undef EXPERIMENTAL_TIME_CACHING + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + vtkCxxRevisionMacro(vtkPV3FoamReader, "$Revision: 1.5$"); vtkStandardNewMacro(vtkPV3FoamReader); -#undef EXPERIMENTAL_TIME_CACHING + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // vtkPV3FoamReader::vtkPV3FoamReader() { @@ -109,11 +124,18 @@ vtkPV3FoamReader::vtkPV3FoamReader() } +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + vtkPV3FoamReader::~vtkPV3FoamReader() { vtkDebugMacro(<<"Deconstructor"); - delete foamData_; + if (foamData_) + { + // remove patch names + updatePatchNamesView(false); + delete foamData_; + } if (FileName) { @@ -140,6 +162,8 @@ vtkPV3FoamReader::~vtkPV3FoamReader() } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + // Do everything except set the output info int vtkPV3FoamReader::RequestInformation ( @@ -396,13 +420,35 @@ int vtkPV3FoamReader::RequestData } +void vtkPV3FoamReader::SetShowPatchNames(const int val) +{ + if (ShowPatchNames != val) + { + ShowPatchNames = val; + updatePatchNamesView(ShowPatchNames); + } +} + + + void vtkPV3FoamReader::updatePatchNamesView(const bool show) { pqApplicationCore* appCore = pqApplicationCore::instance(); + // need to check this, since our destructor calls this + if (!appCore) + { + return; + } + // Server manager model for querying items in the server manager pqServerManagerModel* smModel = appCore->getServerManagerModel(); + if (!smModel || !foamData_) + { + return; + } + // Get all the pqRenderView instances QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>(); @@ -414,6 +460,8 @@ void vtkPV3FoamReader::updatePatchNamesView(const bool show) show ); } + + // use refresh here? } diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h similarity index 73% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h index 4a6eb3723edb3d67fc27a876c5cd32613ef72b01..df73979205ef11886c27c7d0ced23907d9edfb9f 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/PV3FoamReader/vtkPV3FoamReader.h @@ -1,25 +1,52 @@ -/*========================================================================= +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + vtkPV3FoamReader + +Description + reads a dataset in OpenFOAM format + + vtkPV3blockMeshReader creates an multiblock dataset. + It uses the OpenFOAM infrastructure (fvMesh, etc) to handle mesh and + field data. + +SourceFiles + vtkPV3blockMeshReader.cxx + +\*---------------------------------------------------------------------------*/ +#ifndef vtkPV3FoamReader_h +#define vtkPV3FoamReader_h - Program: Visualization Toolkit - Module: $RCSfile: vtkPV3FoamReader.h,v $ - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. +// VTK includes +#include "vtkMultiBlockDataSetAlgorithm.h" -=========================================================================*/ -// .NAME vtkPV3FoamReader - reads a dataset in OpenFOAM format -// .SECTION Description -// vtkPV3FoamReader creates an multiblock dataset. -// It uses the OpenFOAM infrastructure (fvMesh, etc) to -// handle mesh and field data. +// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // -#ifndef __vtkPV3FoamReader_h -#define __vtkPV3FoamReader_h +// VTK forward declarations +class vtkDataArraySelection; +class vtkCallbackCommand; // Foam forward declarations namespace Foam @@ -27,13 +54,10 @@ namespace Foam class vtkPV3Foam; } -// VTK includes -#include "vtkMultiBlockDataSetAlgorithm.h" - -// VTK forward declarations -class vtkDataArraySelection; -class vtkCallbackCommand; +/*---------------------------------------------------------------------------*\ + Class vtkPV3FoamReader Declaration +\*---------------------------------------------------------------------------*/ class VTK_IO_EXPORT vtkPV3FoamReader : @@ -54,16 +78,16 @@ public: vtkSetStringMacro(FileName); vtkGetStringMacro(FileName); - // Description: - // GUI update control - vtkSetMacro(UpdateGUI, int); - vtkGetMacro(UpdateGUI, int); - // Description: // FOAM mesh caching control vtkSetMacro(CacheMesh, int); vtkGetMacro(CacheMesh, int); + // Description: + // GUI update control + vtkSetMacro(UpdateGUI, int); + vtkGetMacro(UpdateGUI, int); + // Description: // FOAM extrapolate internal values onto the patches vtkSetMacro(ExtrapolatePatches, int); @@ -80,7 +104,7 @@ public: // Description: // FOAM display patch names control - vtkSetMacro(ShowPatchNames, int); + virtual void SetShowPatchNames(int); vtkGetMacro(ShowPatchNames, int); // Description: diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/files similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/files rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/files diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/options b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/options similarity index 89% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/options rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/options index 1e936c1d5de89d2884fdd81bf1d77a059a38ce4a..d58afde30bdee58d22bb21af13ca19796ab476d5 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/Make/options +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/Make/options @@ -1,18 +1,20 @@ EXE_INC = \ + -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude \ -I$(ParaView_DIR)/VTK \ -I$(ParaView_INST_DIR) \ -I$(ParaView_INST_DIR)/VTK \ -I$(ParaView_INST_DIR)/VTK/Common \ -I$(ParaView_INST_DIR)/VTK/Filtering \ -I$(ParaView_INST_DIR)/VTK/Rendering \ + -I../../vtkPV3Readers/lnInclude \ -I../PV3FoamReader LIB_LIBS = \ + -lvtkPV3Readers \ + -lmeshTools \ -lfiniteVolume \ -lgenericPatchFields \ -llagrangian \ - -lmeshTools \ $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkDataArrayTemplateImplicit.txx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkDataArrayTemplateImplicit.txx similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkDataArrayTemplateImplicit.txx rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkDataArrayTemplateImplicit.txx diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkOpenFOAMPoints.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkOpenFOAMPoints.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkOpenFOAMPoints.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkOpenFOAMPoints.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3Foam.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamAddToSelection.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFaceField.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamFields.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamLagrangianFields.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMesh.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshLagrangian.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshPatch.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshSet.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshSet.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshSet.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshSet.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshVolume.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshZone.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshZone.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshZone.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamMeshZone.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPatchField.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamPointFields.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfoFields.H diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUtils.C diff --git a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H similarity index 96% rename from applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H index 4925a31284242e6f792bc949943cb5189f2d0e03..d5387be61f3e703d191d96c8640deccb7a4131b9 100644 --- a/applications/utilities/postProcessing/graphics/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamVolFields.H @@ -109,6 +109,12 @@ void Foam::vtkPV3Foam::convertVolFields // // Convert patches - if activated // + + // The name for the interpolated patch point field must be consistent + // with the interpolated volume point field. + // This could be done better. + const word pointFldName = "volPointInterpolate(" + tf.name() + ')'; + for ( int partId = partInfoPatches_.start(); @@ -155,7 +161,7 @@ void Foam::vtkPV3Foam::convertVolFields convertPatchPointField ( - tf.name(), + pointFldName, ppInterpList[patchId].faceToPointInterpolate(tpptf)(), output, partInfoPatches_, @@ -175,7 +181,7 @@ void Foam::vtkPV3Foam::convertVolFields convertPatchPointField ( - tf.name(), + pointFldName, ppInterpList[patchId].faceToPointInterpolate(ptf)(), output, partInfoPatches_, diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/Allwclean b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/Allwclean similarity index 67% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/Allwclean rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/Allwclean index 30ee40ddae59aebfc80c648baa6d40ce74204f43..d2c85df001142d7a9c09d855fc3df2acea6dcaba 100755 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/Allwclean +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/Allwclean @@ -2,6 +2,9 @@ cd ${0%/*} || exit 1 # run from this directory set -x +# deal with client/server vs combined plugins +rm -f $FOAM_LIBBIN/libPV3blockMeshReader* 2>/dev/null + rm -rf PV3blockMeshReader/Make wclean libso vtkPV3blockMesh diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/Allwmake b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..443100d3810e4046a68d4783c481809830b617da --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/Allwmake @@ -0,0 +1,21 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory +set -x + +if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] +then + case "$ParaView_VERSION" in + 3*) + wmake libso vtkPV3blockMesh + ( + cd PV3blockMeshReader + mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1 + cd Make/$WM_OPTIONS + cmake ../.. + make + ) + ;; + esac +fi + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/CMakeLists.txt b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/CMakeLists.txt similarity index 56% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/CMakeLists.txt rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/CMakeLists.txt index fc645367f49e1f026c64d4a4a140c486c7d48d7e..3376fa0d91caec4c8734f5d24626759caf8a64c5 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/CMakeLists.txt +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/CMakeLists.txt @@ -7,7 +7,7 @@ # the pqReader.xml file contains xml defining readers with their # file extensions and descriptions. -cmake_minimum_required(VERSION 2.4) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) FIND_PACKAGE(ParaView REQUIRED) INCLUDE(${PARAVIEW_USE_FILE}) @@ -33,19 +33,46 @@ SET( "Single output directory for building all libraries." ) -# Build the server-side plugin +# +# Define combined plugin +# +# Try to extend the auto-generated panel +QT4_WRAP_CPP(MOC_SRCS pqPV3blockMeshReaderPanel.h) + +ADD_PARAVIEW_OBJECT_PANEL(IFACES IFACE_SRCS + CLASS_NAME pqPV3blockMeshReaderPanel + XML_NAME PV3blockMeshReader # name of SourceProxy in *SM.xml + XML_GROUP sources +) + ADD_PARAVIEW_PLUGIN( PV3blockMeshReader_SM "1.0" SERVER_MANAGER_XML PV3blockMeshReader_SM.xml - SERVER_MANAGER_SOURCES vtkPV3blockMeshReader.cxx + SERVER_MANAGER_SOURCES vtkPV3blockMeshReader.cxx + GUI_INTERFACES ${IFACES} + GUI_SOURCES pqPV3blockMeshReaderPanel.cxx + ${MOC_SRCS} ${UI_SRCS} ${IFACE_SRCS} + GUI_RESOURCE_FILES PV3blockMeshReader.xml ) + +# # +# # Define the server-side portion of the reader plugin +# # +# ADD_PARAVIEW_PLUGIN(PV3blockMeshReader_SM "1.0" +# SERVER_MANAGER_XML PV3blockMeshReader_SM.xml +# SERVER_MANAGER_SOURCES vtkPV3blockMeshReader.cxx +# ) +# # +# # Define the client-side portion of the reader plugin +# # +# ADD_PARAVIEW_PLUGIN( +# PV3blockMeshReader "1.0" +# GUI_RESOURCES PV3blockMeshReader.qrc +# ) + + # Build the client-side plugin -ADD_PARAVIEW_PLUGIN( - PV3blockMeshReader - "1.0" - GUI_RESOURCES PV3blockMeshReader.qrc -) TARGET_LINK_LIBRARIES( PV3blockMeshReader_SM diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.qrc b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.qrc similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.qrc rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.qrc diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.xml similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.xml rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader.xml diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml similarity index 94% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml index 5eea03fe2bc4515f73cbf713ce20b075c617bc4f..2ac4774ff0de47f3e5dff9ec5a4cb01c8fb14434 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/PV3blockMeshReader_SM.xml @@ -16,14 +16,13 @@ </Documentation> </StringVectorProperty> - <!-- Global settings --> - <!-- Show Point Numbers check-box --> <IntVectorProperty - name="ShowPointNumbers" + name="UiShowPointNumbers" command="SetShowPointNumbers" number_of_elements="1" default_values="1" + is_internal="1" animateable="0"> <BooleanDomain name="bool"/> <Documentation> @@ -44,7 +43,6 @@ </Documentation> </IntVectorProperty> - <!-- Selections --> <!-- Available Parts (blocks) array --> @@ -93,6 +91,11 @@ </ArraySelectionDomain> </StringVectorProperty> + <Hints> + <Property name="FileName" show="0"/> + <Property name="UiShowPointNumbers" show="0"/> + </Hints> + </SourceProxy> </ProxyGroup> </ServerManagerConfiguration> diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.cxx new file mode 100644 index 0000000000000000000000000000000000000000..8114a1470907a46c4976aad1812e7ccc997a4613 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.cxx @@ -0,0 +1,109 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "pqPV3blockMeshReaderPanel.h" + +// QT +#include <QGridLayout> +#include <QCheckBox> +#include <QLabel> +#include <QLayout> +#include <QString> +#include <QtDebug> + +// Paraview<->QT UI +#include "pqAnimationScene.h" +#include "pqApplicationCore.h" +#include "pqPipelineRepresentation.h" +#include "pqServerManagerModel.h" +#include "pqView.h" + +// Paraview Server Manager +#include "vtkSMDoubleVectorProperty.h" +#include "vtkSMIntVectorProperty.h" +#include "vtkSMProperty.h" +#include "vtkSMSourceProxy.h" + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +pqPV3blockMeshReaderPanel::pqPV3blockMeshReaderPanel +( + pqProxy *proxy, + QWidget *p +) +: + pqAutoGeneratedObjectPanel(proxy, p), + sourceProxy_(vtkSMSourceProxy::SafeDownCast(this->proxy())) +{ + // create first sublayout (at top of the panel) + QGridLayout *sect1 = new QGridLayout(); + this->PanelLayout->addLayout(sect1, 0, 0, 1, -1); + + + // checkbox for showing point numbers + ShowPointNumbers_ = new QCheckBox("Show Point Numbers"); + ShowPointNumbers_->setChecked(true); + + connect + ( + ShowPointNumbers_, + SIGNAL(stateChanged(int)), + this, + SLOT(ShowPointNumbersToggled()) + ); + + sect1->addWidget(ShowPointNumbers_); + + + // immediate update on the Server Manager side + vtkSMIntVectorProperty::SafeDownCast + ( + sourceProxy_->GetProperty("UiShowPointNumbers") + )->SetImmediateUpdate(true); + +} + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void pqPV3blockMeshReaderPanel::ShowPointNumbersToggled() +{ + vtkSMIntVectorProperty::SafeDownCast + ( + sourceProxy_->GetProperty("UiShowPointNumbers") + )->SetElement(0, ShowPointNumbers_->isChecked()); + + // update the active view + if (this->view()) + { + this->view()->render(); + } + // OR: update all views + // pqApplicationCore::instance()->render(); +} + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.h new file mode 100644 index 0000000000000000000000000000000000000000..8096338315ec3532e5abc15c9b44916ae53c8998 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/pqPV3blockMeshReaderPanel.h @@ -0,0 +1,94 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + pqPV3blockMeshReaderPanel + +Description + GUI modifications for the ParaView reader panel + + A custom panel for the PV3blockMeshReader. + +SourceFiles + pqPV3blockMeshReaderPanel.cxx + +\*---------------------------------------------------------------------------*/ +#ifndef pqPV3blockMeshReaderPanel_h +#define pqPV3blockMeshReaderPanel_h + +#include "pqAutoGeneratedObjectPanel.h" + +// Forward declaration of QT classes + +class QCheckBox; +class QLineEdit; +class QTimer; +class QToolButton; + +// Forward declaration of ParaView classes +class vtkSMSourceProxy; + + +/*---------------------------------------------------------------------------*\ + Class pqPV3blockMeshReaderPanel Declaration +\*---------------------------------------------------------------------------*/ + +class pqPV3blockMeshReaderPanel +: + public pqAutoGeneratedObjectPanel +{ + // Private data + Q_OBJECT; + typedef pqAutoGeneratedObjectPanel Superclass; + + //- Server Manager Source Proxy + vtkSMSourceProxy* sourceProxy_; + + //- Show Point Numbers checkbox + QCheckBox* ShowPointNumbers_; + +protected slots: + + void ShowPointNumbersToggled(); + + +public: + + // Constructors + + //- Construct from components + pqPV3blockMeshReaderPanel(pqProxy*, QWidget*); + + + //- Destructor + // virtual ~pqPV3blockMeshReaderPanel(); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx similarity index 79% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx index 451c8b5855abc0992d6f501c2c16471a2f8bb705..bf17a60ca314c90c312c14cd57de55ba5ff261e9 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.cxx @@ -1,18 +1,28 @@ -/*========================================================================= - - Program: Visualization Toolkit - Module: $RCSfile: vtkPV3blockMeshReader.cxx,v $ - - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. - - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. - -=========================================================================*/ - +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ #include "vtkPV3blockMeshReader.h" #include "pqApplicationCore.h" @@ -33,9 +43,14 @@ // Foam includes #include "vtkPV3blockMesh.H" -vtkCxxRevisionMacro(vtkPV3blockMeshReader, "$Revision: 1.5$"); +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +vtkCxxRevisionMacro(vtkPV3blockMeshReader, "$Revision:$"); vtkStandardNewMacro(vtkPV3blockMeshReader); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + vtkPV3blockMeshReader::vtkPV3blockMeshReader() { Debug = 0; @@ -76,11 +91,18 @@ vtkPV3blockMeshReader::vtkPV3blockMeshReader() } +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + vtkPV3blockMeshReader::~vtkPV3blockMeshReader() { vtkDebugMacro(<<"Deconstructor"); - delete foamData_; + if (foamData_) + { + // remove point numbers + updatePointNumbersView(false); + delete foamData_; + } if (FileName) { @@ -95,6 +117,8 @@ vtkPV3blockMeshReader::~vtkPV3blockMeshReader() } +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + // Do everything except set the output info int vtkPV3blockMeshReader::RequestInformation ( @@ -211,16 +235,37 @@ int vtkPV3blockMeshReader::RequestData } + +void vtkPV3blockMeshReader::SetShowPointNumbers(const int val) +{ + if (ShowPointNumbers != val) + { + ShowPointNumbers = val; + updatePointNumbersView(ShowPointNumbers); + } +} + + void vtkPV3blockMeshReader::updatePointNumbersView(const bool show) { pqApplicationCore* appCore = pqApplicationCore::instance(); + // need to check this, since our destructor calls this + if (!appCore) + { + return; + } + // Server manager model for querying items in the server manager pqServerManagerModel* smModel = appCore->getServerManagerModel(); + if (!smModel || !foamData_) + { + return; + } + // Get all the pqRenderView instances QList<pqRenderView*> renderViews = smModel->findItems<pqRenderView*>(); - for (int viewI=0; viewI<renderViews.size(); ++viewI) { foamData_->renderPointNumbers @@ -229,6 +274,8 @@ void vtkPV3blockMeshReader::updatePointNumbersView(const bool show) show ); } + + // use refresh here? } diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h similarity index 63% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h index b26cde357dd481b37d2b07edbf2a458bfb5a0578..ae704d4a3be6f9a011b796c032a88837ab8295a1 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/PV3blockMeshReader/vtkPV3blockMeshReader.h @@ -1,38 +1,61 @@ -/*========================================================================= +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. - Program: Visualization Toolkit - Module: $RCSfile: vtkPV3blockMeshReader.h,v $ + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. - Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen - All rights reserved. - See Copyright.txt or http://www.kitware.com/Copyright.htm for details. + 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. - This software is distributed WITHOUT ANY WARRANTY; without even - the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - PURPOSE. See the above copyright notice for more information. + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -=========================================================================*/ -// .NAME vtkPV3blockMeshReader - reads a dataset in OpenFOAM bockMesh format -// .SECTION Description -// vtkPV3blockMeshReader creates an multiblock dataset. -// It uses the OpenFOAM infrastructure (blockMesh). +Class + vtkPV3blockMeshReader -#ifndef __vtkPV3blockMeshReader_h -#define __vtkPV3blockMeshReader_h +Description + reads a dataset in OpenFOAM bockMesh format -// Foam forward declarations -namespace Foam -{ - class vtkPV3blockMesh; -} + vtkPV3blockMeshReader creates an multiblock dataset. + It uses the OpenFOAM infrastructure (blockMesh). + +SourceFiles + vtkPV3blockMeshReader.cxx + +\*---------------------------------------------------------------------------*/ + +#ifndef vtkPV3blockMeshReader_h +#define vtkPV3blockMeshReader_h // VTK includes #include "vtkMultiBlockDataSetAlgorithm.h" +// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // + // VTK forward declarations class vtkDataArraySelection; class vtkCallbackCommand; +namespace Foam +{ + class vtkPV3blockMesh; +} + +/*---------------------------------------------------------------------------*\ + Class vtkPV3blockMeshReader Declaration +\*---------------------------------------------------------------------------*/ class VTK_IO_EXPORT vtkPV3blockMeshReader : @@ -49,15 +72,16 @@ public: vtkSetStringMacro(FileName); vtkGetStringMacro(FileName); + // Description: + // Display corner point labels + virtual void SetShowPointNumbers(int); + vtkGetMacro(ShowPointNumbers, int); + // Description: // GUI update control vtkSetMacro(UpdateGUI, int); vtkGetMacro(UpdateGUI, int); - // Description: - // FOAM display patch names control - vtkSetMacro(ShowPointNumbers, int); - vtkGetMacro(ShowPointNumbers, int); // Description: // Parts (blocks) selection list control @@ -121,6 +145,7 @@ protected: char* FileName; + private: //- Disallow default bitwise copy construct @@ -132,6 +157,8 @@ private: //- Add/remove point numbers to/from the view void updatePointNumbersView(const bool show); + + //- Show Point Numbers int ShowPointNumbers; //- Dummy variable/switch to invoke a reader update diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/Make/files b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/Make/files similarity index 100% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/Make/files rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/Make/files diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/Make/options b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/Make/options similarity index 87% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/Make/options rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/Make/options index 2e5727ba771c060bb4855afee63eeedc3184a12d..5d19916934a3411cbab36efe317af52c16fd16fd 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/Make/options +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/Make/options @@ -7,9 +7,11 @@ EXE_INC = \ -I$(ParaView_INST_DIR)/VTK/Common \ -I$(ParaView_INST_DIR)/VTK/Filtering \ -I$(ParaView_INST_DIR)/VTK/Rendering \ + -I../../vtkPV3Readers/lnInclude \ -I../PV3blockMeshReader LIB_LIBS = \ + -lvtkPV3Readers \ -lmeshTools \ -lblockMesh \ $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkDataArrayTemplateImplicit.txx similarity index 100% rename from applications/utilities/postProcessing/graphics/PVFoamReader/vtkFoam/vtkDataArrayTemplateImplicit.txx rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkDataArrayTemplateImplicit.txx diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkOpenFOAMPoints.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkOpenFOAMPoints.H similarity index 84% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkOpenFOAMPoints.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkOpenFOAMPoints.H index b6fa0c83b0ed105f9bfaadb8d3cbe30229262365..85ddd163b9e7bc71657d0fa69ced8a6ac392a048 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkOpenFOAMPoints.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkOpenFOAMPoints.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -44,6 +44,21 @@ inline void vtkInsertNextOpenFOAMPoint points->InsertNextPoint(p.x(), p.y(), p.z()); } +inline void vtkInsertNextOpenFOAMPoint +( + vtkPoints *points, + const Foam::point& p, + const Foam::scalar scaleFactor +) +{ + points->InsertNextPoint + ( + p.x()*scaleFactor, + p.y()*scaleFactor, + p.z()*scaleFactor + ); +} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C similarity index 95% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C index 2dc5bc32e3aff5d092706c7bd263d9f9eed2e857..e9d36ec91eee61a8a67473b68656d0bd393cad32 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -219,6 +219,14 @@ Foam::vtkPV3blockMesh::~vtkPV3blockMesh() Info<< "<end> Foam::vtkPV3blockMesh::~vtkPV3blockMesh" << endl; } + // Hmm. pointNumberTextActors are not getting removed + // + forAll(pointNumberTextActorsPtrs_, pointI) + { + pointNumberTextActorsPtrs_[pointI]->Delete(); + } + pointNumberTextActorsPtrs_.clear(); + delete meshPtr_; } @@ -376,6 +384,7 @@ void Foam::vtkPV3blockMesh::renderPointNumbers if (show && meshPtr_) { const pointField& cornerPts = meshPtr_->blockPointField(); + const scalar scaleFactor = meshPtr_->scaleFactor(); pointNumberTextActorsPtrs_.setSize(cornerPts.size()); forAll(cornerPts, pointI) @@ -399,9 +408,9 @@ void Foam::vtkPV3blockMesh::renderPointNumbers txt->GetPositionCoordinate()->SetValue ( - cornerPts[pointI].x(), - cornerPts[pointI].y(), - cornerPts[pointI].z() + cornerPts[pointI].x()*scaleFactor, + cornerPts[pointI].y()*scaleFactor, + cornerPts[pointI].z()*scaleFactor ); // Add text to each renderer diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H similarity index 99% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H index 6001267ef86c5d720bd188d7e3d4bab2d152af57..a159b3cba58978185c46eebdfb8d5579996ce2df 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMesh.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C similarity index 92% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C index c163ba14ed479236779910afa39accd1218de037..4f76f5ebf2225f4c4915a3aa352052dc796b1d31 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshConvert.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -66,6 +66,7 @@ void Foam::vtkPV3blockMesh::convertMeshBlocks } int blockI = 0; + const scalar scaleFactor = blkMesh.scaleFactor(); for ( @@ -103,7 +104,8 @@ void Foam::vtkPV3blockMesh::convertMeshBlocks vtkInsertNextOpenFOAMPoint ( vtkpoints, - blockPoints[blockLabels[ptI]] + blockPoints[blockLabels[ptI]], + scaleFactor ); nodeIds[ptI] = ptI; @@ -159,6 +161,7 @@ void Foam::vtkPV3blockMesh::convertMeshEdges const curvedEdgeList& edges = blkMesh.edges(); int edgeI = 0; + const scalar scaleFactor = blkMesh.scaleFactor(); for ( @@ -212,7 +215,12 @@ void Foam::vtkPV3blockMesh::convertMeshEdges vtkIdType pointIds[edgePoints.size()]; forAll(edgePoints, ptI) { - vtkInsertNextOpenFOAMPoint(vtkpoints, edgePoints[ptI]); + vtkInsertNextOpenFOAMPoint + ( + vtkpoints, + edgePoints[ptI], + scaleFactor + ); pointIds[ptI] = ptI; } @@ -266,6 +274,7 @@ void Foam::vtkPV3blockMesh::convertMeshCorners label datasetNo = 0; // restart at dataset 0 const pointField& blockPoints = meshPtr_->blockPointField(); + const scalar& scaleFactor = meshPtr_->scaleFactor(); if (debug) { @@ -284,7 +293,12 @@ void Foam::vtkPV3blockMesh::convertMeshCorners vtkIdType pointId = 0; forAll(blockPoints, ptI) { - vtkInsertNextOpenFOAMPoint(vtkpoints, blockPoints[ptI]); + vtkInsertNextOpenFOAMPoint + ( + vtkpoints, + blockPoints[ptI], + scaleFactor + ); vtkcells->InsertNextCell(1, &pointId); pointId++; diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C similarity index 99% rename from applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C rename to applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C index b948c5e97978495ea66de789803e09b352523593..bde724d9a7fee2c9d90c18d6768b9b5648ec1501 100644 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C +++ b/applications/utilities/postProcessing/graphics/PV3Readers/PV3blockMeshReader/vtkPV3blockMesh/vtkPV3blockMeshUtils.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/Make/files b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..134b8de963e813e2955fdac51ea10d5e684e6c94 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/Make/files @@ -0,0 +1,3 @@ +vtkPV3Readers.C + +LIB = $(FOAM_LIBBIN)/libvtkPV3Readers diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/Make/options b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..876a3e334ed8e70bf22bfcebad8a83bc4b1c8864 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(ParaView_DIR)/VTK \ + -I$(ParaView_INST_DIR) \ + -I$(ParaView_INST_DIR)/VTK \ + -I$(ParaView_INST_DIR)/VTK/Common \ + -I$(ParaView_INST_DIR)/VTK/Filtering \ + -I$(ParaView_INST_DIR)/VTK/Rendering + +LIB_LIBS = \ + $(GLIBS) diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/vtkPV3Readers.C b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/vtkPV3Readers.C new file mode 100644 index 0000000000000000000000000000000000000000..ed10463f91fd4bbd9bf2d3473a3be345d2e056e4 --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/vtkPV3Readers.C @@ -0,0 +1,330 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Misc helper methods and utilities + +\*---------------------------------------------------------------------------*/ + +#include "vtkPV3Readers.H" + +// Foam includes +#include "IFstream.H" + +// VTK includes +#include "vtkDataArraySelection.h" +#include "vtkDataSet.h" +#include "vtkMultiBlockDataSet.h" +#include "vtkInformation.h" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::vtkPV3Readers, 0); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + //! @cond fileScope + // Extract up to the first non-word characters + inline word getFirstWord(const char* str) + { + if (str) + { + label n = 0; + while (str[n] && word::valid(str[n])) + { + ++n; + } + return word(str, n, true); + } + else + { + return word::null; + } + + } + //! @endcond fileScope + +} // End namespace Foam + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::vtkPV3Readers::AddToBlock +( + vtkMultiBlockDataSet* output, + vtkDataSet* dataset, + const partInfo& selector, + const label datasetNo, + const std::string& datasetName +) +{ + const int blockNo = selector.block(); + + vtkDataObject* blockDO = output->GetBlock(blockNo); + vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); + + if (!block) + { + if (blockDO) + { + FatalErrorIn("Foam::vtkPV3Readers::AddToBlock") + << "Block already has a vtkDataSet assigned to it" + << endl; + return; + } + + block = vtkMultiBlockDataSet::New(); + output->SetBlock(blockNo, block); + block->Delete(); + } + + if (debug) + { + Info<< "block[" << blockNo << "] has " + << block->GetNumberOfBlocks() + << " datasets prior to adding set " << datasetNo + << " with name: " << datasetName << endl; + } + + block->SetBlock(datasetNo, dataset); + + // name the block when assigning dataset 0 + if (datasetNo == 0) + { + output->GetMetaData(blockNo)->Set + ( + vtkCompositeDataSet::NAME(), + selector.name() + ); + } + + if (datasetName.size()) + { + block->GetMetaData(datasetNo)->Set + ( + vtkCompositeDataSet::NAME(), + datasetName.c_str() + ); + } +} + + +vtkDataSet* Foam::vtkPV3Readers::GetDataSetFromBlock +( + vtkMultiBlockDataSet* output, + const partInfo& selector, + const label datasetNo +) +{ + const int blockNo = selector.block(); + + vtkDataObject* blockDO = output->GetBlock(blockNo); + vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); + + if (block) + { + return vtkDataSet::SafeDownCast(block->GetBlock(datasetNo)); + } + + return 0; +} + + +// ununsed at the moment +Foam::label Foam::vtkPV3Readers::GetNumberOfDataSets +( + vtkMultiBlockDataSet* output, + const partInfo& selector +) +{ + const int blockNo = selector.block(); + + vtkDataObject* blockDO = output->GetBlock(blockNo); + vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(blockDO); + if (block) + { + return block->GetNumberOfBlocks(); + } + + return 0; +} + + +// Foam::word Foam::vtkPV3Readers::getPartName(int partId) +// { +// return getFirstWord(reader_->GetPartArrayName(partId)); +// } + + +Foam::wordHashSet Foam::vtkPV3Readers::getSelected +( + vtkDataArraySelection* select +) +{ + int nElem = select->GetNumberOfArrays(); + wordHashSet selections(2*nElem); + + for (int elemI=0; elemI < nElem; ++elemI) + { + if (select->GetArraySetting(elemI)) + { + selections.insert(getFirstWord(select->GetArrayName(elemI))); + } + } + + return selections; +} + + +Foam::wordHashSet Foam::vtkPV3Readers::getSelected +( + vtkDataArraySelection* select, + const partInfo& selector +) +{ + int nElem = select->GetNumberOfArrays(); + wordHashSet selections(2*nElem); + + for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + { + if (select->GetArraySetting(elemI)) + { + selections.insert(getFirstWord(select->GetArrayName(elemI))); + } + } + + return selections; +} + + +Foam::stringList Foam::vtkPV3Readers::getSelectedArrayEntries +( + vtkDataArraySelection* select +) +{ + stringList selections(select->GetNumberOfArrays()); + label nElem = 0; + + forAll(selections, elemI) + { + if (select->GetArraySetting(elemI)) + { + selections[nElem++] = select->GetArrayName(elemI); + } + } + selections.setSize(nElem); + + + if (debug) + { + label nElem = select->GetNumberOfArrays(); + Info<< "available("; + for (int elemI = 0; elemI < nElem; ++elemI) + { + Info<< " \"" << select->GetArrayName(elemI) << "\""; + } + Info<< " )\nselected("; + + forAll(selections, elemI) + { + Info<< " " << selections[elemI]; + } + Info<< " )\n"; + } + + return selections; +} + + +Foam::stringList Foam::vtkPV3Readers::getSelectedArrayEntries +( + vtkDataArraySelection* select, + const partInfo& selector +) +{ + stringList selections(selector.size()); + label nElem = 0; + + for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + { + if (select->GetArraySetting(elemI)) + { + selections[nElem++] = select->GetArrayName(elemI); + } + } + selections.setSize(nElem); + + + if (debug) + { + Info<< "available("; + for (int elemI = selector.start(); elemI < selector.end(); ++elemI) + { + Info<< " \"" << select->GetArrayName(elemI) << "\""; + } + Info<< " )\nselected("; + + forAll(selections, elemI) + { + Info<< " " << selections[elemI]; + } + Info<< " )\n"; + } + + return selections; +} + + +void Foam::vtkPV3Readers::setSelectedArrayEntries +( + vtkDataArraySelection* select, + const stringList& selections +) +{ + const int nElem = select->GetNumberOfArrays(); + select->DisableAllArrays(); + + // Loop through entries, setting values from selectedEntries + for (int elemI=0; elemI < nElem; ++elemI) + { + string arrayName(select->GetArrayName(elemI)); + + forAll(selections, elemI) + { + if (selections[elemI] == arrayName) + { + select->EnableArray(arrayName.c_str()); + break; + } + } + } +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/vtkPV3Readers.H b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/vtkPV3Readers.H new file mode 100644 index 0000000000000000000000000000000000000000..fba4da5d948388eb2f982302859876fc4603667a --- /dev/null +++ b/applications/utilities/postProcessing/graphics/PV3Readers/vtkPV3Readers/vtkPV3Readers.H @@ -0,0 +1,229 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Namespace + Foam::vtkPV3Readers + +Description + A collection of helper functions when building a reader interface in + ParaView3. + +SourceFiles + vtkPV3Readers.C + +\*---------------------------------------------------------------------------*/ + +#ifndef vtkPV3Readers_H +#define vtkPV3Readers_H + +// do not include legacy strstream headers +#ifndef VTK_EXCLUDE_STRSTREAM_HEADERS +# define VTK_EXCLUDE_STRSTREAM_HEADERS +#endif + +#include "className.H" +#include "fileName.H" +#include "stringList.H" +#include "wordList.H" +#include "HashSet.H" + + +// * * * * * * * * * * * * * Forward Declarations * * * * * * * * * * * * * // + +class vtkDataArraySelection; +class vtkDataSet; +class vtkPoints; +class vtkPV3FoamReader; +class vtkRenderer; +class vtkTextActor; +class vtkMultiBlockDataSet; +class vtkPolyData; +class vtkUnstructuredGrid; +class vtkIndent; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace vtkPV3Readers +{ + //- Declare name of the class and its debug switch + NamespaceName("vtkPV3Readers"); + + //- Bookkeeping for GUI checklists and the multi-block organization + class partInfo + { + const char *name_; + int block_; + int start_; + int size_; + + public: + + partInfo(const char *name, const int blockNo=0) + : + name_(name), + block_(blockNo), + start_(-1), + size_(0) + {} + + //- Return the block holding these datasets + int block() const + { + return block_; + } + + //- Assign block number, return previous value + int block(int blockNo) + { + int prev = block_; + block_ = blockNo; + return prev; + } + + const char* name() const + { + return name_; + } + + int start() const + { + return start_; + } + + int end() const + { + return start_ + size_; + } + + int size() const + { + return size_; + } + + bool empty() const + { + return !size_; + } + + void reset() + { + start_ = -1; + size_ = 0; + } + + //- Assign new start and reset the size + void operator=(const int i) + { + start_ = i; + size_ = 0; + } + + //- Increment the size + void operator+=(const int n) + { + size_ += n; + } + }; + + + //- Convenience method use to convert the readers from VTK 5 + // multiblock API to the current composite data infrastructure + void AddToBlock + ( + vtkMultiBlockDataSet* output, + vtkDataSet* dataset, + const partInfo& selector, + const label datasetNo, + const std::string& datasetName + ); + + + //- Convenience method use to convert the readers from VTK 5 + // multiblock API to the current composite data infrastructure + vtkDataSet* GetDataSetFromBlock + ( + vtkMultiBlockDataSet* output, + const partInfo& selector, + const label datasetNo + ); + + //- Convenience method use to convert the readers from VTK 5 + // multiblock API to the current composite data infrastructure + // ununsed at the moment + label GetNumberOfDataSets + ( + vtkMultiBlockDataSet* output, + const partInfo& selector + ); + + + //- Retrieve the current selections as a wordHashSet + wordHashSet getSelected + ( + vtkDataArraySelection* select + ); + + + //- Retrieve a sub-list of the current selections + wordHashSet getSelected + ( + vtkDataArraySelection*, + const partInfo& + ); + + + //- Retrieve the current selections + stringList getSelectedArrayEntries(vtkDataArraySelection*); + + //- Retrieve a sub-list of the current selections + stringList getSelectedArrayEntries + ( + vtkDataArraySelection* select, + const partInfo& selector + ); + + + //- Set selection(s) + void setSelectedArrayEntries + ( + vtkDataArraySelection*, + const stringList& + ); + + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace vtkPV3 + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/Allwmake b/applications/utilities/postProcessing/graphics/PV3blockMeshReader/Allwmake deleted file mode 100755 index 3e2c407e6e11cf08b9cd62d17f5942a3e2e8d424..0000000000000000000000000000000000000000 --- a/applications/utilities/postProcessing/graphics/PV3blockMeshReader/Allwmake +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -cd ${0%/*} || exit 1 # run from this directory -set -x - -if [ -d "$ParaView_DIR" -a -r "$ParaView_DIR" ] -then - case "$ParaView_VERSION" in - 3*) - wmake libso vtkPV3blockMesh - ( - cd PV3blockMeshReader - mkdir -p Make/$WM_OPTIONS > /dev/null 2>&1 - cd Make/$WM_OPTIONS - cmake ../.. - make - ) - ;; - esac -fi - -# ----------------------------------------------------------------- end-of-file diff --git a/applications/utilities/preProcessing/wallFunctionTable/Allwclean b/applications/utilities/preProcessing/wallFunctionTable/Allwclean new file mode 100755 index 0000000000000000000000000000000000000000..bf93e1c06b73b1711ff8d87c7c149526bfb6219a --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/Allwclean @@ -0,0 +1,5 @@ +#!/bin/sh + +wclean libso tabulatedWallFunction +wclean + diff --git a/applications/utilities/preProcessing/wallFunctionTable/Allwmake b/applications/utilities/preProcessing/wallFunctionTable/Allwmake new file mode 100755 index 0000000000000000000000000000000000000000..57795a542fae3d0cdd2659b8b95b2e4d266db12f --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/Allwmake @@ -0,0 +1,5 @@ +#!/bin/sh + +wmake libso tabulatedWallFunction +wmake + diff --git a/applications/utilities/preProcessing/wallFunctionTable/Make/files b/applications/utilities/preProcessing/wallFunctionTable/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..49a6c94aa19e61659e935217a57711b0eb08c871 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/Make/files @@ -0,0 +1,3 @@ +wallFunctionTableApp.C + +EXE = $(FOAM_APPBIN)/wallFunctionTable diff --git a/applications/utilities/preProcessing/wallFunctionTable/Make/options b/applications/utilities/preProcessing/wallFunctionTable/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..6c78939e7cc5087cd4fad50e145e4b434b783887 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/Make/options @@ -0,0 +1,8 @@ +EXE_INC = \ + -I./tabulatedWallFunction/lnInclude \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -ltabulatedWallFunctions \ + -lfiniteVolume diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/Make/files b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/Make/files new file mode 100644 index 0000000000000000000000000000000000000000..77c9217ded71d0e5387e6ac154435516055bf011 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/Make/files @@ -0,0 +1,7 @@ +tabulatedWallFunction/tabulatedWallFunction.C +tabulatedWallFunction/newTabulatedWallFunction.C + +SpaldingsLaw/SpaldingsLaw.C +general/general.C + +LIB = $(FOAM_LIBBIN)/libtabulatedWallFunctions diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/Make/options b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/Make/options new file mode 100644 index 0000000000000000000000000000000000000000..cc5bf25a93e183eff1054ae71ded26852e5ef8fd --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/Make/options @@ -0,0 +1,9 @@ + +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/lnInclude \ + -I$(LIB_SRC)/transportModels + +LIB_LIBS = \ + -lfiniteVolume diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/SpaldingsLaw/SpaldingsLaw.C b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/SpaldingsLaw/SpaldingsLaw.C new file mode 100644 index 0000000000000000000000000000000000000000..2138000f6e3abf2d21c3dfbd7a8cdb81b8f91f8a --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/SpaldingsLaw/SpaldingsLaw.C @@ -0,0 +1,197 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "SpaldingsLaw.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace tabulatedWallFunctions + { + defineTypeNameAndDebug(SpaldingsLaw, 0); + addToRunTimeSelectionTable + ( + tabulatedWallFunction, + SpaldingsLaw, + dictionary + ); + } +} + +const Foam::label Foam::tabulatedWallFunctions::SpaldingsLaw::maxIters_ = 1000; + +const Foam::scalar + Foam::tabulatedWallFunctions::SpaldingsLaw::tolerance_ = 1e-4; + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void Foam::tabulatedWallFunctions::SpaldingsLaw::invertFunction() +{ + // Initialise u+ and R + scalar Re = 0.0; + scalar uPlus = 1; + + // Populate the table + for (label i=0; i<invertedTable_.size(); i++) + { + if (invertedTable_.log10()) + { + Re = pow(10, (i*invertedTable_.dx() + invertedTable_.x0())); + } + else + { + Re = i*invertedTable_.dx() + invertedTable_.x0(); + } + + // Use latest available u+ estimate + if (i > 0) + { + uPlus = invertedTable_[i-1]; + } + + // Newton iterations to determine u+ + label iter = 0; + scalar error = GREAT; + do + { + scalar kUPlus = min(kappa_*uPlus, 50); + scalar A = + E_*sqr(uPlus) + + uPlus + *(exp(kUPlus) - pow3(kUPlus)/6 - 0.5*sqr(kUPlus) - kUPlus - 1); + + scalar f = - Re + A/E_; + + scalar df = + ( + 2*E_*uPlus + + exp(kUPlus)*(kUPlus + 1) + - 2/3*pow3(kUPlus) + - 1.5*sqr(kUPlus) + - 2*kUPlus + - 1 + )/E_; + + scalar uPlusNew = uPlus - f/(df + ROOTVSMALL); + error = mag((uPlus - uPlusNew)/uPlusNew); + uPlus = uPlusNew; + } while (error > tolerance_ && ++iter < maxIters_); + + if (iter == maxIters_) + { + WarningIn("SpaldingsLaw::invertFunction()") + << "Newton iterations not converged:" << nl + << " iters = " << iter << ", error = " << error << endl; + } + + // Set new values - constrain u+ >= 0 + invertedTable_[i] = max(0, uPlus); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::tabulatedWallFunctions::SpaldingsLaw::SpaldingsLaw +( + const dictionary& dict, + const polyMesh& mesh +) +: + tabulatedWallFunction(dict, mesh, typeName), + kappa_(readScalar(coeffDict_.lookup("kappa"))), + E_(readScalar(coeffDict_.lookup("E"))) +{ + invertFunction(); + + if (debug) + { + writeData(Info); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::tabulatedWallFunctions::SpaldingsLaw::~SpaldingsLaw() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::scalar Foam::tabulatedWallFunctions::SpaldingsLaw::yPlus +( + const scalar uPlus +) const +{ + scalar kUPlus = min(kappa_*uPlus, 50); + + return + uPlus + + 1/E_*(exp(kUPlus) - pow3(kUPlus)/6 - 0.5*sqr(kUPlus) - kUPlus - 1); +} + + +Foam::scalar Foam::tabulatedWallFunctions::SpaldingsLaw::Re +( + const scalar uPlus +) const +{ + return uPlus*yPlus(uPlus); +} + + +void Foam::tabulatedWallFunctions::SpaldingsLaw::writeData(Ostream& os) const +{ + if (invertedTable_.log10()) + { + os << "log10(Re), y+, u+:" << endl; + forAll(invertedTable_, i) + { + scalar uPlus = invertedTable_[i]; + scalar Re = ::log10(this->Re(uPlus)); + scalar yPlus = this->yPlus(uPlus); + os << Re << ", " << yPlus << ", " << uPlus << endl; + } + } + else + { + os << "Re, y+, u+:" << endl; + forAll(invertedTable_, i) + { + scalar uPlus = invertedTable_[i]; + scalar Re = this->Re(uPlus); + scalar yPlus = this->yPlus(uPlus); + os << Re << ", " << yPlus << ", " << uPlus << endl; + } + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/SpaldingsLaw/SpaldingsLaw.H b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/SpaldingsLaw/SpaldingsLaw.H new file mode 100644 index 0000000000000000000000000000000000000000..07853ef5ebfa9800572775dcf989175b26a7d99f --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/SpaldingsLaw/SpaldingsLaw.H @@ -0,0 +1,140 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::tabulatedWallFunctions::SpaldingsLaw + +Description + Computes U+ as a function of Reynolds number by inverting Spaldings law. + + Example dictionary specification: + + tabulatedWallFunction SpaldingsLaw; + + // Output table info + tableName uPlusWallFunctionData; // Output table name + log10 yes; // Rey interpreted as log10(Rey) + dx 0.2; // Interval log10(Rey) + x0 -3; // Minimum log10(Rey) + xMax 7; // Maximum log10(Rey) + + SpaldingsLawCoeffs + { + kappa 0.41; // Von Karman constant + E 9.8; // Law-of-the-wall E coefficient + } + + +SourceFiles + SpaldingsLaw.C + +\*---------------------------------------------------------------------------*/ + +#ifndef SpaldingsLaw_H +#define SpaldingsLaw_H + +#include "tabulatedWallFunction.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace tabulatedWallFunctions +{ + +/*---------------------------------------------------------------------------*\ + Class SpaldingsLaw Declaration +\*---------------------------------------------------------------------------*/ + +class SpaldingsLaw +: + public tabulatedWallFunction +{ +protected: + + // Protected data + + //- Von Karman constant + scalar kappa_; + + //- Law-of-the-wall E coefficient + scalar E_; + + + // Newton iteration solution properties + + //- Maximum number of iterations + static const label maxIters_; + + //- Tolerance + static const scalar tolerance_; + + + // Protected member functions + + //- Invert the function + virtual void invertFunction(); + + +public: + + //- Run-time type information + TypeName("SpaldingsLaw"); + + + // Constructors + SpaldingsLaw(const dictionary& dict, const polyMesh& mesh); + + //- Destructor + virtual ~SpaldingsLaw(); + + + // Member Functions + + // Access + + //- Return y+ as a function of u+ + virtual scalar yPlus(const scalar uPlus) const; + + //- Return Reynolds number as a function of u+ + virtual scalar Re(const scalar uPlus) const; + + + // I-O + + //- Write to Ostream + virtual void writeData(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace tabulatedWallFunctions +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.C b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.C new file mode 100644 index 0000000000000000000000000000000000000000..76792dc2f83cdffdbe6382f81ab31076230d14c6 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.C @@ -0,0 +1,254 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "general.H" +#include "addToRunTimeSelectionTable.H" +#include "Tuple2.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace tabulatedWallFunctions + { + defineTypeNameAndDebug(general, 0); + addToRunTimeSelectionTable + ( + tabulatedWallFunction, + general, + dictionary + ); + } +} + +template<> +const char* +Foam::NamedEnum<Foam::tabulatedWallFunctions::general::interpolationType, 1>:: + names[] = + { + "linear" + }; + +const +Foam::NamedEnum<Foam::tabulatedWallFunctions::general::interpolationType, 1> + Foam::tabulatedWallFunctions::general::interpolationTypeNames_; + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +void Foam::tabulatedWallFunctions::general::invertTable() +{ + scalarList Rey(uPlus_.size(), 0.0); + + // Calculate Reynolds number + forAll(uPlus_, i) + { + Rey[i] = yPlus_[i]*uPlus_[i]; + if (invertedTable_.log10()) + { + Rey[i] = ::log10(max(ROOTVSMALL, Rey[i])); + } + } + + // Populate the U+ vs Re table + forAll(invertedTable_, i) + { + scalar Re = i*invertedTable_.dx() + invertedTable_.x0(); + invertedTable_[i] = max(0, interpolate(Re, Rey, uPlus_)); + } +} + + +Foam::scalar Foam::tabulatedWallFunctions::general::interpolate +( + const scalar xi, + const scalarList& x, + const scalarList& fx +) const +{ + switch (interpType_) + { + case itLinear: + { + if (xi < x[0]) + { + return fx[0]; + } + else if (xi > x[x.size()-1]) + { + return fx[x.size()-1]; + } + else + { + label i2 = 0; + while (x[i2] < xi) + { + i2++; + } + label i1 = i2 - 1; + + return (xi - x[i1])/(x[i2] - x[i1])*(fx[i2] - fx[i1]) + fx[i1]; + } + + break; + } + default: + { + FatalErrorIn + ( + "tabulatedWallFunctions::general::interpolate" + "(" + "const scalar, " + "const scalarList&, " + "const scalarList&" + ")" + ) << "Unknown interpolation method" << nl + << abort(FatalError); + } + } + + return 0.0; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::tabulatedWallFunctions::general::general +( + const dictionary& dict, + const polyMesh& mesh +) +: + tabulatedWallFunction(dict, mesh, typeName), + interpType_(interpolationTypeNames_[coeffDict_.lookup("interpType")]), + yPlus_(), + uPlus_(), + log10YPlus_(coeffDict_.lookup("log10YPlus")), + log10UPlus_(coeffDict_.lookup("log10UPlus")) +{ + List<Tuple2<scalar, scalar> > inputTable = coeffDict_.lookup("inputTable"); + if (inputTable.size() < 2) + { + FatalErrorIn + ( + "tabulatedWallFunctions::general::general" + "(" + "const dictionary&, " + "const polyMesh&" + ")" + ) << "Input table must have at least 2 values" << nl + << exit(FatalError); + } + + yPlus_.setSize(inputTable.size()); + uPlus_.setSize(inputTable.size()); + + forAll(inputTable, i) + { + if (log10YPlus_) + { + yPlus_[i] = pow(10, inputTable[i].first()); + } + else + { + yPlus_[i] = inputTable[i].first(); + } + + if (log10UPlus_) + { + uPlus_[i] = pow(10, inputTable[i].second()); + } + else + { + uPlus_[i] = inputTable[i].second(); + } + } + + invertTable(); + + if (debug) + { + writeData(Info); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::tabulatedWallFunctions::general::~general() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::scalar Foam::tabulatedWallFunctions::general::yPlus +( + const scalar uPlus +) const +{ + return interpolate(uPlus, uPlus_, yPlus_); +} + + +Foam::scalar Foam::tabulatedWallFunctions::general::Re +( + const scalar uPlus +) const +{ + return uPlus*yPlus(uPlus); +} + + +// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // + +void Foam::tabulatedWallFunctions::general::writeData(Ostream& os) const +{ + if (invertedTable_.log10()) + { + os << "log10(Re), y+, u+:" << endl; + forAll(invertedTable_, i) + { + scalar uPlus = invertedTable_[i]; + scalar Re = ::log10(this->Re(uPlus)); + scalar yPlus = this->yPlus(uPlus); + os << Re << ", " << yPlus << ", " << uPlus << endl; + } + } + else + { + os << "Re, y+, u+:" << endl; + forAll(invertedTable_, i) + { + scalar uPlus = invertedTable_[i]; + scalar Re = this->Re(uPlus); + scalar yPlus = this->yPlus(uPlus); + os << Re << ", " << yPlus << ", " << uPlus << endl; + } + } +} + + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.H b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.H new file mode 100644 index 0000000000000000000000000000000000000000..032d2d6cc14cba8a5ff7b30ab63fa197d9c1fe18 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/general/general.H @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::tabulatedWallFunctions::general + +Description + Computes U+ as a function of Reynolds number by inverting table of + y+ vs U+ + + Example dictionary specification: + + tabulatedWallFunction general; + + // Output table info + tableName uPlusWallFunctionData; // Output table name + log10 yes; // Re interpreted as log10(Rey) + dx 0.2; // Interval log10(Rey) + x0 -3; // Minimum log10(Rey) + xMax 7; // Maximum log10(Rey) + + generalCoeffs + { + interpType linear; // Interpolation method + log10YPlus true; // y+ values defined as log10(y+) + log10UPlus true; // U+ values defined as log10(y+) + inputTable + ( + (yPlusValue0 uPlusValue0) + ... + (yPlusValueN uPlusValueN) + ); + + } + + +SourceFiles + general.C + +\*---------------------------------------------------------------------------*/ + +#ifndef general_H +#define general_H + +#include "tabulatedWallFunction.H" +#include "NamedEnum.H" +#include "Switch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace tabulatedWallFunctions +{ + +/*---------------------------------------------------------------------------*\ + Class general Declaration +\*---------------------------------------------------------------------------*/ + +class general +: + public tabulatedWallFunction +{ +public: + + // Public data types + + //- Enumeration listing available interpolation types + enum interpolationType + { + itLinear + }; + + static const NamedEnum<interpolationType, 1> interpolationTypeNames_; + + +protected: + + // Protected data + + //- Type of interpolation to apply when inverting the data set + interpolationType interpType_; + + //- Input y+ values + List<scalar> yPlus_; + + //- Input U+ values + List<scalar> uPlus_; + + //- Are y+ values entered as log10(y+)? + Switch log10YPlus_; + + //- Are U+ values entered as log10(U+)? + Switch log10UPlus_; + + + // Protected member functions + + //- Invert the table + virtual void invertTable(); + + //- Interpolate + virtual scalar interpolate + ( + const scalar xi, + const scalarList& x, + const scalarList& fx + ) const; + + +public: + + //- Run-time type information + TypeName("general"); + + + // Constructors + general(const dictionary& dict, const polyMesh& mesh); + + //- Destructor + virtual ~general(); + + + // Member Functions + + // Access + + //- Return y+ as a function of u+ + virtual scalar yPlus(const scalar uPlus) const; + + //- Return Reynolds number as a function of u+ + virtual scalar Re(const scalar uPlus) const; + + + // I-O + + //- Write to Ostream + virtual void writeData(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace tabulatedWallFunctions +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/newTabulatedWallFunction.C b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/newTabulatedWallFunction.C new file mode 100644 index 0000000000000000000000000000000000000000..af10c175679968159d792b75947947410049a496 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/newTabulatedWallFunction.C @@ -0,0 +1,71 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "tabulatedWallFunction.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace tabulatedWallFunctions +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +autoPtr<tabulatedWallFunction> tabulatedWallFunction::New +( + const dictionary& dict, + const polyMesh& mesh +) +{ + word twfTypeName = dict.lookup("tabulatedWallFunction"); + + Info<< "Selecting tabulatedWallFunction " << twfTypeName << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(twfTypeName); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "tabulatedWallFunction::New(const dictionary&, const polyMesh&)" + ) << "Unknown tabulatedWallFunction type " << twfTypeName + << nl << nl << "Valid tabulatedWallFunction types are:" << nl + << dictionaryConstructorTablePtr_->toc() + << exit(FatalError); + } + + return autoPtr<tabulatedWallFunction>(cstrIter()(dict, mesh)); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace tabulatedWallFunctions +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunction.C b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunction.C new file mode 100644 index 0000000000000000000000000000000000000000..4c0087a87bc8b469622e3a6d10662273e33bf80b --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunction.C @@ -0,0 +1,88 @@ + +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "tabulatedWallFunction.H" +#include "Time.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + namespace tabulatedWallFunctions + { + defineTypeNameAndDebug(tabulatedWallFunction, 0); + defineRunTimeSelectionTable(tabulatedWallFunction, dictionary); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::tabulatedWallFunctions::tabulatedWallFunction::tabulatedWallFunction +( + const dictionary& dict, + const polyMesh& mesh, + const word& name +) +: + dict_(dict), + mesh_(mesh), + coeffDict_(dict.subDict(name + "Coeffs")), + invertedTableName_(dict.lookup("invertedTableName")), + invertedTable_(invertedTableName_, mesh_, dict, true) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::tabulatedWallFunctions::tabulatedWallFunction::~tabulatedWallFunction() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::tabulatedWallFunctions::tabulatedWallFunction::write() +{ + if (invertedTable_.log10()) + { + invertedTable_.note() = + "U+ as a function of log10(Re) computed using " + type(); + } + else + { + invertedTable_.note() = + "U+ as a function of Re computed using " + type(); + } + + Info<< "Writing inverted table to\n " << invertedTable_.objectPath() + << endl; + + invertedTable_.write(); +} + + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunction.H b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunction.H new file mode 100644 index 0000000000000000000000000000000000000000..416b1d9249922707b26909a3fc95dd4ebda6add0 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunction.H @@ -0,0 +1,148 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::tabulatedWallFunctions::tabulatedWallFunction + +Description + Base class for models that generate tabulated wall function data. + +SourceFiles + tabulatedWallFunction.C + +\*---------------------------------------------------------------------------*/ + +#ifndef tabulatedWallFunction_H +#define tabulatedWallFunction_H + +#include "dictionary.H" +#include "polyMesh.H" +#include "runTimeSelectionTables.H" +#include "Switch.H" +#include "uniformInterpolationTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace tabulatedWallFunctions +{ + +/*---------------------------------------------------------------------------*\ + Class tabulatedWallFunction Declaration +\*---------------------------------------------------------------------------*/ + +class tabulatedWallFunction +{ +protected: + + // Proteced data + + //- Main dictionary + const dictionary dict_; + + //- Reference to the mesh database + const polyMesh& mesh_; + + //- Coefficients dictionary + const dictionary coeffDict_; + + //- Name of inverted table + word invertedTableName_; + + //- Inverted table + uniformInterpolationTable<scalar> invertedTable_; + + +public: + + //- Run-time type information + TypeName("tabulatedWallFunction"); + + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + tabulatedWallFunction, + dictionary, + ( + const dictionary& dict, + const polyMesh& mesh + ), + (dict, mesh) + ); + + //- Constructor + tabulatedWallFunction + ( + const dictionary& dict, + const polyMesh& mesh, + const word& name + ); + + //- Destructor + virtual ~tabulatedWallFunction(); + + + //- Selector + static autoPtr<tabulatedWallFunction> New + ( + const dictionary& dict, + const polyMesh& mesh + ); + + + // Member Functions + + // Access + + //- Return the inverted table name + inline const word& invertedTableName() const; + + //- Return the inverted table + inline const uniformInterpolationTable<scalar>& + invertedTable() const; + + + // I-O + + //- Write + virtual void write(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace tabulatedWallFunctions +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "tabulatedWallFunctionI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableName.C b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunctionI.H similarity index 72% rename from src/OpenFOAM/containers/HashTables/HashTable/HashTableName.C rename to applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunctionI.H index a806319041714db45dbfd62c0401180093ab0c0f..1b70904a669374298b1a925e090e5ff9aac5cbee 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableName.C +++ b/applications/utilities/preProcessing/wallFunctionTable/tabulatedWallFunction/tabulatedWallFunction/tabulatedWallFunctionI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,10 +24,22 @@ License \*---------------------------------------------------------------------------*/ -#include "HashTable.H" +#include "tabulatedWallFunction.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inline const Foam::word& +Foam::tabulatedWallFunctions::tabulatedWallFunction::invertedTableName() const +{ + return invertedTableName_; +} + + +inline const Foam::uniformInterpolationTable<Foam::scalar>& +Foam::tabulatedWallFunctions::tabulatedWallFunction::invertedTable() const +{ + return invertedTable_; +} -defineTypeNameAndDebug(Foam::HashTableName, 0); // ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/wallFunctionDict b/applications/utilities/preProcessing/wallFunctionTable/wallFunctionDict new file mode 100644 index 0000000000000000000000000000000000000000..85cd0ba5aa57e8a2b91e0bd3ad1619fc22c428a4 --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/wallFunctionDict @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object wallFunctionDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +tabulatedWallFunction SpaldingsLaw; + +invertedTableName uPlusWallFunctionData; + +dx 0.2; + +x0 -3; + +xMax 7; + +log10 yes; + +bound yes; + +SpaldingsLawCoeffs +{ + kappa 0.41; + E 9.8; +} + + +// ************************************************************************* // diff --git a/applications/utilities/preProcessing/wallFunctionTable/wallFunctionTableApp.C b/applications/utilities/preProcessing/wallFunctionTable/wallFunctionTableApp.C new file mode 100644 index 0000000000000000000000000000000000000000..a729a771c9251f7c601f6c1e4f9e22ac48c137fc --- /dev/null +++ b/applications/utilities/preProcessing/wallFunctionTable/wallFunctionTableApp.C @@ -0,0 +1,68 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Application + wallFunctionTable + +Description + Generates a table suitable for use by tabulated wall functions + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "tabulatedWallFunction.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + + IOdictionary dict + ( + IOobject + ( + "wallFunctionDict", + runTime.constant(), + mesh, + IOobject::MUST_READ + ) + ); + + autoPtr<tabulatedWallFunctions::tabulatedWallFunction> + twf(tabulatedWallFunctions::tabulatedWallFunction::New(dict, mesh)); + +// twf->writeData(Info); + + twf->write(); + + Info << "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/doc/codingStyleGuide.org b/doc/codingStyleGuide.org new file mode 100644 index 0000000000000000000000000000000000000000..d9c5c3c9c660453fda988dfa79ddc2214bb53293 --- /dev/null +++ b/doc/codingStyleGuide.org @@ -0,0 +1,275 @@ +# -*- mode: org; -*- +# +#+TITLE: OpenFOAM C++ style guide +#+AUTHOR: OpenCFD Ltd. +#+DATE: November 2009 +#+LINK: http://www.opencfd.co.uk +#+OPTIONS: author:nil ^:{} + +* OpenFOAM C++ style guide + +*** General + + 80 character lines max + + The body of control statements (eg, if, else, while, etc). + always delineated with brace brackets + + + stream output + << is always four characters after the start of the stream, so that the << + symbols align, i.e. + + Info<< + os << + + + so + + WarningIn("className::functionName()") + << "Warning message" + + NOT + + WarningIn("className::functionName()") + << "Warning message" + + + no unnecessary class section headers, i.e. remove + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + + // Check + + // Edit + + // Write + + if they contain nothing, even if planned for 'future use' + + + class titles are centred + + /*---------------------------------------------------------------------------*\ + Class exampleClass Declaration + \*---------------------------------------------------------------------------*/ + + NOT + + /*---------------------------------------------------------------------------*\ + Class exampleClass Declaration + \*---------------------------------------------------------------------------*/ + +*** .H Files + + header file spacing + Leave two empty lines between sections (as per functions in the .C file etc) + + + use "//- Comment" comments in header file + + add descriptions to class data and functions + + destructor + If adding a comment to the destructor - use //- and code as a normal function: + + //- Destructor + ~className(); + + inline functions + Use inline functions where appropriate in a separate classNameI.H file. + Do not clutter up the header file with function bodies + +*** .C Files + + Do not open/close namespaces in a .C file + Fully scope the function name, i.e. + + Foam::returnType Foam::className::functionName() + + NOT + + namespace Foam + { + ... + + returnType className::functionName() + + ... + } + + EXCEPTION + + When there are multiple levels of namespace, they may be used in the .C + file, i.e. + + namespace Foam + { + namespace compressible + { + namespace RASModels + { + + ... + + } // End namespace RASModels + } // End namespace compressible + } // End namespace Foam + + + Use two empty lines between functions + +*** Coding Practise + + passing data as arguments or return + Pass label and scalar as copy, anything bigger by reference + + const + Use everywhere it is applicable. + + variable initialisation using "=" + + const className& variableName = otherClass.data(); + + NOT + + const className& variableName(otherClass.data()); + + + virtual functions + If a class is virtual - make all derived classes virtual. + +*** Conditional Statements + if (condition) + { + code; + } + + OR + + if + ( + long condition + ) + { + code; + } + + NOT (no space between "if" and "(") + + if(condition) + { + code; + } + +*** `for' Loops + for (i = 0; i < maxI; i++) + { + code; + } + + OR + + for + ( + i = 0; + i < maxI; + i++ + ) + { + code; + } + + NOT (no space between "for" and "(") + + for(i = 0; i < maxI; i++) + { + code; + } + +*** `forAll' loops + like for loops, but + + forAll( + + NOT + + forAll ( + +*** Splitting Over Multiple Lines + + splitting return type and function name + + split initially after the function return type and left align + + + do not put "const" onto it's own line - use a split to keep it with the + function name and arguments. + + so: + + const Foam::longReturnTypeName& + Foam::longClassName::longFunctionName const + + NOT + + const Foam::longReturnTypeName& + Foam::longClassName::longFunctionName const + + NOR + + const Foam::longReturnTypeName& Foam::longClassName::longFunctionName + const + + NOR + + const Foam::longReturnTypeName& Foam::longClassName:: + longFunctionName const + + + + if need to split again, split at the function name (leaving behind the + preceding scoping "::"'s), and again, left align, i.e. + + const Foam::longReturnTypeName& + Foam::veryveryveryverylongClassName:: + veryveryveryverylongFunctionName const + + + splitting long lines at an "=" + + Indent after split + + variableName = + longClassName.longFunctionName(longArgument); + + OR (where necessary) + + variableName = + longClassName.longFunctionName + ( + longArgument1, + longArgument2 + ); + + NOT + + variableName = + longClassName.longFunctionName(longArgument); + + NOR + + variableName = longClassName.longFunctionName + ( + longArgument1, + longArgument2 + ); + +*** Maths and Logic + + operator spacing + + a + b, a - b + + a*b, a/b + + a & b, a ^ b + + a = b, a != b + + a < b, a > b, a >= b, a <= b + + a || b, a && b + + + splitting formulae over several lines + Split and indent as per "splitting long lines at an "="" + with the operator on the lower line. Align operator so that first + variable, function or bracket on the next line is 4 spaces indented i.e. + + variableName = + a*(a + b) + - exp(c/d) + *(k + t) + + + splitting logical tests over several lines + + indent operator so that the next variable to test is aligned with the + four space indentation, i.e. + + if + ( + a == true + && b == c + ) diff --git a/etc/cshrc b/etc/cshrc index 39a5210ca085789e7d2fa8de426d319682127bbb..f5fe32d26e1b3fce73b4f6436607517b780519c7 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -32,7 +32,7 @@ #------------------------------------------------------------------------------ setenv WM_PROJECT OpenFOAM -setenv WM_PROJECT_VERSION dev +if ( ! $?WM_PROJECT_VERSION ) setenv WM_PROJECT_VERSION 1.6 ################################################################################ # USER EDITABLE PART @@ -120,7 +120,6 @@ case Linux: case x86_64: switch ($WM_ARCH_OPTION) case 32: - setenv WM_ARCH linux setenv WM_COMPILER_ARCH '-64' setenv WM_CC 'gcc' setenv WM_CXX 'g++' diff --git a/src/ODE/ODESolvers/SIBS/SIBS.C b/src/ODE/ODESolvers/SIBS/SIBS.C index ec5c196ff028d8c95db3c245beb0dbfa5840e0e3..ecc3164d0a44acc8af6696c93d6cee01fa4d102e 100644 --- a/src/ODE/ODESolvers/SIBS/SIBS.C +++ b/src/ODE/ODESolvers/SIBS/SIBS.C @@ -121,7 +121,7 @@ void Foam::SIBS::solve kMax_ = kOpt_; } - label k=0; + label k = 0; scalar h = hTry; yTemp_ = y; @@ -213,7 +213,7 @@ void Foam::SIBS::solve x = xNew_; hDid = h; - first_=0; + first_ = 0; scalar wrkmin = GREAT; scalar scale = 1.0; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 2823c2a9ec3f0e45310365741915f3667a3446f9..d9a30f3a82441ed99e3df78b87abb7da3e1fd1ee 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -61,8 +61,8 @@ $(sha1)/SHA1Digest.C primitives/random/Random.C -containers/HashTables/HashTable/HashTableName.C -containers/HashTables/StaticHashTable/StaticHashTableName.C +containers/HashTables/HashTable/HashTableCore.C +containers/HashTables/StaticHashTable/StaticHashTableCore.C containers/Lists/SortableList/ParSortableListName.C containers/Lists/PackedList/PackedListName.C containers/Lists/ListOps/ListOps.C @@ -108,11 +108,14 @@ StringStreams = $(Streams)/StringStreams $(StringStreams)/StringStreamsPrint.C Pstreams = $(Streams)/Pstreams -$(Pstreams)/Pstream.C -$(Pstreams)/PstreamCommsStruct.C +$(Pstreams)/UIPstream.C $(Pstreams)/IPstream.C +$(Pstreams)/UPstream.C +$(Pstreams)/UPstreamCommsStruct.C +$(Pstreams)/Pstream.C +$(Pstreams)/UOPstream.C $(Pstreams)/OPstream.C -$(Pstreams)/PstreamsPrint.C +$(Pstreams)/PstreamBuffers.C dictionary = db/dictionary $(dictionary)/dictionary.C diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C index 10bcadc761a429bdf4f51b2832cb07321ae363b9..4bc3921682d87d65609d42b13db314ac1b5a8fe7 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.C @@ -30,44 +30,15 @@ License #include "HashTable.H" #include "List.H" -// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // - -template<class T, class Key, class Hash> -Foam::label Foam::HashTable<T, Key, Hash>::canonicalSize(const label size) -{ - if (size < 1) - { - return 0; - } - - // enforce power of two - unsigned int goodSize = size; - - if (goodSize & (goodSize - 1)) - { - // brute-force is fast enough - goodSize = 1; - while (goodSize < unsigned(size)) - { - goodSize <<= 1; - } - } - - return goodSize; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable(const label size) : - HashTableName(), + HashTableCore(), nElmts_(0), - tableSize_(canonicalSize(size)), - table_(NULL), - endIter_(*this, NULL, 0), - endConstIter_(*this, NULL, 0) + tableSize_(HashTableCore::canonicalSize(size)), + table_(NULL) { if (tableSize_) { @@ -84,12 +55,10 @@ Foam::HashTable<T, Key, Hash>::HashTable(const label size) template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable(const HashTable<T, Key, Hash>& ht) : - HashTableName(), + HashTableCore(), nElmts_(0), tableSize_(ht.tableSize_), - table_(NULL), - endIter_(*this, NULL, 0), - endConstIter_(*this, NULL, 0) + table_(NULL) { if (tableSize_) { @@ -113,12 +82,10 @@ Foam::HashTable<T, Key, Hash>::HashTable const Xfer<HashTable<T, Key, Hash> >& ht ) : - HashTableName(), + HashTableCore(), nElmts_(0), tableSize_(0), - table_(NULL), - endIter_(*this, NULL, 0), - endConstIter_(*this, NULL, 0) + table_(NULL) { transfer(ht()); } @@ -182,7 +149,7 @@ Foam::HashTable<T, Key, Hash>::find { if (key == ep->key_) { - return iterator(*this, ep, hashIdx); + return iterator(this, ep, hashIdx); } } } @@ -195,7 +162,7 @@ Foam::HashTable<T, Key, Hash>::find } # endif - return end(); + return iterator(); } @@ -214,7 +181,7 @@ Foam::HashTable<T, Key, Hash>::find { if (key == ep->key_) { - return const_iterator(*this, ep, hashIdx); + return const_iterator(this, ep, hashIdx); } } } @@ -227,32 +194,32 @@ Foam::HashTable<T, Key, Hash>::find } # endif - return cend(); + return const_iterator(); } template<class T, class Key, class Hash> Foam::List<Key> Foam::HashTable<T, Key, Hash>::toc() const { - List<Key> tofc(nElmts_); - label i = 0; + List<Key> keys(nElmts_); + label keyI = 0; for (const_iterator iter = cbegin(); iter != cend(); ++iter) { - tofc[i++] = iter.key(); + keys[keyI++] = iter.key(); } - return tofc; + return keys; } template<class T, class Key, class Hash> Foam::List<Key> Foam::HashTable<T, Key, Hash>::sortedToc() const { - List<Key> sortedList = this->toc(); - sort(sortedList); + List<Key> sortedLst = this->toc(); + sort(sortedLst); - return sortedList; + return sortedLst; } @@ -290,7 +257,7 @@ bool Foam::HashTable<T, Key, Hash>::set table_[hashIdx] = new hashedEntry(key, table_[hashIdx], newEntry); nElmts_++; - if (double(nElmts_)/tableSize_ > 0.8) + if (double(nElmts_)/tableSize_ > 0.8 && tableSize_ < maxTableSize) { # ifdef FULLDEBUG if (debug) @@ -342,18 +309,22 @@ bool Foam::HashTable<T, Key, Hash>::set template<class T, class Key, class Hash> -bool Foam::HashTable<T, Key, Hash>::erase(const iterator& cit) +bool Foam::HashTable<T, Key, Hash>::iteratorBase::erase() { - if (cit.elmtPtr_) // note: endIter_ also has 0 elmtPtr_ + // note: entryPtr_ is NULL for end(), so this catches that too + if (entryPtr_) { - iterator& it = const_cast<iterator&>(cit); - - // Search element before elmtPtr_ + // Search element before entryPtr_ hashedEntry* prev = 0; - for (hashedEntry* ep = table_[it.hashIndex_]; ep; ep = ep->next_) + for + ( + hashedEntry* ep = hashTable_->table_[hashIndex_]; + ep; + ep = ep->next_ + ) { - if (ep == it.elmtPtr_) + if (ep == entryPtr_) { break; } @@ -362,98 +333,76 @@ bool Foam::HashTable<T, Key, Hash>::erase(const iterator& cit) if (prev) { - // Have element before elmtPtr - prev->next_ = it.elmtPtr_->next_; - delete it.elmtPtr_; - it.elmtPtr_ = prev; + // has an element before entryPtr - reposition to there + prev->next_ = entryPtr_->next_; + delete entryPtr_; + entryPtr_ = prev; } else { - // elmtPtr is first element on SLList - table_[it.hashIndex_] = it.elmtPtr_->next_; - delete it.elmtPtr_; - - // Search back for previous non-zero table entry - while (--it.hashIndex_ >= 0 && !table_[it.hashIndex_]) - {} - - if (it.hashIndex_ >= 0) - { - // In table entry search for last element - it.elmtPtr_ = table_[it.hashIndex_]; - - while (it.elmtPtr_ && it.elmtPtr_->next_) - { - it.elmtPtr_ = it.elmtPtr_->next_; - } - } - else - { - // No previous found. Mark with special value which is - // - not end()/cend() - // - handled by operator++ - it.elmtPtr_ = reinterpret_cast<hashedEntry*>(this); - it.hashIndex_ = -1; - } + // entryPtr was first element on SLList + hashTable_->table_[hashIndex_] = entryPtr_->next_; + delete entryPtr_; + + // assign any non-NULL pointer value so it doesn't look + // like end()/cend() + entryPtr_ = reinterpret_cast<hashedEntry*>(this); + + // Mark with special hashIndex value to signal it has been rewound. + // The next increment will bring it back to the present location. + // + // From the current position 'curPos', we wish to continue at + // prevPos='curPos-1', which we mark as markPos='-curPos-1'. + // The negative lets us notice it is special, the extra '-1' + // is needed to avoid ambiguity for position '0'. + // To retrieve prevPos, we would later use '-(markPos+1) - 1' + hashIndex_ = -hashIndex_ - 1; } - nElmts_--; - -# ifdef FULLDEBUG - if (debug) - { - Info<< "HashTable<T, Key, Hash>::erase(iterator&) : " - << "hashedEntry " << it.elmtPtr_->key_ << " removed.\n"; - } -# endif + hashTable_->nElmts_--; return true; } else { -# ifdef FULLDEBUG - if (debug) - { - Info<< "HashTable<T, Key, Hash>::erase(iterator&) : " - << "cannot remove hashedEntry from hash table\n"; - } -# endif - return false; } } + +// NOTE: +// We use (const iterator&) here, but manipulate its contents anyhow. +// The parameter should be (iterator&), but then the compiler doesn't find +// it correctly and tries to call as (iterator) instead. +// template<class T, class Key, class Hash> -bool Foam::HashTable<T, Key, Hash>::erase(const Key& key) +bool Foam::HashTable<T, Key, Hash>::erase(const iterator& iter) { - iterator fnd = find(key); + // adjust iterator after erase + return const_cast<iterator&>(iter).erase(); +} - if (fnd != end()) - { - return erase(fnd); - } - else - { - return false; - } + +template<class T, class Key, class Hash> +bool Foam::HashTable<T, Key, Hash>::erase(const Key& key) +{ + return erase(find(key)); } template<class T, class Key, class Hash> Foam::label Foam::HashTable<T, Key, Hash>::erase(const UList<Key>& keys) { + const label nTotal = nElmts_; label count = 0; - // Remove listed keys from this table - if (this->size()) + // Remove listed keys from this table - terminates early if possible + for (label keyI = 0; count < nTotal && keyI < keys.size(); ++keyI) { - forAll(keys, keyI) + if (erase(keys[keyI])) { - if (erase(keys[keyI])) - { - count++; - } + count++; } } @@ -462,24 +411,21 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase(const UList<Key>& keys) template<class T, class Key, class Hash> -template<class AnyType> +template<class AnyType, class AnyHash> Foam::label Foam::HashTable<T, Key, Hash>::erase ( - const HashTable<AnyType, Key, Hash>& rhs + const HashTable<AnyType, Key, AnyHash>& rhs ) { label count = 0; - // Remove rhs elements from this table - if (this->size()) + // Remove rhs keys from this table - terminates early if possible + // Could optimize depending on which hash is smaller ... + for (iterator iter = begin(); iter != end(); ++iter) { - // NOTE: could further optimize depending on which hash is smaller - for (iterator iter = begin(); iter != end(); ++iter) + if (rhs.found(iter.key()) && erase(iter)) { - if (rhs.found(iter.key()) && erase(iter)) - { - count++; - } + count++; } } @@ -490,7 +436,7 @@ Foam::label Foam::HashTable<T, Key, Hash>::erase template<class T, class Key, class Hash> void Foam::HashTable<T, Key, Hash>::resize(const label sz) { - label newSize = canonicalSize(sz); + label newSize = HashTableCore::canonicalSize(sz); if (newSize == tableSize_) { @@ -505,22 +451,22 @@ void Foam::HashTable<T, Key, Hash>::resize(const label sz) return; } - HashTable<T, Key, Hash>* newTable = new HashTable<T, Key, Hash>(newSize); + HashTable<T, Key, Hash>* tmpTable = new HashTable<T, Key, Hash>(newSize); for (const_iterator iter = cbegin(); iter != cend(); ++iter) { - newTable->insert(iter.key(), *iter); + tmpTable->insert(iter.key(), *iter); } - label oldTableSize = tableSize_; - tableSize_ = newTable->tableSize_; - newTable->tableSize_ = oldTableSize; + label oldSize = tableSize_; + tableSize_ = tmpTable->tableSize_; + tmpTable->tableSize_ = oldSize; hashedEntry** oldTable = table_; - table_ = newTable->table_; - newTable->table_ = oldTable; + table_ = tmpTable->table_; + tmpTable->table_ = oldTable; - delete newTable; + delete tmpTable; } @@ -556,6 +502,19 @@ void Foam::HashTable<T, Key, Hash>::clearStorage() } +template<class T, class Key, class Hash> +void Foam::HashTable<T, Key, Hash>::shrink() +{ + const label newSize = HashTableCore::canonicalSize(nElmts_); + + if (newSize < tableSize_) + { + // avoid having the table disappear on us + resize(newSize ? newSize : 2); + } +} + + template<class T, class Key, class Hash> void Foam::HashTable<T, Key, Hash>::transfer(HashTable<T, Key, Hash>& ht) { @@ -619,18 +578,12 @@ bool Foam::HashTable<T, Key, Hash>::operator== const HashTable<T, Key, Hash>& rhs ) const { - // Are all my elements in rhs? - for (const_iterator iter = cbegin(); iter != cend(); ++iter) + // sizes (number of keys) must match + if (size() != rhs.size()) { - const_iterator fnd = rhs.find(iter.key()); - - if (fnd == rhs.cend() || fnd() != iter()) - { - return false; - } + return false; } - // Are all rhs elements in me? for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { const_iterator fnd = find(iter.key()); @@ -640,6 +593,7 @@ bool Foam::HashTable<T, Key, Hash>::operator== return false; } } + return true; } diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H index 666b93ebec80fe331e7a2f656bf3a4307b09476e..a945859880a15c6da17ad2e5e7dba099ac3536ba 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTable.H @@ -71,23 +71,60 @@ Ostream& operator<<(Ostream&, const HashTable<T, Key, Hash>&); /*---------------------------------------------------------------------------*\ - Class HashTableName Declaration + Class HashTableCore Declaration \*---------------------------------------------------------------------------*/ -TemplateName(HashTable); +//- Template-invariant bits for HashTable +struct HashTableCore +{ + //- Return a canonical (power-of-two) size + static label canonicalSize(const label); + + //- Maximum allowable table size + static const label maxTableSize; + + //- Construct null + HashTableCore() + {} + + //- Define template name and debug + ClassName("HashTable"); + + //- A zero-sized end iterator + struct iteratorEnd + { + //- Construct null + iteratorEnd() + {} + }; + + //- iteratorEnd set to beyond the end of any HashTable + inline static iteratorEnd cend() + { + return iteratorEnd(); + } + + //- iteratorEnd set to beyond the end of any HashTable + inline static iteratorEnd end() + { + return iteratorEnd(); + } + +}; /*---------------------------------------------------------------------------*\ - Class HashTable Declaration + Class HashTable Declaration \*---------------------------------------------------------------------------*/ template<class T, class Key=word, class Hash=string::hash> class HashTable : - public HashTableName + public HashTableCore { // Private data type for table entries + //- Structure to hold a hashed entry with SLList for collisions struct hashedEntry { //- The lookup key @@ -99,18 +136,15 @@ class HashTable //- The data object T obj_; - //- Constructors + //- Construct from key, next pointer and object + inline hashedEntry(const Key&, hashedEntry* next, const T&); - //- Construct given key, next pointer and object - inline hashedEntry - ( - const Key&, - hashedEntry* next, - const T& newEntry - ); + private: + //- Disallow default bitwise copy construct + hashedEntry(const hashedEntry&); - //- Dissallow construction as copy - hashedEntry(const hashedEntry&); + //- Disallow default bitwise assignment + void operator=(const hashedEntry&); }; @@ -119,7 +153,7 @@ class HashTable //- The current number of elements in table label nElmts_; - //- Number of primary entries allocated in table (not necessarily used) + //- Number of primary entries allocated in table label tableSize_; //- The table of primary entries @@ -140,17 +174,23 @@ class HashTable public: + // Forward declaration of iterators + + class iteratorBase; + class iterator; + class const_iterator; + //- Declare friendship with the HashPtrTable class template<class T2, class Key2, class Hash2> friend class HashPtrTable; + //- Declare friendship with the iteratorBase + friend class iteratorBase; - // Forward declaration of STL iterators - - class iterator; + //- Declare friendship with the iterator friend class iterator; - class const_iterator; + //- Declare friendship with the const_iterator friend class const_iterator; @@ -178,7 +218,10 @@ public: // Access - //- Return number of elements in table. + //- The size of the underlying table + inline label capacity() const; + + //- Return number of elements in table inline label size() const; //- Return true if the hash table is empty @@ -212,10 +255,11 @@ public: //- Assign a new hashedEntry, overwriting existing entries inline bool set(const Key&, const T& newElmt); - //- Erase an hashedEntry specified by given iterator + //- Erase a hashedEntry specified by given iterator + // This invalidates the iterator until the next operator++ bool erase(const iterator&); - //- Erase an hashedEntry specified by given key if in table + //- Erase a hashedEntry specified by the given key bool erase(const Key&); //- Remove entries given by the listed keys from this HashTable @@ -224,10 +268,10 @@ public: //- Remove entries given by the given keys from this HashTable // Return the number of elements removed. - // The parameter HashTable needs the same type of keys, but - // but the type of values held is arbitrary. - template<class AnyType> - label erase(const HashTable<AnyType, Key, Hash>&); + // The parameter HashTable needs the same type of key, but the + // type of values held and the hashing function are arbitrary. + template<class AnyType, class AnyHash> + label erase(const HashTable<AnyType, Key, AnyHash>&); //- Resize the hash table for efficiency void resize(const label newSize); @@ -239,31 +283,33 @@ public: // Equivalent to clear() followed by resize(0) void clearStorage(); + //- Shrink the allocated table to approx. twice number of elements + void shrink(); + //- Transfer the contents of the argument table into this table // and annull the argument table. void transfer(HashTable<T, Key, Hash>&); //- Transfer contents to the Xfer container - inline Xfer<HashTable<T, Key, Hash> > xfer(); + inline Xfer< HashTable<T, Key, Hash> > xfer(); // Member Operators - //- Find and return an hashedEntry + //- Find and return a hashedEntry inline T& operator[](const Key&); - //- Find and return an hashedEntry + //- Find and return a hashedEntry inline const T& operator[](const Key&) const; - //- Find and return an hashedEntry, create it null if not present. + //- Find and return a hashedEntry, create it null if not present inline T& operator()(const Key&); //- Assignment void operator=(const HashTable<T, Key, Hash>&); - //- Equality. Two hash tables are equal if all contents of first are - // also in second and vice versa. So does not depend on table size or - // order! + //- Equality. Hash tables are equal if the keys and values are equal. + // Independent of table storage size and table order. bool operator==(const HashTable<T, Key, Hash>&) const; //- The opposite of the equality operation. Takes linear time. @@ -289,134 +335,193 @@ public: typedef label size_type; - // STL iterator + // Iterators and helpers - //- An STL-conforming iterator - class iterator + //- The iterator base for HashTable + // Note: data and functions are protected, to allow reuse by iterator + // and prevent most external usage. + // iterator and const_iterator have the same size, allowing + // us to reinterpret_cast between them (if desired) + class iteratorBase { - friend class HashTable; - friend class const_iterator; + // Private Data - // Private data - - //- Reference to the HashTable this is an iterator for - HashTable<T, Key, Hash>& hashTable_; + //- Pointer to the HashTable for which this is an iterator + // This also lets us use the default bitwise copy/assignment + HashTable<T, Key, Hash>* hashTable_; //- Current element - hashedEntry* elmtPtr_; + hashedEntry* entryPtr_; //- Current hash index label hashIndex_; - public: + protected: + + // Protected Member Functions // Constructors + //- Construct null - equivalent to an 'end' position + inline iteratorBase(); + + //- Construct from hash table, moving to its 'begin' position + inline explicit iteratorBase + ( + const HashTable<T, Key, Hash>* curHashTable + ); + //- Construct from hash table, element and hash index - inline iterator + inline explicit iteratorBase ( - HashTable<T, Key, Hash>& curHashTable, - hashedEntry* elmt, - label hashIndex + const HashTable<T, Key, Hash>* curHashTable, + const hashedEntry* elmt, + const label hashIndex ); + + //- Increment to the next position + inline void increment(); + + //- Erase the HashTable element at the current position + bool erase(); + + //- Return non-const access to referenced object + inline T& object(); + + //- Return const access to referenced object + inline const T& cobject() const; + + public: + // Member operators - inline void operator=(const iterator&); + // Access + + //- Return the Key corresponding to the iterator + inline const Key& key() const; + + //- Compare hashedEntry element pointers + inline bool operator==(const iteratorBase&) const; + inline bool operator!=(const iteratorBase&) const; + + //- Compare hashedEntry to iteratorEnd pointers + inline bool operator==(const iteratorEnd& unused) const; + inline bool operator!=(const iteratorEnd& unused) const; + }; + + + //- An STL-conforming iterator + class iterator + : + public iteratorBase + { + friend class HashTable; + + // Private Member Functions + + //- Construct from hash table, moving to its 'begin' position + inline explicit iterator + ( + HashTable<T, Key, Hash>* curHashTable + ); + + //- Construct from hash table, element and hash index + inline explicit iterator + ( + HashTable<T, Key, Hash>* curHashTable, + hashedEntry* elmt, + const label hashIndex + ); + + public: + + // Constructors + + //- Construct null (end iterator) + inline iterator(); + + //- Construct end iterator + inline iterator(const iteratorEnd& unused); + + // Member operators - inline bool operator==(const iterator&) const; - inline bool operator!=(const iterator&) const; + //- Conversion to a const_iterator + inline operator const_iterator() const; - inline bool operator==(const const_iterator&) const; - inline bool operator!=(const const_iterator&) const; + // Access + //- Return referenced hash value inline T& operator*(); inline T& operator()(); + //- Return referenced hash value inline const T& operator*() const; inline const T& operator()() const; inline iterator& operator++(); inline iterator operator++(int); - - inline const Key& key() const; }; - //- iterator set to the begining of the HashTable inline iterator begin(); - //- iterator set to beyond the end of the HashTable - inline const iterator& end(); - // STL const_iterator //- An STL-conforming const_iterator class const_iterator + : + public iteratorBase { - friend class iterator; - - // Private data - - //- Reference to the HashTable this is an iterator for - const HashTable<T, Key, Hash>& hashTable_; - - //- Current element - const hashedEntry* elmtPtr_; - - //- Current hash index - label hashIndex_; - + friend class HashTable; - public: + // Private Member Functions - // Constructors + //- Construct from hash table, moving to its 'begin' position + inline explicit const_iterator + ( + const HashTable<T, Key, Hash>* curHashTable + ); //- Construct from hash table, element and hash index - inline const_iterator + inline explicit const_iterator ( - const HashTable<T, Key, Hash>& curHashTable, + const HashTable<T, Key, Hash>* curHashTable, const hashedEntry* elmt, - label hashIndex + const label hashIndex ); - //- Construct from the non-const iterator - inline const_iterator(const iterator&); + public: + // Constructors - // Member operators + //- Construct null (end iterator) + inline const_iterator(); - inline void operator=(const const_iterator&); + //- Construct end iterator + inline const_iterator(const iteratorEnd& unused); - inline bool operator==(const const_iterator&) const; - inline bool operator!=(const const_iterator&) const; + // Member operators - inline bool operator==(const iterator&) const; - inline bool operator!=(const iterator&) const; + // Access + //- Return referenced hash value inline const T& operator*() const; inline const T& operator()() const; inline const_iterator& operator++(); inline const_iterator operator++(int); - inline const Key& key() const; }; //- const_iterator set to the beginning of the HashTable inline const_iterator cbegin() const; - //- const_iterator set to beyond the end of the HashTable - inline const const_iterator& cend() const; - //- const_iterator set to the beginning of the HashTable inline const_iterator begin() const; - //- const_iterator set to beyond the end of the HashTable - inline const const_iterator& end() const; - // IOstream Operator @@ -432,14 +537,6 @@ public: const HashTable<T, Key, Hash>& ); - -private: - - //- iterator returned by end() - iterator endIter_; - - //- const_iterator returned by end() - const_iterator endConstIter_; }; diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C new file mode 100644 index 0000000000000000000000000000000000000000..1162ad5c1d717f7eb2c33fe6f39a4e5d390b36e5 --- /dev/null +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableCore.C @@ -0,0 +1,67 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "HashTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::HashTableCore, 0); + +const Foam::label Foam::HashTableCore::maxTableSize +( + Foam::HashTableCore::canonicalSize + ( + Foam::labelMax/2 + ) +); + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::label Foam::HashTableCore::canonicalSize(const label size) +{ + if (size < 1) + { + return 0; + } + + // enforce power of two + unsigned int goodSize = size; + + if (goodSize & (goodSize - 1)) + { + // brute-force is fast enough + goodSize = 1; + while (goodSize < unsigned(size)) + { + goodSize <<= 1; + } + } + + return goodSize; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H index 5212d57f5168d289e5fcdc6b9fdedef1e9569632..610f3ccf2fd059c8a9700ee2da0985147824e2f1 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableI.H @@ -33,12 +33,12 @@ inline Foam::HashTable<T, Key, Hash>::hashedEntry::hashedEntry ( const Key& key, hashedEntry* next, - const T& newEntry + const T& obj ) : key_(key), next_(next), - obj_(newEntry) + obj_(obj) {} @@ -55,6 +55,13 @@ Foam::HashTable<T, Key, Hash>::hashKeyIndex(const Key& key) const // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template<class T, class Key, class Hash> +inline Foam::label Foam::HashTable<T, Key, Hash>::capacity() const +{ + return tableSize_; +} + + template<class T, class Key, class Hash> inline Foam::label Foam::HashTable<T, Key, Hash>::size() const { @@ -152,70 +159,218 @@ inline T& Foam::HashTable<T, Key, Hash>::operator()(const Key& key) } -// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * iterator base * * * * * * * * * * * * * * * // template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::iterator::iterator +inline Foam::HashTable<T, Key, Hash>::iteratorBase::iteratorBase() +: + hashTable_(0), + entryPtr_(0), + hashIndex_(0) +{} + + +template<class T, class Key, class Hash> +inline Foam::HashTable<T, Key, Hash>::iteratorBase::iteratorBase ( - HashTable<T, Key, Hash>& hashTbl, - hashedEntry* elmt, - label hashIndex + const HashTable<T, Key, Hash>* hashTbl ) : - hashTable_(hashTbl), - elmtPtr_(elmt), - hashIndex_(hashIndex) -{} + hashTable_(const_cast<HashTable<T, Key, Hash>*>(hashTbl)), + entryPtr_(0), + hashIndex_(0) +{ + if (hashTable_->nElmts_ && hashTable_->table_) + { + // find first non-NULL table entry + while + ( + !(entryPtr_ = hashTable_->table_[hashIndex_]) + && ++hashIndex_ < hashTable_->tableSize_ + ) + {} + + if (hashIndex_ >= hashTable_->tableSize_) + { + // make into an end iterator + entryPtr_ = 0; + hashIndex_ = 0; + } + } +} template<class T, class Key, class Hash> -inline void Foam::HashTable<T, Key, Hash>::iterator::operator= +inline Foam::HashTable<T, Key, Hash>::iteratorBase::iteratorBase ( - const iterator& iter + const HashTable<T, Key, Hash>* hashTbl, + const hashedEntry* elmt, + const label hashIndex ) +: + hashTable_(const_cast<HashTable<T, Key, Hash>*>(hashTbl)), + entryPtr_(const_cast<hashedEntry*>(elmt)), + hashIndex_(hashIndex) +{} + + +template<class T, class Key, class Hash> +inline void +Foam::HashTable<T, Key, Hash>::iteratorBase::increment() +{ + // A negative index is a special value from erase + if (hashIndex_ < 0) + { + // the markPos='-curPos-1', but we wish to continue at 'curPos-1' + // thus use '-(markPos+1) -1' + hashIndex_ = -(hashIndex_+1) - 1; + } + else if (entryPtr_) + { + if (entryPtr_->next_) + { + // Move to next element on the SLList + entryPtr_ = entryPtr_->next_; + return; + } + } + // else + // { + // // if we reach here (entryPtr_ is NULL) it is already at the end() + // // we should probably stop + // } + + + // Step to the next table entry + while + ( + ++hashIndex_ < hashTable_->tableSize_ + && !(entryPtr_ = hashTable_->table_[hashIndex_]) + ) + {} + + if (hashIndex_ >= hashTable_->tableSize_) + { + // make into an end iterator + entryPtr_ = 0; + hashIndex_ = 0; + } +} + + +template<class T, class Key, class Hash> +inline +const Key& Foam::HashTable<T, Key, Hash>::iteratorBase::key() const +{ + return entryPtr_->key_; +} + + +template<class T, class Key, class Hash> +inline T& +Foam::HashTable<T, Key, Hash>::iteratorBase::object() { - elmtPtr_ = iter.elmtPtr_; - hashIndex_ = iter.hashIndex_; + return entryPtr_->obj_; } template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::iterator::operator== +inline const T& +Foam::HashTable<T, Key, Hash>::iteratorBase::cobject() const +{ + return entryPtr_->obj_; +} + + +template<class T, class Key, class Hash> +inline bool Foam::HashTable<T, Key, Hash>::iteratorBase::operator== ( - const iterator& iter + const iteratorBase& iter ) const { - return elmtPtr_ == iter.elmtPtr_; + return entryPtr_ == iter.entryPtr_; } template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::iterator::operator!= +inline bool Foam::HashTable<T, Key, Hash>::iteratorBase::operator!= ( - const iterator& iter + const iteratorBase& iter ) const { - return elmtPtr_ != iter.elmtPtr_; + return entryPtr_ != iter.entryPtr_; } template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::iterator::operator== +inline bool Foam::HashTable<T, Key, Hash>::iteratorBase::operator== ( - const const_iterator& iter + const iteratorEnd& ) const { - return elmtPtr_ == iter.elmtPtr_; + return !entryPtr_; } template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::iterator::operator!= +inline bool Foam::HashTable<T, Key, Hash>::iteratorBase::operator!= ( - const const_iterator& iter + const iteratorEnd& ) const { - return elmtPtr_ != iter.elmtPtr_; + return entryPtr_; +} + + +// * * * * * * * * * * * * * * * * STL iterator * * * * * * * * * * * * * * // + +template<class T, class Key, class Hash> +inline Foam::HashTable<T, Key, Hash>::iterator::iterator() +: + iteratorBase() +{} + + +template<class T, class Key, class Hash> +inline Foam::HashTable<T, Key, Hash>::iterator::iterator +( + const iteratorEnd& +) +: + iteratorBase() +{} + + +template<class T, class Key, class Hash> +inline Foam::HashTable<T, Key, Hash>::iterator::iterator +( + HashTable<T, Key, Hash>* hashTbl +) +: + iteratorBase(hashTbl) +{} + + +template<class T, class Key, class Hash> +inline Foam::HashTable<T, Key, Hash>::iterator::iterator +( + HashTable<T, Key, Hash>* hashTbl, + hashedEntry* elmt, + const label hashIndex +) +: + iteratorBase(hashTbl, elmt, hashIndex) +{} + + +template<class T, class Key, class Hash> +inline Foam::HashTable<T, Key, Hash>::iterator::operator +typename Foam::HashTable<T, Key, Hash>::const_iterator() const +{ + return *reinterpret_cast + < + const typename Foam::HashTable<T, Key, Hash>::const_iterator* + >(this); } @@ -223,7 +378,7 @@ template<class T, class Key, class Hash> inline T& Foam::HashTable<T, Key, Hash>::iterator::operator*() { - return elmtPtr_->obj_; + return this->object(); } @@ -231,7 +386,7 @@ template<class T, class Key, class Hash> inline T& Foam::HashTable<T, Key, Hash>::iterator::operator()() { - return elmtPtr_->obj_; + return this->object(); } @@ -239,7 +394,7 @@ template<class T, class Key, class Hash> inline const T& Foam::HashTable<T, Key, Hash>::iterator::operator*() const { - return elmtPtr_->obj_; + return this->cobject(); } @@ -247,7 +402,7 @@ template<class T, class Key, class Hash> inline const T& Foam::HashTable<T, Key, Hash>::iterator::operator()() const { - return elmtPtr_->obj_; + return this->cobject(); } @@ -256,53 +411,18 @@ inline typename Foam::HashTable<T, Key, Hash>::iterator& Foam::HashTable<T, Key, Hash>::iterator::operator++() { - // Check for special value from erase. (sets hashIndex to -1) - if (hashIndex_ >= 0) - { - // Do we have additional elements on the SLList? - if (elmtPtr_ && elmtPtr_->next_) - { - elmtPtr_ = elmtPtr_->next_; - return *this; - } - } - - // Step to the next table entry - while - ( - ++hashIndex_ < hashTable_.tableSize_ - && !(elmtPtr_ = hashTable_.table_[hashIndex_]) - ) - {} - - if (hashIndex_ == hashTable_.tableSize_) - { - // make end iterator - elmtPtr_ = 0; - hashIndex_ = 0; - } + this->increment(); return *this; } template<class T, class Key, class Hash> inline typename Foam::HashTable<T, Key, Hash>::iterator -Foam::HashTable<T, Key, Hash>::iterator::operator++ -( - int -) +Foam::HashTable<T, Key, Hash>::iterator::operator++(int) { - iterator tmp = *this; - ++*this; - return tmp; -} - - -template<class T, class Key, class Hash> -inline -const Key& Foam::HashTable<T, Key, Hash>::iterator::key() const -{ - return elmtPtr_->key_; + iterator old = *this; + this->increment(); + return old; } @@ -310,135 +430,64 @@ template<class T, class Key, class Hash> inline typename Foam::HashTable<T, Key, Hash>::iterator Foam::HashTable<T, Key, Hash>::begin() { - label i = 0; - - if (nElmts_) - { - while (table_ && !table_[i] && ++i < tableSize_) - {} - } - else - { - i = tableSize_; - } - - if (i == tableSize_) - { -# ifdef FULLDEBUG - if (debug) - { - Info<< "HashTable is empty\n"; - } -# endif - - return HashTable<T, Key, Hash>::endIter_; - } - else - { - return iterator(*this, table_[i], i); - } -} - - -template<class T, class Key, class Hash> -inline const typename Foam::HashTable<T, Key, Hash>::iterator& -Foam::HashTable<T, Key, Hash>::end() -{ - return HashTable<T, Key, Hash>::endIter_; + return iterator(this); } // * * * * * * * * * * * * * * * STL const_iterator * * * * * * * * * * * * * // template<class T, class Key, class Hash> -inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator -( - const HashTable<T, Key, Hash>& hashTbl, - const hashedEntry* elmt, - label hashIndex -) +inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator() : - hashTable_(hashTbl), - elmtPtr_(elmt), - hashIndex_(hashIndex) + iteratorBase() {} template<class T, class Key, class Hash> inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator ( - const iterator& iter + const iteratorEnd& ) : - hashTable_(iter.hashTable_), - elmtPtr_(iter.elmtPtr_), - hashIndex_(iter.hashIndex_) + iteratorBase() {} template<class T, class Key, class Hash> -inline void Foam::HashTable<T, Key, Hash>::const_iterator::operator= +inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator ( - const const_iterator& iter + const HashTable<T, Key, Hash>* hashTbl ) -{ - elmtPtr_ = iter.elmtPtr_; - hashIndex_ = iter.hashIndex_; -} - - -template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::const_iterator::operator== -( - const const_iterator& iter -) const -{ - return elmtPtr_ == iter.elmtPtr_; -} - - -template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::const_iterator::operator!= -( - const const_iterator& iter -) const -{ - return elmtPtr_ != iter.elmtPtr_; -} - - -template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::const_iterator::operator== -( - const iterator& iter -) const -{ - return elmtPtr_ == iter.elmtPtr_; -} +: + iteratorBase(hashTbl) +{} template<class T, class Key, class Hash> -inline bool Foam::HashTable<T, Key, Hash>::const_iterator::operator!= +inline Foam::HashTable<T, Key, Hash>::const_iterator::const_iterator ( - const iterator& iter -) const -{ - return elmtPtr_ != iter.elmtPtr_; -} + const HashTable<T, Key, Hash>* hashTbl, + const hashedEntry* elmt, + const label hashIndex +) +: + iteratorBase(hashTbl, elmt, hashIndex) +{} template<class T, class Key, class Hash> inline const T& Foam::HashTable<T, Key, Hash>::const_iterator::operator*() const { - return elmtPtr_->obj_; + return this->cobject(); } + template<class T, class Key, class Hash> inline const T& Foam::HashTable<T, Key, Hash>::const_iterator::operator()() const { - return elmtPtr_->obj_; + return this->cobject(); } @@ -447,43 +496,18 @@ inline typename Foam::HashTable<T, Key, Hash>::const_iterator& Foam::HashTable<T, Key, Hash>::const_iterator::operator++() { - if - ( - !(elmtPtr_ = elmtPtr_->next_) - && ++hashIndex_ < hashTable_.tableSize_ - && !(elmtPtr_ = hashTable_.table_[hashIndex_]) - ) - { - while - ( - ++hashIndex_ < hashTable_.tableSize_ - && !(elmtPtr_ = hashTable_.table_[hashIndex_]) - ) - {} - } - + this->increment(); return *this; } template<class T, class Key, class Hash> inline typename Foam::HashTable<T, Key, Hash>::const_iterator -Foam::HashTable<T, Key, Hash>::const_iterator::operator++ -( - int -) -{ - const_iterator tmp = *this; - ++*this; - return tmp; -} - - -template<class T, class Key, class Hash> -inline -const Key& Foam::HashTable<T, Key, Hash>::const_iterator::key() const +Foam::HashTable<T, Key, Hash>::const_iterator::operator++(int) { - return elmtPtr_->key_; + const_iterator old = *this; + this->increment(); + return old; } @@ -491,41 +515,7 @@ template<class T, class Key, class Hash> inline typename Foam::HashTable<T, Key, Hash>::const_iterator Foam::HashTable<T, Key, Hash>::cbegin() const { - label i = 0; - - if (nElmts_) - { - while (table_ && !table_[i] && ++i < tableSize_) - {} - } - else - { - i = tableSize_; - } - - if (i == tableSize_) - { -# ifdef FULLDEBUG - if (debug) - { - Info<< "HashTable is empty\n"; - } -# endif - - return HashTable<T, Key, Hash>::endConstIter_; - } - else - { - return const_iterator(*this, table_[i], i); - } -} - - -template<class T, class Key, class Hash> -inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& -Foam::HashTable<T, Key, Hash>::cend() const -{ - return HashTable<T, Key, Hash>::endConstIter_; + return const_iterator(this); } @@ -537,12 +527,4 @@ Foam::HashTable<T, Key, Hash>::begin() const } -template<class T, class Key, class Hash> -inline const typename Foam::HashTable<T, Key, Hash>::const_iterator& -Foam::HashTable<T, Key, Hash>::end() const -{ - return HashTable<T, Key, Hash>::endConstIter_; -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C index bef0cf50bcac828e5c7d5655d2c3acc1fd9837d4..0459dcab68d3a4c06e12366a4b6ef6c257c22a5d 100644 --- a/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/HashTable/HashTableIO.C @@ -33,16 +33,19 @@ License template<class T, class Key, class Hash> Foam::HashTable<T, Key, Hash>::HashTable(Istream& is, const label size) : - HashTableName(), + HashTableCore(), nElmts_(0), - tableSize_(canonicalSize(size)), - table_(new hashedEntry*[tableSize_]), - endIter_(*this, NULL, 0), - endConstIter_(*this, NULL, 0) + tableSize_(HashTableCore::canonicalSize(size)), + table_(NULL) { - for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++) + if (tableSize_) { - table_[hashIdx] = 0; + table_ = new hashedEntry*[tableSize_]; + + for (label hashIdx = 0; hashIdx < tableSize_; hashIdx++) + { + table_[hashIdx] = 0; + } } operator>>(is, *this); diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C index 8d5362b89d1afe705eaf5f641384e03c70106b2b..1d0ab2c786046e5d661220779abbd2e0d81ae1e9 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.C @@ -33,8 +33,7 @@ License // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // -template<class T, class Key, class Hash> -Foam::label Foam::StaticHashTable<T, Key, Hash>::canonicalSize(const label size) +Foam::label Foam::StaticHashTableCore::canonicalSize(const label size) { if (size < 1) { @@ -64,8 +63,8 @@ Foam::label Foam::StaticHashTable<T, Key, Hash>::canonicalSize(const label size) template<class T, class Key, class Hash> Foam::StaticHashTable<T, Key, Hash>::StaticHashTable(const label size) : - StaticHashTableName(), - keys_(canonicalSize(size)), + StaticHashTableCore(), + keys_(StaticHashTableCore::canonicalSize(size)), objects_(keys_.size()), nElmts_(0), endIter_(*this, keys_.size(), 0), @@ -89,7 +88,7 @@ Foam::StaticHashTable<T, Key, Hash>::StaticHashTable const StaticHashTable<T, Key, Hash>& ht ) : - StaticHashTableName(), + StaticHashTableCore(), keys_(ht.keys_), objects_(ht.objects_), nElmts_(ht.nElmts_), @@ -105,7 +104,7 @@ Foam::StaticHashTable<T, Key, Hash>::StaticHashTable const Xfer< StaticHashTable<T, Key, Hash> >& ht ) : - StaticHashTableName(), + StaticHashTableCore(), keys_(0), objects_(0), nElmts_(0), @@ -224,15 +223,15 @@ Foam::StaticHashTable<T, Key, Hash>::find template<class T, class Key, class Hash> Foam::List<Key> Foam::StaticHashTable<T, Key, Hash>::toc() const { - List<Key> tofc(nElmts_); - label i = 0; + List<Key> keys(nElmts_); + label keyI = 0; for (const_iterator iter = cbegin(); iter != cend(); ++iter) { - tofc[i++] = iter.key(); + keys[keyI++] = iter.key(); } - return tofc; + return keys; } @@ -319,24 +318,9 @@ bool Foam::StaticHashTable<T, Key, Hash>::erase(const iterator& cit) if (it.elemIndex_ < 0) { // No previous element in the local list - - // Search back for previous non-zero table entry - while (--it.hashIndex_ >= 0 && !objects_[it.hashIndex_].size()) - {} - - if (it.hashIndex_ >= 0) - { - // The last element in the local list - it.elemIndex_ = objects_[it.hashIndex_].size() - 1; - } - else - { - // No previous found. Mark with special value which is - // - not end() - // - handled by operator++ - it.hashIndex_ = -1; - it.elemIndex_ = 0; - } + // Mark with as special value (see notes in HashTable) + it.hashIndex_ = -it.hashIndex_ - 1; + it.elemIndex_ = 0; } nElmts_--; @@ -407,8 +391,8 @@ Foam::label Foam::StaticHashTable<T, Key, Hash>::erase template<class T, class Key, class Hash> void Foam::StaticHashTable<T, Key, Hash>::resize(const label sz) { - label newSize = canonicalSize(sz); - + label newSize = StaticHashTableCore::canonicalSize(sz); + if (newSize == keys_.size()) { # ifdef FULLDEBUG @@ -543,18 +527,8 @@ bool Foam::StaticHashTable<T, Key, Hash>::operator== const StaticHashTable<T, Key, Hash>& rhs ) const { - // Are all my elements in rhs? - for (const_iterator iter = cbegin(); iter != cend(); ++iter) - { - const_iterator fnd = rhs.find(iter.key()); - - if (fnd == rhs.cend() || fnd() != iter()) - { - return false; - } - } + // sizes (number of keys) must match - // Are all rhs elements in me? for (const_iterator iter = rhs.cbegin(); iter != rhs.cend(); ++iter) { const_iterator fnd = find(iter.key()); @@ -564,6 +538,7 @@ bool Foam::StaticHashTable<T, Key, Hash>::operator== return false; } } + return true; } diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H index 25b5933e9da57ed754e609cf6ceec0e91331e3b2..09edf50c4644135cfa6d20330bf8d989894022a9 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTable.H @@ -76,7 +76,33 @@ template<class T, class Key, class Hash> Ostream& operator<< Class StaticHashTableName Declaration \*---------------------------------------------------------------------------*/ -TemplateName(StaticHashTable); +/*---------------------------------------------------------------------------*\ + Class StaticHashTableCore Declaration +\*---------------------------------------------------------------------------*/ + +//- Template-invariant bits for StaticHashTable +struct StaticHashTableCore +{ + //- Return a canonical (power-of-two) size + static label canonicalSize(const label); + + //- Construct null + StaticHashTableCore() + {} + + //- Define template name and debug + ClassName("StaticHashTable"); + + //- A zero-sized end iterator + struct iteratorEnd + { + //- Construct null + iteratorEnd() + {} + }; + +}; + /*---------------------------------------------------------------------------*\ @@ -86,7 +112,7 @@ TemplateName(StaticHashTable); template<class T, class Key=word, class Hash=string::hash> class StaticHashTable : - public StaticHashTableName + public StaticHashTableCore { // Private data type for table entries diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableName.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C similarity index 96% rename from src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableName.C rename to src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C index cb7df68de334d5fd0d51faa110309853f16b8ad3..2ee3b4221ef8dcc991f4f31fa63d25a01c5c9824 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableName.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableCore.C @@ -28,6 +28,6 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -defineTypeNameAndDebug(Foam::StaticHashTableName, 0); +defineTypeNameAndDebug(Foam::StaticHashTableCore, 0); // ************************************************************************* // diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H index abd988a4df4704611be896cd7f798083f09f504c..bd031708e947365fa0ac464834043865907582fa 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableI.H @@ -267,8 +267,13 @@ Foam::StaticHashTable<T, Key, Hash>::Iterator TableRef >::operator++() { - // Check for special value from erase. (sets hashIndex to -1) - if (hashIndex_ >= 0) + // A negative index is a special value from erase + // (see notes in HashTable) + if (hashIndex_ < 0) + { + hashIndex_ = -(hashIndex_+1) - 1; + } + else { // Try the next element on the local list elemIndex_++; diff --git a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C index 3280ad738995f5af13e5aa31fd400be1593abbb2..5b07784266cca0a650b94d413b2ddc35a16a1f34 100644 --- a/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C +++ b/src/OpenFOAM/containers/HashTables/StaticHashTable/StaticHashTableIO.C @@ -37,9 +37,9 @@ Foam::StaticHashTable<T, Key, Hash>::StaticHashTable const label size ) : - StaticHashTableName(), - keys_(size), - objects_(size), + StaticHashTableCore(), + keys_(StaticHashTableCore::canonicalSize(size)), + objects_(StaticHashTableCore::canonicalSize(size)), nElmts_(0), endIter_(*this, keys_.size(), 0), endConstIter_(*this, keys_.size(), 0) diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C index 8e802fe48ea5453089c9073d792d15108ed4284c..e91b725624f8344881d99dc00e89672f59bf6fbe 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.C @@ -28,16 +28,18 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -template<class T> -Foam::CompactListList<T>::CompactListList(const List<List<T> >& ll) +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList(const List<Container>& ll) : - offsets_(ll.size()) + size_(ll.size()), + offsets_(ll.size()+1) { label sumSize = 0; + offsets_[0] = 0; forAll(ll, i) { sumSize += ll[i].size(); - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize); @@ -45,7 +47,7 @@ Foam::CompactListList<T>::CompactListList(const List<List<T> >& ll) label k = 0; forAll(ll, i) { - const List<T>& lli = ll[i]; + const Container& lli = ll[i]; forAll(lli, j) { @@ -55,62 +57,67 @@ Foam::CompactListList<T>::CompactListList(const List<List<T> >& ll) } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( const UList<label>& rowSizes ) : - offsets_(rowSizes.size()) + size_(rowSizes.size()), + offsets_(rowSizes.size()+1) { label sumSize = 0; + offsets_[0] = 0; forAll(rowSizes, i) { sumSize += rowSizes[i]; - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize); } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( const UList<label>& rowSizes, const T& t ) : - offsets_(rowSizes.size()) + size_(rowSizes.size()), + offsets_(rowSizes.size()+1) { label sumSize = 0; + offsets_[0] = 0; forAll(rowSizes, i) { sumSize += rowSizes[i]; - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize, t); } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( - const Xfer<CompactListList<T> >& lst + const Xfer<CompactListList<T, Container> >& lst ) { transfer(lst()); } -template<class T> -Foam::CompactListList<T>::CompactListList +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList ( - CompactListList<T>& lst, + CompactListList<T, Container>& lst, bool reUse ) : + size_(lst.size()), offsets_(lst.offsets_, reUse), m_(lst.m_, reUse) {} @@ -118,22 +125,25 @@ Foam::CompactListList<T>::CompactListList // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class T> -void Foam::CompactListList<T>::setSize(const label nRows) +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize(const label nRows) { if (nRows == 0) { clear(); } - if (nRows < offsets_.size()) + if (nRows < size()) { - offsets_.setSize(nRows); - m_.setSize(offsets_[nRows - 1]); + size_ = nRows; + offsets_.setSize(nRows+1); + m_.setSize(offsets_[nRows]); } - else if (nRows > offsets_.size()) + else if (nRows > size()) { - FatalErrorIn("CompactListList<T>::setSize(const label nRows)") - << "Cannot be used to extend the list from " << offsets_.size() + FatalErrorIn + ( + "CompactListList<T, Container>::setSize(const label nRows)" + ) << "Cannot be used to extend the list from " << offsets_.size() << " to " << nRows << nl << " Please use one of the other setSize member functions" << abort(FatalError); @@ -141,73 +151,83 @@ void Foam::CompactListList<T>::setSize(const label nRows) } -template<class T> -void Foam::CompactListList<T>::setSize +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize ( const label nRows, const label nData ) { - offsets_.setSize(nRows); + size_ = nRows; + offsets_.setSize(nRows+1); m_.setSize(nData); } -template<class T> -void Foam::CompactListList<T>::setSize +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize ( const label nRows, const label nData, const T& t ) { - offsets_.setSize(nRows); + size_ = nRows; + offsets_.setSize(nRows+1); m_.setSize(nData, t); } -template<class T> -void Foam::CompactListList<T>::setSize(const UList<label>& rowSizes) +template<class T, class Container> +void Foam::CompactListList<T, Container>::setSize(const UList<label>& rowSizes) { - offsets_.setSize(rowSizes.size()); + size_ = rowSizes.size(); + offsets_.setSize(rowSizes.size()+1); label sumSize = 0; + offsets_[0] = 0; forAll(rowSizes, i) { sumSize += rowSizes[i]; - offsets_[i] = sumSize; + offsets_[i+1] = sumSize; } m_.setSize(sumSize); } -template<class T> -Foam::labelList Foam::CompactListList<T>::sizes() const +template<class T, class Container> +Foam::labelList Foam::CompactListList<T, Container>::sizes() const { - labelList rowSizes(offsets_.size()); + labelList rowSizes(size()); - label prevOffset = 0; - forAll(offsets_, i) + if (rowSizes.size() > 0) { - rowSizes[i] = offsets_[i]-prevOffset; - prevOffset = offsets_[i]; + forAll(rowSizes, i) + { + rowSizes[i] = offsets_[i+1] - offsets_[i]; + } } return rowSizes; } -template<class T> -void Foam::CompactListList<T>::clear() +template<class T, class Container> +void Foam::CompactListList<T, Container>::clear() { + size_ = 0; offsets_.clear(); m_.clear(); } -template<class T> -void Foam::CompactListList<T>::transfer(CompactListList<T>& a) +template<class T, class Container> +void Foam::CompactListList<T, Container>::transfer +( + CompactListList<T, Container>& a +) { + size_ = a.size_; offsets_.transfer(a.offsets_); m_.transfer(a.m_); } @@ -215,24 +235,15 @@ void Foam::CompactListList<T>::transfer(CompactListList<T>& a) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template<class T> -Foam::List<Foam::List<T> > Foam::CompactListList<T>::operator()() const +template<class T, class Container> +Foam::List<Container> Foam::CompactListList<T, Container>::operator()() +const { - List<List<T> > ll(offsets_.size()); + List<Container> ll(size()); - label offsetPrev = 0; - forAll(offsets_, i) + forAll(ll, i) { - List<T>& lst = ll[i]; - - lst.setSize(offsets_[i] - offsetPrev); - - forAll(lst, j) - { - lst[j] = m_[offsetPrev + j]; - } - - offsetPrev = offsets_[i]; + ll[i] = Container(operator[](i)); } return ll; diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H index f0a80cc1bd8eacd86f6f65b87f07ed9002ce4335..f1875dde70da930c069503e1d9a2e1b1e7ebf956 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListList.H @@ -29,15 +29,17 @@ Description A packed storage unstructured matrix of objects of type \<T\> using an offset table for access. - The offset table is the size of the number of rows whose elements are the + The offset table is the size of the number of rows+1 + whose elements are the accumulated sizes of the rows, i.e. - - offset[i] gives the index of first element of row i + 1 - - offset[i] - offset[i-1] is the number of elements in row i - - and for i = 0, offset[i-1] = 0. + - offset[i] gives the index of first element of row i + - offset[i+1] - offset[i] is the number of elements in row i Storage is allocated on free-store during construction. + As a special case a null-contructed CompactListList has an empty + offsets_ (instead of size 1). + SourceFiles CompactListList.C CompactListListI.H @@ -57,21 +59,23 @@ namespace Foam // Forward declaration of friend functions and operators -template<class T> class CompactListList; +template<class T, class Container> class CompactListList; -template<class T> Istream& operator>>(Istream&, CompactListList<T>&); -template<class T> Ostream& operator<<(Ostream&, const CompactListList<T>&); +template<class T, class Container> Istream& operator>>(Istream&, CompactListList<T, Container>&); +template<class T, class Container> Ostream& operator<<(Ostream&, const CompactListList<T, Container>&); /*---------------------------------------------------------------------------*\ Class CompactListList Declaration \*---------------------------------------------------------------------------*/ -template<class T> +template<class T, class Container = List<T> > class CompactListList { // Private data + label size_; + //- Offset table List<label> offsets_; @@ -84,7 +88,7 @@ public: // Static Member Functions //- Return a null CompactListList - inline static const CompactListList<T>& null(); + inline static const CompactListList<T, Container>& null(); // Constructors @@ -92,7 +96,7 @@ public: inline CompactListList(); //- Construct by converting given List<List<T> > - CompactListList(const List<List<T> >&); + explicit CompactListList(const List<Container>&); //- Construct given size of offset table (number of rows) // and number of data. @@ -103,22 +107,22 @@ public: inline CompactListList(const label nRows, const label nData, const T&); //- Construct given list of row-sizes. - CompactListList(const UList<label>& rowSizes); + explicit CompactListList(const UList<label>& rowSizes); //- Construct given list of row-sizes CompactListList(const UList<label>& rowSizes, const T&); //- Construct by transferring the parameter contents - CompactListList(const Xfer<CompactListList<T> >&); + explicit CompactListList(const Xfer<CompactListList<T, Container> >&); //- Construct as copy or re-use as specified. - CompactListList(CompactListList<T>&, bool reUse); + CompactListList(CompactListList<T, Container>&, bool reUse); //- Construct from Istream. CompactListList(Istream&); //- Clone - inline autoPtr<CompactListList<T> > clone() const; + inline autoPtr<CompactListList<T, Container> > clone() const; // Member Functions @@ -131,7 +135,7 @@ public: //- Return true if the number of rows is zero inline bool empty() const; - //- Return the offset table + //- Return the offset table (= size()+1) inline const List<label>& offsets() const; //- Return non-const access to the offset table @@ -180,10 +184,10 @@ public: //- Transfer the contents of the argument CompactListList // into this CompactListList and annull the argument list. - void transfer(CompactListList<T>&); + void transfer(CompactListList<T, Container>&); //- Transfer the contents to the Xfer container - inline Xfer<CompactListList<T> > xfer(); + inline Xfer<CompactListList<T, Container> > xfer(); // Other @@ -211,8 +215,8 @@ public: //- Return const subscript-checked element. inline const T& operator()(const label i, const label j) const; - //- Return as List<List<T> > - List<List<T> > operator()() const; + //- Return as List<Container> + List<Container> operator()() const; //- Assignment of all entries to the given value inline void operator=(const T&); @@ -222,10 +226,18 @@ public: //- Read CompactListList from Istream, discarding contents // of existing CompactListList. - friend Istream& operator>> <T>(Istream&, CompactListList<T>&); + friend Istream& operator>> <T, Container> + ( + Istream&, + CompactListList<T, Container>& + ); // Write CompactListList to Ostream. - friend Ostream& operator<< <T>(Ostream&, const CompactListList<T>&); + friend Ostream& operator<< <T, Container> + ( + Ostream&, + const CompactListList<T, Container>& + ); }; diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H index dc57627911d5c63e8175b059731bf6d1ded3f27e..59a2ba8ddd75fad08ef0ccedf66c0a25a0970169 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListI.H @@ -24,142 +24,140 @@ License \*---------------------------------------------------------------------------*/ +#include "ListOps.H" +#include "SubList.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template<class T> -inline Foam::CompactListList<T>::CompactListList() +template<class T, class Container> +inline Foam::CompactListList<T, Container>::CompactListList() +: + size_(0) {} -template<class T> -inline Foam::CompactListList<T>::CompactListList +template<class T, class Container> +inline Foam::CompactListList<T, Container>::CompactListList ( const label nRows, const label nData ) : - offsets_(nRows, 0), + size_(nRows), + offsets_(nRows+1, 0), m_(nData) {} -template<class T> -inline Foam::CompactListList<T>::CompactListList +template<class T, class Container> +inline Foam::CompactListList<T, Container>::CompactListList ( const label nRows, const label nData, const T& t ) : - offsets_(nRows, 0), + size_(nRows), + offsets_(nRows+1, 0), m_(nData, t) {} -template<class T> -inline Foam::autoPtr<Foam::CompactListList<T> > -Foam::CompactListList<T>::clone() const +template<class T, class Container> +inline Foam::autoPtr<Foam::CompactListList<T, Container> > +Foam::CompactListList<T, Container>::clone() const { - return autoPtr<CompactListList<T> >(new CompactListList<T>(*this)); + return autoPtr<CompactListList<T, Container> > + ( + new CompactListList<T, Container>(*this) + ); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template<class T> -inline const Foam::CompactListList<T>& Foam::CompactListList<T>::null() +template<class T, class Container> +inline const Foam::CompactListList<T, Container>& +Foam::CompactListList<T, Container>::null() { - return *reinterpret_cast< CompactListList<T>* >(0); + return *reinterpret_cast< CompactListList<T, Container>* >(0); } -template<class T> -inline Foam::label Foam::CompactListList<T>::size() const +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::size() const { - return offsets_.size(); + return size_; } -template<class T> -inline bool Foam::CompactListList<T>::empty() const +template<class T, class Container> +inline bool Foam::CompactListList<T, Container>::empty() const { - return offsets_.empty(); + return !size_; } -template<class T> -inline const Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() const +template<class T, class Container> +inline const Foam::List<Foam::label>& +Foam::CompactListList<T, Container>::offsets() const { return offsets_; } -template<class T> -inline Foam::List<Foam::label>& Foam::CompactListList<T>::offsets() +template<class T, class Container> +inline Foam::List<Foam::label>& Foam::CompactListList<T, Container>::offsets() { return offsets_; } -template<class T> -inline const Foam::List<T>& Foam::CompactListList<T>::m() const +template<class T, class Container> +inline const Foam::List<T>& Foam::CompactListList<T, Container>::m() +const { return m_; } -template<class T> -inline Foam::List<T>& Foam::CompactListList<T>::m() +template<class T, class Container> +inline Foam::List<T>& Foam::CompactListList<T, Container>::m() { return m_; } -template<class T> -inline Foam::label Foam::CompactListList<T>::index +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::index ( const label i, const label j ) const { - if (i == 0) - { - return j; - } - else - { - return offsets_[i-1] + j; - } + return offsets_[i] + j; } -template<class T> -inline Foam::label Foam::CompactListList<T>::whichRow(const label i) const +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::whichRow(const label i) +const { if (i < 0 || i >= m_.size()) { FatalErrorIn ( - "CompactListList<T>::whichRow(const label) const" + "CompactListList<T, Container>::whichRow(const label) const" ) << "Index " << i << " outside 0.." << m_.size() << abort(FatalError); } - forAll(offsets_, rowI) - { - if (i < offsets_[rowI]) - { - return rowI; - } - } - - return -1; + return findLower(offsets_, i+1); } -template<class T> -inline Foam::label Foam::CompactListList<T>::whichColumn +template<class T, class Container> +inline Foam::label Foam::CompactListList<T, Container>::whichColumn ( const label row, const label i @@ -169,22 +167,23 @@ inline Foam::label Foam::CompactListList<T>::whichColumn } -template<class T> -inline Foam::Xfer<Foam::CompactListList<T> > Foam::CompactListList<T>::xfer() +template<class T, class Container> +inline Foam::Xfer<Foam::CompactListList<T, Container> > +Foam::CompactListList<T, Container>::xfer() { return xferMove(*this); } -template<class T> -inline void Foam::CompactListList<T>::resize(const label nRows) +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize(const label nRows) { this->setSize(nRows); } -template<class T> -inline void Foam::CompactListList<T>::resize +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize ( const label nRows, const label nData @@ -194,8 +193,8 @@ inline void Foam::CompactListList<T>::resize } -template<class T> -inline void Foam::CompactListList<T>::resize +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize ( const label nRows, const label nData, @@ -206,8 +205,11 @@ inline void Foam::CompactListList<T>::resize } -template<class T> -inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes) +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::resize +( + const UList<label>& rowSizes +) { this->setSize(rowSizes); } @@ -215,42 +217,35 @@ inline void Foam::CompactListList<T>::resize(const UList<label>& rowSizes) // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -template<class T> -inline Foam::UList<T> Foam::CompactListList<T>::operator[] +template<class T, class Container> +inline Foam::UList<T> Foam::CompactListList<T, Container>::operator[] ( const label i ) { - if (i == 0) - { - return UList<T>(m_.begin(), offsets_[i]); - } - else - { - return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]); - } + label start = offsets_[i]; + return UList<T>(&m_[start], offsets_[i+1] - start); } -template<class T> -inline const Foam::UList<T> Foam::CompactListList<T>::operator[] +template<class T, class Container> +inline const Foam::UList<T> +Foam::CompactListList<T, Container>::operator[] ( const label i ) const { - if (i == 0) - { - return UList<T>(m_.begin(), offsets_[i]); - } - else - { - return UList<T>(&m_[offsets_[i-1]], offsets_[i] - offsets_[i-1]); - } + label start = offsets_[i]; + return UList<T> + ( + const_cast<T*>(&m_[start]), + offsets_[i+1] - start + ); } -template<class T> -inline T& Foam::CompactListList<T>::operator() +template<class T, class Container> +inline T& Foam::CompactListList<T, Container>::operator() ( const label i, const label j @@ -260,8 +255,8 @@ inline T& Foam::CompactListList<T>::operator() } -template<class T> -inline const T& Foam::CompactListList<T>::operator() +template<class T, class Container> +inline const T& Foam::CompactListList<T, Container>::operator() ( const label i, const label j @@ -271,8 +266,8 @@ inline const T& Foam::CompactListList<T>::operator() } -template<class T> -inline void Foam::CompactListList<T>::operator=(const T& t) +template<class T, class Container> +inline void Foam::CompactListList<T, Container>::operator=(const T& t) { m_ = t; } diff --git a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C index 0360e60ee6b9ef55dc2ec1f4cd0aa73defd4500b..54fe3e3c70b7f3be69c18b863f0386873b7eae17 100644 --- a/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C +++ b/src/OpenFOAM/containers/Lists/CompactListList/CompactListListIO.C @@ -29,8 +29,8 @@ License // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -template<class T> -Foam::CompactListList<T>::CompactListList(Istream& is) +template<class T, class Container> +Foam::CompactListList<T, Container>::CompactListList(Istream& is) { operator>>(is, *this); } @@ -38,16 +38,25 @@ Foam::CompactListList<T>::CompactListList(Istream& is) // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // -template<class T> -Foam::Istream& Foam::operator>>(Istream& is, CompactListList<T>& lst) +template<class T, class Container> +Foam::Istream& Foam::operator>>(Istream& is, CompactListList<T, Container>& lst) { is >> lst.offsets_ >> lst.m_; + // Note: empty list gets output as two empty lists + if (lst.offsets_.size() == 0) + { + lst.size_ = 0; + } + else + { + lst.size_ = lst.offsets_.size()-1; + } return is; } -template<class T> -Foam::Ostream& Foam::operator<<(Ostream& os, const CompactListList<T>& lst) +template<class T, class Container> +Foam::Ostream& Foam::operator<<(Ostream& os, const CompactListList<T, Container>& lst) { os << lst.offsets_ << lst.m_; return os; diff --git a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H index 76f9527701d4eec378553f1f4767572be282055a..0e59184f668d5efa825f609be1875b73e4763df3 100644 --- a/src/OpenFOAM/containers/Lists/FixedList/FixedList.H +++ b/src/OpenFOAM/containers/Lists/FixedList/FixedList.H @@ -109,17 +109,17 @@ public: //- Null constructor. inline FixedList(); - //- Construct from components - inline FixedList(const T v[Size]); + //- Construct from C-array. + explicit inline FixedList(const T v[Size]); //- Construct from value - inline FixedList(const T&); + explicit inline FixedList(const T&); //- Construct from UList. - inline FixedList(const UList<T>&); + explicit inline FixedList(const UList<T>&); //- Construct from SLList. - inline FixedList(const SLList<T>&); + explicit inline FixedList(const SLList<T>&); //- Copy constructor. inline FixedList(const FixedList<T, Size>&); diff --git a/src/OpenFOAM/containers/Lists/List/List.H b/src/OpenFOAM/containers/Lists/List/List.H index b89f6c95a9f15c2bfe07eddfb3aa537a30c1d9b1..7e623f6560f8008fdedbaa0d132651d8c0c2d0f4 100644 --- a/src/OpenFOAM/containers/Lists/List/List.H +++ b/src/OpenFOAM/containers/Lists/List/List.H @@ -123,22 +123,22 @@ public: //- Construct as copy of FixedList<T, Size> template<unsigned Size> - List(const FixedList<T, Size>&); + explicit List(const FixedList<T, Size>&); //- Construct as copy of PtrList<T> - List(const PtrList<T>&); + explicit List(const PtrList<T>&); //- Construct as copy of SLList<T> - List(const SLList<T>&); + explicit List(const SLList<T>&); //- Construct as copy of IndirectList<T> - List(const IndirectList<T>&); + explicit List(const IndirectList<T>&); //- Construct as copy of UIndirectList<T> - List(const UIndirectList<T>&); + explicit List(const UIndirectList<T>&); //- Construct as copy of BiIndirectList<T> - List(const BiIndirectList<T>&); + explicit List(const BiIndirectList<T>&); //- Construct from Istream. List(Istream&); diff --git a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H index 1e6070e8368ad3a93d765fa112f0febe4ecb9452..82ac19fc0e532305100010cb82cb3fab17bc3899 100644 --- a/src/OpenFOAM/containers/Lists/PackedList/PackedList.H +++ b/src/OpenFOAM/containers/Lists/PackedList/PackedList.H @@ -162,7 +162,7 @@ public: inline PackedList(); //- Construct with given size, initializes list to 0. - inline PackedList(const label size); + explicit inline PackedList(const label size); //- Construct with given size and value for all elements. PackedList(const label size, const unsigned val); @@ -174,7 +174,7 @@ public: inline PackedList(const Xfer< PackedList<nBits> >&); //- Construct from a list of labels - PackedList(const UList<label>&); + explicit PackedList(const UList<label>&); //- Clone inline autoPtr< PackedList<nBits> > clone() const; diff --git a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H index b5167e5ef8977f02334642c9d31f32ed91ac16e3..3f3e6d8fe6c284e32d1683ca6ab0010854c73b40 100644 --- a/src/OpenFOAM/containers/Lists/PtrList/PtrList.H +++ b/src/OpenFOAM/containers/Lists/PtrList/PtrList.H @@ -136,7 +136,7 @@ public: PtrList(PtrList<T>&, bool reUse); //- Construct as copy of SLPtrList<T> - PtrList(const SLPtrList<T>&); + explicit PtrList(const SLPtrList<T>&); //- Construct from Istream using given Istream constructor class template<class INew> diff --git a/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.C b/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.C index aa6118dc42d930a77ad00d5290ca521fffb1c9d1..0d6084671e43ca17bfb66de9a2c9c04199263a64 100644 --- a/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.C +++ b/src/OpenFOAM/containers/Lists/SortableList/ParSortableList.C @@ -114,7 +114,7 @@ void Foam::ParSortableList<Type>::checkAndSend } { - OPstream toSlave(destProcI); + OPstream toSlave(Pstream::blocking, destProcI); toSlave << values << indices; } } @@ -311,7 +311,7 @@ void Foam::ParSortableList<Type>::sort() Pout<< "Receiving from " << procI << endl; } - IPstream fromSlave(procI); + IPstream fromSlave(Pstream::blocking, procI); fromSlave >> recValues >> recIndices; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C index 4ad3f6bbeceea29c60afeb80465e0a1d9f8db7b2..a970d6104cef67f4fd68e867bbdb73b8b839f97f 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.C @@ -24,291 +24,22 @@ License \*---------------------------------------------------------------------------*/ -#include "error.H" #include "IPstream.H" -#include "int.H" -#include "token.H" -#include <cctype> +// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // - -inline void Foam::IPstream::checkEof() -{ - if (bufPosition_ == messageSize_) - { - setEof(); - } -} - - -template<class T> -inline void Foam::IPstream::readFromBuffer(T& t) -{ - const size_t align = sizeof(T); - bufPosition_ = align + ((bufPosition_ - 1) & ~(align - 1)); - - t = reinterpret_cast<T&>(buf_[bufPosition_]); - bufPosition_ += sizeof(T); - checkEof(); -} - - -inline void Foam::IPstream::readFromBuffer +Foam::IPstream::IPstream ( - void* data, - size_t count, - size_t align + const commsTypes commsType, + const int fromProcNo, + const label bufSize, + streamFormat format, + versionNumber version ) -{ - if (align > 1) - { - bufPosition_ = align + ((bufPosition_ - 1) & ~(align - 1)); - } - - register const char* bufPtr = &buf_[bufPosition_]; - register char* dataPtr = reinterpret_cast<char*>(data); - register size_t i = count; - while (i--) *dataPtr++ = *bufPtr++; - bufPosition_ += count; - checkEof(); -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::IPstream::~IPstream() -{ - if (bufPosition_ < messageSize_) - { - FatalErrorIn("IPstream::~IPstream()") - << "Message not fully consumed. messageSize:" << messageSize_ - << " bytes of which only " << bufPosition_ - << " consumed." << Foam::abort(FatalError); - } -} - - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -Foam::Istream& Foam::IPstream::read(token& t) -{ - // Return the put back token if it exists - if (Istream::getBack(t)) - { - return *this; - } - - char c; - - // return on error - if (!read(c)) - { - t.setBad(); - return *this; - } - - // Set the line number of this token to the current stream line number - t.lineNumber() = lineNumber(); - - // Analyse input starting with this character. - switch (c) - { - // Punctuation - case token::END_STATEMENT : - case token::BEGIN_LIST : - case token::END_LIST : - case token::BEGIN_SQR : - case token::END_SQR : - case token::BEGIN_BLOCK : - case token::END_BLOCK : - case token::COLON : - case token::COMMA : - case token::ASSIGN : - case token::ADD : - case token::SUBTRACT : - case token::MULTIPLY : - case token::DIVIDE : - { - t = token::punctuationToken(c); - return *this; - } - - // Word - case token::WORD : - { - word* pval = new word; - if (read(*pval)) - { - if (token::compound::isCompound(*pval)) - { - t = token::compound::New(*pval, *this).ptr(); - delete pval; - } - else - { - t = pval; - } - } - else - { - delete pval; - t.setBad(); - } - return *this; - } - - // String - case token::STRING : - { - string* pval = new string; - if (read(*pval)) - { - t = pval; - } - else - { - delete pval; - t.setBad(); - } - return *this; - } - - // Label - case token::LABEL : - { - label val; - if (read(val)) - { - t = val; - } - else - { - t.setBad(); - } - return *this; - } - - // floatScalar - case token::FLOAT_SCALAR : - { - floatScalar val; - if (read(val)) - { - t = val; - } - else - { - t.setBad(); - } - return *this; - } - - // doubleScalar - case token::DOUBLE_SCALAR : - { - doubleScalar val; - if (read(val)) - { - t = val; - } - else - { - t.setBad(); - } - return *this; - } - - // Character (returned as a single character word) or error - default: - { - if (isalpha(c)) - { - t = word(c); - return *this; - } - - setBad(); - t.setBad(); - - return *this; - } - } -} - - -Foam::Istream& Foam::IPstream::read(char& c) -{ - c = buf_[bufPosition_]; - bufPosition_++; - checkEof(); - return *this; -} - - -Foam::Istream& Foam::IPstream::read(word& str) -{ - size_t len; - readFromBuffer(len); - str = &buf_[bufPosition_]; - bufPosition_ += len + 1; - checkEof(); - return *this; -} - - -Foam::Istream& Foam::IPstream::read(string& str) -{ - size_t len; - readFromBuffer(len); - str = &buf_[bufPosition_]; - bufPosition_ += len + 1; - checkEof(); - return *this; -} - - -Foam::Istream& Foam::IPstream::read(label& val) -{ - readFromBuffer(val); - return *this; -} - - -Foam::Istream& Foam::IPstream::read(floatScalar& val) -{ - readFromBuffer(val); - return *this; -} - - -Foam::Istream& Foam::IPstream::read(doubleScalar& val) -{ - readFromBuffer(val); - return *this; -} - - -Foam::Istream& Foam::IPstream::read(char* data, std::streamsize count) -{ - if (format() != BINARY) - { - FatalErrorIn("IPstream::read(char*, std::streamsize)") - << "stream format not binary" - << Foam::abort(FatalError); - } - - readFromBuffer(data, count, 8); - return *this; -} - - -Foam::Istream& Foam::IPstream::rewind() -{ - bufPosition_ = 0; - return *this; -} +: + Pstream(commsType, bufSize), + UIPstream(commsType, fromProcNo, buf_) +{} // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H index db40ccfd4f5cd37cbb9f6f1fcca0bb814bf7b21c..acc59de87bf045db5171eec073e39c8030f5c83f 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/IPstream.H @@ -38,7 +38,7 @@ SourceFiles #ifndef IPstream_H #define IPstream_H -#include "Istream.H" +#include "UIPstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,26 +52,8 @@ namespace Foam class IPstream : public Pstream, - public Istream + public UIPstream { - // Private data - - int fromProcNo_; - label messageSize_; - - - // Private member functions - - //- Check the bufferPosition_ against messageSize_ for EOF - inline void checkEof(); - - //- Read a T from the transfer buffer - template<class T> - inline void readFromBuffer(T&); - - //- Read data from the transfer buffer - inline void readFromBuffer(void* data, size_t count, size_t align); - public: @@ -88,76 +70,6 @@ public: versionNumber version=currentVersion ); - - // Destructor - - ~IPstream(); - - - // Member functions - - // Inquiry - - //- Return flags of output stream - ios_base::fmtflags flags() const - { - return ios_base::fmtflags(0); - } - - - // Read functions - - //- Read into given buffer from given processor and return the - // message size - static label read - ( - const commsTypes commsType, - const int fromProcNo, - char* buf, - const std::streamsize bufSize - ); - - //- Return next token from stream - Istream& read(token&); - - //- Read a character - Istream& read(char&); - - //- Read a word - Istream& read(word&); - - // Read a string (including enclosing double-quotes) - Istream& read(string&); - - //- Read a label - Istream& read(label&); - - //- Read a floatScalar - Istream& read(floatScalar&); - - //- Read a doubleScalar - Istream& read(doubleScalar&); - - //- Read binary block - Istream& read(char*, std::streamsize); - - //- Rewind and return the stream so that it may be read again - Istream& rewind(); - - - // Edit - - //- Set flags of stream - ios_base::fmtflags flags(const ios_base::fmtflags) - { - return ios_base::fmtflags(0); - } - - - // Print - - //- Print description of IOstream to Ostream - void print(Ostream&) const; }; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.C index ab576d0ef44cc3dbe1d274ea471984e9a454de0a..e2cf40b780f780f5a403e61c472cb6ee123a334f 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.C @@ -22,68 +22,9 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Write primitive and binary block from OPstream - \*---------------------------------------------------------------------------*/ -#include "error.H" - #include "OPstream.H" -#include "int.H" -#include "token.H" - -#include <cctype> - -// * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // - -template<class T> -inline void Foam::OPstream::writeToBuffer(const T& t) -{ - writeToBuffer(&t, sizeof(T), sizeof(T)); -} - - -inline void Foam::OPstream::writeToBuffer(const char& c) -{ - if (size_t(buf_.size()) < bufPosition_ + 1U) - { - enlargeBuffer(1); - } - - buf_[bufPosition_] = c; - bufPosition_ ++; -} - - -inline void Foam::OPstream::writeToBuffer -( - const void* data, - size_t count, - size_t align -) -{ - label oldPos = bufPosition_; - - if (align > 1) - { - // Align bufPosition. Pads bufPosition_ - oldPos characters. - bufPosition_ = align + ((bufPosition_ - 1) & ~(align - 1)); - } - - if (size_t(buf_.size()) < bufPosition_ + count) - { - enlargeBuffer(bufPosition_ - oldPos + count); - } - - register char* bufPtr = &buf_[bufPosition_]; - register const char* dataPtr = reinterpret_cast<const char*>(data); - register size_t i = count; - while (i--) *bufPtr++ = *dataPtr++; - - bufPosition_ += count; -} - // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // @@ -92,137 +33,14 @@ Foam::OPstream::OPstream const commsTypes commsType, const int toProcNo, const label bufSize, + const int tag, streamFormat format, versionNumber version ) : Pstream(commsType, bufSize), - Ostream(format, version), - toProcNo_(toProcNo) -{ - setOpened(); - setGood(); - - if (!bufSize) - { - buf_.setSize(1000); - } -} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -Foam::Ostream& Foam::OPstream::write(const token&) -{ - notImplemented("Ostream& OPstream::write(const token&)"); - setBad(); - return *this; -} - - -Foam::Ostream& Foam::OPstream::write(const char c) -{ - if (!isspace(c)) - { - writeToBuffer(c); - } - - return *this; -} - - -Foam::Ostream& Foam::OPstream::write(const char* str) -{ - word nonWhiteChars(string::validate<word>(str)); - - if (nonWhiteChars.size() == 1) - { - return write(nonWhiteChars.c_str()[1]); - } - else if (nonWhiteChars.size()) - { - return write(nonWhiteChars); - } - else - { - return *this; - } -} - - -Foam::Ostream& Foam::OPstream::write(const word& str) -{ - write(char(token::WORD)); - - size_t len = str.size(); - writeToBuffer(len); - writeToBuffer(str.c_str(), len + 1, 1); - - return *this; -} - - -Foam::Ostream& Foam::OPstream::write(const string& str) -{ - write(char(token::STRING)); - - size_t len = str.size(); - writeToBuffer(len); - writeToBuffer(str.c_str(), len + 1, 1); - - return *this; -} - - -Foam::Ostream& Foam::OPstream::writeQuoted(const std::string& str, const bool) -{ - write(char(token::STRING)); - - size_t len = str.size(); - writeToBuffer(len); - writeToBuffer(str.c_str(), len + 1, 1); - - return *this; -} - - -Foam::Ostream& Foam::OPstream::write(const label val) -{ - write(char(token::LABEL)); - writeToBuffer(val); - return *this; -} - - -Foam::Ostream& Foam::OPstream::write(const floatScalar val) -{ - write(char(token::FLOAT_SCALAR)); - writeToBuffer(val); - return *this; -} - - -Foam::Ostream& Foam::OPstream::write(const doubleScalar val) -{ - write(char(token::DOUBLE_SCALAR)); - writeToBuffer(val); - return *this; -} - - -Foam::Ostream& Foam::OPstream::write(const char* data, std::streamsize count) -{ - if (format() != BINARY) - { - FatalErrorIn("Ostream::write(const char*, std::streamsize)") - << "stream format not binary" - << Foam::abort(FatalError); - } - - writeToBuffer(data, count, 8); - - return *this; -} + UOPstream(commsType, toProcNo, buf_, tag, true, format, version) +{} // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H index bccb5b08efe18a233214fc75f6eaab534d41bbf5..394f9ff4e36ebc1122e946bd0603ee6c7f425348 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/OPstream.H @@ -38,7 +38,7 @@ SourceFiles #ifndef OPstream_H #define OPstream_H -#include "Ostream.H" +#include "UOPstream.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,25 +52,8 @@ namespace Foam class OPstream : public Pstream, - public Ostream + public UOPstream { - // Private data - - int toProcNo_; - - - // Private member functions - - //- Write a T to the transfer buffer - template<class T> - inline void writeToBuffer(const T&); - - //- Write a char to the transfer buffer - inline void writeToBuffer(const char&); - - //- Write data to the transfer buffer - inline void writeToBuffer(const void* data, size_t count, size_t align); - public: @@ -83,126 +66,11 @@ public: const commsTypes commsType, const int toProcNo, const label bufSize = 0, + const int tag = UPstream::msgType(), streamFormat format=BINARY, versionNumber version=currentVersion ); - - // Destructor - - ~OPstream(); - - - // Member functions - - // Inquiry - - //- Return flags of output stream - ios_base::fmtflags flags() const - { - return ios_base::fmtflags(0); - } - - - // Write functions - - //- Write given buffer to given processor - static bool write - ( - const commsTypes commsType, - const int toProcNo, - const char* buf, - const std::streamsize bufSize - ); - - //- Write next token to stream - Ostream& write(const token&); - - //- Write character - Ostream& write(const char); - - //- Write character string - Ostream& write(const char*); - - //- Write word - Ostream& write(const word&); - - //- Write string - Ostream& write(const string&); - - //- Write std::string surrounded by quotes. - // Optional write without quotes. - Ostream& writeQuoted - ( - const std::string&, - const bool quoted=true - ); - - //- Write label - Ostream& write(const label); - - //- Write floatScalar - Ostream& write(const floatScalar); - - //- Write doubleScalar - Ostream& write(const doubleScalar); - - //- Write binary block - Ostream& write(const char*, std::streamsize); - - //- Add indentation characters - void indent() - {} - - - // Stream state functions - - //- Flush stream - void flush() - {} - - //- Add newline and flush stream - void endl() - {} - - //- Get width of output field - int width() const - { - return 0; - } - - //- Set width of output field (and return old width) - int width(const int) - { - return 0; - } - - //- Get precision of output field - int precision() const - { - return 0; - } - - //- Set precision of output field (and return old precision) - int precision(const int) - { - return 0; - } - - - // Edit - - //- Set flags of stream - ios_base::fmtflags flags(const ios_base::fmtflags) - { - return ios_base::fmtflags(0); - } - - - // Print - - //- Print description of IOstream to Ostream - void print(Ostream&) const; }; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.C index 213ae54c76151e3352b406d78701099f80d611c0..5c62c47a99c8061caf5eb71c1df4267655cbcd90 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.C @@ -25,226 +25,16 @@ License \*---------------------------------------------------------------------------*/ #include "Pstream.H" -#include "debug.H" -#include "dictionary.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // defineTypeNameAndDebug(Foam::Pstream, 0); -template<> -const char* Foam::NamedEnum<Foam::Pstream::commsTypes, 3>::names[] = -{ - "blocking", - "scheduled", - "nonBlocking" -}; - -const Foam::NamedEnum<Foam::Pstream::commsTypes, 3> - Foam::Pstream::commsTypeNames; - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::Pstream::setParRun() -{ - parRun_ = true; - - Pout.prefix() = '[' + name(myProcNo()) + "] "; - Perr.prefix() = '[' + name(myProcNo()) + "] "; -} - - -void Foam::Pstream::calcLinearComm(const label nProcs) -{ - linearCommunication_.setSize(nProcs); - - // Master - labelList belowIDs(nProcs - 1); - forAll(belowIDs, i) - { - belowIDs[i] = i + 1; - } - - linearCommunication_[0] = commsStruct - ( - nProcs, - 0, - -1, - belowIDs, - labelList(0) - ); - - // Slaves. Have no below processors, only communicate up to master - for (label procID = 1; procID < nProcs; procID++) - { - linearCommunication_[procID] = commsStruct - ( - nProcs, - procID, - 0, - labelList(0), - labelList(0) - ); - } -} - - -// Append my children (and my children children etc.) to allReceives. -void Foam::Pstream::collectReceives -( - const label procID, - const List<DynamicList<label> >& receives, - DynamicList<label>& allReceives -) -{ - const DynamicList<label>& myChildren = receives[procID]; - - forAll(myChildren, childI) - { - allReceives.append(myChildren[childI]); - collectReceives(myChildren[childI], receives, allReceives); - } -} - - -// Tree like schedule. For 8 procs: -// (level 0) -// 0 receives from 1 -// 2 receives from 3 -// 4 receives from 5 -// 6 receives from 7 -// (level 1) -// 0 receives from 2 -// 4 receives from 6 -// (level 2) -// 0 receives from 4 -// -// The sends/receives for all levels are collected per processor (one send per -// processor; multiple receives possible) creating a table: -// -// So per processor: -// proc receives from sends to -// ---- ------------- -------- -// 0 1,2,4 - -// 1 - 0 -// 2 3 0 -// 3 - 2 -// 4 5 0 -// 5 - 4 -// 6 7 4 -// 7 - 6 -void Foam::Pstream::calcTreeComm(label nProcs) -{ - label nLevels = 1; - while ((1 << nLevels) < nProcs) - { - nLevels++; - } - - List<DynamicList<label> > receives(nProcs); - labelList sends(nProcs, -1); - - // Info<< "Using " << nLevels << " communication levels" << endl; - - label offset = 2; - label childOffset = offset/2; - - for (label level = 0; level < nLevels; level++) - { - label receiveID = 0; - while (receiveID < nProcs) - { - // Determine processor that sends and we receive from - label sendID = receiveID + childOffset; - - if (sendID < nProcs) - { - receives[receiveID].append(sendID); - sends[sendID] = receiveID; - } - - receiveID += offset; - } - - offset <<= 1; - childOffset <<= 1; - } - - // For all processors find the processors it receives data from - // (and the processors they receive data from etc.) - List<DynamicList<label> > allReceives(nProcs); - for (label procID = 0; procID < nProcs; procID++) - { - collectReceives(procID, receives, allReceives[procID]); - } - - - treeCommunication_.setSize(nProcs); - - for (label procID = 0; procID < nProcs; procID++) - { - treeCommunication_[procID] = commsStruct - ( - nProcs, - procID, - sends[procID], - receives[procID].shrink(), - allReceives[procID].shrink() - ); - } -} - - -// Callback from Pstream::init() : initialize linear and tree communication -// schedules now that nProcs is known. -void Foam::Pstream::initCommunicationSchedule() -{ - calcLinearComm(nProcs()); - calcTreeComm(nProcs()); -} - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -// Initialise my process number to 0 (the master) -int Foam::Pstream::myProcNo_(0); - -// By default this is not a parallel run -bool Foam::Pstream::parRun_(false); - -// List of process IDs -Foam::List<int> Foam::Pstream::procIDs_(1, 0); - -// Standard transfer message type -int Foam::Pstream::msgType_(1); - -// Linear communication schedule -Foam::List<Foam::Pstream::commsStruct> Foam::Pstream::linearCommunication_(0); - -// Multi level communication schedule -Foam::List<Foam::Pstream::commsStruct> Foam::Pstream::treeCommunication_(0); - -// Should compact transfer be used in which floats replace doubles -// reducing the bandwidth requirement at the expense of some loss -// in accuracy -bool Foam::Pstream::floatTransfer -( - debug::optimisationSwitch("floatTransfer", 0) -); - -// Number of processors at which the reduce algorithm changes from linear to -// tree -int Foam::Pstream::nProcsSimpleSum -( - debug::optimisationSwitch("nProcsSimpleSum", 16) -); - -// Default commsType -Foam::Pstream::commsTypes Foam::Pstream::defaultCommsType -( - commsTypeNames.read(debug::optimisationSwitches().lookup("commsType")) -); - // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H index f30caf0d9eb2b4c9d1193e869e32b31fd6fb36e0..44f9af58b598bc19335878af93ab4c9bc3434756 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/Pstream.H @@ -30,22 +30,18 @@ Description SourceFiles Pstream.C - PstreamsPrint.C - PstreamCommsStruct.C gatherScatter.C combineGatherScatter.C gatherScatterList.C + exchange.C \*---------------------------------------------------------------------------*/ #ifndef Pstream_H #define Pstream_H -#include "labelList.H" +#include "UPstream.H" #include "DynamicList.H" -#include "HashTable.H" -#include "string.H" -#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,162 +53,16 @@ namespace Foam \*---------------------------------------------------------------------------*/ class Pstream +: + public UPstream { -public: - - //- Types of communications - enum commsTypes - { - blocking, - scheduled, - nonBlocking - }; - - static const NamedEnum<commsTypes, 3> commsTypeNames; - - //- Structure for communicating between processors - class commsStruct - { - // Private data - - //- procID of above processor - label above_; - - //- procIDs of processors directly below me - labelList below_; - - //- procIDs of all processors below (so not just directly below) - labelList allBelow_; - - //- procIDs of all processors not below. (inverse set of allBelow_ - // and minus myProcNo) - labelList allNotBelow_; - - - public: - - // Constructors - - //- Construct null - commsStruct(); - - //- Construct from components - commsStruct - ( - const label, - const labelList&, - const labelList&, - const labelList& - ); - - //- Construct from components; construct allNotBelow_ - commsStruct - ( - const label nProcs, - const label myProcID, - const label, - const labelList&, - const labelList& - ); - - - // Member Functions - - // Access - - label above() const - { - return above_; - } - - const labelList& below() const - { - return below_; - } - - const labelList& allBelow() const - { - return allBelow_; - } - - const labelList& allNotBelow() const - { - return allNotBelow_; - } - - - // Member operators - - bool operator==(const commsStruct&) const; - - bool operator!=(const commsStruct&) const; - - - // Ostream Operator - - friend Ostream& operator<<(Ostream&, const commsStruct&); - }; - - -private: - - // Private data - - static int myProcNo_; - static bool parRun_; - - static List<int> procIDs_; - static int msgType_; - - static List<commsStruct> linearCommunication_; - static List<commsStruct> treeCommunication_; - - - // Private member functions - - //- Set data for parallel running - static void setParRun(); - - //- Calculate linear communication schedule - static void calcLinearComm(const label nProcs); - - //- Calculate tree communication schedule - static void calcTreeComm(const label nProcs); - - //- Helper function for tree communication schedule determination - // Collects all processorIDs below a processor - static void collectReceives - ( - const label procID, - const List<DynamicList<label> >& receives, - DynamicList<label>& allReceives - ); - - //- Initialize all communication schedules. Callback from - // Pstream::init() - static void initCommunicationSchedule(); - - protected: // Protected data - //- Communications type of this stream - commsTypes commsType_; - //- Transfer buffer - List<char> buf_; - - //- Current buffer read/write location - int bufPosition_; - - - // Protected member functions - - //- Increase the size of the transfer buffer - inline void enlargeBuffer(size_t count); - + DynamicList<char> buf_; public: @@ -220,21 +70,6 @@ public: ClassName("Pstream"); - // Static data - - //- Should compact transfer be used in which floats replace doubles - // reducing the bandwidth requirement at the expense of some loss - // in accuracy - static bool floatTransfer; - - //- Number of processors at which the sum algorithm changes from linear - // to tree - static int nProcsSimpleSum; - - //- Default commsType - static commsTypes defaultCommsType; - - // Constructors //- Construct given optional buffer size @@ -244,151 +79,16 @@ public: const label bufSize = 0 ) : - commsType_(commsType), - bufPosition_(0) + UPstream(commsType), + buf_(0) { if (bufSize) { - buf_.setSize(bufSize + 2*sizeof(scalar) + 1); + buf_.setCapacity(bufSize + 2*sizeof(scalar) + 1); } } - // Member functions - - //- Add the valid option this type of communications library - // adds/requires on the command line - static void addValidParOptions(HashTable<string>& validParOptions); - - //- Initialisation function called from main - // Spawns slave processes and initialises inter-communication - static bool init(int& argc, char**& argv); - - //- Non-blocking comms: wait until all have finished. - static void waitRequests(); - - //- Non-blocking comms: has request i finished? - static bool finishedRequest(const label i); - - //- Is this a parallel run? - static bool parRun() - { - return parRun_; - } - - //- Number of processes in parallel run - static label nProcs() - { - return procIDs_.size(); - } - - //- Am I the master process - static bool master() - { - return myProcNo_ == 0; - } - - //- Process index of the master - static int masterNo() - { - return 0; - } - - //- Number of this process (starting from masterNo() = 0) - static int myProcNo() - { - return myProcNo_; - } - - //- Process IDs - static const List<int>& procIDs() - { - return procIDs_; - } - - //- Process ID of given process index - static int procID(int procNo) - { - return procIDs_[procNo]; - } - - //- Process index of first slave - static int firstSlave() - { - return 1; - } - - //- Process index of last slave - static int lastSlave() - { - return nProcs() - 1; - } - - //- Communication schedule for linear all-to-master (proc 0) - static const List<commsStruct>& linearCommunication() - { - return linearCommunication_; - } - - //- Communication schedule for tree all-to-master (proc 0) - static const List<commsStruct>& treeCommunication() - { - return treeCommunication_; - } - - //- Message tag of standard messages - static int& msgType() - { - return msgType_; - } - - - //- Get the communications type of the stream - commsTypes commsType() const - { - return commsType_; - } - - //- Set the communications type of the stream - commsTypes commsType(const commsTypes ct) - { - commsTypes oldCommsType = commsType_; - commsType_ = ct; - return oldCommsType; - } - - //- Transfer buffer - const List<char>& buf() const - { - return buf_; - } - - //- Transfer buffer - List<char>& buf() - { - return buf_; - } - - //- Current buffer read/write location - int bufPosition() const - { - return bufPosition_; - } - - //- Current buffer read/write location - int& bufPosition() - { - return bufPosition_; - } - - - //- Exit program - static void exit(int errnum = 1); - - //- Abort program - static void abort(); - - // Gather and scatter //- Gather data. Apply bop to combine Value @@ -501,8 +201,8 @@ public: // Gather/scatter keeping the individual processor data separate. - // Values is a List of size Pstream::nProcs() where - // Values[Pstream::myProcNo()] is the data for the current processor. + // Values is a List of size UPstream::nProcs() where + // Values[UPstream::myProcNo()] is the data for the current processor. //- Gather data but keep individual values separate template <class T> @@ -527,16 +227,25 @@ public: //- Like above but switches between linear/tree communication template <class T> static void scatterList(List<T>& Values); -}; -inline void Pstream::enlargeBuffer(size_t count) -{ - buf_.setSize(max(int(buf_.size() + count), 2*buf_.size())); -} + // Exchange + //- Exchange data. Sends sendData, receives into recvData, sets + // sizes (not bytes). sizes[p0][p1] is what processor p0 has + // sent to p1. Continuous data only. + // If block=true will wait for all transfers to finish. + template <class Container, class T> + static void exchange + ( + const List<Container >&, + List<Container >&, + labelListList& sizes, + const int tag = UPstream::msgType(), + const bool block = true + ); -Ostream& operator<<(Ostream&, const Pstream::commsStruct&); +}; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -549,9 +258,9 @@ Ostream& operator<<(Ostream&, const Pstream::commsStruct&); # include "gatherScatter.C" # include "combineGatherScatter.C" # include "gatherScatterList.C" +# include "exchange.C" #endif - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #endif diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C new file mode 100644 index 0000000000000000000000000000000000000000..87f940db406263fc8e747134db6197456772cd0a --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C @@ -0,0 +1,117 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "PstreamBuffers.H" + +/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */ + +namespace Foam +{ + + DynamicList<char> PstreamBuffers::nullBuf(0); +} + + +// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // + +Foam::PstreamBuffers::PstreamBuffers +( + const UPstream::commsTypes commsType, + const int tag, + IOstream::streamFormat format, + IOstream::versionNumber version +) +: + commsType_(commsType), + tag_(tag), + format_(format), + version_(version), + sendBuf_(UPstream::nProcs()), + recvBuf_(UPstream::nProcs()), + finishedSendsCalled_(false) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +void Foam::PstreamBuffers::finishedSends(const bool block) +{ + finishedSendsCalled_ = true; + + if (commsType_ == UPstream::nonBlocking) + { + labelListList sizes; + Pstream::exchange<DynamicList<char>, char> + ( + sendBuf_, + recvBuf_, + sizes, + tag_, + block + ); + } +} + + +void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block) +{ + finishedSendsCalled_ = true; + + if (commsType_ == UPstream::nonBlocking) + { + labelListList sizes; + labelListList send,recv; + + Pstream::exchange<DynamicList<char>, char> + ( + sendBuf_, + recvBuf_, + sizes, + tag_, + block + ); + } + else + { + sizes.setSize(UPstream::nProcs()); + labelList& nsTransPs = sizes[UPstream::myProcNo()]; + nsTransPs.setSize(UPstream::nProcs()); + + forAll(sendBuf_, procI) + { + nsTransPs[procI] = sendBuf_[procI].size(); + } + + // Send sizes across. + int oldTag = UPstream::msgType(); + UPstream::msgType() = tag_; + combineReduce(sizes, UPstream::listEq()); + UPstream::msgType() = oldTag; + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H new file mode 100644 index 0000000000000000000000000000000000000000..d3dbbf23db7f60f61f64996439e57591f62ec3c1 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H @@ -0,0 +1,155 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::PstreamBuffers + +Description + Buffers for inter-processor communications streams (UOPstream, UIPstream). + + Use UOPstream to stream data into buffers, call finishedSends() to + notify that data is in buffers and then use IUPstream to get data out + of received buffers. Works with both blocking and nonBlocking. Does + not make much sense with scheduled since there you would not need these + explicit buffers. + + Example usage: + + PstreamBuffers pBuffers(Pstream::nonBlocking); + + for (label procI = 0; procI < Pstream::nProcs(); procI++) + { + if (procI != Pstream::myProcNo()) + { + someObject vals; + + UOPstream str(procI, pBuffers); + str << vals; + } + } + + pBuffers.finishedSends(); // no-op for blocking + + for (label procI = 0; procI < Pstream::nProcs(); procI++) + { + if (procI != Pstream::myProcNo()) + { + UIPstream str(procI, pBuffers); + someObject vals(str); + } + } + + +SourceFiles + PstreamBuffers.C + +\*---------------------------------------------------------------------------*/ + +#include "Pstream.H" + +#ifndef PstreamBuffers_H +#define PstreamBuffers_H + +#include "DynamicList.H" +#include "UPstream.H" +#include "IOstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class PstreamBuffers Declaration +\*---------------------------------------------------------------------------*/ + +class PstreamBuffers +{ + friend class UOPstream; + friend class UIPstream; + + // Private data + + //- Communications type of this stream + const UPstream::commsTypes commsType_; + + const int tag_; + + const IOstream::streamFormat format_; + + const IOstream::versionNumber version_; + + //- send buffer + List<DynamicList<char> > sendBuf_; + + //- receive buffer + List<DynamicList<char> > recvBuf_; + + bool finishedSendsCalled_; + + // Private member functions + +public: + + // Static data + + static DynamicList<char> nullBuf; + + + // Constructors + + //- Construct given comms type, + // write format and IO version + PstreamBuffers + ( + const UPstream::commsTypes commsType, + const int tag = UPstream::msgType(), + IOstream::streamFormat format=IOstream::BINARY, + IOstream::versionNumber version=IOstream::currentVersion + ); + + + // Member functions + + //- Mark all sends as having been done. This will start receives + // in non-blocking mode. If block will wait for all transfers to + // finish (only relevant for nonBlocking mode) + void finishedSends(const bool block = true); + + //- Mark all sends as having been done. Same as above but also returns + // sizes (bytes) transferred. + void finishedSends(labelListList& sizes, const bool block = true); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H index 62779c800a1b5a96730837225da92d93fcbcef9a..68821134b5adf6a4f673b537586a35a2261d5f11 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCombineReduceOps.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA InClass - Foam::Pstream + Foam Description Combination-Reduction operation for a parallel run. The @@ -37,6 +37,7 @@ Description #ifndef PstreamCombineReduceOps_H #define PstreamCombineReduceOps_H +#include "UPstream.H" #include "Pstream.H" #include "ops.H" @@ -50,7 +51,7 @@ namespace Foam template <class T, class CombineOp> void combineReduce ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, T& Value, const CombineOp& cop ) @@ -63,15 +64,15 @@ void combineReduce template <class T, class CombineOp> void combineReduce(T& Value, const CombineOp& cop) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - Pstream::combineGather(Pstream::linearCommunication(), Value, cop); - Pstream::combineScatter(Pstream::linearCommunication(), Value); + Pstream::combineGather(UPstream::linearCommunication(), Value, cop); + Pstream::combineScatter(UPstream::linearCommunication(), Value); } else { - Pstream::combineGather(Pstream::treeCommunication(), Value, cop); - Pstream::combineScatter(Pstream::treeCommunication(), Value); + Pstream::combineGather(UPstream::treeCommunication(), Value, cop); + Pstream::combineScatter(UPstream::treeCommunication(), Value); } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H index 1779ed8600f395efd55de61d3190f08424f2955d..53eeedf1c02b2dd001c1d59ffff17b29f75b3b62 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H @@ -41,7 +41,7 @@ namespace Foam template <class T, class BinaryOp> void reduce ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, T& Value, const BinaryOp& bop ) @@ -59,13 +59,13 @@ void reduce const BinaryOp& bop ) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - reduce(Pstream::linearCommunication(), Value, bop); + reduce(UPstream::linearCommunication(), Value, bop); } else { - reduce(Pstream::treeCommunication(), Value, bop); + reduce(UPstream::treeCommunication(), Value, bop); } } @@ -80,13 +80,13 @@ T returnReduce { T WorkValue(Value); - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - reduce(Pstream::linearCommunication(), WorkValue, bop); + reduce(UPstream::linearCommunication(), WorkValue, bop); } else { - reduce(Pstream::treeCommunication(), WorkValue, bop); + reduce(UPstream::treeCommunication(), WorkValue, bop); } return WorkValue; diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C new file mode 100644 index 0000000000000000000000000000000000000000..4c38db6c692cb0598618a85b5496519fdc7f7d9d --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.C @@ -0,0 +1,322 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "error.H" +#include "UIPstream.H" +#include "int.H" +#include "token.H" +#include <cctype> + + +// * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // + +inline void Foam::UIPstream::checkEof() +{ + if (externalBufPosition_ == messageSize_) + { + setEof(); + } +} + + +template<class T> +inline void Foam::UIPstream::readFromBuffer(T& t) +{ + const size_t align = sizeof(T); + externalBufPosition_ = align + ((externalBufPosition_ - 1) & ~(align - 1)); + + t = reinterpret_cast<T&>(externalBuf_[externalBufPosition_]); + externalBufPosition_ += sizeof(T); + checkEof(); +} + + +inline void Foam::UIPstream::readFromBuffer +( + void* data, + size_t count, + size_t align +) +{ + if (align > 1) + { + externalBufPosition_ = + align + + ((externalBufPosition_ - 1) & ~(align - 1)); + } + + register const char* bufPtr = &externalBuf_[externalBufPosition_]; + register char* dataPtr = reinterpret_cast<char*>(data); + register size_t i = count; + while (i--) *dataPtr++ = *bufPtr++; + externalBufPosition_ += count; + checkEof(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::UIPstream::~UIPstream() +{ + if (externalBufPosition_ < messageSize_) + { + FatalErrorIn("UIPstream::~UIPstream()") + << "Message not fully consumed. messageSize:" << messageSize_ + << " bytes of which only " << externalBufPosition_ + << " consumed." << Foam::abort(FatalError); + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::Istream& Foam::UIPstream::read(token& t) +{ + // Return the put back token if it exists + if (Istream::getBack(t)) + { + return *this; + } + + char c; + + // return on error + if (!read(c)) + { + t.setBad(); + return *this; + } + + // Set the line number of this token to the current stream line number + t.lineNumber() = lineNumber(); + + // Analyse input starting with this character. + switch (c) + { + // Punctuation + case token::END_STATEMENT : + case token::BEGIN_LIST : + case token::END_LIST : + case token::BEGIN_SQR : + case token::END_SQR : + case token::BEGIN_BLOCK : + case token::END_BLOCK : + case token::COLON : + case token::COMMA : + case token::ASSIGN : + case token::ADD : + case token::SUBTRACT : + case token::MULTIPLY : + case token::DIVIDE : + { + t = token::punctuationToken(c); + return *this; + } + + // Word + case token::WORD : + { + word* pval = new word; + if (read(*pval)) + { + if (token::compound::isCompound(*pval)) + { + t = token::compound::New(*pval, *this).ptr(); + delete pval; + } + else + { + t = pval; + } + } + else + { + delete pval; + t.setBad(); + } + return *this; + } + + // String + case token::STRING : + { + string* pval = new string; + if (read(*pval)) + { + t = pval; + } + else + { + delete pval; + t.setBad(); + } + return *this; + } + + // Label + case token::LABEL : + { + label val; + if (read(val)) + { + t = val; + } + else + { + t.setBad(); + } + return *this; + } + + // floatScalar + case token::FLOAT_SCALAR : + { + floatScalar val; + if (read(val)) + { + t = val; + } + else + { + t.setBad(); + } + return *this; + } + + // doubleScalar + case token::DOUBLE_SCALAR : + { + doubleScalar val; + if (read(val)) + { + t = val; + } + else + { + t.setBad(); + } + return *this; + } + + // Character (returned as a single character word) or error + default: + { + if (isalpha(c)) + { + t = word(c); + return *this; + } + + setBad(); + t.setBad(); + + return *this; + } + } +} + + +Foam::Istream& Foam::UIPstream::read(char& c) +{ + c = externalBuf_[externalBufPosition_]; + externalBufPosition_++; + checkEof(); + return *this; +} + + +Foam::Istream& Foam::UIPstream::read(word& str) +{ + size_t len; + readFromBuffer(len); + str = &externalBuf_[externalBufPosition_]; + externalBufPosition_ += len + 1; + checkEof(); + return *this; +} + + +Foam::Istream& Foam::UIPstream::read(string& str) +{ + size_t len; + readFromBuffer(len); + str = &externalBuf_[externalBufPosition_]; + externalBufPosition_ += len + 1; + checkEof(); + return *this; +} + + +Foam::Istream& Foam::UIPstream::read(label& val) +{ + readFromBuffer(val); + return *this; +} + + +Foam::Istream& Foam::UIPstream::read(floatScalar& val) +{ + readFromBuffer(val); + return *this; +} + + +Foam::Istream& Foam::UIPstream::read(doubleScalar& val) +{ + readFromBuffer(val); + return *this; +} + + +Foam::Istream& Foam::UIPstream::read(char* data, std::streamsize count) +{ + if (format() != BINARY) + { + FatalErrorIn("UIPstream::read(char*, std::streamsize)") + << "stream format not binary" + << Foam::abort(FatalError); + } + + readFromBuffer(data, count, 8); + return *this; +} + + +Foam::Istream& Foam::UIPstream::rewind() +{ + externalBufPosition_ = 0; + return *this; +} + + +void Foam::UIPstream::print(Ostream& os) const +{ + os << "Reading from processor " << fromProcNo_ + << " to processor " << myProcNo() << Foam::endl; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H new file mode 100644 index 0000000000000000000000000000000000000000..aebef123b1586d5855ac301feda4779c60fef8ef --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UIPstream.H @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::UIPstream + +Description + Input inter-processor communications stream operating on external + buffer. + +SourceFiles + UIPstream.C + +\*---------------------------------------------------------------------------*/ + +#include "Pstream.H" + +#ifndef UIPstream_H +#define UIPstream_H + +#include "UPstream.H" +#include "Istream.H" +#include "PstreamBuffers.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class UIPstream Declaration +\*---------------------------------------------------------------------------*/ + +class UIPstream +: + public UPstream, + public Istream +{ + // Private data + + int fromProcNo_; + + DynamicList<char>& externalBuf_; + + label externalBufPosition_; + + const int tag_; + + label messageSize_; + + + // Private member functions + + //- Check the bufferPosition against messageSize_ for EOF + inline void checkEof(); + + //- Read a T from the transfer buffer + template<class T> + inline void readFromBuffer(T&); + + //- Read data from the transfer buffer + inline void readFromBuffer(void* data, size_t count, size_t align); + + +public: + + // Constructors + + //- Construct given process index to read from and optional buffer size, + // read format and IO version + UIPstream + ( + const commsTypes commsType, + const int fromProcNo, + DynamicList<char>& externalBuf, + const int tag = UPstream::msgType(), + streamFormat format=BINARY, + versionNumber version=currentVersion + ); + + //- Construct given buffers + UIPstream(const int fromProcNo, PstreamBuffers&); + + + // Destructor + + ~UIPstream(); + + + // Member functions + + // Inquiry + + //- Return flags of output stream + ios_base::fmtflags flags() const + { + return ios_base::fmtflags(0); + } + + + // Read functions + + //- Read into given buffer from given processor and return the + // message size + static label read + ( + const commsTypes commsType, + const int fromProcNo, + char* buf, + const std::streamsize bufSize, + const int tag = UPstream::msgType() + ); + + //- Return next token from stream + Istream& read(token&); + + //- Read a character + Istream& read(char&); + + //- Read a word + Istream& read(word&); + + // Read a string (including enclosing double-quotes) + Istream& read(string&); + + //- Read a label + Istream& read(label&); + + //- Read a floatScalar + Istream& read(floatScalar&); + + //- Read a doubleScalar + Istream& read(doubleScalar&); + + //- Read binary block + Istream& read(char*, std::streamsize); + + //- Rewind and return the stream so that it may be read again + Istream& rewind(); + + + // Edit + + //- Set flags of stream + ios_base::fmtflags flags(const ios_base::fmtflags) + { + return ios_base::fmtflags(0); + } + + + // Print + + //- Print description of IOstream to Ostream + void print(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C new file mode 100644 index 0000000000000000000000000000000000000000..dead2917d97fd0432d5c28931a9625569cff3a7b --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.C @@ -0,0 +1,275 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Write primitive and binary block from UOPstream + +\*---------------------------------------------------------------------------*/ + +#include "error.H" + +#include "UOPstream.H" +#include "int.H" +#include "token.H" + +#include <cctype> + +// * * * * * * * * * * * * * Private member functions * * * * * * * * * * * // + +template<class T> +inline void Foam::UOPstream::writeToBuffer(const T& t) +{ + writeToBuffer(&t, sizeof(T), sizeof(T)); +} + + +inline void Foam::UOPstream::writeToBuffer(const char& c) +{ + if (!sendBuf_.capacity()) + { + sendBuf_.setCapacity(1000); + } + sendBuf_.append(c); +} + + +inline void Foam::UOPstream::writeToBuffer +( + const void* data, + size_t count, + size_t align +) +{ + if (!sendBuf_.capacity()) + { + sendBuf_.setCapacity(1000); + } + + label alignedPos = sendBuf_.size(); + + if (align > 1) + { + // Align bufPosition. Pads sendBuf_.size() - oldPos characters. + alignedPos = align + ((sendBuf_.size() - 1) & ~(align - 1)); + } + + // Extend if necessary + sendBuf_.setSize(alignedPos + count); + + register const char* dataPtr = reinterpret_cast<const char*>(data); + register size_t i = count; + while (i--) sendBuf_[alignedPos++] = *dataPtr++; +} + + + +// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // + +Foam::UOPstream::UOPstream +( + const commsTypes commsType, + const int toProcNo, + DynamicList<char>& sendBuf, + const int tag, + const bool sendAtDestruct, + streamFormat format, + versionNumber version +) +: + UPstream(commsType), + Ostream(format, version), + toProcNo_(toProcNo), + sendBuf_(sendBuf), + tag_(tag), + sendAtDestruct_(sendAtDestruct) +{ + setOpened(); + setGood(); +} + + +Foam::UOPstream::UOPstream(const int toProcNo, PstreamBuffers& buffers) +: + UPstream(buffers.commsType_), + Ostream(buffers.format_, buffers.version_), + toProcNo_(toProcNo), + sendBuf_(buffers.sendBuf_[toProcNo]), + tag_(buffers.tag_), + sendAtDestruct_(buffers.commsType_ != UPstream::nonBlocking) +{ + setOpened(); + setGood(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::UOPstream::~UOPstream() +{ + if (sendAtDestruct_) + { + if + ( + !UOPstream::write + ( + commsType_, + toProcNo_, + sendBuf_.begin(), + sendBuf_.size(), + tag_ + ) + ) + { + FatalErrorIn("UOPstream::~UOPstream()") + << "Failed sending outgoing message of size " << sendBuf_.size() + << " to processor " << toProcNo_ + << Foam::abort(FatalError); + } + } +} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::Ostream& Foam::UOPstream::write(const token&) +{ + notImplemented("Ostream& UOPstream::write(const token&)"); + setBad(); + return *this; +} + + +Foam::Ostream& Foam::UOPstream::write(const char c) +{ + if (!isspace(c)) + { + writeToBuffer(c); + } + + return *this; +} + + +Foam::Ostream& Foam::UOPstream::write(const char* str) +{ + word nonWhiteChars(string::validate<word>(str)); + + if (nonWhiteChars.size() == 1) + { + return write(nonWhiteChars.c_str()[1]); + } + else if (nonWhiteChars.size()) + { + return write(nonWhiteChars); + } + else + { + return *this; + } +} + + +Foam::Ostream& Foam::UOPstream::write(const word& str) +{ + write(char(token::WORD)); + + size_t len = str.size(); + writeToBuffer(len); + writeToBuffer(str.c_str(), len + 1, 1); + + return *this; +} + + +Foam::Ostream& Foam::UOPstream::write(const string& str) +{ + write(char(token::STRING)); + + size_t len = str.size(); + writeToBuffer(len); + writeToBuffer(str.c_str(), len + 1, 1); + + return *this; +} + + +Foam::Ostream& Foam::UOPstream::writeQuoted(const std::string& str, const bool) +{ + write(char(token::STRING)); + + size_t len = str.size(); + writeToBuffer(len); + writeToBuffer(str.c_str(), len + 1, 1); + + return *this; +} + + +Foam::Ostream& Foam::UOPstream::write(const label val) +{ + write(char(token::LABEL)); + writeToBuffer(val); + return *this; +} + + +Foam::Ostream& Foam::UOPstream::write(const floatScalar val) +{ + write(char(token::FLOAT_SCALAR)); + writeToBuffer(val); + return *this; +} + + +Foam::Ostream& Foam::UOPstream::write(const doubleScalar val) +{ + write(char(token::DOUBLE_SCALAR)); + writeToBuffer(val); + return *this; +} + + +Foam::Ostream& Foam::UOPstream::write(const char* data, std::streamsize count) +{ + if (format() != BINARY) + { + FatalErrorIn("Ostream::write(const char*, std::streamsize)") + << "stream format not binary" + << Foam::abort(FatalError); + } + + writeToBuffer(data, count, 8); + + return *this; +} + + +void Foam::UOPstream::print(Ostream& os) const +{ + os << "Writing from processor " << toProcNo_ + << " to processor " << myProcNo() << Foam::endl; +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H new file mode 100644 index 0000000000000000000000000000000000000000..46dbeac58d11ae1ace1be513867c41fb1469bd80 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UOPstream.H @@ -0,0 +1,233 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::UOPstream + +Description + Output inter-processor communications stream operating on external + buffer. + +SourceFiles + UOPstream.C + +\*---------------------------------------------------------------------------*/ + +#include "Pstream.H" + +#ifndef UOPstream_H +#define UOPstream_H + +#include "UPstream.H" +#include "Ostream.H" +#include "DynamicList.H" +#include "PstreamBuffers.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class UOPstream Declaration +\*---------------------------------------------------------------------------*/ + +class UOPstream +: + public UPstream, + public Ostream +{ + // Private data + + int toProcNo_; + + DynamicList<char>& sendBuf_; + + const int tag_; + + const bool sendAtDestruct_; + + + // Private member functions + + //- Write a T to the transfer buffer + template<class T> + inline void writeToBuffer(const T&); + + //- Write a char to the transfer buffer + inline void writeToBuffer(const char&); + + //- Write data to the transfer buffer + inline void writeToBuffer(const void* data, size_t count, size_t align); + + +public: + + // Constructors + + //- Construct given process index to send to and optional buffer size, + // write format and IO version + UOPstream + ( + const commsTypes commsType, + const int toProcNo, + DynamicList<char>& sendBuf, + const int tag = UPstream::msgType(), + const bool sendAtDestruct = true, + streamFormat format=BINARY, + versionNumber version=currentVersion + ); + + //- Construct given buffers + UOPstream(const int toProcNo, PstreamBuffers&); + + + // Destructor + + ~UOPstream(); + + + // Member functions + + // Inquiry + + //- Return flags of output stream + ios_base::fmtflags flags() const + { + return ios_base::fmtflags(0); + } + + + // Write functions + + //- Write given buffer to given processor + static bool write + ( + const commsTypes commsType, + const int toProcNo, + const char* buf, + const std::streamsize bufSize, + const int tag = UPstream::msgType() + ); + + //- Write next token to stream + Ostream& write(const token&); + + //- Write character + Ostream& write(const char); + + //- Write character string + Ostream& write(const char*); + + //- Write word + Ostream& write(const word&); + + //- Write string + Ostream& write(const string&); + + //- Write std::string surrounded by quotes. + // Optional write without quotes. + Ostream& writeQuoted + ( + const std::string&, + const bool quoted=true + ); + + //- Write label + Ostream& write(const label); + + //- Write floatScalar + Ostream& write(const floatScalar); + + //- Write doubleScalar + Ostream& write(const doubleScalar); + + //- Write binary block + Ostream& write(const char*, std::streamsize); + + //- Add indentation characters + void indent() + {} + + + // Stream state functions + + //- Flush stream + void flush() + {} + + //- Add newline and flush stream + void endl() + {} + + //- Get width of output field + int width() const + { + return 0; + } + + //- Set width of output field (and return old width) + int width(const int) + { + return 0; + } + + //- Get precision of output field + int precision() const + { + return 0; + } + + //- Set precision of output field (and return old precision) + int precision(const int) + { + return 0; + } + + + // Edit + + //- Set flags of stream + ios_base::fmtflags flags(const ios_base::fmtflags) + { + return ios_base::fmtflags(0); + } + + + // Print + + //- Print description of IOstream to Ostream + void print(Ostream&) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C new file mode 100644 index 0000000000000000000000000000000000000000..45cab4130a438114394ff360aaacc23b5badf227 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.C @@ -0,0 +1,251 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "UPstream.H" +#include "debug.H" +#include "dictionary.H" +#include "IOstreams.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::UPstream, 0); + +template<> +const char* Foam::NamedEnum<Foam::UPstream::commsTypes, 3>::names[] = +{ + "blocking", + "scheduled", + "nonBlocking" +}; + +const Foam::NamedEnum<Foam::UPstream::commsTypes, 3> + Foam::UPstream::commsTypeNames; + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::UPstream::setParRun() +{ + parRun_ = true; + + Pout.prefix() = '[' + name(myProcNo()) + "] "; + Perr.prefix() = '[' + name(myProcNo()) + "] "; +} + + +void Foam::UPstream::calcLinearComm(const label nProcs) +{ + linearCommunication_.setSize(nProcs); + + // Master + labelList belowIDs(nProcs - 1); + forAll(belowIDs, i) + { + belowIDs[i] = i + 1; + } + + linearCommunication_[0] = commsStruct + ( + nProcs, + 0, + -1, + belowIDs, + labelList(0) + ); + + // Slaves. Have no below processors, only communicate up to master + for (label procID = 1; procID < nProcs; procID++) + { + linearCommunication_[procID] = commsStruct + ( + nProcs, + procID, + 0, + labelList(0), + labelList(0) + ); + } +} + + +// Append my children (and my children children etc.) to allReceives. +void Foam::UPstream::collectReceives +( + const label procID, + const List<DynamicList<label> >& receives, + DynamicList<label>& allReceives +) +{ + const DynamicList<label>& myChildren = receives[procID]; + + forAll(myChildren, childI) + { + allReceives.append(myChildren[childI]); + collectReceives(myChildren[childI], receives, allReceives); + } +} + + +// Tree like schedule. For 8 procs: +// (level 0) +// 0 receives from 1 +// 2 receives from 3 +// 4 receives from 5 +// 6 receives from 7 +// (level 1) +// 0 receives from 2 +// 4 receives from 6 +// (level 2) +// 0 receives from 4 +// +// The sends/receives for all levels are collected per processor (one send per +// processor; multiple receives possible) creating a table: +// +// So per processor: +// proc receives from sends to +// ---- ------------- -------- +// 0 1,2,4 - +// 1 - 0 +// 2 3 0 +// 3 - 2 +// 4 5 0 +// 5 - 4 +// 6 7 4 +// 7 - 6 +void Foam::UPstream::calcTreeComm(label nProcs) +{ + label nLevels = 1; + while ((1 << nLevels) < nProcs) + { + nLevels++; + } + + List<DynamicList<label> > receives(nProcs); + labelList sends(nProcs, -1); + + // Info<< "Using " << nLevels << " communication levels" << endl; + + label offset = 2; + label childOffset = offset/2; + + for (label level = 0; level < nLevels; level++) + { + label receiveID = 0; + while (receiveID < nProcs) + { + // Determine processor that sends and we receive from + label sendID = receiveID + childOffset; + + if (sendID < nProcs) + { + receives[receiveID].append(sendID); + sends[sendID] = receiveID; + } + + receiveID += offset; + } + + offset <<= 1; + childOffset <<= 1; + } + + // For all processors find the processors it receives data from + // (and the processors they receive data from etc.) + List<DynamicList<label> > allReceives(nProcs); + for (label procID = 0; procID < nProcs; procID++) + { + collectReceives(procID, receives, allReceives[procID]); + } + + + treeCommunication_.setSize(nProcs); + + for (label procID = 0; procID < nProcs; procID++) + { + treeCommunication_[procID] = commsStruct + ( + nProcs, + procID, + sends[procID], + receives[procID].shrink(), + allReceives[procID].shrink() + ); + } +} + + +// Callback from UPstream::init() : initialize linear and tree communication +// schedules now that nProcs is known. +void Foam::UPstream::initCommunicationSchedule() +{ + calcLinearComm(nProcs()); + calcTreeComm(nProcs()); +} + + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +// Initialise my process number to 0 (the master) +int Foam::UPstream::myProcNo_(0); + +// By default this is not a parallel run +bool Foam::UPstream::parRun_(false); + +// List of process IDs +Foam::List<int> Foam::UPstream::procIDs_(1, 0); + +// Standard transfer message type +int Foam::UPstream::msgType_(1); + +// Linear communication schedule +Foam::List<Foam::UPstream::commsStruct> Foam::UPstream::linearCommunication_(0); + +// Multi level communication schedule +Foam::List<Foam::UPstream::commsStruct> Foam::UPstream::treeCommunication_(0); + +// Should compact transfer be used in which floats replace doubles +// reducing the bandwidth requirement at the expense of some loss +// in accuracy +bool Foam::UPstream::floatTransfer +( + debug::optimisationSwitch("floatTransfer", 0) +); + +// Number of processors at which the reduce algorithm changes from linear to +// tree +int Foam::UPstream::nProcsSimpleSum +( + debug::optimisationSwitch("nProcsSimpleSum", 16) +); + +// Default commsType +Foam::UPstream::commsTypes Foam::UPstream::defaultCommsType +( + commsTypeNames.read(debug::optimisationSwitches().lookup("commsType")) +); + + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H new file mode 100644 index 0000000000000000000000000000000000000000..fcfe9dd0c9410766183aabc182dd809a4d9ccd86 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstream.H @@ -0,0 +1,381 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::UPstream + +Description + Inter-processor communications stream + +SourceFiles + UPstream.C + UPstreamsPrint.C + UPstreamCommsStruct.C + gatherScatter.C + combineGatherScatter.C + gatherScatterList.C + +\*---------------------------------------------------------------------------*/ + +#ifndef UPstream_H +#define UPstream_H + +#include "labelList.H" +#include "DynamicList.H" +#include "HashTable.H" +#include "string.H" +#include "NamedEnum.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class UPstream Declaration +\*---------------------------------------------------------------------------*/ + +class UPstream +{ + +public: + + //- Types of communications + enum commsTypes + { + blocking, + scheduled, + nonBlocking + }; + + static const NamedEnum<commsTypes, 3> commsTypeNames; + + // Public classes + + //- Structure for communicating between processors + class commsStruct + { + // Private data + + //- procID of above processor + label above_; + + //- procIDs of processors directly below me + labelList below_; + + //- procIDs of all processors below (so not just directly below) + labelList allBelow_; + + //- procIDs of all processors not below. (inverse set of + // allBelow_ and minus myProcNo) + labelList allNotBelow_; + + + public: + + // Constructors + + //- Construct null + commsStruct(); + + //- Construct from components + commsStruct + ( + const label, + const labelList&, + const labelList&, + const labelList& + ); + + //- Construct from components; construct allNotBelow_ + commsStruct + ( + const label nProcs, + const label myProcID, + const label, + const labelList&, + const labelList& + ); + + + // Member Functions + + // Access + + label above() const + { + return above_; + } + + const labelList& below() const + { + return below_; + } + + const labelList& allBelow() const + { + return allBelow_; + } + + const labelList& allNotBelow() const + { + return allNotBelow_; + } + + + // Member operators + + bool operator==(const commsStruct&) const; + + bool operator!=(const commsStruct&) const; + + + // Ostream Operator + + friend Ostream& operator<<(Ostream&, const commsStruct&); + }; + + + //- combineReduce operator for lists. Used for counting. + class listEq + { + + public: + + template<class T> + void operator()(T& x, const T& y) const + { + forAll(y, i) + { + if (y[i].size()) + { + x[i] = y[i]; + } + } + } + }; + + +private: + + // Private data + + static int myProcNo_; + static bool parRun_; + + static List<int> procIDs_; + static int msgType_; + + static List<commsStruct> linearCommunication_; + static List<commsStruct> treeCommunication_; + + + // Private member functions + + //- Set data for parallel running + static void setParRun(); + + //- Calculate linear communication schedule + static void calcLinearComm(const label nProcs); + + //- Calculate tree communication schedule + static void calcTreeComm(const label nProcs); + + //- Helper function for tree communication schedule determination + // Collects all processorIDs below a processor + static void collectReceives + ( + const label procID, + const List<DynamicList<label> >& receives, + DynamicList<label>& allReceives + ); + + //- Initialize all communication schedules. Callback from + // UPstream::init() + static void initCommunicationSchedule(); + + +protected: + + // Protected data + + //- Communications type of this stream + commsTypes commsType_; + +public: + + // Declare name of the class and its debug switch + ClassName("UPstream"); + + + // Static data + + //- Should compact transfer be used in which floats replace doubles + // reducing the bandwidth requirement at the expense of some loss + // in accuracy + static bool floatTransfer; + + //- Number of processors at which the sum algorithm changes from linear + // to tree + static int nProcsSimpleSum; + + //- Default commsType + static commsTypes defaultCommsType; + + + // Constructors + + //- Construct given optional buffer size + UPstream(const commsTypes commsType) + : + commsType_(commsType) + {} + + + // Member functions + + //- Add the valid option this type of communications library + // adds/requires on the command line + static void addValidParOptions(HashTable<string>& validParOptions); + + //- Initialisation function called from main + // Spawns slave processes and initialises inter-communication + static bool init(int& argc, char**& argv); + + //- Non-blocking comms: wait until all have finished. + static void waitRequests(); + + //- Non-blocking comms: has request i finished? + static bool finishedRequest(const label i); + + //- Is this a parallel run? + static bool parRun() + { + return parRun_; + } + + //- Number of processes in parallel run + static label nProcs() + { + return procIDs_.size(); + } + + //- Am I the master process + static bool master() + { + return myProcNo_ == 0; + } + + //- Process index of the master + static int masterNo() + { + return 0; + } + + //- Number of this process (starting from masterNo() = 0) + static int myProcNo() + { + return myProcNo_; + } + + //- Process IDs + static const List<int>& procIDs() + { + return procIDs_; + } + + //- Process ID of given process index + static int procID(int procNo) + { + return procIDs_[procNo]; + } + + //- Process index of first slave + static int firstSlave() + { + return 1; + } + + //- Process index of last slave + static int lastSlave() + { + return nProcs() - 1; + } + + //- Communication schedule for linear all-to-master (proc 0) + static const List<commsStruct>& linearCommunication() + { + return linearCommunication_; + } + + //- Communication schedule for tree all-to-master (proc 0) + static const List<commsStruct>& treeCommunication() + { + return treeCommunication_; + } + + //- Message tag of standard messages + static int& msgType() + { + return msgType_; + } + + + //- Get the communications type of the stream + commsTypes commsType() const + { + return commsType_; + } + + //- Set the communications type of the stream + commsTypes commsType(const commsTypes ct) + { + commsTypes oldCommsType = commsType_; + commsType_ = ct; + return oldCommsType; + } + + + //- Exit program + static void exit(int errnum = 1); + + //- Abort program + static void abort(); + + +}; + + +Ostream& operator<<(Ostream&, const UPstream::commsStruct&); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCommsStruct.C b/src/OpenFOAM/db/IOstreams/Pstreams/UPstreamCommsStruct.C similarity index 88% rename from src/OpenFOAM/db/IOstreams/Pstreams/PstreamCommsStruct.C rename to src/OpenFOAM/db/IOstreams/Pstreams/UPstreamCommsStruct.C index 3a2d7f12f5967ed341c5410726c4e14db6d1d2cb..cae479cf40ffc4e0d8b42f641fd36ae1e1fabaab 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamCommsStruct.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/UPstreamCommsStruct.C @@ -24,12 +24,12 @@ License \*---------------------------------------------------------------------------*/ -#include "Pstream.H" +#include "UPstream.H" #include "boolList.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::Pstream::commsStruct::commsStruct() +Foam::UPstream::commsStruct::commsStruct() : above_(-1), below_(0), @@ -38,7 +38,7 @@ Foam::Pstream::commsStruct::commsStruct() {} -Foam::Pstream::commsStruct::commsStruct +Foam::UPstream::commsStruct::commsStruct ( const label above, const labelList& below, @@ -53,7 +53,7 @@ Foam::Pstream::commsStruct::commsStruct {} -Foam::Pstream::commsStruct::commsStruct +Foam::UPstream::commsStruct::commsStruct ( const label nProcs, const label myProcID, @@ -91,7 +91,7 @@ Foam::Pstream::commsStruct::commsStruct // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // -bool Foam::Pstream::commsStruct::operator==(const commsStruct& comm) const +bool Foam::UPstream::commsStruct::operator==(const commsStruct& comm) const { return ( @@ -103,7 +103,7 @@ bool Foam::Pstream::commsStruct::operator==(const commsStruct& comm) const } -bool Foam::Pstream::commsStruct::operator!=(const commsStruct& comm) const +bool Foam::UPstream::commsStruct::operator!=(const commsStruct& comm) const { return !operator==(comm); } @@ -111,7 +111,7 @@ bool Foam::Pstream::commsStruct::operator!=(const commsStruct& comm) const // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // -Foam::Ostream& Foam::operator<<(Ostream& os, const Pstream::commsStruct& comm) +Foam::Ostream& Foam::operator<<(Ostream& os, const UPstream::commsStruct& comm) { os << comm.above_ << token::SPACE << comm.below_ << token::SPACE diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C b/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C index 20cf9db4a6c2be0c09c175bb438876a30125788b..e25000f8ca1271125e09840cac1b797d419585a9 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/combineGatherScatter.C @@ -49,15 +49,15 @@ namespace Foam template <class T, class CombineOp> void Pstream::combineGather ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, T& Value, const CombineOp& cop ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const commsStruct& myComm = comms[Pstream::myProcNo()]; + const commsStruct& myComm = comms[UPstream::myProcNo()]; // Receive from my downstairs neighbours forAll(myComm.below(), belowI) @@ -67,9 +67,9 @@ void Pstream::combineGather if (contiguous<T>()) { T value; - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, belowID, reinterpret_cast<char*>(&value), sizeof(T) @@ -85,7 +85,7 @@ void Pstream::combineGather } else { - IPstream fromBelow(Pstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID); T value(fromBelow); if (debug & 2) @@ -109,9 +109,9 @@ void Pstream::combineGather if (contiguous<T>()) { - OPstream::write + UOPstream::write ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(&Value), sizeof(T) @@ -119,7 +119,7 @@ void Pstream::combineGather } else { - OPstream toAbove(Pstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above()); toAbove << Value; } } @@ -130,33 +130,37 @@ void Pstream::combineGather template <class T, class CombineOp> void Pstream::combineGather(T& Value, const CombineOp& cop) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - combineGather(Pstream::linearCommunication(), Value, cop); + combineGather(UPstream::linearCommunication(), Value, cop); } else { - combineGather(Pstream::treeCommunication(), Value, cop); + combineGather(UPstream::treeCommunication(), Value, cop); } } template <class T> -void Pstream::combineScatter(const List<Pstream::commsStruct>& comms, T& Value) +void Pstream::combineScatter +( + const List<UPstream::commsStruct>& comms, + T& Value +) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; + const UPstream::commsStruct& myComm = comms[UPstream::myProcNo()]; // Reveive from up if (myComm.above() != -1) { if (contiguous<T>()) { - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(&Value), sizeof(T) @@ -164,7 +168,7 @@ void Pstream::combineScatter(const List<Pstream::commsStruct>& comms, T& Value) } else { - IPstream fromAbove(Pstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above()); Value = T(fromAbove); } @@ -187,9 +191,9 @@ void Pstream::combineScatter(const List<Pstream::commsStruct>& comms, T& Value) if (contiguous<T>()) { - OPstream::write + UOPstream::write ( - Pstream::scheduled, + UPstream::scheduled, belowID, reinterpret_cast<const char*>(&Value), sizeof(T) @@ -197,7 +201,7 @@ void Pstream::combineScatter(const List<Pstream::commsStruct>& comms, T& Value) } else { - OPstream toBelow(Pstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID); toBelow << Value; } } @@ -208,13 +212,13 @@ void Pstream::combineScatter(const List<Pstream::commsStruct>& comms, T& Value) template <class T> void Pstream::combineScatter(T& Value) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - combineScatter(Pstream::linearCommunication(), Value); + combineScatter(UPstream::linearCommunication(), Value); } else { - combineScatter(Pstream::treeCommunication(), Value); + combineScatter(UPstream::treeCommunication(), Value); } } @@ -226,15 +230,15 @@ void Pstream::combineScatter(T& Value) template <class T, class CombineOp> void Pstream::listCombineGather ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, List<T>& Values, const CombineOp& cop ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const commsStruct& myComm = comms[Pstream::myProcNo()]; + const commsStruct& myComm = comms[UPstream::myProcNo()]; // Receive from my downstairs neighbours forAll(myComm.below(), belowI) @@ -245,9 +249,9 @@ void Pstream::listCombineGather { List<T> receivedValues(Values.size()); - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, belowID, reinterpret_cast<char*>(receivedValues.begin()), receivedValues.byteSize() @@ -266,7 +270,7 @@ void Pstream::listCombineGather } else { - IPstream fromBelow(Pstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID); List<T> receivedValues(fromBelow); if (debug & 2) @@ -293,9 +297,9 @@ void Pstream::listCombineGather if (contiguous<T>()) { - OPstream::write + UOPstream::write ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(Values.begin()), Values.byteSize() @@ -303,7 +307,7 @@ void Pstream::listCombineGather } else { - OPstream toAbove(Pstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above()); toAbove << Values; } } @@ -314,13 +318,13 @@ void Pstream::listCombineGather template <class T, class CombineOp> void Pstream::listCombineGather(List<T>& Values, const CombineOp& cop) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - listCombineGather(Pstream::linearCommunication(), Values, cop); + listCombineGather(UPstream::linearCommunication(), Values, cop); } else { - listCombineGather(Pstream::treeCommunication(), Values, cop); + listCombineGather(UPstream::treeCommunication(), Values, cop); } } @@ -328,23 +332,23 @@ void Pstream::listCombineGather(List<T>& Values, const CombineOp& cop) template <class T> void Pstream::listCombineScatter ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, List<T>& Values ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; + const UPstream::commsStruct& myComm = comms[UPstream::myProcNo()]; // Reveive from up if (myComm.above() != -1) { if (contiguous<T>()) { - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(Values.begin()), Values.byteSize() @@ -352,7 +356,7 @@ void Pstream::listCombineScatter } else { - IPstream fromAbove(Pstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above()); fromAbove >> Values; } @@ -375,9 +379,9 @@ void Pstream::listCombineScatter if (contiguous<T>()) { - OPstream::write + UOPstream::write ( - Pstream::scheduled, + UPstream::scheduled, belowID, reinterpret_cast<const char*>(Values.begin()), Values.byteSize() @@ -385,7 +389,7 @@ void Pstream::listCombineScatter } else { - OPstream toBelow(Pstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID); toBelow << Values; } } @@ -396,13 +400,13 @@ void Pstream::listCombineScatter template <class T> void Pstream::listCombineScatter(List<T>& Values) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - listCombineScatter(Pstream::linearCommunication(), Values); + listCombineScatter(UPstream::linearCommunication(), Values); } else { - listCombineScatter(Pstream::treeCommunication(), Values); + listCombineScatter(UPstream::treeCommunication(), Values); } } @@ -416,22 +420,22 @@ void Pstream::listCombineScatter(List<T>& Values) template <class Container, class CombineOp> void Pstream::mapCombineGather ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, Container& Values, const CombineOp& cop ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const commsStruct& myComm = comms[Pstream::myProcNo()]; + const commsStruct& myComm = comms[UPstream::myProcNo()]; // Receive from my downstairs neighbours forAll(myComm.below(), belowI) { label belowID = myComm.below()[belowI]; - IPstream fromBelow(Pstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID); Container receivedValues(fromBelow); if (debug & 2) @@ -471,7 +475,7 @@ void Pstream::mapCombineGather << " data:" << Values << endl; } - OPstream toAbove(Pstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above()); toAbove << Values; } } @@ -481,13 +485,13 @@ void Pstream::mapCombineGather template <class Container, class CombineOp> void Pstream::mapCombineGather(Container& Values, const CombineOp& cop) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - mapCombineGather(Pstream::linearCommunication(), Values, cop); + mapCombineGather(UPstream::linearCommunication(), Values, cop); } else { - mapCombineGather(Pstream::treeCommunication(), Values, cop); + mapCombineGather(UPstream::treeCommunication(), Values, cop); } } @@ -495,19 +499,19 @@ void Pstream::mapCombineGather(Container& Values, const CombineOp& cop) template <class Container> void Pstream::mapCombineScatter ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, Container& Values ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const Pstream::commsStruct& myComm = comms[Pstream::myProcNo()]; + const UPstream::commsStruct& myComm = comms[UPstream::myProcNo()]; // Reveive from up if (myComm.above() != -1) { - IPstream fromAbove(Pstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above()); fromAbove >> Values; if (debug & 2) @@ -527,7 +531,7 @@ void Pstream::mapCombineScatter Pout<< " sending to " << belowID << " data:" << Values << endl; } - OPstream toBelow(Pstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID); toBelow << Values; } } @@ -537,19 +541,17 @@ void Pstream::mapCombineScatter template <class Container> void Pstream::mapCombineScatter(Container& Values) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - mapCombineScatter(Pstream::linearCommunication(), Values); + mapCombineScatter(UPstream::linearCommunication(), Values); } else { - mapCombineScatter(Pstream::treeCommunication(), Values); + mapCombineScatter(UPstream::treeCommunication(), Values); } } - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C new file mode 100644 index 0000000000000000000000000000000000000000..64ced34ecf4c54f4e181a31a5f747f84641872d7 --- /dev/null +++ b/src/OpenFOAM/db/IOstreams/Pstreams/exchange.C @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Description + Exchange data. + +\*---------------------------------------------------------------------------*/ + +#include "Pstream.H" +#include "contiguous.H" +#include "PstreamCombineReduceOps.H" +#include "UPstream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +//template <template<class> class ListType, class T> +template <class Container, class T> +void Pstream::exchange +( + const List<Container >& sendBufs, + List<Container >& recvBufs, + labelListList& sizes, + const int tag, + const bool block +) +{ + if (UPstream::parRun()) + { + if (!contiguous<T>()) + { + FatalErrorIn + ( + "Pstream::exchange(..)" + ) << "Continuous data only." << Foam::abort(FatalError); + } + + if (sendBufs.size() != UPstream::nProcs()) + { + FatalErrorIn + ( + "Pstream::exchange(..)" + ) << "Size of list:" << sendBufs.size() + << " does not equal the number of processors:" + << UPstream::nProcs() + << Foam::abort(FatalError); + } + + sizes.setSize(UPstream::nProcs()); + labelList& nsTransPs = sizes[UPstream::myProcNo()]; + nsTransPs.setSize(UPstream::nProcs()); + + forAll(sendBufs, procI) + { + nsTransPs[procI] = sendBufs[procI].size(); + } + + // Send sizes across. + int oldTag = UPstream::msgType(); + UPstream::msgType() = tag; + combineReduce(sizes, UPstream::listEq()); + UPstream::msgType() = oldTag; + + + // Set up receives + // ~~~~~~~~~~~~~~~ + + recvBufs.setSize(sendBufs.size()); + forAll(sizes, procI) + { + label nRecv = sizes[procI][UPstream::myProcNo()]; + + if (procI != Pstream::myProcNo() && nRecv > 0) + { + recvBufs[procI].setSize(nRecv); + UIPstream::read + ( + UPstream::nonBlocking, + procI, + reinterpret_cast<char*>(recvBufs[procI].begin()), + nRecv*sizeof(T), + tag + ); + } + } + + + // Set up sends + // ~~~~~~~~~~~~ + + forAll(sendBufs, procI) + { + if (procI != Pstream::myProcNo() && sendBufs[procI].size() > 0) + { + if + ( + !UOPstream::write + ( + UPstream::nonBlocking, + procI, + reinterpret_cast<const char*>(sendBufs[procI].begin()), + sendBufs[procI].size()*sizeof(T), + tag + ) + ) + { + FatalErrorIn("Pstream::exchange(..)") + << "Cannot send outgoing message. " + << "to:" << procI << " nBytes:" + << label(sendBufs[procI].size()*sizeof(T)) + << Foam::abort(FatalError); + } + } + } + + + // Wait for all to finish + // ~~~~~~~~~~~~~~~~~~~~~~ + + if (block) + { + Pstream::waitRequests(); + } + } + + // Do myself + recvBufs[Pstream::myProcNo()] = sendBufs[Pstream::myProcNo()]; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C index 5239ed73eba5cf66c7760ccaf5cb389dd0351f5c..ffadc81f5cb1e91617615c8d994f74aca732bae0 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatter.C @@ -30,7 +30,9 @@ Description \*---------------------------------------------------------------------------*/ +#include "UOPstream.H" #include "OPstream.H" +#include "UIPstream.H" #include "IPstream.H" #include "contiguous.H" @@ -44,15 +46,15 @@ namespace Foam template <class T, class BinaryOp> void Pstream::gather ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, T& Value, const BinaryOp& bop ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const commsStruct& myComm = comms[Pstream::myProcNo()]; + const commsStruct& myComm = comms[UPstream::myProcNo()]; // Receive from my downstairs neighbours forAll(myComm.below(), belowI) @@ -61,9 +63,9 @@ void Pstream::gather if (contiguous<T>()) { - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, myComm.below()[belowI], reinterpret_cast<char*>(&value), sizeof(T) @@ -71,7 +73,7 @@ void Pstream::gather } else { - IPstream fromBelow(Pstream::scheduled, myComm.below()[belowI]); + IPstream fromBelow(UPstream::scheduled, myComm.below()[belowI]); fromBelow >> value; } @@ -83,9 +85,9 @@ void Pstream::gather { if (contiguous<T>()) { - OPstream::write + UOPstream::write ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(&Value), sizeof(T) @@ -93,7 +95,7 @@ void Pstream::gather } else { - OPstream toAbove(Pstream::scheduled, myComm.above()); + OPstream toAbove(UPstream::scheduled, myComm.above()); toAbove << Value; } } @@ -104,33 +106,33 @@ void Pstream::gather template <class T, class BinaryOp> void Pstream::gather(T& Value, const BinaryOp& bop) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - gather(Pstream::linearCommunication(), Value, bop); + gather(UPstream::linearCommunication(), Value, bop); } else { - gather(Pstream::treeCommunication(), Value, bop); + gather(UPstream::treeCommunication(), Value, bop); } } template <class T> -void Pstream::scatter(const List<Pstream::commsStruct>& comms, T& Value) +void Pstream::scatter(const List<UPstream::commsStruct>& comms, T& Value) { - if (Pstream::parRun()) + if (UPstream::parRun()) { // Get my communication order - const commsStruct& myComm = comms[Pstream::myProcNo()]; + const commsStruct& myComm = comms[UPstream::myProcNo()]; // Reveive from up if (myComm.above() != -1) { if (contiguous<T>()) { - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(&Value), sizeof(T) @@ -138,7 +140,7 @@ void Pstream::scatter(const List<Pstream::commsStruct>& comms, T& Value) } else { - IPstream fromAbove(Pstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above()); fromAbove >> Value; } } @@ -148,9 +150,9 @@ void Pstream::scatter(const List<Pstream::commsStruct>& comms, T& Value) { if (contiguous<T>()) { - OPstream::write + UOPstream::write ( - Pstream::scheduled, + UPstream::scheduled, myComm.below()[belowI], reinterpret_cast<const char*>(&Value), sizeof(T) @@ -158,7 +160,7 @@ void Pstream::scatter(const List<Pstream::commsStruct>& comms, T& Value) } else { - OPstream toBelow(Pstream::scheduled,myComm.below()[belowI]); + OPstream toBelow(UPstream::scheduled,myComm.below()[belowI]); toBelow << Value; } } @@ -169,13 +171,13 @@ void Pstream::scatter(const List<Pstream::commsStruct>& comms, T& Value) template <class T> void Pstream::scatter(T& Value) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - scatter(Pstream::linearCommunication(), Value); + scatter(UPstream::linearCommunication(), Value); } else { - scatter(Pstream::treeCommunication(), Value); + scatter(UPstream::treeCommunication(), Value); } } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C index 52f13d1688f721bc3087c685e2ae6b10483a3295..1374c4dba80c474aefc650e24fa3926aa7526dd9 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/gatherScatterList.C @@ -27,7 +27,7 @@ Description communication schedule (usually linear-to-master or tree-to-master). The gathered data will be a list with element procID the data from processor procID. Before calling every processor should insert its value into - Values[Pstream::myProcNo()]. + Values[UPstream::myProcNo()]. Note: after gather every processor only knows its own data and that of the processors below it. Only the 'master' of the communication schedule holds a fully filled List. Use scatter to distribute the data. @@ -48,26 +48,26 @@ namespace Foam template <class T> void Pstream::gatherList ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, List<T>& Values ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { - if (Values.size() != Pstream::nProcs()) + if (Values.size() != UPstream::nProcs()) { FatalErrorIn ( - "Pstream::gatherList(const List<Pstream::commsStruct>&" + "UPstream::gatherList(const List<UPstream::commsStruct>&" ", List<T>)" ) << "Size of list:" << Values.size() << " does not equal the number of processors:" - << Pstream::nProcs() + << UPstream::nProcs() << Foam::abort(FatalError); } // Get my communication order - const commsStruct& myComm = comms[Pstream::myProcNo()]; + const commsStruct& myComm = comms[UPstream::myProcNo()]; // Receive from my downstairs neighbours forAll(myComm.below(), belowI) @@ -79,9 +79,9 @@ void Pstream::gatherList { List<T> receivedValues(belowLeaves.size() + 1); - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, belowID, reinterpret_cast<char*>(receivedValues.begin()), receivedValues.byteSize() @@ -96,7 +96,7 @@ void Pstream::gatherList } else { - IPstream fromBelow(Pstream::scheduled, belowID); + IPstream fromBelow(UPstream::scheduled, belowID); fromBelow >> Values[belowID]; if (debug & 2) @@ -132,14 +132,14 @@ void Pstream::gatherList if (debug & 2) { Pout<< " sending to " << myComm.above() - << " data from me:" << Pstream::myProcNo() - << " data:" << Values[Pstream::myProcNo()] << endl; + << " data from me:" << UPstream::myProcNo() + << " data:" << Values[UPstream::myProcNo()] << endl; } if (contiguous<T>()) { List<T> sendingValues(belowLeaves.size() + 1); - sendingValues[0] = Values[Pstream::myProcNo()]; + sendingValues[0] = Values[UPstream::myProcNo()]; forAll(belowLeaves, leafI) { @@ -148,7 +148,7 @@ void Pstream::gatherList OPstream::write ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<const char*>(sendingValues.begin()), sendingValues.byteSize() @@ -156,8 +156,8 @@ void Pstream::gatherList } else { - OPstream toAbove(Pstream::scheduled, myComm.above()); - toAbove << Values[Pstream::myProcNo()]; + OPstream toAbove(UPstream::scheduled, myComm.above()); + toAbove << Values[UPstream::myProcNo()]; forAll(belowLeaves, leafI) { @@ -180,13 +180,13 @@ void Pstream::gatherList template <class T> void Pstream::gatherList(List<T>& Values) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - gatherList(Pstream::linearCommunication(), Values); + gatherList(UPstream::linearCommunication(), Values); } else { - gatherList(Pstream::treeCommunication(), Values); + gatherList(UPstream::treeCommunication(), Values); } } @@ -194,26 +194,26 @@ void Pstream::gatherList(List<T>& Values) template <class T> void Pstream::scatterList ( - const List<Pstream::commsStruct>& comms, + const List<UPstream::commsStruct>& comms, List<T>& Values ) { - if (Pstream::parRun()) + if (UPstream::parRun()) { - if (Values.size() != Pstream::nProcs()) + if (Values.size() != UPstream::nProcs()) { FatalErrorIn ( - "Pstream::scatterList(const List<Pstream::commsStruct>&" + "UPstream::scatterList(const List<UPstream::commsStruct>&" ", List<T>)" ) << "Size of list:" << Values.size() << " does not equal the number of processors:" - << Pstream::nProcs() + << UPstream::nProcs() << Foam::abort(FatalError); } // Get my communication order - const commsStruct& myComm = comms[Pstream::myProcNo()]; + const commsStruct& myComm = comms[UPstream::myProcNo()]; // Reveive from up if (myComm.above() != -1) @@ -224,9 +224,9 @@ void Pstream::scatterList { List<T> receivedValues(notBelowLeaves.size()); - IPstream::read + UIPstream::read ( - Pstream::scheduled, + UPstream::scheduled, myComm.above(), reinterpret_cast<char*>(receivedValues.begin()), receivedValues.byteSize() @@ -239,7 +239,7 @@ void Pstream::scatterList } else { - IPstream fromAbove(Pstream::scheduled, myComm.above()); + IPstream fromAbove(UPstream::scheduled, myComm.above()); forAll(notBelowLeaves, leafI) { @@ -273,7 +273,7 @@ void Pstream::scatterList OPstream::write ( - Pstream::scheduled, + UPstream::scheduled, belowID, reinterpret_cast<const char*>(sendingValues.begin()), sendingValues.byteSize() @@ -281,7 +281,7 @@ void Pstream::scatterList } else { - OPstream toBelow(Pstream::scheduled, belowID); + OPstream toBelow(UPstream::scheduled, belowID); // Send data destined for all other processors below belowID forAll(notBelowLeaves, leafI) @@ -305,13 +305,13 @@ void Pstream::scatterList template <class T> void Pstream::scatterList(List<T>& Values) { - if (Pstream::nProcs() < Pstream::nProcsSimpleSum) + if (UPstream::nProcs() < UPstream::nProcsSimpleSum) { - scatterList(Pstream::linearCommunication(), Values); + scatterList(UPstream::linearCommunication(), Values); } else { - scatterList(Pstream::treeCommunication(), Values); + scatterList(UPstream::treeCommunication(), Values); } } diff --git a/src/OpenFOAM/db/scalarRange/scalarRange.C b/src/OpenFOAM/db/scalarRange/scalarRange.C index 7623e14c272c41a9d899d59dd3bc585c7b246df7..393b19bba42846845b7737bdc3e125733789b5d6 100644 --- a/src/OpenFOAM/db/scalarRange/scalarRange.C +++ b/src/OpenFOAM/db/scalarRange/scalarRange.C @@ -42,7 +42,7 @@ Foam::scalarRange::scalarRange() {} -Foam::scalarRange::scalarRange(const scalar& lower, const scalar& upper) +Foam::scalarRange::scalarRange(const scalar lower, const scalar upper) : type_(RANGE), value_(lower), @@ -123,7 +123,7 @@ Foam::scalar Foam::scalarRange::upper() const } -bool Foam::scalarRange::selected(const scalar& value) const +bool Foam::scalarRange::selected(const scalar value) const { switch (type_) { diff --git a/src/OpenFOAM/db/scalarRange/scalarRange.H b/src/OpenFOAM/db/scalarRange/scalarRange.H index b9968716644173a608fc61159ea1bbbcc3d66930..f12380923775a7a91fce961131244236373c46d7 100644 --- a/src/OpenFOAM/db/scalarRange/scalarRange.H +++ b/src/OpenFOAM/db/scalarRange/scalarRange.H @@ -92,7 +92,7 @@ public: scalarRange(); //- Construct a Range - scalarRange(const scalar& lower, const scalar& upper); + scalarRange(const scalar lower, const scalar upper); //- Construct from Istream. // Since commas can be used as list delimiters, @@ -119,7 +119,7 @@ public: scalar upper() const; //- Return true if the value is within the range - bool selected(const scalar&) const; + bool selected(const scalar) const; // Member Operators diff --git a/src/OpenFOAM/db/scalarRange/scalarRanges.C b/src/OpenFOAM/db/scalarRange/scalarRanges.C index c59e2b5a9d615e49c05bfa8432e51eaa9261c10d..f8b3c077b1283d8cb7278a3df8caa147a6849cf0 100644 --- a/src/OpenFOAM/db/scalarRange/scalarRanges.C +++ b/src/OpenFOAM/db/scalarRange/scalarRanges.C @@ -57,7 +57,7 @@ Foam::scalarRanges::scalarRanges(Istream& is) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::scalarRanges::selected(const scalar& value) const +bool Foam::scalarRanges::selected(const scalar value) const { forAll(*this, i) { diff --git a/src/OpenFOAM/db/scalarRange/scalarRanges.H b/src/OpenFOAM/db/scalarRange/scalarRanges.H index 5483454ae680cf8e4e75ad2dde0dcbfb5847c005..c3bf1ea66856ad8359561425720dd2b01ebab357 100644 --- a/src/OpenFOAM/db/scalarRange/scalarRanges.H +++ b/src/OpenFOAM/db/scalarRange/scalarRanges.H @@ -66,7 +66,7 @@ public: // Member Functions //- Return true if the given value is within the ranges - bool selected(const scalar&) const; + bool selected(const scalar) const; //- Return the set of selected entries in the given list // that are within the ranges diff --git a/src/OpenFOAM/global/unitConversion/unitConversion.H b/src/OpenFOAM/global/unitConversion/unitConversion.H index 0ab93f1a50ec67f943e190a87b2388adf9d11988..c83582cf8448489468d6913a01e9421c6b376466 100644 --- a/src/OpenFOAM/global/unitConversion/unitConversion.H +++ b/src/OpenFOAM/global/unitConversion/unitConversion.H @@ -22,7 +22,7 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Namespace +InNamespace Foam Description @@ -35,8 +35,6 @@ Description #include "mathematicalConstants.H" -using namespace Foam::constant::mathematical; - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam @@ -45,15 +43,15 @@ namespace Foam // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Conversion from degrees to radians -inline scalar degToRad(const scalar& deg) +inline scalar degToRad(const scalar deg) { - return (deg*pi/180.0); + return (deg * constant::mathematical::pi/180.0); } //- Conversion from radians to degrees -inline scalar radToDeg(const scalar& rad) +inline scalar radToDeg(const scalar rad) { - return (rad*180.0/pi); + return (rad * 180.0/constant::mathematical::pi); } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTable.C b/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTable.C new file mode 100644 index 0000000000000000000000000000000000000000..6ce66c2d786f8b88a014b70abce4901869a0a8b3 --- /dev/null +++ b/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTable.C @@ -0,0 +1,236 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "uniformInterpolationTable.H" +#include "Time.H" + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +template <class Type> +void Foam::uniformInterpolationTable<Type>::checkTable() const +{ + if (size() < 2) + { + FatalErrorIn("uniformInterpolationTable<Type>::checkTable()") + << "Table " << name() << ": must have at least 2 values." << nl + << "Table size = " << size() << nl + << " min, interval width = " << x0_ << ", " << dx_ << nl + << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template <class Type> +Foam::uniformInterpolationTable<Type>::uniformInterpolationTable +( + const IOobject& io, + bool readFields +) +: + IOobject(io), + List<scalar>(2, 0.0), + x0_(0.0), + dx_(1.0), + log10_(false), + bound_(false) +{ + if (readFields) + { + IOdictionary dict(io); + + dict.lookup("data") >> *this; + dict.lookup("x0") >> x0_; + dict.lookup("dx") >> dx_; + dict.lookup("log10") >> log10_; + dict.lookup("bound") >> bound_; + } + + checkTable(); +} + + +template <class Type> +Foam::uniformInterpolationTable<Type>::uniformInterpolationTable +( + const word& tableName, + const objectRegistry& db, + const dictionary& dict, + const bool initialiseOnly +) +: + IOobject + ( + tableName, + db.time().constant(), + db, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // if used in BCs, could be used by multiple patches + ), + List<scalar>(2, 0.0), + x0_(readScalar(dict.lookup("x0"))), + dx_(readScalar(dict.lookup("dx"))), + log10_(dict.lookup("log10")), + bound_(dict.lookup("bound")) +{ + if (initialiseOnly) + { + scalar xMax = readScalar(dict.lookup("xMax")); + label nIntervals = static_cast<label>(xMax - x0_)/dx_ + 1; + this->setSize(nIntervals); + } + else + { + dict.lookup("data") >> *this; + } + + checkTable(); +} + + +template <class Type> +Foam::uniformInterpolationTable<Type>::uniformInterpolationTable +( + const uniformInterpolationTable& uit +) +: + IOobject(uit), + List<scalar>(uit), + x0_(uit.x0_), + dx_(uit.dx_), + log10_(uit.log10_), + bound_(uit.bound_) +{ + checkTable(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +template <class Type> +Foam::uniformInterpolationTable<Type>::~uniformInterpolationTable() +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +template <class Type> +Type Foam::uniformInterpolationTable<Type>::interpolate(scalar x) const +{ + if (bound_) + { + x = max(min(xMax() - SMALL*dx_, x), x0_); + } + else + { + if (x < x0_) + { + FatalErrorIn + ( + "uniformInterpolationTable<Type>::interpolate(scalar x)" + ) << "Supplied value is less than minimum table value:" << nl + << "xMin=" << x0_ << ", xMax=" << xMax() << ", x=" << x << nl + << exit(FatalError); + } + + if (x > xMax()) + { + FatalErrorIn + ( + "uniformInterpolationTable<Type>::interpolate(scalar x)" + ) << "Supplied value is greater than maximum table value:" << nl + << "xMin=" << x0_ << ", xMax=" << xMax() << ", x=" << x << nl + << exit(FatalError); + } + } + + label i = static_cast<label>((x - x0_)/dx_); + + scalar xLo = x0_ + i*dx_; + + Type fx = (x - xLo)/dx_*(operator[](i+1) - operator[](i)) + operator[](i); + + if (debug) + { + Info<< "Table: " << name() << ", x=" << x + << ", x_lo=" << xLo << ", x_hi=" << xLo + dx_ + << ", f(x_lo)=" << operator[](i) << ", f(x_hi)=" << operator[](i+1) + << ", f(x)=" << fx << endl; + } + + return fx; +} + + +template <class Type> +Type Foam::uniformInterpolationTable<Type>::interpolateLog10 +( + scalar x +) const +{ + if (log10_) + { + if (x > 0) + { + x = ::log10(x); + } + else if (bound_ && (x <= 0)) + { + x = x0_; + } + else + { + FatalErrorIn + ( + "uniformInterpolationTable<Type>::interpolateLog10(scalar x)" + ) << "Table " << name() << nl + << "Supplied value must be greater than 0 when in log10 mode" + << nl << "x=" << x << nl << exit(FatalError); + } + } + + return interpolate(x); +} + + +template <class Type> +void Foam::uniformInterpolationTable<Type>::write() const +{ + IOdictionary dict(*this); + + dict.add("data", static_cast<const List<scalar>&>(*this)); + dict.add("x0", x0_); + dict.add("dx", dx_); + dict.add("log10", log10_); + dict.add("bound", bound_); + + dict.regIOobject::write(); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTable.H b/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTable.H new file mode 100644 index 0000000000000000000000000000000000000000..42ce5c87ae9fcecdf11df7d872713d761e3374ae --- /dev/null +++ b/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTable.H @@ -0,0 +1,221 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::uniformInterpolationTable + +Description + Table with uniform interval in independant variable, with linear + interpolation + + Example usage (scalar): values specified in a dictionary: + + { + x0 0; // lower limit + dx 0.2; // fixed interval + log10 true; // take log(10) when interpolating? + data // list of dependent data values + ( + 7870 // value at x0 + 7870 // value at x0 + dx + ... + 7870 // value at x0 + n*dx + ); + } + +SourceFiles + uniformInterpolationTable.C + +\*---------------------------------------------------------------------------*/ + +#ifndef uniformInterpolationTable_H +#define uniformInterpolationTable_H + +#include "List.H" +#include "Switch.H" +#include "IOobject.H" +#include "objectRegistry.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class uniformInterpolationTable Declaration +\*---------------------------------------------------------------------------*/ + +template <class Type> +class uniformInterpolationTable +: + public IOobject, + public List<Type> +{ + // Private data + + // Control parameetrs + + //- Lower limit + scalar x0_; + + //- Fixed interval + scalar dx_; + + //- Flag to indicate that x data is given in log10(x) form + Switch log10_; + + //- Bound x values + Switch bound_; + + + // Private Member Functions + + //- Check that the table is valid + void checkTable() const; + + //- Disallow default bitwise assignment + void operator=(const uniformInterpolationTable&); + + +public: + + // Constructors + + //- Construct from IOobject and readFields flag. Creates a null object + // if readFields = false + uniformInterpolationTable(const IOobject& io, const bool readFields); + + //- Construct from name, objectRegistry and dictionary. + // If initialiseOnly flag is set, control parameters are read from + // the dictionary, but not the data table + uniformInterpolationTable + ( + const word& tableName, + const objectRegistry& db, + const dictionary& dict, + const bool initialiseOnly = false + ); + + //- Construct as copy + uniformInterpolationTable(const uniformInterpolationTable& uit); + + + //- Destructor + ~uniformInterpolationTable(); + + + // Member Functions + + // Access + + //- Return the lower limit + inline scalar x0() const; + + //- Return the fixed interval + inline scalar dx() const; + + //- Return the log10(x) flag + inline const Switch& log10() const; + + //- Return the bound flag + inline const Switch& bound() const; + + + // Edit + + //- Return the lower limit + inline scalar& x0(); + + //- Return the fixed interval + inline scalar& dx(); + + //- Return the log10(x) flag + inline Switch& log10(); + + //- Return the bound flag + inline Switch& bound(); + + + // Evaluation + + //- Return the minimum x value + inline scalar xMin() const; + + //- Return the maximum x value + inline scalar xMax() const; + + //- Interpolate + Type interpolate(scalar x) const; + + //- Interpolate - takes log10 flag into account + Type interpolateLog10(scalar x) const; + + + // Override ancestor size() function and [] operator + + //- Return the size of the table + label size() const + { + return List<Type>::size(); + } + + //- Use List[] operator for read access + Type operator[](label x) const + { + return List<Type>::operator[](x); + } + + //- Use List[] operator for write access + Type& operator[](label x) + { + return List<Type>::operator[](x); + } + + + // I-O + + //- Write + void write() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "uniformInterpolationTableI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "uniformInterpolationTable.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTableI.H b/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTableI.H new file mode 100644 index 0000000000000000000000000000000000000000..29028f355b7ab95dab61331069e04c70dc156dd2 --- /dev/null +++ b/src/OpenFOAM/interpolations/uniformInterpolationTable/uniformInterpolationTableI.H @@ -0,0 +1,97 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +template <class Type> +Foam::scalar Foam::uniformInterpolationTable<Type>::x0() const +{ + return x0_; +} + + +template <class Type> +Foam::scalar Foam::uniformInterpolationTable<Type>::dx() const +{ + return dx_; +} + + +template <class Type> +const Foam::Switch& Foam::uniformInterpolationTable<Type>::log10() const +{ + return log10_; +} + + +template <class Type> +const Foam::Switch& Foam::uniformInterpolationTable<Type>::bound() const +{ + return bound_; +} + + +template <class Type> +Foam::scalar& Foam::uniformInterpolationTable<Type>::x0() +{ + return x0_; +} + + +template <class Type> +Foam::scalar& Foam::uniformInterpolationTable<Type>::dx() +{ + return dx_; +} + + +template <class Type> +Foam::Switch& Foam::uniformInterpolationTable<Type>::log10() +{ + return log10_; +} + + +template <class Type> +Foam::Switch& Foam::uniformInterpolationTable<Type>::bound() +{ + return bound_; +} + + +template <class Type> +Foam::scalar Foam::uniformInterpolationTable<Type>::xMin() const +{ + return x0_; +} + + +template <class Type> +Foam::scalar Foam::uniformInterpolationTable<Type>::xMax() const +{ + return x0_ + dx_*(size() - 1); +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C index ecc094a84057616ee90d122f73b8dc7130d38a3f..7976d3c71ae3e71c156fca77cd7932bea1862bb2 100644 --- a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C +++ b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.C @@ -32,7 +32,20 @@ template<class Type> Foam::simpleMatrix<Type>::simpleMatrix(const label mSize) : scalarSquareMatrix(mSize), - source_(mSize, pTraits<Type>::zero) + source_(mSize) +{} + + +template<class Type> +Foam::simpleMatrix<Type>::simpleMatrix +( + const label mSize, + const scalar coeffVal, + const Type& sourceVal +) +: + scalarSquareMatrix(mSize, mSize, coeffVal), + source_(mSize, sourceVal) {} @@ -148,7 +161,11 @@ Foam::simpleMatrix<Type> Foam::operator- template<class Type> -Foam::simpleMatrix<Type> Foam::operator*(const scalar s, const simpleMatrix<Type>& m) +Foam::simpleMatrix<Type> Foam::operator* +( + const scalar s, + const simpleMatrix<Type>& m +) { return simpleMatrix<Type>(s*m.matrix_, s*m.source_); } @@ -157,7 +174,11 @@ Foam::simpleMatrix<Type> Foam::operator*(const scalar s, const simpleMatrix<Type // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // template<class Type> -Foam::Ostream& Foam::operator<<(Ostream& os, const simpleMatrix<Type>& m) +Foam::Ostream& Foam::operator<< +( + Ostream& os, + const simpleMatrix<Type>& m +) { os << static_cast<const scalarSquareMatrix&>(m) << nl << m.source_; return os; diff --git a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H index fd875281cc76f144a7e6470a227e605fb470922f..a32f318d3311b6c47fab687475308e3014019cb4 100644 --- a/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H +++ b/src/OpenFOAM/matrices/simpleMatrix/simpleMatrix.H @@ -26,7 +26,7 @@ Class Foam::simpleMatrix Description - Foam::simpleMatrix + A simple square matrix solver with scalar coefficients. SourceFiles simpleMatrix.C @@ -75,8 +75,12 @@ public: // Constructors //- Construct given size + // Note: this does not initialise the coefficients or the source. simpleMatrix(const label); + //- Construct given size and initial values for coefficients and source + simpleMatrix(const label, const scalar, const Type&); + //- Construct from components simpleMatrix(const scalarSquareMatrix&, const Field<Type>&); @@ -91,11 +95,13 @@ public: // Access + //- Return access to the source Field<Type>& source() { return source_; } + //- Return const-access to the source const Field<Type>& source() const { return source_; diff --git a/src/OpenFOAM/matrices/solution/solution.C b/src/OpenFOAM/matrices/solution/solution.C index c63dceec4eab01206c48000edf0fe9ed318a176f..ba0db67bd4165e71c6cdba9e525ad3b81668d6a3 100644 --- a/src/OpenFOAM/matrices/solution/solution.C +++ b/src/OpenFOAM/matrices/solution/solution.C @@ -60,6 +60,7 @@ Foam::solution::solution(const objectRegistry& obr, const fileName& dictName) ) ), cache_(ITstream("cache", tokenList())()), + caching_(false), relaxationFactors_(ITstream("relaxationFactors", tokenList())()), defaultRelaxationFactor_(0), solvers_(ITstream("solvers", tokenList())()) @@ -150,12 +151,19 @@ Foam::label Foam::solution::upgradeSolverDict bool Foam::solution::cache(const word& name) const { - if (debug) + if (caching_) { - Info<< "Find cache entry for " << name << endl; - } + if (debug) + { + Info<< "Cache: find entry for " << name << endl; + } - return cache_.found(name); + return cache_.found(name); + } + else + { + return false; + } } @@ -248,6 +256,7 @@ bool Foam::solution::read() if (dict.found("cache")) { cache_ = dict.subDict("cache"); + caching_ = cache_.lookupOrDefault<Switch>("active", true); } if (dict.found("relaxationFactors")) diff --git a/src/OpenFOAM/matrices/solution/solution.H b/src/OpenFOAM/matrices/solution/solution.H index 36724bf49556cb24ea8518acd62201547a33e723..ac1304fedcc65a2bd5ce529335b853823b626277 100644 --- a/src/OpenFOAM/matrices/solution/solution.H +++ b/src/OpenFOAM/matrices/solution/solution.H @@ -37,6 +37,7 @@ SourceFiles #define solution_H #include "IOdictionary.H" +#include "Switch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,6 +57,9 @@ class solution //- Dictionary of temporary fields to cache dictionary cache_; + //- Switch for the caching mechanism + Switch caching_; + //- Dictionary of relaxation factors for all the fields dictionary relaxationFactors_; diff --git a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C index cc7cf978bdf96420904f44e75e17306524e65e4e..625ac53bd9ab892f1e359167e66b973df91ef5bb 100644 --- a/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C +++ b/src/OpenFOAM/meshes/meshShapes/tetCell/tetCell.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "tetCell.H" @@ -44,7 +42,7 @@ Foam::cellShape Foam::tetCell::tetCellShape() const const cellModel& tet = *tetModelPtr_; - return cellShape(tet, *this); + return cellShape(tet, labelList(*this)); } diff --git a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C index eee664b1fb6b9f6ff96106e62e6e9bea746a79ef..eb99350c131d49577d126dd4f82aebd45b3499ba 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C +++ b/src/OpenFOAM/meshes/pointMesh/pointPatches/constraint/processor/processorPointPatch.C @@ -229,11 +229,7 @@ void processorPointPatch::initPatchPatchPoints() // Send the patchPatchPoints to the neighbouring processor - OPstream toNeighbProc - ( - Pstream::blocking, - neighbProcNo() - ); + OPstream toNeighbProc(Pstream::blocking, neighbProcNo()); toNeighbProc << ppmp.size() // number of points for checking @@ -252,11 +248,7 @@ void processorPointPatch::initPatchPatchPoints() void Foam::processorPointPatch::calcPatchPatchPoints() { // Get the patchPatchPoints from the neighbouring processor - IPstream fromNeighbProc - ( - Pstream::blocking, - neighbProcNo() - ); + IPstream fromNeighbProc(Pstream::blocking, neighbProcNo()); label nbrNPoints(readLabel(fromNeighbProc)); labelListList patchPatchPoints(fromNeighbProc); diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C index 54cfc5eea56f674da929a8790888e003a5ba0fde..37481760bab41b344c285bd1a7237f3bbcfcbca3 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.C @@ -30,7 +30,7 @@ License Foam::globalIndex::globalIndex(const label localSize) : - offsets_(Pstream::nProcs()) + offsets_(Pstream::nProcs()+1) { labelList localSizes(Pstream::nProcs()); localSizes[Pstream::myProcNo()] = localSize; @@ -38,7 +38,8 @@ Foam::globalIndex::globalIndex(const label localSize) Pstream::scatterList(localSizes); // just to balance out comms label offset = 0; - forAll(offsets_, procI) + offsets_[0] = 0; + for (label procI = 0; procI < Pstream::nProcs(); procI++) { label oldOffset = offset; offset += localSizes[procI]; @@ -51,7 +52,7 @@ Foam::globalIndex::globalIndex(const label localSize) << "). Please recompile with larger datatype for label." << exit(FatalError); } - offsets_[procI] = offset; + offsets_[procI+1] = offset; } } diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H index e394f679d042dd0c425f6fa7a869ebafeb5f2a4a..4bf4f4a4ba8de1257351e1408af35400c74eb585 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndex.H @@ -64,7 +64,7 @@ class globalIndex { // Private data - //- Start off procI+1. (so like CompactListList) + //- Start of procI. Size is nProcs()+1. (so like CompactListList) labelList offsets_; @@ -81,10 +81,6 @@ public: // Member Functions - ////- Start of procI+1 data - //inline const labelList& offsets() const; - - // Queries relating to my processor //- my local size diff --git a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H index d7c44107c665e29d0fd38900b2767e116b5e1b57..f00fbbeb81f00568b529dff285082ef7bbd1d28a 100644 --- a/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H +++ b/src/OpenFOAM/meshes/polyMesh/globalMeshData/globalIndexI.H @@ -28,26 +28,15 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -//inline const Foam::labelList& Foam::globalIndex::offsets() const -//{ -// return offsets_; -//} - - inline Foam::label Foam::globalIndex::offset(const label procI) const { - return (procI == 0 ? 0 : offsets_[procI-1]); + return offsets_[procI]; } inline Foam::label Foam::globalIndex::localSize(const label procI) const { - return - ( - procI == 0 - ? offsets_[procI] - : offsets_[procI] - offsets_[procI-1] - ); + return offsets_[procI+1] - offsets_[procI]; } @@ -59,7 +48,7 @@ inline Foam::label Foam::globalIndex::localSize() const inline Foam::label Foam::globalIndex::size() const { - return offsets_[Pstream::nProcs()-1]; + return offsets_[Pstream::nProcs()]; } @@ -69,7 +58,7 @@ inline Foam::label Foam::globalIndex::toGlobal const label i ) const { - return(procI == 0 ? i : i + offsets_[procI-1]); + return i + offsets_[procI]; } @@ -82,9 +71,7 @@ inline Foam::label Foam::globalIndex::toGlobal(const label i) const //- Is on local processor inline bool Foam::globalIndex::isLocal(const label procI, const label i) const { - return - (i < offsets_[procI]) - && (i >= (procI == 0 ? 0 : offsets_[procI-1])); + return i >= offsets_[procI] && i < offsets_[procI+1]; } @@ -97,9 +84,9 @@ inline bool Foam::globalIndex::isLocal(const label i) const inline Foam::label Foam::globalIndex::toLocal(const label procI, const label i) const { - label localI = (procI == 0 ? i : i - offsets_[procI-1]); + label localI = i - offsets_[procI]; - if (localI < 0 || i >= offsets_[procI]) + if (localI < 0 || i >= offsets_[procI+1]) { FatalErrorIn("globalIndex::toLocal(const label, const label)") << "Global " << i << " does not belong on processor " @@ -118,9 +105,7 @@ inline Foam::label Foam::globalIndex::toLocal(const label i) const inline Foam::label Foam::globalIndex::whichProcID(const label i) const { - label index = findLower(offsets_, i+1); - - if (index == Pstream::nProcs()-1) + if (i < 0 || i >= offsets_[Pstream::nProcs()]) { FatalErrorIn("globalIndex::whichProcID(const label)") << "Global " << i << " does not belong on any processor." @@ -128,7 +113,7 @@ inline Foam::label Foam::globalIndex::whichProcID(const label i) const << abort(FatalError); } - return index+1; + return findLower(offsets_, i+1); } diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 0c524920afb772bdaf1682afb7e3a40aeec40f92..47620111b8244b2b105dba09ec725442935fc2ce 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -27,7 +27,7 @@ License #include "mapDistribute.H" #include "commSchedule.H" #include "HashSet.H" -#include "ListOps.H" +#include "globalIndex.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -124,7 +124,7 @@ Foam::List<Foam::labelPair> Foam::mapDistribute::schedule ); // Processors involved in my schedule - return UIndirectList<labelPair>(allComms, mySchedule); + return List<labelPair>(UIndirectList<labelPair>(allComms, mySchedule)); //if (debug) @@ -257,6 +257,304 @@ Foam::mapDistribute::mapDistribute } +Foam::mapDistribute::mapDistribute +( + const globalIndex& globalNumbering, + labelList& elements, + List<Map<label> >& compactMap +) +: + constructSize_(0), + schedulePtr_() +{ + // 1. Construct per processor compact addressing of the global elements + // needed. The ones from the local processor are not included since + // these are always all needed. + compactMap.setSize(Pstream::nProcs()); + { + // Count all (non-local) elements needed. Just for presizing map. + labelList nNonLocal(Pstream::nProcs(), 0); + + forAll(elements, i) + { + label globalIndex = elements[i]; + + if (!globalNumbering.isLocal(globalIndex)) + { + label procI = globalNumbering.whichProcID(globalIndex); + nNonLocal[procI]++; + } + } + + forAll(compactMap, procI) + { + if (procI != Pstream::myProcNo()) + { + compactMap[procI].resize(2*nNonLocal[procI]); + } + } + + + // Collect all (non-local) elements needed. + forAll(elements, i) + { + label globalIndex = elements[i]; + + if (!globalNumbering.isLocal(globalIndex)) + { + label procI = globalNumbering.whichProcID(globalIndex); + label index = globalNumbering.toLocal(procI, globalIndex); + label nCompact = compactMap[procI].size(); + compactMap[procI].insert(index, nCompact); + } + } + + //// Sort remote elements needed (not really necessary) + //forAll(compactMap, procI) + //{ + // if (procI != Pstream::myProcNo()) + // { + // Map<label>& globalMap = compactMap[procI]; + // + // SortableList<label> sorted(globalMap.toc().xfer()); + // + // forAll(sorted, i) + // { + // Map<label>::iterator iter = globalMap.find(sorted[i]); + // iter() = i; + // } + // } + //} + } + + + // 2. The overall compact addressing is + // - myProcNo data first (uncompacted) + // - all other processors consecutively + + labelList compactStart(Pstream::nProcs()); + compactStart[Pstream::myProcNo()] = 0; + constructSize_ = globalNumbering.localSize(); + forAll(compactStart, procI) + { + if (procI != Pstream::myProcNo()) + { + compactStart[procI] = constructSize_; + constructSize_ += compactMap[procI].size(); + } + } + + + + // 3. Find out what to receive/send in compact addressing. + + // What I want to receive is what others have to send + labelListList wantedRemoteElements(Pstream::nProcs()); + // Compact addressing for received data + constructMap_.setSize(Pstream::nProcs()); + forAll(compactMap, procI) + { + if (procI == Pstream::myProcNo()) + { + // All my own elements are used + label nLocal = globalNumbering.localSize(); + wantedRemoteElements[procI] = identity(nLocal); + constructMap_[procI] = identity(nLocal); + } + else + { + // Remote elements wanted from processor procI + labelList& remoteElem = wantedRemoteElements[procI]; + labelList& localElem = constructMap_[procI]; + remoteElem.setSize(compactMap[procI].size()); + localElem.setSize(compactMap[procI].size()); + label i = 0; + forAllIter(Map<label>, compactMap[procI], iter) + { + remoteElem[i] = iter.key(); + label compactI = compactStart[procI]+iter(); + localElem[i] = compactI; + iter() = compactI; + i++; + } + } + } + + subMap_.setSize(Pstream::nProcs()); + labelListList sendSizes; + Pstream::exchange<labelList, label> + ( + wantedRemoteElements, + subMap_, + sendSizes + ); + + // Renumber elements + forAll(elements, i) + { + elements[i] = renumber(globalNumbering, compactMap, elements[i]); + } +} + + +Foam::mapDistribute::mapDistribute +( + const globalIndex& globalNumbering, + labelListList& cellCells, + List<Map<label> >& compactMap +) +: + constructSize_(0), + schedulePtr_() +{ + // 1. Construct per processor compact addressing of the global elements + // needed. The ones from the local processor are not included since + // these are always all needed. + compactMap.setSize(Pstream::nProcs()); + { + // Count all (non-local) elements needed. Just for presizing map. + labelList nNonLocal(Pstream::nProcs(), 0); + + forAll(cellCells, cellI) + { + const labelList& cCells = cellCells[cellI]; + + forAll(cCells, i) + { + label globalIndex = cCells[i]; + + if (!globalNumbering.isLocal(globalIndex)) + { + label procI = globalNumbering.whichProcID(globalIndex); + nNonLocal[procI]++; + } + } + } + + forAll(compactMap, procI) + { + if (procI != Pstream::myProcNo()) + { + compactMap[procI].resize(2*nNonLocal[procI]); + } + } + + + // Collect all (non-local) elements needed. + + + // Collect all (non-local) elements needed. + forAll(cellCells, cellI) + { + const labelList& cCells = cellCells[cellI]; + + forAll(cCells, i) + { + label globalIndex = cCells[i]; + + if (!globalNumbering.isLocal(globalIndex)) + { + label procI = globalNumbering.whichProcID(globalIndex); + label index = globalNumbering.toLocal(procI, globalIndex); + label nCompact = compactMap[procI].size(); + compactMap[procI].insert(index, nCompact); + } + } + } + + //// Sort remote elements needed (not really necessary) + //forAll(compactMap, procI) + //{ + // if (procI != Pstream::myProcNo()) + // { + // Map<label>& globalMap = compactMap[procI]; + // + // SortableList<label> sorted(globalMap.toc().xfer()); + // + // forAll(sorted, i) + // { + // Map<label>::iterator iter = globalMap.find(sorted[i]); + // iter() = i; + // } + // } + //} + } + + + // 2. The overall compact addressing is + // - myProcNo data first (uncompacted) + // - all other processors consecutively + + labelList compactStart(Pstream::nProcs()); + compactStart[Pstream::myProcNo()] = 0; + constructSize_ = globalNumbering.localSize(); + forAll(compactStart, procI) + { + if (procI != Pstream::myProcNo()) + { + compactStart[procI] = constructSize_; + constructSize_ += compactMap[procI].size(); + } + } + + + + // 3. Find out what to receive/send in compact addressing. + + // What I want to receive is what others have to send + labelListList wantedRemoteElements(Pstream::nProcs()); + // Compact addressing for received data + constructMap_.setSize(Pstream::nProcs()); + forAll(compactMap, procI) + { + if (procI == Pstream::myProcNo()) + { + // All my own elements are used + label nLocal = globalNumbering.localSize(); + wantedRemoteElements[procI] = identity(nLocal); + constructMap_[procI] = identity(nLocal); + } + else + { + // Remote elements wanted from processor procI + labelList& remoteElem = wantedRemoteElements[procI]; + labelList& localElem = constructMap_[procI]; + remoteElem.setSize(compactMap[procI].size()); + localElem.setSize(compactMap[procI].size()); + label i = 0; + forAllIter(Map<label>, compactMap[procI], iter) + { + remoteElem[i] = iter.key(); + label compactI = compactStart[procI]+iter(); + localElem[i] = compactI; + iter() = compactI; + i++; + } + } + } + + subMap_.setSize(Pstream::nProcs()); + labelListList sendSizes; + Pstream::exchange<labelList, label> + ( + wantedRemoteElements, + subMap_, + sendSizes + ); + + // Renumber elements + forAll(cellCells, cellI) + { + labelList& cCells = cellCells[cellI]; + + forAll(cCells, i) + { + cCells[i] = renumber(globalNumbering, compactMap, cCells[i]); + } + } +} + + Foam::mapDistribute::mapDistribute(const mapDistribute& map) : constructSize_(map.constructSize_), @@ -266,7 +564,27 @@ Foam::mapDistribute::mapDistribute(const mapDistribute& map) {} -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +Foam::label Foam::mapDistribute::renumber +( + const globalIndex& globalNumbering, + const List<Map<label> >& compactMap, + const label globalI +) +{ + if (globalNumbering.isLocal(globalI)) + { + return globalNumbering.toLocal(globalI); + } + else + { + label procI = globalNumbering.whichProcID(globalI); + label index = globalNumbering.toLocal(procI, globalI); + return compactMap[procI][index]; + } +} + void Foam::mapDistribute::compact(const boolList& elemIsUsed) { diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H index c6962355fdd5c24ce58ce70dcc54b557a72a0fe0..684a7edf27b314c000ab178cd544bff706b4264d 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.H @@ -39,6 +39,16 @@ Note: Note2: number of items send on one processor have to equal the number of items received on the other processor. + Constructors using compact numbering: all my own elements first + (whether used or not) followed by used-only remote elements. + So e.g 4 procs and on proc 1 the compact + table will first have all globalIndex.localSize() elements from proc1 + followed by used-only elements of proc0, proc2, proc3. + The constructed mapDistribute sends the local elements from and + receives the remote elements into their compact position. + compactMap[procI] is the position of elements from procI in the compact + map. compactMap[myProcNo()] is empty since trivial addressing. The indices + into compactMap[procI] are local, not global, indices. SourceFiles mapDistribute.C @@ -52,6 +62,7 @@ SourceFiles #include "labelPair.H" #include "Pstream.H" #include "boolList.H" +#include "Map.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -59,6 +70,7 @@ namespace Foam { class mapPolyMesh; +class globalIndex; /*---------------------------------------------------------------------------*\ Class mapDistribute Declaration @@ -83,28 +95,6 @@ class mapDistribute public: - // Public classes - - //- combineReduce operator for lists. Used for counting. - class listEq - { - - public: - - template<class T> - void operator()(T& x, const T& y) const - { - forAll(y, i) - { - if (y[i].size()) - { - x[i] = y[i]; - } - } - } - }; - - // Constructors //- Construct from components @@ -123,6 +113,27 @@ public: const labelList& recvProcs ); + //- Construct from list of (possibly) remote elements in globalIndex + // numbering. Determines compact numbering (see above) and + // distribute map to get data into this ordering and renumbers the + // elements to be in compact numbering. + mapDistribute + ( + const globalIndex&, + labelList& elements, + List<Map<label> >& compactMap + ); + + //- Special variant that works with the into sorted into bins + // according to local indices. E.g. think cellCells where + // cellCells[localCellI] is a list of global cells + mapDistribute + ( + const globalIndex&, + labelListList& cellCells, + List<Map<label> >& compactMap + ); + //- Construct copy mapDistribute(const mapDistribute&); @@ -180,6 +191,15 @@ public: // Other + //- Helper for construct from globalIndex. Renumbers element + // (in globalIndex numbering) into compact indices. + static label renumber + ( + const globalIndex&, + const List<Map<label> >& compactMap, + const label globalElement + ); + //- Compact maps. Gets per field a bool whether it is used (locally) // and works out itself what this side and sender side can remove // from maps. diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index bd3e6b744e6c844b9c867a8ec11be081b81b04fb..09ce0cb1b7dd500c60feb435916fc4396568060e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -25,6 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "Pstream.H" +#include "PstreamBuffers.H" #include "PstreamCombineReduceOps.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -185,17 +186,9 @@ void Foam::mapDistribute::distribute { if (!contiguous<T>()) { - // 1. convert to contiguous buffer - // 2. send buffer - // 3. receive buffer - // 4. read from buffer into List<T> + PstreamBuffers pBuffs(Pstream::nonBlocking); - List<List<char> > sendFields(Pstream::nProcs()); - labelListList allNTrans(Pstream::nProcs()); - labelList& nsTransPs = allNTrans[Pstream::myProcNo()]; - nsTransPs.setSize(Pstream::nProcs(), 0); - - // Stream data into sendField buffers + // Stream data into buffer for (label domain = 0; domain < Pstream::nProcs(); domain++) { const labelList& map = subMap[domain]; @@ -203,66 +196,13 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { // Put data into send buffer - OPstream toDomain(Pstream::nonBlocking, domain); + UOPstream toDomain(domain, pBuffs); toDomain << UIndirectList<T>(field, map); - - // Store the size - nsTransPs[domain] = toDomain.bufPosition(); - - // Transfer buffer out - sendFields[domain].transfer(toDomain.buf()); - toDomain.bufPosition() = 0; - - } - } - - // Send sizes across - combineReduce(allNTrans, listEq()); - - // Start sending buffers - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = subMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) - { - OPstream::write - ( - Pstream::nonBlocking, - domain, - reinterpret_cast<const char*> - ( - sendFields[domain].begin() - ), - nsTransPs[domain] - ); - } - } - - // Set up receives from neighbours - - PtrList<IPstream> fromSlave(Pstream::nProcs()); - - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = constructMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) - { - // Start receiving - fromSlave.set - ( - domain, - new IPstream - ( - Pstream::nonBlocking, - domain, - allNTrans[domain][Pstream::myProcNo()] - ) - ); } } + // Start receiving + pBuffs.finishedSends(); { // Set up 'send' to myself @@ -285,10 +225,6 @@ void Foam::mapDistribute::distribute } } - - // Wait till all finished - Pstream::waitRequests(); - // Consume for (label domain = 0; domain < Pstream::nProcs(); domain++) { @@ -296,7 +232,8 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - List<T> recvField(fromSlave[domain]); + UIPstream str(domain, pBuffs); + List<T> recvField(str); if (recvField.size() != map.size()) { @@ -322,9 +259,6 @@ void Foam::mapDistribute::distribute { field[map[i]] = recvField[i]; } - - // Delete receive buffer - fromSlave.set(domain, NULL); } } } @@ -618,17 +552,10 @@ void Foam::mapDistribute::distribute { if (!contiguous<T>()) { - // 1. convert to contiguous buffer - // 2. send buffer - // 3. receive buffer - // 4. read from buffer into List<T> - - List<List<char> > sendFields(Pstream::nProcs()); - labelListList allNTrans(Pstream::nProcs()); - labelList& nsTransPs = allNTrans[Pstream::myProcNo()]; - nsTransPs.setSize(Pstream::nProcs()); +//XXXXXX + PstreamBuffers pBuffs(Pstream::nonBlocking); - // Stream data into sendField buffers + // Stream data into buffer for (label domain = 0; domain < Pstream::nProcs(); domain++) { const labelList& map = subMap[domain]; @@ -636,65 +563,13 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { // Put data into send buffer - OPstream toDomain(Pstream::nonBlocking, domain); + UOPstream toDomain(domain, pBuffs); toDomain << UIndirectList<T>(field, map); - - // Store the size - nsTransPs[domain] = toDomain.bufPosition(); - - // Transfer buffer out - sendFields[domain].transfer(toDomain.buf()); - toDomain.bufPosition() = 0; - } - } - - // Send sizes across - combineReduce(allNTrans, listEq()); - - // Start sending buffers - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = subMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) - { - OPstream::write - ( - Pstream::nonBlocking, - domain, - reinterpret_cast<const char*> - ( - sendFields[domain].begin() - ), - nsTransPs[domain] - ); - } - } - - // Set up receives from neighbours - - PtrList<IPstream> fromSlave(Pstream::nProcs()); - - for (label domain = 0; domain < Pstream::nProcs(); domain++) - { - const labelList& map = constructMap[domain]; - - if (domain != Pstream::myProcNo() && map.size()) - { - // Start receiving - fromSlave.set - ( - domain, - new IPstream - ( - Pstream::nonBlocking, - domain, - allNTrans[domain][Pstream::myProcNo()] - ) - ); } } + // Start receiving + pBuffs.finishedSends(); { // Set up 'send' to myself @@ -715,7 +590,7 @@ void Foam::mapDistribute::distribute // Wait till all finished - Pstream::waitRequests(); + UPstream::waitRequests(); // Consume for (label domain = 0; domain < Pstream::nProcs(); domain++) @@ -724,7 +599,8 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { - List<T> recvField(fromSlave[domain]); + UIPstream str(domain, pBuffs); + List<T> recvField(str); if (recvField.size() != map.size()) { @@ -750,9 +626,6 @@ void Foam::mapDistribute::distribute { cop(field[map[i]], recvField[i]); } - - // Delete receive buffer - fromSlave.set(domain, NULL); } } } @@ -796,7 +669,7 @@ void Foam::mapDistribute::distribute if (domain != Pstream::myProcNo() && map.size()) { recvFields[domain].setSize(map.size()); - IPstream::read + UIPstream::read ( Pstream::nonBlocking, domain, diff --git a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C index da198638a23cbdbde87b217125d07dcbc302d288..f450272502e3599e31ef738be74ffb199d13fdb5 100644 --- a/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/syncTools/syncToolsTemplates.C @@ -402,11 +402,7 @@ void Foam::syncTools::syncPointMap { // Send to master { - OPstream toMaster - ( - Pstream::blocking, - Pstream::masterNo() - ); + OPstream toMaster(Pstream::blocking, Pstream::masterNo()); toMaster << sharedPointValues; } // Receive merged values diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamsPrint.C b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H similarity index 75% rename from src/OpenFOAM/db/IOstreams/Pstreams/PstreamsPrint.C rename to src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H index 2e744303b36373d1eade9552ebd2201b77eae1f5..4afb30dd22888ee7cff0cf4357fe2ad5560ba186 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamsPrint.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitivePatch/uindirectPrimitivePatch.H @@ -22,28 +22,32 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +Typedef + Foam::uindirectPrimitivePatch + Description - Prints out a description of the streams + Foam::uindirectPrimitivePatch \*---------------------------------------------------------------------------*/ -#include "IPstream.H" -#include "OPstream.H" +#ifndef uindirectPrimitivePatch_H +#define uindirectPrimitivePatch_H + +#include "PrimitivePatch.H" +#include "face.H" +#include "UIndirectList.H" +#include "pointField.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Foam::IPstream::print(Ostream& os) const +namespace Foam { - os << "Reading from processor " << fromProcNo_ - << " to processor " << myProcNo() << Foam::endl; + typedef PrimitivePatch<face, UIndirectList, const pointField&> + uindirectPrimitivePatch; } +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Foam::OPstream::print(Ostream& os) const -{ - os << "Writing from processor " << toProcNo_ - << " to processor " << myProcNo() << Foam::endl; -} - +#endif // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H index fe2bf0986508ea59c9985ac45fe66684b790cb24..16e1fc3a22519b5c4c3ceb6b80a37879eafa26ff 100644 --- a/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H +++ b/src/OpenFOAM/meshes/primitiveShapes/objectHit/objectHit.H @@ -76,7 +76,7 @@ public: {} //- Construct from components - objectHit(const bool success, const label& obj) + objectHit(const bool success, const label obj) : hit_(success), hitObject_(obj) @@ -111,7 +111,7 @@ public: { return ((a.hit_ == b.hit_) && (a.hitObject_ == b.hitObject_)); } - + friend bool operator!=(const objectHit& a, const objectHit& b) { return (!(a == b)); diff --git a/src/OpenFOAM/primitives/hashes/Hash/Hash.H b/src/OpenFOAM/primitives/hashes/Hash/Hash.H index dd16517dfe041935831a907696969452666ce790..b998daea1bb8fe86db54ee9084134b23b6ddff75 100644 --- a/src/OpenFOAM/primitives/hashes/Hash/Hash.H +++ b/src/OpenFOAM/primitives/hashes/Hash/Hash.H @@ -107,7 +107,7 @@ public: //- Incrementally hash a label. // This will necessarily return a different value than the // non-incremental version. - unsigned operator()(const label& p, unsigned seed) const + unsigned operator()(const label p, unsigned seed) const { return Hasher(&p, sizeof(label), seed); } @@ -115,11 +115,10 @@ public: //- Return the unsigned representation of a label. // This helps if people have relied on the hash value corresponding to // the natural order. - unsigned operator()(const label& p) const + unsigned operator()(const label p) const { return p; } - }; diff --git a/src/OpenFOAM/primitives/random/Random.C b/src/OpenFOAM/primitives/random/Random.C index 848b3a554720705422ea129b4f2219941b62774d..570817e692f709a0cbd1f09ee48d7a398d61b05d 100644 --- a/src/OpenFOAM/primitives/random/Random.C +++ b/src/OpenFOAM/primitives/random/Random.C @@ -47,8 +47,7 @@ namespace Foam // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// construct given seed -Random::Random(const label& seed) +Random::Random(const label seed) { if (seed > 1) { diff --git a/src/OpenFOAM/primitives/random/Random.H b/src/OpenFOAM/primitives/random/Random.H index f611f906001ffe505c289ddfb383014bb1ada81b..2339e607b5aa953490bde14c48bdf0e7c3a9d7fb 100644 --- a/src/OpenFOAM/primitives/random/Random.H +++ b/src/OpenFOAM/primitives/random/Random.H @@ -61,7 +61,7 @@ public: // Constructors //- Construct given seed - Random(const label&); + Random(const label); // Member functions @@ -70,14 +70,19 @@ public: //- scalar [0..1] (so including 0,1) scalar scalar01(); + //- vector with every component scalar01 vector vector01(); + //- sphericalTensor with every component scalar01 sphericalTensor sphericalTensor01(); + //- symmTensor with every component scalar01 symmTensor symmTensor01(); + //- tensor with every component scalar01 tensor tensor01(); + //- label [lower..upper] label integer(const label lower, const label upper); diff --git a/src/Pstream/dummy/Make/files b/src/Pstream/dummy/Make/files index 073e090a0ff42f95e9bc64eba003a348a729fbbc..c025891574bf3e80d0099f7b382864188a6e8a62 100644 --- a/src/Pstream/dummy/Make/files +++ b/src/Pstream/dummy/Make/files @@ -1,5 +1,5 @@ -Pstream.C -IPread.C -OPwrite.C +UPstream.C +UIPread.C +UOPwrite.C LIB = $(FOAM_LIBBIN)/dummy/libPstream diff --git a/src/Pstream/dummy/IPread.C b/src/Pstream/dummy/UIPread.C similarity index 74% rename from src/Pstream/dummy/IPread.C rename to src/Pstream/dummy/UIPread.C index 8e3d64982bdf60e504a00a9d1a02eeb87fa34202..a91a007e43eb60a60926d6ab3f6ed6c39743f1b5 100644 --- a/src/Pstream/dummy/IPread.C +++ b/src/Pstream/dummy/UIPread.C @@ -23,62 +23,66 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Read token and binary block from IPstream + Read from UIPstream \*---------------------------------------------------------------------------*/ -#include "error.H" -#include "IPstream.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#include "UIPstream.H" // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // -Foam::IPstream::IPstream +Foam::UIPstream::UIPstream ( const commsTypes commsType, const int fromProcNo, - const label bufSize, + DynamicList<char>& externalBuf, + const int tag, streamFormat format, versionNumber version ) : - Pstream(commsType, bufSize), + UPstream(commsType), Istream(format, version), fromProcNo_(fromProcNo), + externalBuf_(externalBuf), + externalBufPosition_(0), + tag_(tag), messageSize_(0) { - notImplemented - ( - "IPsream::IPstream" - "(" - "const commsTypes," - "const int fromProcNo," - "const label bufSize," - "streamFormat, versionNumber" - ")" - ); + notImplemented + ( + "UIPstream::UIPstream" + "(" + "const commsTypes," + "const int fromProcNo," + "DynamicList<char>&," + "const int tag," + "streamFormat, versionNumber" + ")" + ); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -int Foam::IPstream::read +Foam::label Foam::UIPstream::read ( const commsTypes commsType, const int fromProcNo, char* buf, - const std::streamsize bufSize + const std::streamsize bufSize, + const int tag ) { notImplemented ( - "IPstream::read" + "UIPstream::read" "(" "const commsTypes," "const int fromProcNo," "char* buf," - "const label bufSize" + "const label bufSize," + "const int tag" ")" ); diff --git a/src/Pstream/dummy/OPwrite.C b/src/Pstream/dummy/UOPwrite.C similarity index 72% rename from src/Pstream/dummy/OPwrite.C rename to src/Pstream/dummy/UOPwrite.C index ad12d738fda3d4849bb5b1cf8c3526e1a02edeba..4f6ce038c39cf01cb4a437dc7d4661b6b96c456e 100644 --- a/src/Pstream/dummy/OPwrite.C +++ b/src/Pstream/dummy/UOPwrite.C @@ -27,41 +27,32 @@ Description \*---------------------------------------------------------------------------*/ -#include "error.H" -#include "OPstream.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::OPstream::~OPstream() -{ - notImplemented("OPstream::~OPstream()"); -} - +#include "UOPstream.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::OPstream::write +bool Foam::UOPstream::write ( const commsTypes commsType, const int toProcNo, const char* buf, - const std::streamsize bufSize + const std::streamsize bufSize, + const int tag ) { - notImplemented - ( - "IPstream::write" - "(" - "const commsTypes commsType," - "const int fromProcNo," - "char* buf," - "const label bufSize" - ")" - ); - - return false; + notImplemented + ( + "UOPstream::write" + "(" + "const commsTypes commsType," + "const int fromProcNo," + "char* buf," + "const label bufSize," + "const int tag" + ")" + ); + + return false; } diff --git a/src/Pstream/dummy/Pstream.C b/src/Pstream/dummy/UPstream.C similarity index 74% rename from src/Pstream/dummy/Pstream.C rename to src/Pstream/dummy/UPstream.C index bd22701cfeb4b436c52a3ddfbb239a3d364d8023..3ff9bd69ec9f479d9379dd679b5563e1f8ba0503 100644 --- a/src/Pstream/dummy/Pstream.C +++ b/src/Pstream/dummy/UPstream.C @@ -24,20 +24,18 @@ License \*---------------------------------------------------------------------------*/ -#include "Pstream.H" +#include "UPstream.H" #include "PstreamReduceOps.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -void Foam::Pstream::addValidParOptions(HashTable<string>& validParOptions) +void Foam::UPstream::addValidParOptions(HashTable<string>& validParOptions) {} -bool Foam::Pstream::init(int& argc, char**& argv) +bool Foam::UPstream::init(int& argc, char**& argv) { - FatalErrorIn("Pstream::init(int& argc, char**& argv)") + FatalErrorIn("UPstream::init(int& argc, char**& argv)") << "Trying to use the dummy Pstream library." << nl << "This dummy library cannot be used in parallel mode" << Foam::exit(FatalError); @@ -46,15 +44,15 @@ bool Foam::Pstream::init(int& argc, char**& argv) } -void Foam::Pstream::exit(int errnum) +void Foam::UPstream::exit(int errnum) { - notImplemented("Pstream::exit(int errnum)"); + notImplemented("UPstream::exit(int errnum)"); } -void Foam::Pstream::abort() +void Foam::UPstream::abort() { - notImplemented("Pstream::abort()"); + notImplemented("UPstream::abort()"); } @@ -63,13 +61,13 @@ void Foam::reduce(scalar&, const sumOp<scalar>&) -void Foam::Pstream::waitRequests() +void Foam::UPstream::waitRequests() {} -bool Foam::Pstream::finishedRequest(const label i) +bool Foam::UPstream::finishedRequest(const label i) { - notImplemented("Pstream::finishedRequest()"); + notImplemented("UPstream::finishedRequest()"); return false; } diff --git a/src/Pstream/mpi/Make/files b/src/Pstream/mpi/Make/files index 6b1d3f4c575cdd33c8080958dc75cea7b1f27304..eccdf776646facdf15c41782c80a2eccf10f7c5f 100644 --- a/src/Pstream/mpi/Make/files +++ b/src/Pstream/mpi/Make/files @@ -1,6 +1,6 @@ -OPwrite.C -IPread.C -Pstream.C +UOPwrite.C +UIPread.C +UPstream.C PstreamGlobals.C LIB = $(FOAM_MPI_LIBBIN)/libPstream diff --git a/src/Pstream/mpi/IPread.C b/src/Pstream/mpi/UIPread.C similarity index 54% rename from src/Pstream/mpi/IPread.C rename to src/Pstream/mpi/UIPread.C index 966ae7ddc99fad8bf65cfd15bddc2591535d9234..14360e0cc095039aa49c2cc8c76a0f6454f40c92 100644 --- a/src/Pstream/mpi/IPread.C +++ b/src/Pstream/mpi/UIPread.C @@ -23,91 +23,161 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Read token and binary block from IPstream + Read from UIPstream \*---------------------------------------------------------------------------*/ #include "mpi.h" -#include "IPstream.H" +#include "UIPstream.H" #include "PstreamGlobals.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -// Outstanding non-blocking operations. -//! @cond fileScope -//Foam::DynamicList<MPI_Request> IPstream_outstandingRequests_; -//! @endcond fileScope +#include "IOstreams.H" // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // -Foam::IPstream::IPstream +Foam::UIPstream::UIPstream ( const commsTypes commsType, const int fromProcNo, - const label bufSize, + DynamicList<char>& externalBuf, + const int tag, streamFormat format, versionNumber version ) : - Pstream(commsType, bufSize), + UPstream(commsType), Istream(format, version), fromProcNo_(fromProcNo), + externalBuf_(externalBuf), + externalBufPosition_(0), + tag_(tag), messageSize_(0) { setOpened(); setGood(); - MPI_Status status; + if (commsType == UPstream::nonBlocking) + { + // Message is already received into externalBuf + } + else + { + MPI_Status status; - // Cannot use buf_.size() since appends a few bytes extra - label realBufSize = bufSize; + label wantedSize = externalBuf_.capacity(); - // If the buffer size is not specified, probe the incomming message - // and set it - if (!bufSize) - { - if (commsType == nonBlocking) + // If the buffer size is not specified, probe the incomming message + // and set it + if (!wantedSize) + { + MPI_Probe(procID(fromProcNo_), tag_, MPI_COMM_WORLD, &status); + MPI_Get_count(&status, MPI_BYTE, &messageSize_); + + externalBuf_.setCapacity(messageSize_); + wantedSize = messageSize_; + } + + messageSize_ = UIPstream::read + ( + commsType, + fromProcNo_, + externalBuf_.begin(), + wantedSize, + tag_ + ); + + // Set addressed size. Leave actual allocated memory intact. + externalBuf_.setSize(messageSize_); + + if (!messageSize_) { FatalErrorIn ( - "IPstream::IPstream(const commsTypes, const int, " - "const label, streamFormat, versionNumber)" - ) << "Can use nonBlocking mode only with pre-allocated buffers" + "UIPstream::UIPstream(const commsTypes, const int, " + "DynamicList<char>&, streamFormat, versionNumber)" + ) << "read failed" << Foam::abort(FatalError); } + } +} - MPI_Probe(procID(fromProcNo_), msgType(), MPI_COMM_WORLD, &status); - MPI_Get_count(&status, MPI_BYTE, &messageSize_); - buf_.setSize(messageSize_); - realBufSize = buf_.size(); +Foam::UIPstream::UIPstream(const int fromProcNo, PstreamBuffers& buffers) +: + UPstream(buffers.commsType_), + Istream(buffers.format_, buffers.version_), + fromProcNo_(fromProcNo), + externalBuf_(buffers.recvBuf_[fromProcNo]), + externalBufPosition_(0), + tag_(buffers.tag_), + messageSize_(0) +{ + if (commsType() != UPstream::scheduled && !buffers.finishedSendsCalled_) + { + FatalErrorIn("UIPstream::UIPstream(const int, PstreamBuffers&)") + << "PstreamBuffers::finishedSends() never called." << endl + << "Please call PstreamBuffers::finishedSends() after doing" + << " all your sends (using UOPstream) and before doing any" + << " receives (using UIPstream)" << Foam::exit(FatalError); } - messageSize_ = read(commsType, fromProcNo_, buf_.begin(), realBufSize); + setOpened(); + setGood(); - if (!messageSize_) + if (commsType() == UPstream::nonBlocking) { - FatalErrorIn + // Message is already received into externalBuf + } + else + { + MPI_Status status; + + label wantedSize = externalBuf_.capacity(); + + // If the buffer size is not specified, probe the incomming message + // and set it + if (!wantedSize) + { + MPI_Probe(procID(fromProcNo_), tag_, MPI_COMM_WORLD, &status); + MPI_Get_count(&status, MPI_BYTE, &messageSize_); + + externalBuf_.setCapacity(messageSize_); + wantedSize = messageSize_; + } + + messageSize_ = UIPstream::read ( - "IPstream::IPstream(const commsTypes, const int, " - "const label, streamFormat, versionNumber)" - ) << "read failed" - << Foam::abort(FatalError); + commsType(), + fromProcNo_, + externalBuf_.begin(), + wantedSize, + tag_ + ); + + // Set addressed size. Leave actual allocated memory intact. + externalBuf_.setSize(messageSize_); + + if (!messageSize_) + { + FatalErrorIn + ( + "UIPstream::UIPstream(const int, PstreamBuffers&)" + ) << "read failed" + << Foam::abort(FatalError); + } } } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::IPstream::read +Foam::label Foam::UIPstream::read ( const commsTypes commsType, const int fromProcNo, char* buf, - const std::streamsize bufSize + const std::streamsize bufSize, + const int tag ) { if (commsType == blocking || commsType == scheduled) @@ -122,7 +192,7 @@ Foam::label Foam::IPstream::read bufSize, MPI_PACKED, procID(fromProcNo), - msgType(), + tag, MPI_COMM_WORLD, &status ) @@ -130,7 +200,7 @@ Foam::label Foam::IPstream::read { FatalErrorIn ( - "IPstream::read" + "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot receive incomming message" << Foam::abort(FatalError); @@ -148,7 +218,7 @@ Foam::label Foam::IPstream::read { FatalErrorIn ( - "IPstream::read" + "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "buffer (" << label(bufSize) << ") not large enough for incomming message (" @@ -170,7 +240,7 @@ Foam::label Foam::IPstream::read bufSize, MPI_PACKED, procID(fromProcNo), - msgType(), + tag, MPI_COMM_WORLD, &request ) @@ -178,7 +248,7 @@ Foam::label Foam::IPstream::read { FatalErrorIn ( - "IPstream::read" + "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "MPI_Recv cannot start non-blocking receive" << Foam::abort(FatalError); @@ -195,7 +265,7 @@ Foam::label Foam::IPstream::read { FatalErrorIn ( - "IPstream::read" + "UIPstream::read" "(const int fromProcNo, char* buf, std::streamsize bufSize)" ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); @@ -205,6 +275,4 @@ Foam::label Foam::IPstream::read } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/src/Pstream/mpi/OPwrite.C b/src/Pstream/mpi/UOPwrite.C similarity index 70% rename from src/Pstream/mpi/OPwrite.C rename to src/Pstream/mpi/UOPwrite.C index 1e963ec13fa767372dbb5ddadfe23af588ad51fd..f8439ba517ed43d09fb82896e429b6e5d065d1ac 100644 --- a/src/Pstream/mpi/OPwrite.C +++ b/src/Pstream/mpi/UOPwrite.C @@ -29,54 +29,18 @@ Description #include "mpi.h" -#include "OPstream.H" +#include "UOPstream.H" #include "PstreamGlobals.H" -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::OPstream::~OPstream() -{ - if (commsType_ == nonBlocking) - { - // alloc nonBlocking only if empty buffer. This denotes the buffer - // having been transfered out. - if (bufPosition_ > 0) - { - FatalErrorIn("OPstream::~OPstream()") - << "OPstream contains buffer so cannot be used with nonBlocking" - << " since destructor would destroy buffer whilst possibly" - << " still sending." << Foam::abort(FatalError); - } - } - else - { - if - ( - !write - ( - commsType_, - toProcNo_, - buf_.begin(), - bufPosition_ - ) - ) - { - FatalErrorIn("OPstream::~OPstream()") - << "MPI cannot send outgoing message" - << Foam::abort(FatalError); - } - } -} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -bool Foam::OPstream::write +bool Foam::UOPstream::write ( const commsTypes commsType, const int toProcNo, const char* buf, - const std::streamsize bufSize + const std::streamsize bufSize, + const int tag ) { bool transferFailed = true; @@ -89,7 +53,7 @@ bool Foam::OPstream::write bufSize, MPI_PACKED, procID(toProcNo), - msgType(), + tag, MPI_COMM_WORLD ); } @@ -101,7 +65,7 @@ bool Foam::OPstream::write bufSize, MPI_PACKED, procID(toProcNo), - msgType(), + tag, MPI_COMM_WORLD ); } @@ -115,7 +79,7 @@ bool Foam::OPstream::write bufSize, MPI_PACKED, procID(toProcNo), - msgType(), + tag, MPI_COMM_WORLD, &request ); @@ -126,8 +90,9 @@ bool Foam::OPstream::write { FatalErrorIn ( - "OPstream::write" - "(const int fromProcNo, char* buf, std::streamsize bufSize)" + "UOPstream::write" + "(const int fromProcNo, char* buf, std::streamsize bufSize" + ", const int)" ) << "Unsupported communications type " << commsType << Foam::abort(FatalError); } diff --git a/src/Pstream/mpi/Pstream.C b/src/Pstream/mpi/UPstream.C similarity index 84% rename from src/Pstream/mpi/Pstream.C rename to src/Pstream/mpi/UPstream.C index a535f4804ede6d95feafcba1fca4d33f7fed788f..b5a76e36e9ee26b8155728d624e6c5c46d877904 100644 --- a/src/Pstream/mpi/Pstream.C +++ b/src/Pstream/mpi/UPstream.C @@ -26,7 +26,7 @@ License #include "mpi.h" -#include "Pstream.H" +#include "UPstream.H" #include "PstreamReduceOps.H" #include "OSspecific.H" #include "PstreamGlobals.H" @@ -50,7 +50,7 @@ License // valid parallel options vary between implementations, but flag common ones. // if they are not removed by MPI_Init(), the subsequent argument processing // will notice that they are wrong -void Foam::Pstream::addValidParOptions(HashTable<string>& validParOptions) +void Foam::UPstream::addValidParOptions(HashTable<string>& validParOptions) { validParOptions.insert("np", ""); validParOptions.insert("p4pg", "PI file"); @@ -62,7 +62,7 @@ void Foam::Pstream::addValidParOptions(HashTable<string>& validParOptions) } -bool Foam::Pstream::init(int& argc, char**& argv) +bool Foam::UPstream::init(int& argc, char**& argv) { MPI_Init(&argc, &argv); @@ -72,8 +72,8 @@ bool Foam::Pstream::init(int& argc, char**& argv) if (numprocs <= 1) { - FatalErrorIn("Pstream::init(int& argc, char**& argv)") - << "bool Pstream::init(int& argc, char**& argv) : " + FatalErrorIn("UPstream::init(int& argc, char**& argv)") + << "bool IPstream::init(int& argc, char**& argv) : " "attempt to run parallel on 1 processor" << Foam::abort(FatalError); } @@ -101,8 +101,8 @@ bool Foam::Pstream::init(int& argc, char**& argv) } else { - FatalErrorIn("Pstream::init(int& argc, char**& argv)") - << "Pstream::init(int& argc, char**& argv) : " + FatalErrorIn("UPstream::init(int& argc, char**& argv)") + << "UPstream::init(int& argc, char**& argv) : " << "environment variable MPI_BUFFER_SIZE not defined" << Foam::abort(FatalError); } @@ -122,7 +122,7 @@ bool Foam::Pstream::init(int& argc, char**& argv) } -void Foam::Pstream::exit(int errnum) +void Foam::UPstream::exit(int errnum) { # ifndef SGIMPI int size; @@ -136,10 +136,10 @@ void Foam::Pstream::exit(int errnum) label n = PstreamGlobals::outstandingRequests_.size(); PstreamGlobals::outstandingRequests_.clear(); - WarningIn("Pstream::exit(int)") + WarningIn("UPstream::exit(int)") << "There are still " << n << " outstanding MPI_Requests." << endl << "This means that your code exited before doing a" - << " Pstream::waitRequests()." << endl + << " UPstream::waitRequests()." << endl << "This should not happen for a normal code exit." << endl; } @@ -156,7 +156,7 @@ void Foam::Pstream::exit(int errnum) } -void Foam::Pstream::abort() +void Foam::UPstream::abort() { MPI_Abort(MPI_COMM_WORLD, 1); } @@ -164,19 +164,19 @@ void Foam::Pstream::abort() void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) { - if (!Pstream::parRun()) + if (!UPstream::parRun()) { return; } - if (Pstream::nProcs() <= Pstream::nProcsSimpleSum) + if (UPstream::nProcs() <= UPstream::nProcsSimpleSum) { - if (Pstream::master()) + if (UPstream::master()) { for ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); + int slave=UPstream::firstSlave(); + slave<=UPstream::lastSlave(); slave++ ) { @@ -189,8 +189,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &value, 1, MPI_SCALAR, - Pstream::procID(slave), - Pstream::msgType(), + UPstream::procID(slave), + UPstream::msgType(), MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -215,8 +215,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &Value, 1, MPI_SCALAR, - Pstream::procID(Pstream::masterNo()), - Pstream::msgType(), + UPstream::procID(UPstream::masterNo()), + UPstream::msgType(), MPI_COMM_WORLD ) ) @@ -230,12 +230,12 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) } - if (Pstream::master()) + if (UPstream::master()) { for ( - int slave=Pstream::firstSlave(); - slave<=Pstream::lastSlave(); + int slave=UPstream::firstSlave(); + slave<=UPstream::lastSlave(); slave++ ) { @@ -246,8 +246,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &Value, 1, MPI_SCALAR, - Pstream::procID(slave), - Pstream::msgType(), + UPstream::procID(slave), + UPstream::msgType(), MPI_COMM_WORLD ) ) @@ -269,8 +269,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &Value, 1, MPI_SCALAR, - Pstream::procID(Pstream::masterNo()), - Pstream::msgType(), + UPstream::procID(UPstream::masterNo()), + UPstream::msgType(), MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -291,8 +291,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) Value = sum; /* - int myProcNo = Pstream::myProcNo(); - int nProcs = Pstream::nProcs(); + int myProcNo = UPstream::myProcNo(); + int nProcs = UPstream::nProcs(); // // receive from children @@ -321,8 +321,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &value, 1, MPI_SCALAR, - Pstream::procID(childProcId), - Pstream::msgType(), + UPstream::procID(childProcId), + UPstream::msgType(), MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -346,7 +346,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) // // send and receive from parent // - if (!Pstream::master()) + if (!UPstream::master()) { int parentId = myProcNo - (myProcNo % thisLevelOffset); @@ -357,8 +357,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &Value, 1, MPI_SCALAR, - Pstream::procID(parentId), - Pstream::msgType(), + UPstream::procID(parentId), + UPstream::msgType(), MPI_COMM_WORLD ) ) @@ -377,8 +377,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &Value, 1, MPI_SCALAR, - Pstream::procID(parentId), - Pstream::msgType(), + UPstream::procID(parentId), + UPstream::msgType(), MPI_COMM_WORLD, MPI_STATUS_IGNORE ) @@ -413,8 +413,8 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) &Value, 1, MPI_SCALAR, - Pstream::procID(childProcId), - Pstream::msgType(), + UPstream::procID(childProcId), + UPstream::msgType(), MPI_COMM_WORLD ) ) @@ -436,7 +436,7 @@ void Foam::reduce(scalar& Value, const sumOp<scalar>& bop) } -void Foam::Pstream::waitRequests() +void Foam::UPstream::waitRequests() { if (PstreamGlobals::outstandingRequests_.size()) { @@ -452,7 +452,7 @@ void Foam::Pstream::waitRequests() { FatalErrorIn ( - "Pstream::waitRequests()" + "UPstream::waitRequests()" ) << "MPI_Waitall returned with error" << Foam::endl; } @@ -461,13 +461,13 @@ void Foam::Pstream::waitRequests() } -bool Foam::Pstream::finishedRequest(const label i) +bool Foam::UPstream::finishedRequest(const label i) { if (i >= PstreamGlobals::outstandingRequests_.size()) { FatalErrorIn ( - "Pstream::finishedRequest(const label)" + "UPstream::finishedRequest(const label)" ) << "There are " << PstreamGlobals::outstandingRequests_.size() << " outstanding send requests and you are asking for i=" << i << nl diff --git a/src/conversion/ensight/file/ensightFile.C b/src/conversion/ensight/file/ensightFile.C index 8cb28f8c5ef5faccd7889f76cb351eaf09b709f0..095d2659f844f7e1200003a5a718eb7a5aa972b4 100644 --- a/src/conversion/ensight/file/ensightFile.C +++ b/src/conversion/ensight/file/ensightFile.C @@ -74,7 +74,7 @@ bool Foam::ensightFile::allowUndef(bool value) } -Foam::scalar Foam::ensightFile::undefValue(const scalar& value) +Foam::scalar Foam::ensightFile::undefValue(const scalar value) { // enable its use too allowUndef_ = true; @@ -133,7 +133,7 @@ Foam::Ostream& Foam::ensightFile::write(const string& value) } -Foam::Ostream& Foam::ensightFile::write(const label& value) +Foam::Ostream& Foam::ensightFile::write(const label value) { if (format() == IOstream::BINARY) { @@ -157,7 +157,7 @@ Foam::Ostream& Foam::ensightFile::write(const label& value) Foam::Ostream& Foam::ensightFile::write ( - const label& value, + const label value, const label fieldWidth ) { @@ -181,7 +181,7 @@ Foam::Ostream& Foam::ensightFile::write } -Foam::Ostream& Foam::ensightFile::write(const scalar& value) +Foam::Ostream& Foam::ensightFile::write(const scalar value) { if (format() == IOstream::BINARY) { diff --git a/src/conversion/ensight/file/ensightFile.H b/src/conversion/ensight/file/ensightFile.H index 1fa91f85614961bf36fe8256fa2e7a86f0d9da30..ca621141603473b23b41c127be152c5b1a8405fe 100644 --- a/src/conversion/ensight/file/ensightFile.H +++ b/src/conversion/ensight/file/ensightFile.H @@ -103,7 +103,7 @@ public: //- Assign the value to represent undef in the results // Returns the previous value // NB: do not use values larger than floatScalarVGREAT - static scalar undefValue(const scalar&); + static scalar undefValue(const scalar); // Output @@ -124,13 +124,13 @@ public: Ostream& write(const string& value); //- write integer as "%10d" or as binary - Ostream& write(const label& value); + Ostream& write(const label value); //- write integer with specified width or as binary - Ostream& write(const label& value, const label fieldWidth); + Ostream& write(const label value, const label fieldWidth); //- write float as "%12.5e" or as binary - Ostream& write(const scalar& value); + Ostream& write(const scalar value); //- Add carriage return to ascii stream void newline(); diff --git a/src/conversion/meshTables/cellTable.C b/src/conversion/meshTables/cellTable.C index 6369f98d9d58ea664675b173ae566296b8bc5a1e..a07cbaf96d9d832524c07f0dd8520602eea99c42 100644 --- a/src/conversion/meshTables/cellTable.C +++ b/src/conversion/meshTables/cellTable.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "cellTable.H" @@ -81,7 +79,7 @@ void Foam::cellTable::addDefaults() void Foam::cellTable::setEntry ( - const label& id, + const label id, const word& keyWord, const word& value ) @@ -192,7 +190,7 @@ Foam::Map<Foam::word> Foam::cellTable::names } -Foam::word Foam::cellTable::name(const label& id) const +Foam::word Foam::cellTable::name(const label id) const { word theName("cellTable_" + Foam::name(id)); @@ -289,19 +287,19 @@ Foam::Map<Foam::word> Foam::cellTable::shells() const -void Foam::cellTable::setMaterial(const label& id, const word& matlType) +void Foam::cellTable::setMaterial(const label id, const word& matlType) { setEntry(id, "MaterialType", matlType); } -void Foam::cellTable::setName(const label& id, const word& name) +void Foam::cellTable::setName(const label id, const word& name) { setEntry(id, "Label", name); } -void Foam::cellTable::setName(const label& id) +void Foam::cellTable::setName(const label id) { iterator iter = find(id); diff --git a/src/conversion/meshTables/cellTable.H b/src/conversion/meshTables/cellTable.H index 4d0079f032b8c248c8f30a2d743ad7fc5512dc37..ff8c1fafb61f5314332b372c09dd9dce907892e7 100644 --- a/src/conversion/meshTables/cellTable.H +++ b/src/conversion/meshTables/cellTable.H @@ -96,7 +96,7 @@ class cellTable //- Add required entries - MaterialType void addDefaults(); - void setEntry(const label& id, const word& keyWord, const word& value); + void setEntry(const label id, const word& keyWord, const word& value); //- Disallow default bitwise copy construct cellTable(const cellTable&); @@ -133,7 +133,7 @@ public: //- Return the name corresponding to id // returns cellTable_ID if not otherwise defined - word name(const label& id) const; + word name(const label id) const; //- Return a Map of (id => name) Map<word> names() const; @@ -157,13 +157,13 @@ public: Map<word> materialTypes() const; //- Assign material Type - void setMaterial(const label&, const word&); + void setMaterial(const label, const word&); //- Assign name - void setName(const label&, const word&); + void setName(const label, const word&); //- Assign default name if not already set - void setName(const label&); + void setName(const label); //- Read constant/cellTable void readDict diff --git a/src/conversion/meshWriter/meshWriter.H b/src/conversion/meshWriter/meshWriter.H index 3961000b88124aa03f820c2a0a88b272546f68f0..e86a74cc46a508448574a3085cfad73eaadebcc3 100644 --- a/src/conversion/meshWriter/meshWriter.H +++ b/src/conversion/meshWriter/meshWriter.H @@ -182,7 +182,7 @@ public: virtual bool writeSurface ( const fileName& timeName = fileName::null, - const bool& triangulate = false + const bool triangulate = false ) const { return false; diff --git a/src/conversion/meshWriter/starcd/STARCDMeshWriter.C b/src/conversion/meshWriter/starcd/STARCDMeshWriter.C index e07f1a2d5085adbbca882705e2b4665d9da0d886..15d681898ee24c907d8bb8cb19647bf6d4ccae1d 100644 --- a/src/conversion/meshWriter/starcd/STARCDMeshWriter.C +++ b/src/conversion/meshWriter/starcd/STARCDMeshWriter.C @@ -530,7 +530,7 @@ bool Foam::meshWriters::STARCD::write(const fileName& meshName) const bool Foam::meshWriters::STARCD::writeSurface ( const fileName& meshName, - const bool& triangulate + const bool triangulate ) const { fileName baseName(meshName); diff --git a/src/conversion/meshWriter/starcd/STARCDMeshWriter.H b/src/conversion/meshWriter/starcd/STARCDMeshWriter.H index dd16bca0f3d5d51950f51cd941d406a0d5ffddff..9e2cfeb0b33c5c243c7a75bb10e11cabf94b61a0 100644 --- a/src/conversion/meshWriter/starcd/STARCDMeshWriter.H +++ b/src/conversion/meshWriter/starcd/STARCDMeshWriter.H @@ -135,7 +135,7 @@ public: virtual bool writeSurface ( const fileName& meshName = fileName::null, - const bool& triangulate = false + const bool triangulate = false ) const; }; diff --git a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C index 7820bcd70bf34719c207cf575cae9b1e4b7c1682..bfa9b2ca0c1df82ad0ec9a854c5293bc365e34ab 100644 --- a/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C +++ b/src/dynamicMesh/polyMeshAdder/faceCoupleInfo.C @@ -1536,7 +1536,7 @@ void Foam::faceCoupleInfo::perfectPointMatch FatalErrorIn ( "faceCoupleInfo::perfectPointMatch" - "(const scalar&, const bool)" + "(const scalar, const bool)" ) << "Did not match all of the master faces to the slave faces" << endl << "This usually means that the slave patch and master patch" @@ -1761,10 +1761,13 @@ void Foam::faceCoupleInfo::subDivisionMatch writeOBJ ( "errorEdges.obj", - UIndirectList<edge> + edgeList ( - cutFaces().edges(), - cutFaces().pointEdges()[cutPointI] + UIndirectList<edge> + ( + cutFaces().edges(), + cutFaces().pointEdges()[cutPointI] + ) ), cutFaces().localPoints(), false diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C index a2b5b08108cedd6969095e1ac4e11f2431c02bd0..41ba56aedba532d58a11226e2a264598cf558e1a 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/addPatchCellLayer.C @@ -110,7 +110,7 @@ Foam::labelListList Foam::addPatchCellLayer::calcGlobalEdgeFaces ); // Extract pp part - return UIndirectList<labelList>(globalEdgeFaces, meshEdges); + return labelListList(UIndirectList<labelList>(globalEdgeFaces, meshEdges)); } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C index 926f2f4913b560ddc4185b612659ffe1123080a9..a47f8a06f11547ebd222a722a9b13c69af147a09 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8.C @@ -55,9 +55,9 @@ namespace Foam class ifEqEqOp { public: - void operator()(label& x, const label& y) const + void operator()(label& x, const label y) const { - x = (x==y) ? x : value; + x = (x == y) ? x : value; } }; } diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C index 6b1874dc4b846850035734e4a009c5f0b421eb9b..fc405b2d0e2b3e56523aa642ed5eba03f15127e0 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.C @@ -39,6 +39,7 @@ License #include "objectMap.H" #include "processorPolyPatch.H" #include "fvMesh.H" +#include "CompactListList.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -488,9 +489,6 @@ void Foam::polyTopoChange::makeCellCells // Neighbours per cell labelList nNbrs(cellMap_.size(), 0); - // Overall number of cellCells - label nCellCells = 0; - // 1. Count neighbours (through internal faces) per cell for (label faceI = 0; faceI < nActiveFaces; faceI++) @@ -499,22 +497,12 @@ void Foam::polyTopoChange::makeCellCells { nNbrs[faceOwner_[faceI]]++; nNbrs[faceNeighbour_[faceI]]++; - nCellCells += 2; } } - cellCells.setSize(cellMap_.size(), nCellCells); - - // 2. Calculate offsets - - labelList& offsets = cellCells.offsets(); + // 2. Construct csr + cellCells.setSize(nNbrs); - label sumSize = 0; - forAll(nNbrs, cellI) - { - sumSize += nNbrs[cellI]; - offsets[cellI] = sumSize; - } // 3. Fill faces per cell @@ -543,8 +531,6 @@ Foam::label Foam::polyTopoChange::getCellOrder labelList& oldToNew ) const { - const labelList& offsets = cellCellAddressing.offsets(); - labelList newOrder(cellCellAddressing.size()); // Fifo buffer for string of cells @@ -560,7 +546,7 @@ Foam::label Foam::polyTopoChange::getCellOrder forAll (visited, cellI) { // find the first non-removed cell that has not been visited yet - if (!cellRemoved(cellI) && visited.get(cellI) == 0) + if (!cellRemoved(cellI) && visited[cellI] == 0) { // use this cell as a start nextCell.append(cellI); @@ -574,23 +560,22 @@ Foam::label Foam::polyTopoChange::getCellOrder { label currentCell = nextCell.removeHead(); - if (visited.get(currentCell) == 0) + if (visited[currentCell] == 0) { - visited.set(currentCell, 1); + visited[currentCell] = 1; // add into cellOrder newOrder[cellInOrder] = currentCell; cellInOrder++; // find if the neighbours have been visited - label i0 = (currentCell == 0 ? 0 : offsets[currentCell-1]); - label i1 = offsets[currentCell]; + const UList<label> cCells = cellCellAddressing[currentCell]; - for (label i = i0; i < i1; i++) + forAll(cCells, i) { - label nbr = cellCellAddressing.m()[i]; + label nbr = cCells[i]; - if (!cellRemoved(nbr) && visited.get(nbr) == 0) + if (!cellRemoved(nbr) && visited[nbr] == 0) { // not visited, add to the list nextCell.append(nbr); diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H index e7a0ba8fb380fd8a258cebf98baa1400440f134e..398ced6b0de6d1ae6df02030fc0d0050b647619a 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChange.H @@ -64,18 +64,12 @@ SourceFiles #ifndef polyTopoChange_H #define polyTopoChange_H -#include "autoPtr.H" #include "DynamicList.H" #include "labelList.H" -#include "IOobject.H" -#include "typeInfo.H" #include "pointField.H" -#include "PtrList.H" -#include "cellList.H" #include "Map.H" #include "HashSet.H" #include "mapPolyMesh.H" -#include "CompactListList.H" #include "PackedBoolList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -95,6 +89,8 @@ class polyPatch; class dictionary; class topoAction; class objectMap; +class IOobject; +template<class T, class Container> class CompactListList; /*---------------------------------------------------------------------------*\ Class polyTopoChange Declaration @@ -273,11 +269,15 @@ class polyTopoChange void makeCellCells ( const label nActiveFaces, - CompactListList<label>& cellCells + CompactListList<label, labelList>& cellCells ) const; //- Cell ordering (bandCompression). Returns number of remaining cells. - label getCellOrder(const CompactListList<label>&, labelList&) const; + label getCellOrder + ( + const CompactListList<label, labelList>&, + labelList& + ) const; //- Do upper-triangular ordering and patch ordering. void getFaceOrder diff --git a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H index e2ea3c2869ed221a50c265a1b6a59238879e6af9..118733ce4228dc75f303fff6066af0119965951d 100644 --- a/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H +++ b/src/dynamicMesh/polyTopoChange/polyTopoChange/polyTopoChangeI.H @@ -24,6 +24,7 @@ License \*---------------------------------------------------------------------------*/ +#include "face.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // diff --git a/src/edgeMesh/edgeMesh.C b/src/edgeMesh/edgeMesh.C index 6a3933c84f4d417c7949f39ba686f1a132b0b0dd..d39810a62d7223debef5b8eb2ae1b3b533dcc10c 100644 --- a/src/edgeMesh/edgeMesh.C +++ b/src/edgeMesh/edgeMesh.C @@ -26,9 +26,6 @@ License #include "edgeMesh.H" #include "mergePoints.H" -#include "StaticHashTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -204,7 +201,7 @@ void Foam::edgeMesh::mergePoints(const scalar mergeDist) } // Compact using a hashtable and commutative hash of edge. - StaticHashTable<label, edge, Hash<edge> > edgeToLabel + HashTable<label, edge, Hash<edge> > edgeToLabel ( 2*edges_.size() ); @@ -228,7 +225,7 @@ void Foam::edgeMesh::mergePoints(const scalar mergeDist) for ( - StaticHashTable<label, edge, Hash<edge> >::const_iterator iter = + HashTable<label, edge, Hash<edge> >::const_iterator iter = edgeToLabel.begin(); iter != edgeToLabel.end(); ++iter diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 7ecbf878a61aa263e4577d596efc88d8e2be577c..5fe44b935751f8c95bdc23e7e561c1b40ac7b359 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -1,6 +1,7 @@ fvMesh/fvMeshGeometry.C fvMesh/fvMesh.C +fvMesh/singleCellFvMesh/singleCellFvMesh.C fvMesh/fvMeshSubset/fvMeshSubset.C fvBoundaryMesh = fvMesh/fvBoundaryMesh @@ -285,6 +286,7 @@ $(divSchemes)/gaussDivScheme/gaussDivSchemes.C gradSchemes = finiteVolume/gradSchemes $(gradSchemes)/gradScheme/gradSchemes.C $(gradSchemes)/gaussGrad/gaussGrads.C + $(gradSchemes)/leastSquaresGrad/leastSquaresVectors.C $(gradSchemes)/leastSquaresGrad/leastSquaresGrads.C $(gradSchemes)/extendedLeastSquaresGrad/extendedLeastSquaresVectors.C diff --git a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H index 9f35446e4dae33e7ef85765da7d1671ee3996e1c..9a3eb151f969e4034f0c7607f2999c82ec4a9783 100644 --- a/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H +++ b/src/finiteVolume/cfdTools/general/porousMedia/porousZone.H @@ -273,7 +273,7 @@ public: } //- Return porosity - const scalar& porosity() const + scalar porosity() const { return porosity_; } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C index c2ae8d81be20fc8f4d3a2f2a76c345dc2167be57..b2930077c0eda047ab871048f9d2a6f2cbccc5e5 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C @@ -26,8 +26,6 @@ License #include "processorFvPatchField.H" #include "processorFvPatch.H" -#include "IPstream.H" -#include "OPstream.H" #include "demandDrivenData.H" #include "transformField.H" diff --git a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H index 5eed0e60ea464e39bf176e0448c67f90a32533b7..58977a15b8f8bc9a66ecc9c03e969b82b8251c56 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/rotatingWallVelocity/rotatingWallVelocityFvPatchVectorField.H @@ -149,7 +149,7 @@ public: } //- Return the rotational speed - const scalar& omega() const + scalar omega() const { return omega_; } diff --git a/src/finiteVolume/finiteVolume/convectionSchemes/convectionScheme/convectionScheme.H b/src/finiteVolume/finiteVolume/convectionSchemes/convectionScheme/convectionScheme.H index c1e46a9e101477790d954629fc1ea1fccc8792fe..25dcbeb130d565aa5c6bf4bb045b714a4bc9d987 100644 --- a/src/finiteVolume/finiteVolume/convectionSchemes/convectionScheme/convectionScheme.H +++ b/src/finiteVolume/finiteVolume/convectionSchemes/convectionScheme/convectionScheme.H @@ -177,7 +177,7 @@ public: virtual tmp<fvMatrix<Type> > fvmDiv ( const surfaceScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) const = 0; virtual tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDiv diff --git a/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C b/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C index a219d8028167646cb5f3fc7e79e563db18174c70..e2077d75ef37d08d222fbd0501e589375e0a94e4 100644 --- a/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C +++ b/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.C @@ -69,7 +69,7 @@ tmp<fvMatrix<Type> > gaussConvectionScheme<Type>::fvmDiv ( const surfaceScalarField& faceFlux, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) const { tmp<surfaceScalarField> tweights = tinterpScheme_().weights(vf); @@ -89,9 +89,9 @@ gaussConvectionScheme<Type>::fvmDiv fvm.upper() = fvm.lower() + faceFlux.internalField(); fvm.negSumDiag(); - forAll(fvm.psi().boundaryField(), patchI) + forAll(vf.boundaryField(), patchI) { - const fvPatchField<Type>& psf = fvm.psi().boundaryField()[patchI]; + const fvPatchField<Type>& psf = vf.boundaryField()[patchI]; const fvsPatchScalarField& patchFlux = faceFlux.boundaryField()[patchI]; const fvsPatchScalarField& pw = weights.boundaryField()[patchI]; diff --git a/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.H b/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.H index 7a4e5da155473234a50ce8b57efce66b34bf5a44..8202f270dc8f303dbdea12fb5d3744b7b570229b 100644 --- a/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.H +++ b/src/finiteVolume/finiteVolume/convectionSchemes/gaussConvectionScheme/gaussConvectionScheme.H @@ -124,7 +124,7 @@ public: tmp<fvMatrix<Type> > fvmDiv ( const surfaceScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) const; tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDiv diff --git a/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.C b/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.C index d147d461eee5457780ef5c548e5f9aec4b0a562e..61cbba5cebddc82d1fb8bb320852fc2ed64e9099 100644 --- a/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.C +++ b/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "multivariateGaussConvectionScheme.H" @@ -81,7 +79,7 @@ tmp<fvMatrix<Type> > multivariateGaussConvectionScheme<Type>::fvmDiv ( const surfaceScalarField& faceFlux, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) const { return gaussConvectionScheme<Type> diff --git a/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.H b/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.H index b8ccb25ed562211d395f9543f672abe73f8e5f7d..419628ddfa0e193d370aa56978d18352f1713994 100644 --- a/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.H +++ b/src/finiteVolume/finiteVolume/convectionSchemes/multivariateGaussConvectionScheme/multivariateGaussConvectionScheme.H @@ -114,7 +114,7 @@ public: tmp<fvMatrix<Type> > fvmDiv ( const surfaceScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) const; tmp<GeometricField<Type, fvPatchField, volMesh> > fvcDiv diff --git a/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.C b/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.C index abc203a73b0d8bd8c8dd42293b664c19b4a51691..0285084dff09d0720990214350958c488985c755 100644 --- a/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.C +++ b/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "EulerD2dt2Scheme.H" @@ -181,7 +181,7 @@ EulerD2dt2Scheme<Type>::fvcD2dt2 coefft *(rho.boundaryField() + rho.oldTime().boundaryField()) *vf.boundaryField() - + - ( coefft *( @@ -232,7 +232,7 @@ template<class Type> tmp<fvMatrix<Type> > EulerD2dt2Scheme<Type>::fvmD2dt2 ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -292,7 +292,7 @@ tmp<fvMatrix<Type> > EulerD2dt2Scheme<Type>::fvmD2dt2 ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -353,7 +353,7 @@ tmp<fvMatrix<Type> > EulerD2dt2Scheme<Type>::fvmD2dt2 ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm diff --git a/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.H b/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.H index bca75562ed34931be3030ed240e468bd058a863c..0823f225dc37ddee20e85dc71478e8f81d724b30 100644 --- a/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.H +++ b/src/finiteVolume/finiteVolume/d2dt2Schemes/EulerD2dt2Scheme/EulerD2dt2Scheme.H @@ -109,19 +109,19 @@ public: tmp<fvMatrix<Type> > fvmD2dt2 ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmD2dt2 ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmD2dt2 ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); }; diff --git a/src/finiteVolume/finiteVolume/d2dt2Schemes/d2dt2Scheme/d2dt2Scheme.H b/src/finiteVolume/finiteVolume/d2dt2Schemes/d2dt2Scheme/d2dt2Scheme.H index 9e5668ecf3d817fa3eb39e7a13e07c03a62bfebc..452373b5014b6e4e05d87684669b054bd4775382 100644 --- a/src/finiteVolume/finiteVolume/d2dt2Schemes/d2dt2Scheme/d2dt2Scheme.H +++ b/src/finiteVolume/finiteVolume/d2dt2Schemes/d2dt2Scheme/d2dt2Scheme.H @@ -153,19 +153,19 @@ public: virtual tmp<fvMatrix<Type> > fvmD2dt2 ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) = 0; virtual tmp<fvMatrix<Type> > fvmD2dt2 ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) = 0; virtual tmp<fvMatrix<Type> > fvmD2dt2 ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) = 0; }; diff --git a/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.C b/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.C index 121df11087b611e5ef11e4eed1ab33b09c75edef..9d810c401cd5589495536f170b7f94ce4314a1c8 100644 --- a/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.C +++ b/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "steadyStateD2dt2Scheme.H" @@ -107,7 +107,7 @@ template<class Type> tmp<fvMatrix<Type> > steadyStateD2dt2Scheme<Type>::fvmD2dt2 ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -128,7 +128,7 @@ tmp<fvMatrix<Type> > steadyStateD2dt2Scheme<Type>::fvmD2dt2 ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -149,7 +149,7 @@ tmp<fvMatrix<Type> > steadyStateD2dt2Scheme<Type>::fvmD2dt2 ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm diff --git a/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.H b/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.H index 004fb22a5e4ddf70f704f43c088087c74087a8d6..9b9327ceee1393d76998d04ca24325869a9e5dfe 100644 --- a/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.H +++ b/src/finiteVolume/finiteVolume/d2dt2Schemes/steadyStateD2dt2Scheme/steadyStateD2dt2Scheme.H @@ -108,19 +108,19 @@ public: tmp<fvMatrix<Type> > fvmD2dt2 ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmD2dt2 ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmD2dt2 ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); }; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C index 6928e20a2e18a52262aca1db2042e5a7a046f5ea..a63a64442700460fd5c9e018c793fc670d9d772f 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "CoEulerDdtScheme.H" @@ -69,10 +69,10 @@ tmp<volScalarField> CoEulerDdtScheme<Type>::CorDeltaT() const forAll(owner, faceI) { - corDeltaT[owner[faceI]] = + corDeltaT[owner[faceI]] = max(corDeltaT[owner[faceI]], cofrDeltaT[faceI]); - corDeltaT[neighbour[faceI]] = + corDeltaT[neighbour[faceI]] = max(corDeltaT[neighbour[faceI]], cofrDeltaT[faceI]); } @@ -127,7 +127,7 @@ tmp<surfaceScalarField> CoEulerDdtScheme<Type>::CofrDeltaT() const const volScalarField& rho = static_cast<const objectRegistry&>(mesh()) .lookupObject<volScalarField>(rhoName_).oldTime(); - + surfaceScalarField Co ( mesh().surfaceInterpolation::deltaCoeffs() @@ -369,7 +369,7 @@ template<class Type> tmp<fvMatrix<Type> > CoEulerDdtScheme<Type>::fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -386,7 +386,7 @@ CoEulerDdtScheme<Type>::fvmDdt scalarField rDeltaT = CorDeltaT()().internalField(); fvm.diag() = rDeltaT*mesh().V(); - + if (mesh().moving()) { fvm.source() = rDeltaT*vf.oldTime().internalField()*mesh().V0(); @@ -405,7 +405,7 @@ tmp<fvMatrix<Type> > CoEulerDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -421,7 +421,7 @@ CoEulerDdtScheme<Type>::fvmDdt scalarField rDeltaT = CorDeltaT()().internalField(); fvm.diag() = rDeltaT*rho.value()*mesh().V(); - + if (mesh().moving()) { fvm.source() = rDeltaT @@ -442,7 +442,7 @@ tmp<fvMatrix<Type> > CoEulerDdtScheme<Type>::fvmDdt ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -588,7 +588,7 @@ CoEulerDdtScheme<Type>::fvcDdtPhiCorr ) ); } - else if + else if ( U.dimensions() == dimVelocity && phi.dimensions() == dimDensity*dimVelocity*dimArea @@ -617,7 +617,7 @@ CoEulerDdtScheme<Type>::fvcDdtPhiCorr ) ); } - else if + else if ( U.dimensions() == dimDensity*dimVelocity && phi.dimensions() == dimDensity*dimVelocity*dimArea diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.H index f2b54169ed5f31e4c02a7dea2a1d41efa7c177a5..65cd320d2d6223f1a087463c7d08e5035a61d83d 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CoEulerDdtScheme/CoEulerDdtScheme.H @@ -142,19 +142,19 @@ public: tmp<fvMatrix<Type> > fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); typedef typename ddtScheme<Type>::fluxFieldType fluxFieldType; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C index 027f0a2b302a5e3f0f88f0b1fa647ae4468c1851..172bea60aa4d9fed0f8ae914c87a78d8567c782b 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.C @@ -625,7 +625,7 @@ template<class Type> tmp<fvMatrix<Type> > CrankNicholsonDdtScheme<Type>::fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { DDt0Field<GeometricField<Type, fvPatchField, volMesh> >& ddt0 = @@ -709,7 +709,7 @@ tmp<fvMatrix<Type> > CrankNicholsonDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { DDt0Field<GeometricField<Type, fvPatchField, volMesh> >& ddt0 = @@ -791,7 +791,7 @@ tmp<fvMatrix<Type> > CrankNicholsonDdtScheme<Type>::fvmDdt ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { DDt0Field<GeometricField<Type, fvPatchField, volMesh> >& ddt0 = diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.H index 87ca9a086d885426a5031fe6d17b22dc906f1cc9..d3177f6a959c1e20e871d8d45995666bfcda0a53 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/CrankNicholsonDdtScheme/CrankNicholsonDdtScheme.H @@ -90,7 +90,7 @@ class CrankNicholsonDdtScheme //- Return the start-time index label startTimeIndex() const; - + //- Cast to the underlying GeoField GeoField& operator()(); @@ -213,19 +213,19 @@ public: tmp<fvMatrix<Type> > fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); typedef typename ddtScheme<Type>::fluxFieldType fluxFieldType; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C index 5b43623c61bd25ea4a584b63999401782635c770..91e4cb403ab1742d90864ee0390044635b214a29 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.C @@ -262,7 +262,7 @@ template<class Type> tmp<fvMatrix<Type> > EulerDdtScheme<Type>::fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -298,7 +298,7 @@ tmp<fvMatrix<Type> > EulerDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -335,7 +335,7 @@ tmp<fvMatrix<Type> > EulerDdtScheme<Type>::fvmDdt ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.H index b06ef32761b30005d98f417c999426d2f3675c5b..3d38050955c72bb402e1580b8d8af05029d115b8 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/EulerDdtScheme/EulerDdtScheme.H @@ -120,19 +120,19 @@ public: tmp<fvMatrix<Type> > fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); typedef typename ddtScheme<Type>::fluxFieldType fluxFieldType; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.C index a06e30e725ec447f7c63b5344d2e56e2148043ea..4906f63567b2b80449d3eea1194f2b426a246131 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "SLTSDdtScheme.H" @@ -369,7 +369,7 @@ template<class Type> tmp<fvMatrix<Type> > SLTSDdtScheme<Type>::fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -388,7 +388,7 @@ SLTSDdtScheme<Type>::fvmDdt Info<< "max/min rDeltaT " << max(rDeltaT) << " " << min(rDeltaT) << endl; fvm.diag() = rDeltaT*mesh().V(); - + if (mesh().moving()) { fvm.source() = rDeltaT*vf.oldTime().internalField()*mesh().V0(); @@ -407,7 +407,7 @@ tmp<fvMatrix<Type> > SLTSDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -423,7 +423,7 @@ SLTSDdtScheme<Type>::fvmDdt scalarField rDeltaT = SLrDeltaT()().internalField(); fvm.diag() = rDeltaT*rho.value()*mesh().V(); - + if (mesh().moving()) { fvm.source() = rDeltaT @@ -444,7 +444,7 @@ tmp<fvMatrix<Type> > SLTSDdtScheme<Type>::fvmDdt ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -590,7 +590,7 @@ SLTSDdtScheme<Type>::fvcDdtPhiCorr ) ); } - else if + else if ( U.dimensions() == dimVelocity && phi.dimensions() == dimDensity*dimVelocity*dimArea @@ -619,7 +619,7 @@ SLTSDdtScheme<Type>::fvcDdtPhiCorr ) ); } - else if + else if ( U.dimensions() == dimDensity*dimVelocity && phi.dimensions() == dimDensity*dimVelocity*dimArea diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H index 850f358299c5b6c31d5f237371cbdd96a4751c71..f300297e6ce32a4bf3b5b063e13b6dbe316a1a09 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/SLTSDdtScheme/SLTSDdtScheme.H @@ -143,19 +143,19 @@ public: tmp<fvMatrix<Type> > fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); typedef typename ddtScheme<Type>::fluxFieldType fluxFieldType; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C index 5b55f27a1e8660ffd82720c64d45cc427adb499c..6051903a9c69422875ecaa6afcdc2b2b719eb7b5 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C @@ -361,7 +361,7 @@ template<class Type> tmp<fvMatrix<Type> > backwardDdtScheme<Type>::fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -413,7 +413,7 @@ tmp<fvMatrix<Type> > backwardDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -464,7 +464,7 @@ tmp<fvMatrix<Type> > backwardDdtScheme<Type>::fvmDdt ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H index 374d05031aa5cbca89f75c93e3600d0914996549..7aceb79c893cd76a06d564896aa1e7521475346e 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.H @@ -131,19 +131,19 @@ public: tmp<fvMatrix<Type> > fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); typedef typename ddtScheme<Type>::fluxFieldType fluxFieldType; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.C index c7b8d4986601ff3261292ef6a0b42f69d38a0eb0..236f66cc29376463f453ab1d4717506346a36759 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "boundedBackwardDdtScheme.H" @@ -413,7 +413,7 @@ boundedBackwardDdtScheme::fvcDdt tmp<fvScalarMatrix> boundedBackwardDdtScheme::fvmDdt ( - volScalarField& vf + const volScalarField& vf ) { tmp<fvScalarMatrix> tfvm @@ -484,7 +484,7 @@ tmp<fvScalarMatrix> boundedBackwardDdtScheme::fvmDdt ( const dimensionedScalar& rho, - volScalarField& vf + const volScalarField& vf ) { tmp<fvScalarMatrix> tfvm @@ -554,7 +554,7 @@ tmp<fvScalarMatrix> boundedBackwardDdtScheme::fvmDdt ( const volScalarField& rho, - volScalarField& vf + const volScalarField& vf ) { tmp<fvScalarMatrix> tfvm diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.H index 7bff042a753928cc51c8384f36661ac1dcc1602d..f1b4121f6e625cb914f0aa13c155972dc60d5e39 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtScheme.H @@ -142,19 +142,19 @@ public: tmp<fvScalarMatrix> fvmDdt ( - volScalarField& + const volScalarField& ); tmp<fvScalarMatrix> fvmDdt ( const dimensionedScalar&, - volScalarField& + const volScalarField& ); tmp<fvScalarMatrix> fvmDdt ( const volScalarField&, - volScalarField& + const volScalarField& ); tmp<surfaceScalarField> fvcDdtPhiCorr diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtSchemes.C b/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtSchemes.C index 666cb2be3bbd9509645c717b21b19d4c3cc21553..67a1d1f69c1fb21a6701789a463410942ebdb70b 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtSchemes.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/boundedBackwardDdtScheme/boundedBackwardDdtSchemes.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "boundedBackwardDdtScheme.H" diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H index 31f8fa090d75eafd520384fc3777b2f6948893c4..e454e9409a6393a63878fb207b116cb95c76fefe 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/ddtScheme/ddtScheme.H @@ -164,19 +164,19 @@ public: virtual tmp<fvMatrix<Type> > fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) = 0; virtual tmp<fvMatrix<Type> > fvmDdt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) = 0; virtual tmp<fvMatrix<Type> > fvmDdt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) = 0; diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C index 7bd7b6f8a83f60424124f4171e2f456e0474070a..3b5736adb86150ad75b17aac3faf2859537f22ca 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "steadyStateDdtScheme.H" @@ -162,7 +162,7 @@ template<class Type> tmp<fvMatrix<Type> > steadyStateDdtScheme<Type>::fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -183,7 +183,7 @@ tmp<fvMatrix<Type> > steadyStateDdtScheme<Type>::fvmDdt ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm @@ -204,7 +204,7 @@ tmp<fvMatrix<Type> > steadyStateDdtScheme<Type>::fvmDdt ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.H b/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.H index 54208441b4cd9a35cf963588ffb3b33e25966715..0af9bb66dbf1f56df7cd02beb9d8f2fa9dcfd34b 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.H +++ b/src/finiteVolume/finiteVolume/ddtSchemes/steadyStateDdtScheme/steadyStateDdtScheme.H @@ -119,19 +119,19 @@ public: tmp<fvMatrix<Type> > fvmDdt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<fvMatrix<Type> > fvmDdt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); typedef typename ddtScheme<Type>::fluxFieldType fluxFieldType; diff --git a/src/finiteVolume/finiteVolume/fvc/fvcGrad.C b/src/finiteVolume/finiteVolume/fvc/fvcGrad.C index 9d61a45e40d19ce9077eb995c7cbe9b1b59970b3..9f5c2bd98fce58db942119aa0025f6351f3dd54c 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcGrad.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcGrad.C @@ -54,7 +54,7 @@ grad const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf ) { - return fv::gaussGrad<Type>::grad(ssf); + return fv::gaussGrad<Type>::gradf(ssf, "grad(" + ssf.name() + ')'); } @@ -99,7 +99,7 @@ grad ( vf.mesh(), vf.mesh().gradScheme(name) - )().grad(vf); + )().grad(vf, name); } diff --git a/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.C b/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.C index 4df081cd070e54c1451a7e9ee1e9c32910c1bdfa..81f37cd09943a40c8ae99ce4ebbe55a1e17cda7b 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.C @@ -22,9 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - - \*---------------------------------------------------------------------------*/ #include "volFields.H" @@ -48,7 +45,7 @@ template<class Type> tmp<fvMatrix<Type> > d2dt2 ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::d2dt2Scheme<Type>::New @@ -64,7 +61,7 @@ tmp<fvMatrix<Type> > d2dt2 ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::d2dt2Scheme<Type>::New @@ -80,7 +77,7 @@ tmp<fvMatrix<Type> > d2dt2 ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::d2dt2Scheme<Type>::New diff --git a/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.H b/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.H index b322391adeb98870926e662ccba38358ab16d3bf..3d7e2a716ba181575fea1d265593a093bb1b8401 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmD2dt2.H @@ -54,20 +54,20 @@ namespace fvm tmp<fvMatrix<Type> > d2dt2 ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > d2dt2 ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > d2dt2 ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); } diff --git a/src/finiteVolume/finiteVolume/fvm/fvmDdt.C b/src/finiteVolume/finiteVolume/fvm/fvmDdt.C index c2e3e976af080d122cdf5c6add9d44e2931bdc14..d7610206d00b9c2781f22cc855c4750fdc23f297 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmDdt.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmDdt.C @@ -45,7 +45,7 @@ template<class Type> tmp<fvMatrix<Type> > ddt ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::ddtScheme<Type>::New @@ -61,7 +61,7 @@ tmp<fvMatrix<Type> > ddt ( const oneField&, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return ddt(vf); @@ -73,7 +73,7 @@ tmp<fvMatrix<Type> > ddt ( const dimensionedScalar& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::ddtScheme<Type>::New @@ -89,7 +89,7 @@ tmp<fvMatrix<Type> > ddt ( const volScalarField& rho, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fv::ddtScheme<Type>::New diff --git a/src/finiteVolume/finiteVolume/fvm/fvmDdt.H b/src/finiteVolume/finiteVolume/fvm/fvmDdt.H index 5472f91f37c358222d4203fc3b3e58533dd4e9ee..2b8124e5596a2562a4d8dded29e90ac3ab78655a 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmDdt.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmDdt.H @@ -54,28 +54,28 @@ namespace fvm template<class Type> tmp<fvMatrix<Type> > ddt ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > ddt ( const oneField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > ddt ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > ddt ( const volScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); } diff --git a/src/finiteVolume/finiteVolume/fvm/fvmDiv.C b/src/finiteVolume/finiteVolume/fvm/fvmDiv.C index 25af21ef2abcfeb3a215ed765c7b9de5c43a96ff..2cc8d0e31f5cb4750c1245fcaeb6a620686a6235 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmDiv.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmDiv.C @@ -22,9 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - - \*---------------------------------------------------------------------------*/ #include "fvmDiv.H" @@ -49,7 +46,7 @@ tmp<fvMatrix<Type> > div ( const surfaceScalarField& flux, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -66,7 +63,7 @@ tmp<fvMatrix<Type> > div ( const tmp<surfaceScalarField>& tflux, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -81,7 +78,7 @@ tmp<fvMatrix<Type> > div ( const surfaceScalarField& flux, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fvm::div(flux, vf, "div("+flux.name()+','+vf.name()+')'); @@ -92,7 +89,7 @@ tmp<fvMatrix<Type> > div ( const tmp<surfaceScalarField>& tflux, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > Div(fvm::div(tflux(), vf)); diff --git a/src/finiteVolume/finiteVolume/fvm/fvmDiv.H b/src/finiteVolume/finiteVolume/fvm/fvmDiv.H index c15fc72decd61f36ce36264797790411906537cb..9e45a883dabab0e3f2350df6a1e5f2a16651d74f 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmDiv.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmDiv.H @@ -56,7 +56,7 @@ namespace fvm tmp<fvMatrix<Type> > div ( const surfaceScalarField&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& name ); @@ -64,7 +64,7 @@ namespace fvm tmp<fvMatrix<Type> > div ( const tmp<surfaceScalarField>&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& name ); @@ -73,14 +73,14 @@ namespace fvm tmp<fvMatrix<Type> > div ( const surfaceScalarField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > div ( const tmp<surfaceScalarField>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); } diff --git a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C index 4a60eadd3d3211dbef5ab58cf55e79cdd831b263..501456da3cb3cb807d90eeb683f0b5d4e4cddcba 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.C @@ -45,7 +45,7 @@ template<class Type> tmp<fvMatrix<Type> > laplacian ( - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -70,7 +70,7 @@ template<class Type> tmp<fvMatrix<Type> > laplacian ( - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { surfaceScalarField Gamma @@ -100,7 +100,7 @@ tmp<fvMatrix<Type> > laplacian ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -116,7 +116,7 @@ tmp<fvMatrix<Type> > laplacian ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return tmp<fvMatrix<Type> > @@ -131,7 +131,7 @@ tmp<fvMatrix<Type> > laplacian ( const oneField&, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -144,7 +144,7 @@ tmp<fvMatrix<Type> > laplacian ( const oneField&, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fvm::laplacian(vf); @@ -156,11 +156,11 @@ tmp<fvMatrix<Type> > laplacian ( const dimensioned<GType>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { - GeometricField<GType, fvsPatchField, surfaceMesh> Gamma + const GeometricField<GType, fvsPatchField, surfaceMesh> Gamma ( IOobject ( @@ -182,10 +182,10 @@ tmp<fvMatrix<Type> > laplacian ( const dimensioned<GType>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { - GeometricField<GType, fvsPatchField, surfaceMesh> Gamma + const GeometricField<GType, fvsPatchField, surfaceMesh> Gamma ( IOobject ( @@ -209,7 +209,7 @@ tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvPatchField, volMesh>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -226,7 +226,7 @@ tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvPatchField, volMesh> >& tgamma, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -241,7 +241,7 @@ tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvPatchField, volMesh>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fvm::laplacian @@ -258,7 +258,7 @@ tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvPatchField, volMesh> >& tgamma, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > Laplacian(fvm::laplacian(tgamma(), vf)); @@ -274,7 +274,7 @@ tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvsPatchField, surfaceMesh>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -291,7 +291,7 @@ tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvsPatchField, surfaceMesh> >& tgamma, - GeometricField<Type, fvPatchField, volMesh>& vf, + const GeometricField<Type, fvPatchField, volMesh>& vf, const word& name ) { @@ -306,7 +306,7 @@ tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvsPatchField, surfaceMesh>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fvm::laplacian @@ -323,7 +323,7 @@ tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvsPatchField, surfaceMesh> >& tGamma, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm(fvm::laplacian(tGamma(), vf)); diff --git a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H index cc06ec5008a7e8f9f940b63490ee0358f0451792..c41774361f821b592f2f92bf88b1dfe73f2ab219 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmLaplacian.H @@ -55,14 +55,14 @@ namespace fvm template<class Type> tmp<fvMatrix<Type> > laplacian ( - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); template<class Type> tmp<fvMatrix<Type> > laplacian ( - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -70,7 +70,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); @@ -78,7 +78,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -86,7 +86,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const oneField&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); @@ -94,7 +94,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const oneField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -102,7 +102,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const dimensioned<GType>&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); @@ -110,7 +110,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const dimensioned<GType>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -118,7 +118,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvPatchField, volMesh>&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); @@ -126,7 +126,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvPatchField, volMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -134,7 +134,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvPatchField, volMesh> >&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); @@ -142,7 +142,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvPatchField, volMesh> >&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -150,7 +150,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvsPatchField, surfaceMesh>&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); @@ -158,7 +158,7 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvsPatchField, surfaceMesh> >&, - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const word& ); @@ -166,14 +166,14 @@ namespace fvm tmp<fvMatrix<Type> > laplacian ( const GeometricField<GType, fvsPatchField, surfaceMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type, class GType> tmp<fvMatrix<Type> > laplacian ( const tmp<GeometricField<GType, fvsPatchField, surfaceMesh> >&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); } diff --git a/src/finiteVolume/finiteVolume/fvm/fvmSup.C b/src/finiteVolume/finiteVolume/fvm/fvmSup.C index 67c18d3c59e9c4ab535c53199f52f23135b493cf..99e2d147467d4bdb290e704d423a9d069071e1b7 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmSup.C +++ b/src/finiteVolume/finiteVolume/fvm/fvmSup.C @@ -35,7 +35,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Su ( const DimensionedField<Type, volMesh>& su, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { const fvMesh& mesh = vf.mesh(); @@ -60,7 +60,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Su ( const tmp<DimensionedField<Type, volMesh> >& tsu, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm = fvm::Su(tsu(), vf); @@ -73,7 +73,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Su ( const tmp<GeometricField<Type, fvPatchField, volMesh> >& tsu, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm = fvm::Su(tsu(), vf); @@ -86,7 +86,7 @@ Foam::zeroField Foam::fvm::Su ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return zeroField(); @@ -98,7 +98,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Sp ( const DimensionedField<scalar, volMesh>& sp, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { const fvMesh& mesh = vf.mesh(); @@ -123,7 +123,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Sp ( const tmp<DimensionedField<scalar, volMesh> >& tsp, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm = fvm::Sp(tsp(), vf); @@ -136,7 +136,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Sp ( const tmp<volScalarField>& tsp, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm = fvm::Sp(tsp(), vf); @@ -150,7 +150,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::Sp ( const dimensionedScalar& sp, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { const fvMesh& mesh = vf.mesh(); @@ -175,7 +175,7 @@ Foam::zeroField Foam::fvm::Sp ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) { return zeroField(); @@ -187,7 +187,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::SuSp ( const DimensionedField<scalar, volMesh>& susp, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { const fvMesh& mesh = vf.mesh(); @@ -215,7 +215,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::SuSp ( const tmp<DimensionedField<scalar, volMesh> >& tsusp, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm = fvm::SuSp(tsusp(), vf); @@ -228,7 +228,7 @@ Foam::tmp<Foam::fvMatrix<Type> > Foam::fvm::SuSp ( const tmp<volScalarField>& tsusp, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<fvMatrix<Type> > tfvm = fvm::SuSp(tsusp(), vf); @@ -241,7 +241,7 @@ Foam::zeroField Foam::fvm::SuSp ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return zeroField(); diff --git a/src/finiteVolume/finiteVolume/fvm/fvmSup.H b/src/finiteVolume/finiteVolume/fvm/fvmSup.H index 425a57c6e34ee8079c34210f26bbdab6ea5b6453..a5662c1733beb09122ed2349d1c0bf07b3e45c74 100644 --- a/src/finiteVolume/finiteVolume/fvm/fvmSup.H +++ b/src/finiteVolume/finiteVolume/fvm/fvmSup.H @@ -56,28 +56,28 @@ namespace fvm tmp<fvMatrix<Type> > Su ( const DimensionedField<Type, volMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > Su ( const tmp<DimensionedField<Type, volMesh> >&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > Su ( const tmp<GeometricField<Type, fvPatchField, volMesh> >&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> zeroField Su ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -87,21 +87,21 @@ namespace fvm tmp<fvMatrix<Type> > Sp ( const DimensionedField<scalar, volMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > Sp ( const tmp<DimensionedField<scalar, volMesh> >&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > Sp ( const tmp<volScalarField>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -109,7 +109,7 @@ namespace fvm tmp<fvMatrix<Type> > Sp ( const dimensionedScalar&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -117,7 +117,7 @@ namespace fvm zeroField Sp ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); @@ -127,28 +127,28 @@ namespace fvm tmp<fvMatrix<Type> > SuSp ( const DimensionedField<scalar, volMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > SuSp ( const tmp<DimensionedField<scalar, volMesh> >&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> tmp<fvMatrix<Type> > SuSp ( const tmp<volScalarField>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); template<class Type> zeroField SuSp ( const zeroField&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); } diff --git a/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.C index 24b7e8bae00be44458a96160067ce909ee0e1fa6..797e0f5b77fa183eb4cae1c15bc393de54e2ad01 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "extendedLeastSquaresGrad.H" @@ -35,27 +35,20 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - template<class Type> -tmp +Foam::tmp < - GeometricField + Foam::GeometricField < - typename outerProduct<vector, Type>::type, fvPatchField, volMesh + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh > > -extendedLeastSquaresGrad<Type>::grad +Foam::fv::extendedLeastSquaresGrad<Type>::calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& vsf + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const { typedef typename outerProduct<vector, Type>::type GradType; @@ -68,7 +61,7 @@ extendedLeastSquaresGrad<Type>::grad ( IOobject ( - "grad("+vsf.name()+')', + name, vsf.instance(), mesh, IOobject::NO_READ, @@ -120,7 +113,7 @@ extendedLeastSquaresGrad<Type>::grad if (vsf.boundaryField()[patchi].coupled()) { - Field<Type> neiVsf = + Field<Type> neiVsf = vsf.boundaryField()[patchi].patchNeighbourField(); forAll(neiVsf, patchFaceI) @@ -162,12 +155,4 @@ extendedLeastSquaresGrad<Type>::grad } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.H index e8da1ca92ff66cbdbae447d16f0b934fa985df6c..40003aa703c4b8d17aff159bc0ab53d3810d5884 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/extendedLeastSquaresGrad/extendedLeastSquaresGrad.H @@ -102,13 +102,16 @@ public: // Member Functions - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const; }; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.C index f8a4992bd1c0b51e6deae79bdcefe502789916fa..c72525e8814ba871c657f9db0cf492c628e01066 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "fourthGrad.H" @@ -35,27 +35,20 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - template<class Type> -tmp +Foam::tmp < - GeometricField + Foam::GeometricField < - typename outerProduct<vector, Type>::type, fvPatchField, volMesh + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh > > -fourthGrad<Type>::grad +Foam::fv::fourthGrad<Type>::calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& vsf + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const { // The fourth-order gradient is calculated in two passes. First, @@ -80,7 +73,7 @@ fourthGrad<Type>::grad ( IOobject ( - "grad("+vsf.name()+')', + name, vsf.instance(), mesh, IOobject::NO_READ, @@ -130,7 +123,7 @@ fourthGrad<Type>::grad const scalarField& lambdap = lambda.boundaryField()[patchi]; // Build the d-vectors - vectorField pd = + vectorField pd = mesh.Sf().boundaryField()[patchi] /( mesh.magSf().boundaryField()[patchi] @@ -171,12 +164,4 @@ fourthGrad<Type>::grad } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.H index 72e2d3b5ade80f84a8f26171e34e4cb1c5614866..1698269b3e67ee61113d4347a92a23876bc97041 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/fourthGrad/fourthGrad.H @@ -83,13 +83,16 @@ public: // Member Functions - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const; }; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C index 57dc262370cdb979ef176b3563d82f13bcb56b59..b8e06f4c55db0f60a077c45c85c295964f2fde9f 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "gaussGrad.H" @@ -29,27 +29,20 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - template<class Type> -tmp +Foam::tmp < - GeometricField + Foam::GeometricField < - typename outerProduct<vector, Type>::type, fvPatchField, volMesh + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh > > -gaussGrad<Type>::grad +Foam::fv::gaussGrad<Type>::gradf ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf + const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf, + const word& name ) { typedef typename outerProduct<vector, Type>::type GradType; @@ -62,7 +55,7 @@ gaussGrad<Type>::grad ( IOobject ( - "grad("+ssf.name()+')', + name, ssf.instance(), mesh, IOobject::NO_READ, @@ -119,27 +112,29 @@ gaussGrad<Type>::grad template<class Type> -tmp +Foam::tmp < - GeometricField + Foam::GeometricField < - typename outerProduct<vector, Type>::type, fvPatchField, volMesh + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh > > -gaussGrad<Type>::grad +Foam::fv::gaussGrad<Type>::calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& vsf + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const { typedef typename outerProduct<vector, Type>::type GradType; tmp<GeometricField<GradType, fvPatchField, volMesh> > tgGrad ( - grad(tinterpScheme_().interpolate(vsf)) + gradf(tinterpScheme_().interpolate(vsf), name) ); GeometricField<GradType, fvPatchField, volMesh>& gGrad = tgGrad(); - gGrad.rename("grad(" + vsf.name() + ')'); correctBoundaryConditions(vsf, gGrad); return tgGrad; @@ -147,7 +142,7 @@ gaussGrad<Type>::grad template<class Type> -void gaussGrad<Type>::correctBoundaryConditions +void Foam::fv::gaussGrad<Type>::correctBoundaryConditions ( const GeometricField<Type, fvPatchField, volMesh>& vsf, GeometricField @@ -174,12 +169,4 @@ void gaussGrad<Type>::correctBoundaryConditions } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H index 8ddfe1bf7cc5fc14204775719487233097346271..4b03d582f0aaf5286b162b4be68b967c4c486d07 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrad.H @@ -89,7 +89,7 @@ public: tinterpScheme_(new linear<Type>(mesh)) {} - //- Construct from Istream + //- Construct from mesh and Istream gaussGrad(const fvMesh& mesh, Istream& is) : gradScheme<Type>(mesh), @@ -116,31 +116,31 @@ public: // Member Functions - //- Return the gradient of the given field + //- Return the gradient of the given field // calculated using Gauss' theorem on the given surface field static tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > gradf ( - const GeometricField<Type, fvsPatchField, surfaceMesh>& + const GeometricField<Type, fvsPatchField, surfaceMesh>&, + const word& name ); - - //- Return the gradient of the given field calculated - // using Gauss' theorem on the interpolated field - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const; - //- Correct the boundary values of the gradient using the patchField // snGrad functions static void correctBoundaryConditions diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrads.C index 3aa827351e33205c356dc8f2572a4abce219d09f..2e98e7df2c3621ed411583380012dcefb82fd5cc 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrads.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/gaussGrad/gaussGrads.C @@ -22,8 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - \*---------------------------------------------------------------------------*/ #include "fvMesh.H" diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C b/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C index 6d7cc56560f86fe08bc0c1297f03f0d8343a0212..267896603ffe813454c4a3f2480afb6962745211 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.C @@ -22,28 +22,16 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Abstract base class for finite volume calculus gradient schemes. - \*---------------------------------------------------------------------------*/ #include "fv.H" -#include "HashTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ +#include "objectRegistry.H" +#include "solution.H" // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * // template<class Type> -tmp<gradScheme<Type> > gradScheme<Type>::New +Foam::tmp<Foam::fv::gradScheme<Type> > Foam::fv::gradScheme<Type>::New ( const fvMesh& mesh, Istream& schemeData @@ -51,7 +39,8 @@ tmp<gradScheme<Type> > gradScheme<Type>::New { if (fv::debug) { - Info<< "gradScheme<Type>::New(Istream& schemeData) : " + Info<< "gradScheme<Type>::New" + "(const fvMesh& mesh, Istream& schemeData) : " "constructing gradScheme<Type>" << endl; } @@ -60,7 +49,8 @@ tmp<gradScheme<Type> > gradScheme<Type>::New { FatalIOErrorIn ( - "gradScheme<Type>::New(Istream& schemeData)", + "gradScheme<Type>::New" + "(const fvMesh& mesh, Istream& schemeData)", schemeData ) << "Grad scheme not specified" << endl << endl << "Valid grad schemes are :" << endl @@ -77,7 +67,8 @@ tmp<gradScheme<Type> > gradScheme<Type>::New { FatalIOErrorIn ( - "gradScheme<Type>::New(Istream& schemeData)", + "gradScheme<Type>::New" + "(const fvMesh& mesh, Istream& schemeData)", schemeData ) << "unknown grad scheme " << schemeName << endl << endl << "Valid grad schemes are :" << endl @@ -92,16 +83,151 @@ tmp<gradScheme<Type> > gradScheme<Type>::New // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class Type> -gradScheme<Type>::~gradScheme() +Foam::fv::gradScheme<Type>::~gradScheme() {} - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -} // End namespace fv +namespace Foam +{ + template<class Type> + inline void cachePrintMessage + ( + const char* message, + const word& name, + const GeometricField<Type, fvPatchField, volMesh>& vf + ) + { + if (solution::debug) + { + Info<< "Cache: " << message << token::SPACE << name + << ", " << vf.name() << " event No. " << vf.eventNo() + << endl; + } + } +} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +template<class Type> +Foam::tmp +< + Foam::GeometricField + < + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh + > +> +Foam::fv::gradScheme<Type>::grad +( + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name +) const +{ + typedef typename outerProduct<vector, Type>::type GradType; + typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType; + + if (!this->mesh().changing() && this->mesh().cache(name)) + { + if (!mesh().objectRegistry::foundObject<GradFieldType>(name)) + { + cachePrintMessage("Calculating and caching", name, vsf); + tmp<GradFieldType> tgGrad = calcGrad(vsf, name); + regIOobject::store(tgGrad.ptr()); + } + + cachePrintMessage("Retreiving", name, vsf); + GradFieldType& gGrad = const_cast<GradFieldType&> + ( + mesh().objectRegistry::lookupObject<GradFieldType>(name) + ); + + if (gGrad.upToDate(vsf)) + { + return gGrad; + } + else + { + cachePrintMessage("Deleting", name, vsf); + gGrad.release(); + delete &gGrad; + + cachePrintMessage("Recalculating", name, vsf); + tmp<GradFieldType> tgGrad = calcGrad(vsf, name); + + cachePrintMessage("Storing", name, vsf); + regIOobject::store(tgGrad.ptr()); + GradFieldType& gGrad = const_cast<GradFieldType&> + ( + mesh().objectRegistry::lookupObject<GradFieldType>(name) + ); + + return gGrad; + } + } + else + { + if (mesh().objectRegistry::foundObject<GradFieldType>(name)) + { + GradFieldType& gGrad = const_cast<GradFieldType&> + ( + mesh().objectRegistry::lookupObject<GradFieldType>(name) + ); + + if (gGrad.ownedByRegistry()) + { + cachePrintMessage("Deleting", name, vsf); + gGrad.release(); + delete &gGrad; + } + } + + cachePrintMessage("Calculating", name, vsf); + return calcGrad(vsf, name); + } +} + + +template<class Type> +Foam::tmp +< + Foam::GeometricField + < + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh + > +> +Foam::fv::gradScheme<Type>::grad +( + const GeometricField<Type, fvPatchField, volMesh>& vsf +) const +{ + return grad(vsf, "grad(" + vsf.name() + ')'); +} + + +template<class Type> +Foam::tmp +< + Foam::GeometricField + < + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh + > +> +Foam::fv::gradScheme<Type>::grad +( + const tmp<GeometricField<Type, fvPatchField, volMesh> >& tvsf +) const +{ + typedef typename outerProduct<vector, Type>::type GradType; + typedef GeometricField<GradType, fvPatchField, volMesh> GradFieldType; + + tmp<GradFieldType> tgrad = grad(tvsf()); + tvsf.clear(); + return tgrad; +} -} // End namespace Foam // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.H b/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.H index e338c3dd9e42f1bb751ce80c1aecef8659071a22..f1d3fa2262581936e1a91b5b058e2d680f9b302b 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/gradScheme/gradScheme.H @@ -114,9 +114,8 @@ public: ); - // Destructor - - virtual ~gradScheme(); + //- Destructor + virtual ~gradScheme(); // Member Functions @@ -127,15 +126,54 @@ public: return mesh_; } - //- Calculate and return the grad of the given field + //- Calculate and return the grad of the given field. + // Used by grad either to recalculate the cached gradient when it is + // out of date with respect to the field or when it is not cached. virtual tmp + < + GeometricField + <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> + > calcGrad + ( + const GeometricField<Type, fvPatchField, volMesh>&, + const word& name + ) const = 0; + + //- Calculate and return the grad of the given field + // which may have been cached + tmp + < + GeometricField + <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> + > grad + ( + const GeometricField<Type, fvPatchField, volMesh>&, + const word& name + ) const; + + //- Calculate and return the grad of the given field + // with the default name + // which may have been cached + tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> > grad ( const GeometricField<Type, fvPatchField, volMesh>& - ) const = 0; + ) const; + + //- Calculate and return the grad of the given field + // with the default name + // which may have been cached + tmp + < + GeometricField + <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> + > grad + ( + const tmp<GeometricField<Type, fvPatchField, volMesh> >& + ) const; }; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.C b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.C index 2ccdcebfdd4b7af825496dad92fb872494e15424..581962315b14f393afe1d0e232262536e2d967de 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "leastSquaresGrad.H" @@ -35,27 +35,20 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - template<class Type> -tmp +Foam::tmp < - GeometricField + Foam::GeometricField < - typename outerProduct<vector, Type>::type, fvPatchField, volMesh + typename Foam::outerProduct<Foam::vector, Type>::type, + Foam::fvPatchField, + Foam::volMesh > > -leastSquaresGrad<Type>::grad +Foam::fv::leastSquaresGrad<Type>::calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& vsf + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const { typedef typename outerProduct<vector, Type>::type GradType; @@ -68,7 +61,7 @@ leastSquaresGrad<Type>::grad ( IOobject ( - "grad("+vsf.name()+')', + name, vsf.instance(), mesh, IOobject::NO_READ, @@ -116,7 +109,7 @@ leastSquaresGrad<Type>::grad if (vsf.boundaryField()[patchi].coupled()) { - Field<Type> neiVsf = + Field<Type> neiVsf = vsf.boundaryField()[patchi].patchNeighbourField(); forAll(neiVsf, patchFaceI) @@ -147,12 +140,4 @@ leastSquaresGrad<Type>::grad } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.H index 90606b83be95e62da7f764d9036769dfc09bff82..efb15a2465ec606bd747d0b36e50009c3b2a6a1c 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/leastSquaresGrad/leastSquaresGrad.H @@ -89,13 +89,16 @@ public: // Member Functions - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const; }; diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.H index 4599902885d7caad492dd8eb8a155139defd6b16..22083de571e94fcbe637c269bd91206e5c0d4715 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrad.H @@ -117,18 +117,82 @@ public: const Type& extrapolate ); - - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const; }; +// * * * * * * * * * * * * Inline Member Function * * * * * * * * * * * * * // + +template<> +inline void cellLimitedGrad<scalar>::limitFace +( + scalar& limiter, + const scalar& maxDelta, + const scalar& minDelta, + const scalar& extrapolate +) +{ + if (extrapolate > maxDelta + VSMALL) + { + limiter = min(limiter, maxDelta/extrapolate); + } + else if (extrapolate < minDelta - VSMALL) + { + limiter = min(limiter, minDelta/extrapolate); + } +} + + +template<class Type> +inline void cellLimitedGrad<Type>::limitFace +( + Type& limiter, + const Type& maxDelta, + const Type& minDelta, + const Type& extrapolate +) +{ + for(direction cmpt=0; cmpt<Type::nComponents; cmpt++) + { + cellLimitedGrad<scalar>::limitFace + ( + limiter.component(cmpt), + maxDelta.component(cmpt), + minDelta.component(cmpt), + extrapolate.component(cmpt) + ); + } +} + + +// * * * * * * * * Template Member Function Specialisations * * * * * * * * // + +template<> +tmp<volVectorField> cellLimitedGrad<scalar>::calcGrad +( + const volScalarField& vsf, + const word& name +) const; + + +template<> +tmp<volTensorField> cellLimitedGrad<vector>::calcGrad +( + const volVectorField& vsf, + const word& name +) const; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fv diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C index c4f0bf524a5c553c3d55e71d32b01f058596eea2..fbc2b8fba542a2c52921ba70e5f6f635ef0ee68d 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellLimitedGrad/cellLimitedGrads.C @@ -36,70 +36,25 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fv { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makeFvGradScheme(cellLimitedGrad) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<> -inline void cellLimitedGrad<scalar>::limitFace -( - scalar& limiter, - const scalar& maxDelta, - const scalar& minDelta, - const scalar& extrapolate -) -{ - if (extrapolate > maxDelta + VSMALL) - { - limiter = min(limiter, maxDelta/extrapolate); - } - else if (extrapolate < minDelta - VSMALL) - { - limiter = min(limiter, minDelta/extrapolate); - } + makeFvGradScheme(cellLimitedGrad) } - -template<class Type> -inline void cellLimitedGrad<Type>::limitFace -( - Type& limiter, - const Type& maxDelta, - const Type& minDelta, - const Type& extrapolate -) -{ - for(direction cmpt=0; cmpt<Type::nComponents; cmpt++) - { - cellLimitedGrad<scalar>::limitFace - ( - limiter.component(cmpt), - maxDelta.component(cmpt), - minDelta.component(cmpt), - extrapolate.component(cmpt) - ); - } } - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<> -tmp<volVectorField> cellLimitedGrad<scalar>::grad +Foam::tmp<Foam::volVectorField> +Foam::fv::cellLimitedGrad<Foam::scalar>::calcGrad ( - const volScalarField& vsf + const volScalarField& vsf, + const word& name ) const { const fvMesh& mesh = vsf.mesh(); - tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf); + tmp<volVectorField> tGrad = basicGradScheme_().calcGrad(vsf, name); if (k_ < SMALL) { @@ -244,14 +199,16 @@ tmp<volVectorField> cellLimitedGrad<scalar>::grad template<> -tmp<volTensorField> cellLimitedGrad<vector>::grad +Foam::tmp<Foam::volTensorField> +Foam::fv::cellLimitedGrad<Foam::vector>::calcGrad ( - const volVectorField& vsf + const volVectorField& vsf, + const word& name ) const { const fvMesh& mesh = vsf.mesh(); - tmp<volTensorField> tGrad = basicGradScheme_().grad(vsf); + tmp<volTensorField> tGrad = basicGradScheme_().calcGrad(vsf, name); if (k_ < SMALL) { @@ -402,12 +359,4 @@ tmp<volTensorField> cellLimitedGrad<vector>::grad } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H index 05953638b2ee7049f0ab93dc9f56c5b681a09978..d9b389d0f54147eb4fdd01d1821bd4ef58fe4ac3 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrad.H @@ -117,13 +117,16 @@ public: const vector& dcf ); - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const; }; @@ -178,6 +181,24 @@ inline void cellMDLimitedGrad<Type>::limitFace } +// * * * * * * * * Template Member Function Specialisations * * * * * * * * // + +template<> +tmp<volVectorField> cellMDLimitedGrad<scalar>::calcGrad +( + const volScalarField& vsf, + const word& name +) const; + + +template<> +tmp<volTensorField> cellMDLimitedGrad<vector>::calcGrad +( + const volVectorField& vsf, + const word& name +) const; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fv diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrads.C index 5a35033428c340220b6474ff4ab407ea1c1ed91f..fffc74e97a02e52e93d22003fd9cd8b4254f8fd6 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrads.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/cellMDLimitedGrad/cellMDLimitedGrads.C @@ -36,27 +36,26 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fv { + makeFvGradScheme(cellMDLimitedGrad) +} +} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makeFvGradScheme(cellMDLimitedGrad) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<> -tmp<volVectorField> cellMDLimitedGrad<scalar>::grad +Foam::tmp<Foam::volVectorField> +Foam::fv::cellMDLimitedGrad<Foam::scalar>::calcGrad ( - const volScalarField& vsf + const volScalarField& vsf, + const word& name ) const { const fvMesh& mesh = vsf.mesh(); - tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf); + tmp<volVectorField> tGrad = basicGradScheme_().calcGrad(vsf, name); if (k_ < SMALL) { @@ -190,14 +189,16 @@ tmp<volVectorField> cellMDLimitedGrad<scalar>::grad template<> -tmp<volTensorField> cellMDLimitedGrad<vector>::grad +Foam::tmp<Foam::volTensorField> +Foam::fv::cellMDLimitedGrad<Foam::vector>::calcGrad ( - const volVectorField& vsf + const volVectorField& vsf, + const word& name ) const { const fvMesh& mesh = vsf.mesh(); - tmp<volTensorField> tGrad = basicGradScheme_().grad(vsf); + tmp<volTensorField> tGrad = basicGradScheme_().calcGrad(vsf, name); if (k_ < SMALL) { @@ -329,12 +330,4 @@ tmp<volTensorField> cellMDLimitedGrad<vector>::grad } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrad.H index 8af5298f42fe62681f71de972fad68c4e55fc27a..96393c771e6e164e823114bea012baa72a50a896 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrad.H @@ -118,17 +118,63 @@ public: // Member Functions - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& - ) const; + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name + ) const + { + return grad(vsf); + } }; +// * * * * * * * * * * * * Inline Member Function * * * * * * * * * * * * * // + +template<class Type> +inline void faceLimitedGrad<Type>::limitFace +( + scalar& limiter, + const scalar maxDelta, + const scalar minDelta, + const scalar extrapolate +) const +{ + if (extrapolate > maxDelta + VSMALL) + { + limiter = min(limiter, maxDelta/extrapolate); + } + else if (extrapolate < minDelta - VSMALL) + { + limiter = min(limiter, minDelta/extrapolate); + } +} + + +// * * * * * * * * Template Member Function Specialisations * * * * * * * * // + +template<> +tmp<volVectorField> faceLimitedGrad<scalar>::calcGrad +( + const volScalarField& vsf, + const word& name +) const; + + +template<> +tmp<volTensorField> faceLimitedGrad<vector>::calcGrad +( + const volVectorField& vsf, + const word& name +) const; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fv diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C index afaf398fbc3b82c24852480ee6650e136200ef06..83c065fa54fe151dd0e5de285958b61f58d54082 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceLimitedGrad/faceLimitedGrads.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "faceLimitedGrad.H" @@ -36,49 +36,26 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fv { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -makeFvGradScheme(faceLimitedGrad) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -template<class Type> -inline void faceLimitedGrad<Type>::limitFace -( - scalar& limiter, - const scalar maxDelta, - const scalar minDelta, - const scalar extrapolate -) const -{ - if (extrapolate > maxDelta + VSMALL) - { - limiter = min(limiter, maxDelta/extrapolate); - } - else if (extrapolate < minDelta - VSMALL) - { - limiter = min(limiter, minDelta/extrapolate); - } + makeFvGradScheme(faceLimitedGrad) +} } // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // template<> -tmp<volVectorField> faceLimitedGrad<scalar>::grad +Foam::tmp<Foam::volVectorField> +Foam::fv::faceLimitedGrad<Foam::scalar>::calcGrad ( - const volScalarField& vsf + const volScalarField& vsf, + const word& name ) const { const fvMesh& mesh = vsf.mesh(); - tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf); + tmp<volVectorField> tGrad = basicGradScheme_().calcGrad(vsf, name); if (k_ < SMALL) { @@ -205,14 +182,16 @@ tmp<volVectorField> faceLimitedGrad<scalar>::grad template<> -tmp<volTensorField> faceLimitedGrad<vector>::grad +Foam::tmp<Foam::volTensorField> +Foam::fv::faceLimitedGrad<Foam::vector>::calcGrad ( - const volVectorField& vvf + const volVectorField& vvf, + const word& name ) const { const fvMesh& mesh = vvf.mesh(); - tmp<volTensorField> tGrad = basicGradScheme_().grad(vvf); + tmp<volTensorField> tGrad = basicGradScheme_().calcGrad(vvf, name); if (k_ < SMALL) { @@ -363,12 +342,4 @@ tmp<volTensorField> faceLimitedGrad<vector>::grad } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrad.H b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrad.H index f9c826452ae890b0c5d266c8651346f427e407f5..20177019d7f502b58b58728287c927104c257577 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrad.H +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrad.H @@ -118,17 +118,38 @@ public: // Member Functions - tmp + //- Return the gradient of the given field to the gradScheme::grad + // for optional caching + virtual tmp < GeometricField <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - > grad + > calcGrad ( - const GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& vsf, + const word& name ) const; }; +// * * * * * * * * Template Member Function Specialisations * * * * * * * * // + +template<> +tmp<volVectorField> faceMDLimitedGrad<scalar>::calcGrad +( + const volScalarField& vsf, + const word& name +) const; + + +template<> +tmp<volTensorField> faceMDLimitedGrad<vector>::calcGrad +( + const volVectorField& vsf, + const word& name +) const; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fv diff --git a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrads.C b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrads.C index 27124c46732780386bbe9b9d977a36546fdbbd43..87ddd25096a964e4961b410325133aaf6c7f0d7c 100644 --- a/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrads.C +++ b/src/finiteVolume/finiteVolume/gradSchemes/limitedGradSchemes/faceMDLimitedGrad/faceMDLimitedGrads.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "faceMDLimitedGrad.H" @@ -37,28 +37,25 @@ License namespace Foam { - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - namespace fv { + makeFvGradScheme(faceMDLimitedGrad) +} +} // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makeFvGradScheme(faceMDLimitedGrad) - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -// FaceLimited scalar gradient template<> -tmp<volVectorField> faceMDLimitedGrad<scalar>::grad +Foam::tmp<Foam::volVectorField> +Foam::fv::faceMDLimitedGrad<Foam::scalar>::calcGrad ( - const volScalarField& vsf + const volScalarField& vsf, + const word& name ) const { const fvMesh& mesh = vsf.mesh(); - tmp<volVectorField> tGrad = basicGradScheme_().grad(vsf); + tmp<volVectorField> tGrad = basicGradScheme_().calcGrad(vsf, name); if (k_ < SMALL) { @@ -189,14 +186,16 @@ tmp<volVectorField> faceMDLimitedGrad<scalar>::grad template<> -tmp<volTensorField> faceMDLimitedGrad<vector>::grad +Foam::tmp<Foam::volTensorField> +Foam::fv::faceMDLimitedGrad<Foam::vector>::calcGrad ( - const volVectorField& vvf + const volVectorField& vvf, + const word& name ) const { const fvMesh& mesh = vvf.mesh(); - tmp<volTensorField> tGrad = basicGradScheme_().grad(vvf); + tmp<volTensorField> tGrad = basicGradScheme_().calcGrad(vvf, name); if (k_ < SMALL) { @@ -327,12 +326,4 @@ tmp<volTensorField> faceMDLimitedGrad<vector>::grad } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C index 1df55b7e17b8be53c0c950a885143b0e9d6bec80..b58c2bd41dd0fc70de7f0f638ccb953fe5d6014b 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.C @@ -47,7 +47,7 @@ tmp<fvMatrix<Type> > gaussLaplacianScheme<Type, GType>::fvmLaplacianUncorrected ( const surfaceScalarField& gammaMagSf, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { tmp<surfaceScalarField> tdeltaCoeffs = @@ -67,9 +67,9 @@ gaussLaplacianScheme<Type, GType>::fvmLaplacianUncorrected fvm.upper() = deltaCoeffs.internalField()*gammaMagSf.internalField(); fvm.negSumDiag(); - forAll(fvm.psi().boundaryField(), patchI) + forAll(vf.boundaryField(), patchI) { - const fvPatchField<Type>& psf = fvm.psi().boundaryField()[patchI]; + const fvPatchField<Type>& psf = vf.boundaryField()[patchI]; const fvsPatchScalarField& patchGamma = gammaMagSf.boundaryField()[patchI]; @@ -149,7 +149,7 @@ tmp<fvMatrix<Type> > gaussLaplacianScheme<Type, GType>::fvmLaplacian ( const GeometricField<GType, fvsPatchField, surfaceMesh>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { const fvMesh& mesh = this->mesh(); diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.H b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.H index a6c3138833ab325065ef26ecdb684c629ba26f58..12b33ae0e47f322cef76bad59de78f66226754c3 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.H +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianScheme.H @@ -62,7 +62,7 @@ class gaussLaplacianScheme tmp<fvMatrix<Type> > fvmLaplacianUncorrected ( const surfaceScalarField& gammaMagSf, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > gammaSnGradCorr @@ -126,7 +126,7 @@ public: tmp<fvMatrix<Type> > fvmLaplacian ( const GeometricField<GType, fvsPatchField, surfaceMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); tmp<GeometricField<Type, fvPatchField, volMesh> > fvcLaplacian @@ -146,7 +146,7 @@ template<> \ tmp<fvMatrix<Type> > gaussLaplacianScheme<Type, scalar>::fvmLaplacian \ ( \ const GeometricField<scalar, fvsPatchField, surfaceMesh>&, \ - GeometricField<Type, fvPatchField, volMesh>& \ + const GeometricField<Type, fvPatchField, volMesh>& \ ); \ \ template<> \ diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianSchemes.C b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianSchemes.C index 5dab5ceef08bac4f124e260c26e50c55c9d6d8f9..782f14ea4a97e6a8fbcdfd3f53ef76b018c98428 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianSchemes.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/gaussLaplacianScheme/gaussLaplacianSchemes.C @@ -21,7 +21,7 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - + \*---------------------------------------------------------------------------*/ #include "gaussLaplacianScheme.H" @@ -44,7 +44,7 @@ Foam::tmp<Foam::fvMatrix<Foam::Type> > \ Foam::fv::gaussLaplacianScheme<Foam::Type, Foam::scalar>::fvmLaplacian \ ( \ const GeometricField<scalar, fvsPatchField, surfaceMesh>& gamma, \ - GeometricField<Type, fvPatchField, volMesh>& vf \ + const GeometricField<Type, fvPatchField, volMesh>& vf \ ) \ { \ const fvMesh& mesh = this->mesh(); \ diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C index eb14f253ad8eeeb07b7d8c09be500434c1ccb4e0..78ce0bc2c63a72570ad4df29ecb25f0e9ab05334 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.C @@ -102,7 +102,7 @@ tmp<fvMatrix<Type> > laplacianScheme<Type, GType>::fvmLaplacian ( const GeometricField<GType, fvPatchField, volMesh>& gamma, - GeometricField<Type, fvPatchField, volMesh>& vf + const GeometricField<Type, fvPatchField, volMesh>& vf ) { return fvmLaplacian(tinterpGammaScheme_().interpolate(gamma)(), vf); diff --git a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H index b36d87df9e1a35595976daf4d820c2e94fcd9a4f..4bbe44ed9a446613d18ae52990271c27be2b351a 100644 --- a/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H +++ b/src/finiteVolume/finiteVolume/laplacianSchemes/laplacianScheme/laplacianScheme.H @@ -173,13 +173,13 @@ public: virtual tmp<fvMatrix<Type> > fvmLaplacian ( const GeometricField<GType, fvsPatchField, surfaceMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ) = 0; virtual tmp<fvMatrix<Type> > fvmLaplacian ( const GeometricField<GType, fvPatchField, volMesh>&, - GeometricField<Type, fvPatchField, volMesh>& + const GeometricField<Type, fvPatchField, volMesh>& ); virtual tmp<GeometricField<Type, fvPatchField, volMesh> > fvcLaplacian diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C index 0168bd626affcb42f51da7388308b226af188f22..631d6a9c2fd1315a7b211e03d04738f6958d2b2d 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.C @@ -22,9 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Simple central-difference snGrad scheme with non-orthogonal correction. - \*---------------------------------------------------------------------------*/ #include "correctedSnGrad.H" @@ -34,28 +31,44 @@ Description #include "fvcGrad.H" #include "gaussGrad.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace fv -{ - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template<class Type> -correctedSnGrad<Type>::~correctedSnGrad() +Foam::fv::correctedSnGrad<Type>::~correctedSnGrad() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > -correctedSnGrad<Type>::correction +Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> > +Foam::fv::correctedSnGrad<Type>::fullGradCorrection +( + const GeometricField<Type, fvPatchField, volMesh>& vf +) const +{ + const fvMesh& mesh = this->mesh(); + + // construct GeometricField<Type, fvsPatchField, surfaceMesh> + tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tssf = + mesh.correctionVectors() + & linear<typename outerProduct<vector, Type>::type>(mesh).interpolate + ( + gradScheme<Type>::New + ( + mesh, + mesh.gradScheme(vf.name()) + )().grad(vf, "grad(" + vf.name() + ')') + ); + tssf().rename("snGradCorr(" + vf.name() + ')'); + + return tssf; +} + + +template<class Type> +Foam::tmp<Foam::GeometricField<Type, Foam::fvsPatchField, Foam::surfaceMesh> > +Foam::fv::correctedSnGrad<Type>::correction ( const GeometricField<Type, fvPatchField, volMesh>& vf ) const @@ -89,7 +102,7 @@ correctedSnGrad<Type>::correction mesh.correctionVectors() & linear < - typename + typename outerProduct<vector, typename pTraits<Type>::cmptType>::type >(mesh).interpolate ( @@ -108,12 +121,4 @@ correctedSnGrad<Type>::correction } -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace fv - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H index 235886706689e0d2f6673fd9ea63802dcc0e52cb..3eaa42bfdf5b10b3e15758cb84d535032d994778 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H +++ b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrad.H @@ -108,12 +108,36 @@ public: } //- Return the explicit correction to the correctedSnGrad - // for the given field + // for the given field using the gradient of the field + tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > + fullGradCorrection + ( + const GeometricField<Type, fvPatchField, volMesh>& + ) const; + + //- Return the explicit correction to the correctedSnGrad + // for the given field using the gradients of the field components virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > correction(const GeometricField<Type, fvPatchField, volMesh>&) const; }; +// * * * * * * * * Template Member Function Specialisations * * * * * * * * // + +template<> +tmp<surfaceScalarField> correctedSnGrad<scalar>::correction +( + const volScalarField& vsf +) const; + + +template<> +tmp<surfaceVectorField> correctedSnGrad<vector>::correction +( + const volVectorField& vvf +) const; + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace fv diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrads.C b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrads.C index b416a806fa479cc439b36bc2676d5637581db19f..8377ba7ef4e8b0c92164180a48ddf21dab5a4080 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrads.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/correctedSnGrad/correctedSnGrads.C @@ -22,9 +22,6 @@ License along with OpenFOAM; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -Description - Simple central-difference snGrad scheme with non-orthogonal correction. - \*---------------------------------------------------------------------------*/ #include "correctedSnGrad.H" @@ -40,4 +37,27 @@ namespace fv } } + +template<> +Foam::tmp<Foam::surfaceScalarField> +Foam::fv::correctedSnGrad<Foam::scalar>::correction +( + const volScalarField& vsf +) const +{ + return fullGradCorrection(vsf); +} + + +template<> +Foam::tmp<Foam::surfaceVectorField> +Foam::fv::correctedSnGrad<Foam::vector>::correction +( + const volVectorField& vvf +) const +{ + return fullGradCorrection(vvf); +} + + // ************************************************************************* // diff --git a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C index 2b938b0d0ee16d481e2c9fe3a71199ecfb761f98..1d13f0d915196802308277fd973e137ddde16b65 100644 --- a/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C +++ b/src/finiteVolume/finiteVolume/snGradSchemes/quadraticFitSnGrad/quadraticFitSnGradData.C @@ -251,7 +251,7 @@ Foam::label Foam::quadraticFitSnGradData::calcFit scalarList singVals(minSize_); label nSVDzeros = 0; - const scalar& deltaCoeff = mesh().deltaCoeffs()[faci]; + const scalar deltaCoeff = mesh().deltaCoeffs()[faci]; bool goodFit = false; for(int iIt = 0; iIt < 10 && !goodFit; iIt++) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index 1e49de46837ff1613623633bc791033d46e02595..5e85f505922c3118fb411fa2949f5e72e5a7ac6d 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -183,7 +183,7 @@ void Foam::fvMatrix<Type>::addBoundarySource template<class Type> Foam::fvMatrix<Type>::fvMatrix ( - GeometricField<Type, fvPatchField, volMesh>& psi, + const GeometricField<Type, fvPatchField, volMesh>& psi, const dimensionSet& ds ) : @@ -227,7 +227,13 @@ Foam::fvMatrix<Type>::fvMatrix ); } - psi_.boundaryField().updateCoeffs(); + // Update the boundary coefficients of psi without changing its event No. + GeometricField<Type, fvPatchField, volMesh>& psiRef = + const_cast<GeometricField<Type, fvPatchField, volMesh>&>(psi_); + + label currentStatePsi = psiRef.eventNo(); + psiRef.boundaryField().updateCoeffs(); + psiRef.eventNo() = currentStatePsi; } @@ -322,7 +328,7 @@ Foam::fvMatrix<Type>::fvMatrix(const tmp<fvMatrix<Type> >& tfvm) template<class Type> Foam::fvMatrix<Type>::fvMatrix ( - GeometricField<Type, fvPatchField, volMesh>& psi, + const GeometricField<Type, fvPatchField, volMesh>& psi, Istream& is ) : @@ -404,12 +410,17 @@ void Foam::fvMatrix<Type>::setValues const unallocLabelList& nei = mesh.neighbour(); scalarField& Diag = diag(); + Field<Type>& psi = + const_cast + < + GeometricField<Type, fvPatchField, volMesh>& + >(psi_).internalField(); forAll(cellLabels, i) { label celli = cellLabels[i]; - psi_[celli] = values[i]; + psi[celli] = values[i]; source_[celli] = values[i]*Diag[celli]; if (symmetric() || asymmetric()) diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 4fbc2430d7a55faeafcb12977107f1580811c0e2..8569862e13b7b5bafa8b32e6e49dd633534773f9 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -117,8 +117,9 @@ public: // Private data - // Reference to GeometricField<Type, fvPatchField, volMesh> - GeometricField<Type, fvPatchField, volMesh>& psi_; + //- Const reference to GeometricField<Type, fvPatchField, volMesh> + // Converted into a non-const reference at the point of solution. + const GeometricField<Type, fvPatchField, volMesh>& psi_; //- Dimension set dimensionSet dimensions_; @@ -237,7 +238,7 @@ public: //- Construct given a field to solve for fvMatrix ( - GeometricField<Type, fvPatchField, volMesh>&, + const GeometricField<Type, fvPatchField, volMesh>&, const dimensionSet& ); @@ -245,12 +246,12 @@ public: fvMatrix(const fvMatrix<Type>&); //- Construct as copy of tmp<fvMatrix<Type> > deleting argument -# ifdef ConstructFromTmp + #ifdef ConstructFromTmp fvMatrix(const tmp<fvMatrix<Type> >&); -# endif + #endif //- Construct from Istream given field to solve for - fvMatrix(GeometricField<Type, fvPatchField, volMesh>&, Istream&); + fvMatrix(const GeometricField<Type, fvPatchField, volMesh>&, Istream&); // Destructor @@ -267,11 +268,6 @@ public: return psi_; } - GeometricField<Type, fvPatchField, volMesh>& psi() - { - return psi_; - } - const dimensionSet& dimensions() const { return dimensions_; diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 21f3738a02692932c687d8d02c07e365b661b0e0..c56899bd62ea89da15aacae44c743e069135f452 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -63,10 +63,13 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve << endl; } + GeometricField<Type, fvPatchField, volMesh>& psi = + const_cast<GeometricField<Type, fvPatchField, volMesh>&>(psi_); + lduMatrix::solverPerformance solverPerfVec ( "fvMatrix<Type>::solve", - psi_.name() + psi.name() ); scalarField saveDiag = diag(); @@ -82,7 +85,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve ( pow ( - psi_.mesh().solutionD(), + psi.mesh().solutionD(), pTraits<typename powProduct<Vector<label>, Type::rank>::type>::zero ) ); @@ -93,7 +96,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve // copy field and source - scalarField psiCmpt = psi_.internalField().component(cmpt); + scalarField psiCmpt = psi.internalField().component(cmpt); addBoundaryDiag(diag(), cmpt); scalarField sourceCmpt = source.component(cmpt); @@ -109,7 +112,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve ); lduInterfaceFieldPtrsList interfaces = - psi_.boundaryField().interfaces(); + psi.boundaryField().interfaces(); // Use the initMatrixInterfaces and updateMatrixInterfaces to correct // bouCoeffsCmpt for the explicit part of the coupled boundary @@ -137,7 +140,7 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve // Solver call solverPerf = lduMatrix::solver::New ( - psi_.name() + pTraits<Type>::componentNames[cmpt], + psi.name() + pTraits<Type>::componentNames[cmpt], *this, bouCoeffsCmpt, intCoeffsCmpt, @@ -156,11 +159,11 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Type>::solve solverPerfVec = solverPerf; } - psi_.internalField().replace(cmpt, psiCmpt); + psi.internalField().replace(cmpt, psiCmpt); diag() = saveDiag; } - psi_.correctBoundaryConditions(); + psi.correctBoundaryConditions(); return solverPerfVec; } diff --git a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C index 35e5c3ac35749a386907d9fd1b444f6f17f218f5..5ea0ba6a178f26a300f73887a09371552af1344d 100644 --- a/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C +++ b/src/finiteVolume/fvMatrices/fvScalarMatrix/fvScalarMatrix.C @@ -99,6 +99,10 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve const dictionary& solverControls ) { + GeometricField<scalar, fvPatchField, volMesh>& psi = + const_cast<GeometricField<scalar, fvPatchField, volMesh>&> + (fvMat_.psi()); + scalarField saveDiag = fvMat_.diag(); fvMat_.addBoundaryDiag(fvMat_.diag(), 0); @@ -108,14 +112,17 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::fvSolver::solve // assign new solver controls solver_->read(solverControls); - lduMatrix::solverPerformance solverPerf = - solver_->solve(fvMat_.psi().internalField(), totalSource); + lduMatrix::solverPerformance solverPerf = solver_->solve + ( + psi.internalField(), + totalSource + ); solverPerf.print(); fvMat_.diag() = saveDiag; - fvMat_.psi().correctBoundaryConditions(); + psi.correctBoundaryConditions(); return solverPerf; } @@ -134,6 +141,9 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve << endl; } + GeometricField<scalar, fvPatchField, volMesh>& psi = + const_cast<GeometricField<scalar, fvPatchField, volMesh>&>(psi_); + scalarField saveDiag = diag(); addBoundaryDiag(diag(), 0); @@ -143,19 +153,19 @@ Foam::lduMatrix::solverPerformance Foam::fvMatrix<Foam::scalar>::solve // Solver call lduMatrix::solverPerformance solverPerf = lduMatrix::solver::New ( - psi_.name(), + psi.name(), *this, boundaryCoeffs_, internalCoeffs_, - psi_.boundaryField().interfaces(), + psi.boundaryField().interfaces(), solverControls - )->solve(psi_.internalField(), totalSource); + )->solve(psi.internalField(), totalSource); solverPerf.print(); diag() = saveDiag; - psi_.correctBoundaryConditions(); + psi.correctBoundaryConditions(); return solverPerf; } diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredCPCCellToFaceStencilObject.H b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredCPCCellToFaceStencilObject.H index 68608f210bc9a5bea7e016ad8705d717b941201c..617eb1b92aba5b1fca38772dc6e7ce25468d4bb8 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredCPCCellToFaceStencilObject.H +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredCPCCellToFaceStencilObject.H @@ -55,7 +55,7 @@ class centredCPCCellToFaceStencilObject public: - TypeName("centredCFCCellToFaceStencil"); + TypeName("centredCPCCellToFaceStencil"); // Constructors diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredFECCellToFaceStencilObject.H b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredFECCellToFaceStencilObject.H index 3a802374f7af4de0b48af6c7d036f557e608bdcd..4fcea940d577dbe6b3d3a178aec36d970a9d65da 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredFECCellToFaceStencilObject.H +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/centredFECCellToFaceStencilObject.H @@ -55,7 +55,7 @@ class centredFECCellToFaceStencilObject public: - TypeName("centredCFCCellToFaceStencil"); + TypeName("centredFECCellToFaceStencil"); // Constructors diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCECCellToFaceStencilObject.H b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCECCellToFaceStencilObject.H index d23cdacfef173d7174c306445e6415e7f50c6c0a..2f6761bb39e816f9e44f52c53a1298dd99d55c42 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCECCellToFaceStencilObject.H +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCECCellToFaceStencilObject.H @@ -55,7 +55,7 @@ class upwindCECCellToFaceStencilObject public: - TypeName("upwindCFCCellToFaceStencil"); + TypeName("upwindCECCellToFaceStencil"); // Constructors diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCPCCellToFaceStencilObject.H b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCPCCellToFaceStencilObject.H index b86e0b00b5bc724594945e535864a9a317a4a9ff..545a93be15f00b719492b9aa5a1b3949f0b439f3 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCPCCellToFaceStencilObject.H +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindCPCCellToFaceStencilObject.H @@ -55,7 +55,7 @@ class upwindCPCCellToFaceStencilObject public: - TypeName("upwindCFCCellToFaceStencil"); + TypeName("upwindCPCCellToFaceStencil"); // Constructors diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindFECCellToFaceStencilObject.H b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindFECCellToFaceStencilObject.H index 9bd07a1607357d52784d2dc9f949aef71efee8f2..40a4c0921cfd6e9be620f87c978bcd5649be9ded 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindFECCellToFaceStencilObject.H +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/MeshObjects/upwindFECCellToFaceStencilObject.H @@ -55,7 +55,7 @@ class upwindFECCellToFaceStencilObject public: - TypeName("upwindCFCCellToFaceStencil"); + TypeName("upwindFECCellToFaceStencil"); // Constructors diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C index 8a7224288ce94f4b0fd49b515340855c31a9f7cb..516964a1ac17ca37b2d1214c40bb1945beb3d0ca 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.C @@ -93,202 +93,6 @@ void Foam::extendedCellToFaceStencil::writeStencilStats } -Foam::autoPtr<Foam::mapDistribute> -Foam::extendedCellToFaceStencil::calcDistributeMap -( - const polyMesh& mesh, - const globalIndex& globalNumbering, - labelListList& faceStencil -) -{ - // Convert stencil to schedule - // ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - - // We now know what information we need from other processors. This needs - // to be converted into what information I need to send as well - // (mapDistribute) - - - // 1. Construct per processor compact addressing of the global cells - // needed. The ones from the local processor are not included since - // these are always all needed. - List<Map<label> > globalToProc(Pstream::nProcs()); - { - const labelList& procPatchMap = mesh.globalData().procPatchMap(); - const polyBoundaryMesh& patches = mesh.boundaryMesh(); - - // Presize with (as estimate) size of patch to neighbour. - forAll(procPatchMap, procI) - { - if (procPatchMap[procI] != -1) - { - globalToProc[procI].resize - ( - patches[procPatchMap[procI]].size() - ); - } - } - - // Collect all (non-local) globalcells/faces needed. - forAll(faceStencil, faceI) - { - const labelList& stencilCells = faceStencil[faceI]; - - forAll(stencilCells, i) - { - label globalCellI = stencilCells[i]; - label procI = globalNumbering.whichProcID(stencilCells[i]); - - if (procI != Pstream::myProcNo()) - { - label nCompact = globalToProc[procI].size(); - globalToProc[procI].insert(globalCellI, nCompact); - } - } - } - // Sort global cells needed (not really necessary) - forAll(globalToProc, procI) - { - if (procI != Pstream::myProcNo()) - { - Map<label>& globalMap = globalToProc[procI]; - - SortableList<label> sorted(globalMap.toc().xfer()); - - forAll(sorted, i) - { - Map<label>::iterator iter = globalMap.find(sorted[i]); - iter() = i; - } - } - } - - - //forAll(globalToProc, procI) - //{ - // Pout<< "From processor:" << procI << " want cells/faces:" << endl; - // forAllConstIter(Map<label>, globalToProc[procI], iter) - // { - // Pout<< " global:" << iter.key() - // << " local:" << globalNumbering.toLocal(procI, iter.key()) - // << endl; - // } - // Pout<< endl; - //} - } - - - // 2. The overall compact addressing is - // - myProcNo data first (uncompacted) - // - all other processors consecutively - - labelList compactStart(Pstream::nProcs()); - compactStart[Pstream::myProcNo()] = 0; - label nCompact = globalNumbering.localSize(); - forAll(compactStart, procI) - { - if (procI != Pstream::myProcNo()) - { - compactStart[procI] = nCompact; - nCompact += globalToProc[procI].size(); - } - } - - - // 3. Find out what to receive/send in compact addressing. - labelListList recvCompact(Pstream::nProcs()); - for (label procI = 0; procI < Pstream::nProcs(); procI++) - { - if (procI != Pstream::myProcNo()) - { - labelList wantedGlobals(globalToProc[procI].size()); - recvCompact[procI].setSize(globalToProc[procI].size()); - - label i = 0; - forAllConstIter(Map<label>, globalToProc[procI], iter) - { - wantedGlobals[i] = iter.key(); - recvCompact[procI][i] = compactStart[procI]+iter(); - i++; - } - - // Send the global cell numbers I need from procI - OPstream str(Pstream::blocking, procI); - str << wantedGlobals; - } - else - { - recvCompact[procI] = - compactStart[procI] - + identity(globalNumbering.localSize()); - } - } - labelListList sendCompact(Pstream::nProcs()); - for (label procI = 0; procI < Pstream::nProcs(); procI++) - { - if (procI != Pstream::myProcNo()) - { - // See what neighbour wants to receive (= what I need to send) - - IPstream str(Pstream::blocking, procI); - labelList globalCells(str); - - labelList& procCompact = sendCompact[procI]; - procCompact.setSize(globalCells.size()); - - // Convert from globalCells (all on my processor!) into compact - // addressing - forAll(globalCells, i) - { - label cellI = globalNumbering.toLocal(globalCells[i]); - procCompact[i] = compactStart[Pstream::myProcNo()]+cellI; - } - } - else - { - sendCompact[procI] = recvCompact[procI]; - } - } - - // Convert stencil to compact numbering - forAll(faceStencil, faceI) - { - labelList& stencilCells = faceStencil[faceI]; - - forAll(stencilCells, i) - { - label globalCellI = stencilCells[i]; - label procI = globalNumbering.whichProcID(globalCellI); - if (procI != Pstream::myProcNo()) - { - label localCompact = globalToProc[procI][globalCellI]; - stencilCells[i] = compactStart[procI]+localCompact; - } - else - { - label localCompact = globalNumbering.toLocal(globalCellI); - stencilCells[i] = compactStart[procI]+localCompact; - } - - } - } - - - // Constuct map for distribution of compact data. - autoPtr<mapDistribute> mapPtr - ( - new mapDistribute - ( - nCompact, - sendCompact.xfer(), - recvCompact.xfer() - ) - ); - - return mapPtr; -} - - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::extendedCellToFaceStencil::extendedCellToFaceStencil(const polyMesh& mesh) diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.H b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.H index bb0e92d11fc8d2dc6aa4e55758f8ff0c0c9b08f9..c2899ab8e7e742173be961d94fff91aa42b6aa4a 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.H +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCellToFaceStencil.H @@ -112,14 +112,6 @@ public: // Member Functions - //- Calculate distribute map - static autoPtr<mapDistribute> calcDistributeMap - ( - const polyMesh& mesh, - const globalIndex& globalNumbering, - labelListList& faceStencil - ); - //- Use map to get the data into stencil order template<class T> static void collectData diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C index acca48566fabffc3e0b4cbce3be39283fa83e786..85eb7a0b330398cd7ba742e0f4df818165206c14 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedCentredCellToFaceStencil.C @@ -35,16 +35,19 @@ Foam::extendedCentredCellToFaceStencil::extendedCentredCellToFaceStencil const cellToFaceStencil& stencil ) : - extendedCellToFaceStencil(stencil.mesh()) + extendedCellToFaceStencil(stencil.mesh()), + stencil_(stencil) { - stencil_ = stencil; - // Calculate distribute map (also renumbers elements in stencil) - mapPtr_ = calcDistributeMap + List<Map<label> > compactMap(Pstream::nProcs()); + mapPtr_.reset ( - stencil.mesh(), - stencil.globalNumbering(), - stencil_ + new mapDistribute + ( + stencil.globalNumbering(), + stencil_, + compactMap + ) ); } diff --git a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C index 80e47855a8c8cd4966a80389fe7ac1ff4720238f..b99d9576ef216b3d406e3df23b975dddc6e37a55 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/cellToFace/extendedUpwindCellToFaceStencil.C @@ -419,19 +419,32 @@ Foam::extendedUpwindCellToFaceStencil::extendedUpwindCellToFaceStencil neiStencil_ ); - ownMapPtr_ = calcDistributeMap - ( - stencil.mesh(), - stencil.globalNumbering(), - ownStencil_ - ); + { + List<Map<label> > compactMap(Pstream::nProcs()); + ownMapPtr_.reset + ( + new mapDistribute + ( + stencil.globalNumbering(), + ownStencil_, + compactMap + ) + ); + } - neiMapPtr_ = calcDistributeMap - ( - stencil.mesh(), - stencil.globalNumbering(), - neiStencil_ - ); + { + + List<Map<label> > compactMap(Pstream::nProcs()); + neiMapPtr_.reset + ( + new mapDistribute + ( + stencil.globalNumbering(), + neiStencil_, + compactMap + ) + ); + } // stencil now in compact form if (pureUpwind_) @@ -515,12 +528,18 @@ Foam::extendedUpwindCellToFaceStencil::extendedUpwindCellToFaceStencil ownStencil_ = stencil; - ownMapPtr_ = calcDistributeMap - ( - stencil.mesh(), - stencil.globalNumbering(), - ownStencil_ - ); + { + List<Map<label> > compactMap(Pstream::nProcs()); + ownMapPtr_.reset + ( + new mapDistribute + ( + stencil.globalNumbering(), + ownStencil_, + compactMap + ) + ); + } const fvMesh& mesh = dynamic_cast<const fvMesh&>(stencil.mesh()); diff --git a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C index d7dcc2a093d15d4f28985292d670213b16de4f71..27389955e43ad66092839727727bc4d86c2eb8a1 100644 --- a/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C +++ b/src/finiteVolume/fvMesh/extendedStencil/faceToCell/extendedCentredFaceToCellStencil.C @@ -28,9 +28,6 @@ License #include "extendedCentredFaceToCellStencil.H" #include "faceToCellStencil.H" -// Only for access to calcDistributeMap <- needs to be moved out -#include "extendedCellToFaceStencil.H" - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::extendedCentredFaceToCellStencil::extendedCentredFaceToCellStencil @@ -38,16 +35,19 @@ Foam::extendedCentredFaceToCellStencil::extendedCentredFaceToCellStencil const faceToCellStencil& stencil ) : - extendedFaceToCellStencil(stencil.mesh()) + extendedFaceToCellStencil(stencil.mesh()), + stencil_(stencil) { - stencil_ = stencil; - // Calculate distribute map (also renumbers elements in stencil) - mapPtr_ = extendedCellToFaceStencil::calcDistributeMap + List<Map<label> > compactMap(Pstream::nProcs()); + mapPtr_.reset ( - stencil.mesh(), - stencil.globalNumbering(), - stencil_ + new mapDistribute + ( + stencil.globalNumbering(), + stencil_, + compactMap + ) ); } diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C index 74581231f4c0b383f35b71149ddc99fe5eda26ff..3ecbd0a19720075ef77ec93f6faa8b800d82e993 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.C @@ -27,9 +27,6 @@ Description list of selected cells, it creates the mesh consisting only of the desired cells, with the mapping list for points, faces, and cells. - MJ 23/03/05 on coupled faces change the patch of the face to the - oldInternalFaces patch. - \*---------------------------------------------------------------------------*/ #include "fvMeshSubset.H" diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C new file mode 100644 index 0000000000000000000000000000000000000000..65965f15d94612cdee4cee766e017666dc73a4df --- /dev/null +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.C @@ -0,0 +1,640 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "singleCellFvMesh.H" +#include "syncTools.H" +#include "uindirectPrimitivePatch.H" + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// Conversion is a two step process: +// - from original (fine) patch faces to agglomerations (aggloms might not +// be in correct patch order) +// - from agglomerations to coarse patch faces +void Foam::singleCellFvMesh::agglomerateMesh +( + const fvMesh& mesh, + const labelListList& agglom +) +{ + const polyBoundaryMesh& oldPatches = mesh.boundaryMesh(); + + // Check agglomeration within patch face range and continuous + labelList nAgglom(oldPatches.size()); + + forAll(oldPatches, patchI) + { + const polyPatch& pp = oldPatches[patchI]; + + nAgglom[patchI] = max(agglom[patchI])+1; + + forAll(pp, i) + { + if (agglom[patchI][i] < 0 || agglom[patchI][i] >= pp.size()) + { + FatalErrorIn + ( + "singleCellFvMesh::agglomerateMesh(..)" + ) << "agglomeration on patch " << patchI + << " is out of range 0.." << pp.size()-1 + << exit(FatalError); + } + } + } + + // Check agglomeration is sync + { + // Get neighbouring agglomeration + labelList nbrAgglom(mesh.nFaces()-mesh.nInternalFaces()); + forAll(oldPatches, patchI) + { + const polyPatch& pp = oldPatches[patchI]; + + if (pp.coupled()) + { + label offset = pp.start()-mesh.nInternalFaces(); + forAll(pp, i) + { + nbrAgglom[offset+i] = agglom[patchI][i]; + } + } + } + syncTools::swapBoundaryFaceList(mesh, nbrAgglom, false); + + + // Get correspondence between this agglomeration and remote one + Map<label> localToNbr(nbrAgglom.size()/10); + + forAll(oldPatches, patchI) + { + const polyPatch& pp = oldPatches[patchI]; + + if (pp.coupled()) + { + label offset = pp.start()-mesh.nInternalFaces(); + + forAll(pp, i) + { + label bFaceI = offset+i; + label myZone = agglom[patchI][i]; + label nbrZone = nbrAgglom[bFaceI]; + + Map<label>::const_iterator iter = localToNbr.find(myZone); + + if (iter == localToNbr.end()) + { + // First occurence of this zone. Store correspondence + // to remote zone number. + localToNbr.insert(myZone, nbrZone); + } + else + { + // Check that zone numbers are still the same. + if (iter() != nbrZone) + { + FatalErrorIn + ( + "singleCellFvMesh::agglomerateMesh(..)" + ) << "agglomeration is not synchronised across" + << " coupled patch " << pp.name() + << endl + << "Local agglomeration " << myZone + << ". Remote agglomeration " << nbrZone + << exit(FatalError); + } + } + } + } + } + } + + + label coarseI = 0; + forAll(nAgglom, patchI) + { + coarseI += nAgglom[patchI]; + } + // New faces + faceList patchFaces(coarseI); + // New patch start and size + labelList patchStarts(oldPatches.size()); + labelList patchSizes(oldPatches.size()); + + // From new patch face back to agglomeration + patchFaceMap_.setSize(oldPatches.size()); + + // Face counter + coarseI = 0; + + + forAll(oldPatches, patchI) + { + const polyPatch& pp = oldPatches[patchI]; + + if (pp.size() > 0) + { + patchFaceMap_[patchI].setSize(nAgglom[patchI]); + + // Patchfaces per agglomeration + labelListList agglomToPatch + ( + invertOneToMany(nAgglom[patchI], agglom[patchI]) + ); + + // From agglomeration to compact patch face + labelList agglomToFace(nAgglom[patchI], -1); + + patchStarts[patchI] = coarseI; + + forAll(pp, i) + { + label myAgglom = agglom[patchI][i]; + + if (agglomToFace[myAgglom] == -1) + { + // Agglomeration not yet done. We now have: + // - coarseI : current coarse mesh face + // - patchStarts[patchI] : coarse mesh patch start + // - myAgglom : agglomeration + // - agglomToPatch[myAgglom] : fine mesh faces for zone + label coarsePatchFaceI = coarseI - patchStarts[patchI]; + patchFaceMap_[patchI][coarsePatchFaceI] = myAgglom; + agglomToFace[myAgglom] = coarsePatchFaceI; + + const labelList& fineFaces = agglomToPatch[myAgglom]; + + // Create overall map from fine mesh faces to coarseI. + forAll(fineFaces, fineI) + { + reverseFaceMap_[pp.start()+fineFaces[fineI]] = coarseI; + } + + // Construct single face + uindirectPrimitivePatch upp + ( + UIndirectList<face>(pp, fineFaces), + pp.points() + ); + + if (upp.edgeLoops().size() != 1) + { + FatalErrorIn + ( + "singleCellFvMesh::agglomerateMesh(..)" + ) << "agglomeration does not create a" + << " single, non-manifold" + << " face for agglomeration " << coarseI + << exit(FatalError); + } + + patchFaces[coarseI++] = face + ( + renumber + ( + upp.meshPoints(), + upp.edgeLoops()[0] + ) + ); + } + } + + patchSizes[patchI] = coarseI-patchStarts[patchI]; + } + } + + //Pout<< "patchStarts:" << patchStarts << endl; + //Pout<< "patchSizes:" << patchSizes << endl; + + // Compact numbering for points + reversePointMap_.setSize(mesh.nPoints()); + reversePointMap_.labelList::operator=(-1); + label newI = 0; + + forAll(patchFaces, coarseI) + { + face& f = patchFaces[coarseI]; + + forAll(f, fp) + { + if (reversePointMap_[f[fp]] == -1) + { + reversePointMap_[f[fp]] = newI++; + } + + f[fp] = reversePointMap_[f[fp]]; + } + } + + pointMap_ = invert(newI, reversePointMap_); + + // Subset used points + pointField boundaryPoints(mesh.points(), pointMap_); + + // Add patches (on still zero sized mesh) + List<polyPatch*> newPatches(oldPatches.size()); + forAll(oldPatches, patchI) + { + newPatches[patchI] = oldPatches[patchI].clone + ( + boundaryMesh(), + patchI, + 0, + 0 + ).ptr(); + } + addFvPatches(newPatches); + + // Owner, neighbour is trivial + labelList owner(patchFaces.size(), 0); + labelList neighbour(0); + + + // actually change the mesh + resetPrimitives + ( + xferMove(boundaryPoints), + xferMove(patchFaces), + xferMove(owner), + xferMove(neighbour), + patchSizes, + patchStarts, + true //syncPar + ); + + + // Adapt the zones + cellZones().clear(); + cellZones().setSize(mesh.cellZones().size()); + { + forAll(mesh.cellZones(), zoneI) + { + const cellZone& oldFz = mesh.cellZones()[zoneI]; + + DynamicList<label> newAddressing; + + //Note: uncomment if you think it makes sense. Note that value + // of cell0 is the average. + //// Was old cell0 in this cellZone? + //if (oldFz.localID(0) != -1) + //{ + // newAddressing.append(0); + //} + + cellZones().set + ( + zoneI, + oldFz.clone + ( + newAddressing, + zoneI, + cellZones() + ) + ); + } + } + + faceZones().clear(); + faceZones().setSize(mesh.faceZones().size()); + { + forAll(mesh.faceZones(), zoneI) + { + const faceZone& oldFz = mesh.faceZones()[zoneI]; + + DynamicList<label> newAddressing(oldFz.size()); + DynamicList<bool> newFlipMap(oldFz.size()); + + forAll(oldFz, i) + { + label newFaceI = reverseFaceMap_[oldFz[i]]; + + if (newFaceI != -1) + { + newAddressing.append(newFaceI); + newFlipMap.append(oldFz.flipMap()[i]); + } + } + + faceZones().set + ( + zoneI, + oldFz.clone + ( + newAddressing, + newFlipMap, + zoneI, + faceZones() + ) + ); + } + } + + + pointZones().clear(); + pointZones().setSize(mesh.pointZones().size()); + { + forAll(mesh.pointZones(), zoneI) + { + const pointZone& oldFz = mesh.pointZones()[zoneI]; + + DynamicList<label> newAddressing(oldFz.size()); + + forAll(oldFz, i) + { + label newPointI = reversePointMap_[oldFz[i]]; + if (newPointI != -1) + { + newAddressing.append(newPointI); + } + } + + pointZones().set + ( + zoneI, + oldFz.clone + ( + pointZones(), + zoneI, + newAddressing + ) + ); + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::singleCellFvMesh::singleCellFvMesh +( + const IOobject& io, + const fvMesh& mesh +) +: + fvMesh + ( + io, + xferCopy(pointField()), //points + xferCopy(faceList()), //faces + xferCopy(labelList()), //allOwner + xferCopy(labelList()), //allNeighbour + false //syncPar + ), + patchFaceAgglomeration_ + ( + IOobject + ( + "patchFaceAgglomeration", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + 0 + ), + patchFaceMap_ + ( + IOobject + ( + "patchFaceMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.boundaryMesh().size() + ), + reverseFaceMap_ + ( + IOobject + ( + "reverseFaceMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.nFaces() + ), + pointMap_ + ( + IOobject + ( + "pointMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.nPoints() + ), + reversePointMap_ + ( + IOobject + ( + "reversePointMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.nPoints() + ) +{ + const polyBoundaryMesh& oldPatches = mesh.boundaryMesh(); + + labelListList agglom(oldPatches.size()); + + forAll(oldPatches, patchI) + { + agglom[patchI] = identity(oldPatches[patchI].size()); + } + + agglomerateMesh(mesh, agglom); +} + + +Foam::singleCellFvMesh::singleCellFvMesh +( + const IOobject& io, + const fvMesh& mesh, + const labelListList& patchFaceAgglomeration +) +: + fvMesh + ( + io, + xferCopy(pointField()), //points + xferCopy(faceList()), //faces + xferCopy(labelList()), //allOwner + xferCopy(labelList()), //allNeighbour + false //syncPar + ), + patchFaceAgglomeration_ + ( + IOobject + ( + "patchFaceAgglomeration", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + patchFaceAgglomeration + ), + patchFaceMap_ + ( + IOobject + ( + "patchFaceMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.boundaryMesh().size() + ), + reverseFaceMap_ + ( + IOobject + ( + "reverseFaceMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.nFaces() + ), + pointMap_ + ( + IOobject + ( + "pointMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.nPoints() + ), + reversePointMap_ + ( + IOobject + ( + "reversePointMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ), + mesh.nPoints() + ) +{ + agglomerateMesh(mesh, patchFaceAgglomeration); +} + + +Foam::singleCellFvMesh::singleCellFvMesh(const IOobject& io) +: + fvMesh(io), + patchFaceAgglomeration_ + ( + IOobject + ( + "patchFaceAgglomeration", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ) + ), + patchFaceMap_ + ( + IOobject + ( + "patchFaceMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ) + ), + reverseFaceMap_ + ( + IOobject + ( + "reverseFaceMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ) + ), + pointMap_ + ( + IOobject + ( + "pointMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ) + ), + reversePointMap_ + ( + IOobject + ( + "reversePointMap", + io.instance(), + fvMesh::meshSubDir, + *this, + io.readOpt(), + io.writeOpt() + ) + ) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + + + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H new file mode 100644 index 0000000000000000000000000000000000000000..2a412f1f933c2043d811a48496a0dd26a3c5532a --- /dev/null +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H @@ -0,0 +1,245 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::singleCellFvMesh + +Description + fvMesh as subset of other mesh. Consists of one cell and all original + bounday faces. Useful when manipulating boundary data. Single internal + cell only needed to be able to manipulate in a standard way. + +SourceFiles + singleCellFvMesh.C + singleCellFvMeshInterpolate.C + +\*---------------------------------------------------------------------------*/ + +#ifndef singleCellFvMesh_H +#define singleCellFvMesh_H + +#include "fvPatchFieldMapper.H" +#include "fvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class singleCellFvMesh Declaration +\*---------------------------------------------------------------------------*/ + +class singleCellFvMesh +: + public fvMesh +{ + // Private data + + const labelListIOList patchFaceAgglomeration_; + + //- From patch faces back to agglomeration or fine mesh + labelListIOList patchFaceMap_; + + //- From fine mesh faces to coarse mesh + labelIOList reverseFaceMap_; + + //- From coarse points back to original mesh + labelIOList pointMap_; + + //- From fine points to coarse mesh + labelIOList reversePointMap_; + + + // Private Member Functions + + //- Calculate agglomerated mesh + void agglomerateMesh(const fvMesh&, const labelListList&); + + + //- Disallow default bitwise copy construct + singleCellFvMesh(const singleCellFvMesh&); + + //- Disallow default bitwise assignment + void operator=(const singleCellFvMesh&); + + +public: + + //- Patch field mapper class for non-agglomerated meshes + class directPatchFieldMapper + : + public fvPatchFieldMapper + { + // Private data + + const unallocLabelList& directAddressing_; + + public: + + //- Construct given addressing + directPatchFieldMapper(const unallocLabelList& directAddressing) + : + directAddressing_(directAddressing) + {} + + virtual label size() const + { + return directAddressing_.size(); + } + + virtual bool direct() const + { + return true; + } + + virtual const unallocLabelList& directAddressing() const + { + return directAddressing_; + } + }; + + //- Patch field mapper class for agglomerated meshes + class agglomPatchFieldMapper + : + public fvPatchFieldMapper + { + // Private data + + const labelListList& addressing_; + const scalarListList& weights_; + + public: + + //- Construct given addressing + agglomPatchFieldMapper + ( + const labelListList& addressing, + const scalarListList& weights + ) + : + addressing_(addressing), + weights_(weights) + {} + + virtual label size() const + { + return addressing_.size(); + } + + virtual bool direct() const + { + return false; + } + + virtual const labelListList& addressing() const + { + return addressing_; + } + + virtual const scalarListList& weights() const + { + return weights_; + } + }; + + + + // Constructors + + //- Construct from fvMesh and no agglomeration + singleCellFvMesh(const IOobject& io, const fvMesh&); + + //- Construct from fvMesh and agglomeration of boundary faces. + // agglomeration is per patch, per patch face index the agglomeration + // the face goes into. + singleCellFvMesh + ( + const IOobject& io, + const fvMesh&, + const labelListList& patchFaceAgglomeration + ); + + //- Read from IOobject + singleCellFvMesh(const IOobject& io); + + // Member Functions + + bool agglomerate() const + { + return patchFaceAgglomeration_.size() > 0; + } + + //- From patchFace on this back to original mesh or agglomeration + const labelListList& patchFaceMap() const + { + return patchFaceMap_; + } + + //- From point on this back to original mesh + const labelList& pointMap() const + { + return pointMap_; + } + + //- From face on original mesh to face on this + const labelList& reverseFaceMap() const + { + return reverseFaceMap_; + } + + //- From point on original mesh to point on this (or -1 for removed + // points) + const labelList& reversePointMap() const + { + return reversePointMap_; + } + + //- Map volField. Internal field set to average, patch fields straight + // copies. + template<class Type> + tmp<GeometricField<Type, fvPatchField, volMesh> > + interpolate + ( + const GeometricField<Type, fvPatchField, volMesh>& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "singleCellFvMeshInterpolate.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMeshInterpolate.C b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMeshInterpolate.C new file mode 100644 index 0000000000000000000000000000000000000000..9e3a21a7b8711261d07377482390a7f3c7302109 --- /dev/null +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMeshInterpolate.C @@ -0,0 +1,132 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "singleCellFvMesh.H" +#include "Time.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class Type> +tmp<GeometricField<Type, fvPatchField, volMesh> > singleCellFvMesh::interpolate +( + const GeometricField<Type, fvPatchField, volMesh>& vf +) const +{ + // Create internal-field values + Field<Type> internalField(1, gAverage(vf)); + + // Create and map the patch field values + PtrList<fvPatchField<Type> > patchFields(vf.boundaryField().size()); + + if (agglomerate()) + { + forAll(vf.boundaryField(), patchI) + { + const labelList& agglom = patchFaceAgglomeration_[patchI]; + label nAgglom = max(agglom)+1; + + // Use inverse of agglomeration. This is from agglomeration to + // original (fine) mesh patch face. + labelListList coarseToFine(invertOneToMany(nAgglom, agglom)); + inplaceReorder(patchFaceMap_[patchI], coarseToFine); + scalarListList coarseWeights(nAgglom); + forAll(coarseToFine, coarseI) + { + const labelList& fineFaces = coarseToFine[coarseI]; + coarseWeights[coarseI] = scalarList + ( + fineFaces.size(), + 1.0/fineFaces.size() + ); + } + + patchFields.set + ( + patchI, + fvPatchField<Type>::New + ( + vf.boundaryField()[patchI], + boundary()[patchI], + DimensionedField<Type, volMesh>::null(), + agglomPatchFieldMapper(coarseToFine, coarseWeights) + ) + ); + } + } + else + { + forAll(vf.boundaryField(), patchI) + { + labelList map(identity(vf.boundaryField()[patchI].size())); + + patchFields.set + ( + patchI, + fvPatchField<Type>::New + ( + vf.boundaryField()[patchI], + boundary()[patchI], + DimensionedField<Type, volMesh>::null(), + directPatchFieldMapper(map) + ) + ); + } + } + + // Create the complete field from the pieces + tmp<GeometricField<Type, fvPatchField, volMesh> > tresF + ( + new GeometricField<Type, fvPatchField, volMesh> + ( + IOobject + ( + vf.name(), + time().timeName(), + *this, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + *this, + vf.dimensions(), + internalField, + patchFields + ) + ); + + return tresF; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C index 1465c2648eb53d15bc3bcb7248a6283e6f65d3d3..ff2ecdbdc385439f959a1e33a3aa28189c1a5041 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/LimitedScheme/LimitedScheme.C @@ -66,8 +66,10 @@ tmp<surfaceScalarField> LimitedScheme<Type, Limiter, LimitFunc>::limiter const GeometricField<typename Limiter::phiType, fvPatchField, volMesh>& lPhi = tlPhi(); - GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh> - gradc(fvc::grad(lPhi)); + tmp<GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh> > + tgradc(fvc::grad(lPhi)); + const GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh>& + gradc = tgradc(); const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights(); @@ -116,7 +118,7 @@ tmp<surfaceScalarField> LimitedScheme<Type, Limiter, LimitFunc>::limiter gradc.boundaryField()[patchi].patchNeighbourField(); // Build the d-vectors - vectorField pd = + vectorField pd = mesh.Sf().boundaryField()[patchi] /( mesh.magSf().boundaryField()[patchi] diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.C index 4cda19451b4b95e0443ea4daef45781fee9807bd..104cbdd29bbeb57314826201e76b3b2da1323655 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.C @@ -67,9 +67,22 @@ Foam::linearUpwind<Type>::correction const volVectorField& C = mesh.C(); const surfaceVectorField& Cf = mesh.Cf(); - GeometricField - <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - gradVf = gradScheme_().grad(vf); + tmp + < + GeometricField + < + typename outerProduct<vector, Type>::type, + fvPatchField, + volMesh + > + > tgradVf = gradScheme_().grad(vf, gradSchemeName_); + + const GeometricField + < + typename outerProduct<vector, Type>::type, + fvPatchField, + volMesh + >& gradVf = tgradVf(); forAll(faceFlux, facei) { @@ -95,7 +108,7 @@ Foam::linearUpwind<Type>::correction if (pSfCorr.coupled()) { - const unallocLabelList& pOwner = + const unallocLabelList& pOwner = mesh.boundary()[patchi].faceCells(); const vectorField& pCf = Cf.boundaryField()[patchi]; @@ -106,7 +119,7 @@ Foam::linearUpwind<Type>::correction gradVf.boundaryField()[patchi].patchNeighbourField(); // Build the d-vectors - vectorField pd = + vectorField pd = mesh.Sf().boundaryField()[patchi] /( mesh.magSf().boundaryField()[patchi] @@ -129,7 +142,7 @@ Foam::linearUpwind<Type>::correction } else { - pSfCorr[facei] = + pSfCorr[facei] = (pCf[facei] - pd[facei] - C[own]) & pGradVfNei[facei]; } } diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.H b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.H index 2b51590f8586db7670a1ca8084475b015e7ff952..e5e278a7e9ff9cac422d177906588935a6d18e8a 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwind.H @@ -56,6 +56,7 @@ class linearUpwind { // Private Data + word gradSchemeName_; tmp<fv::gradScheme<Type> > gradScheme_; @@ -84,6 +85,7 @@ public: ) : upwind<Type>(mesh, faceFlux), + gradSchemeName_("grad"), gradScheme_ ( new fv::gaussGrad<Type>(mesh) @@ -100,12 +102,13 @@ public: ) : upwind<Type>(mesh, schemeData), + gradSchemeName_(schemeData), gradScheme_ ( fv::gradScheme<Type>::New ( mesh, - schemeData + mesh.gradScheme(gradSchemeName_) ) ) {} @@ -119,12 +122,13 @@ public: ) : upwind<Type>(mesh, faceFlux, schemeData), + gradSchemeName_(schemeData), gradScheme_ ( fv::gradScheme<Type>::New ( mesh, - schemeData + mesh.gradScheme(gradSchemeName_) ) ) {} diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.C b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.C index 80a137b396931ee6710d84bf4460c186ba609129..c4b52f4da08cde07d3ab38ea325f5d597c53c41c 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.C +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.C @@ -74,9 +74,22 @@ Foam::linearUpwindV<Type>::correction const vectorField& C = mesh.C(); const vectorField& Cf = mesh.Cf(); - GeometricField - <typename outerProduct<vector, Type>::type, fvPatchField, volMesh> - gradVf = gradScheme_().grad(vf); + tmp + < + GeometricField + < + typename outerProduct<vector, Type>::type, + fvPatchField, + volMesh + > + > tgradVf = gradScheme_().grad(vf, gradSchemeName_); + + const GeometricField + < + typename outerProduct<vector, Type>::type, + fvPatchField, + volMesh + >& gradVf = tgradVf(); forAll(faceFlux, facei) { diff --git a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.H b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.H index 7f8c9de742dd6eff299dfb953614113e2bef8684..9d477610a7b51b63198657476c5f4dfca9d236ea 100644 --- a/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.H +++ b/src/finiteVolume/interpolation/surfaceInterpolation/limitedSchemes/linearUpwind/linearUpwindV.H @@ -56,6 +56,7 @@ class linearUpwindV { // Private Data + word gradSchemeName_; tmp<fv::gradScheme<Type> > gradScheme_; @@ -84,6 +85,7 @@ public: ) : upwind<Type>(mesh, faceFlux), + gradSchemeName_("grad"), gradScheme_ ( new fv::gaussGrad<Type>(mesh) @@ -100,12 +102,13 @@ public: ) : upwind<Type>(mesh, schemeData), + gradSchemeName_(schemeData), gradScheme_ ( fv::gradScheme<Type>::New ( mesh, - schemeData + mesh.gradScheme(gradSchemeName_) ) ) {} @@ -119,12 +122,13 @@ public: ) : upwind<Type>(mesh, faceFlux, schemeData), + gradSchemeName_(schemeData), gradScheme_ ( fv::gradScheme<Type>::New ( mesh, - schemeData + mesh.gradScheme(gradSchemeName_) ) ) {} diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C index 3681c5869b586ff206bec141c3b8df1813a387d5..6098e1b8ab882573856e0adbdf863711b3c47fe1 100644 --- a/src/lagrangian/basic/Cloud/Cloud.C +++ b/src/lagrangian/basic/Cloud/Cloud.C @@ -306,29 +306,6 @@ void Foam::Cloud<ParticleType>::deleteParticle(ParticleType& p) } -namespace Foam -{ - -class combineNsTransPs -{ - -public: - - void operator()(labelListList& x, const labelListList& y) const - { - forAll(y, i) - { - if (y[i].size()) - { - x[i] = y[i]; - } - } - } -}; - -} // End namespace Foam - - template<class ParticleType> template<class TrackingData> void Foam::Cloud<ParticleType>::move(TrackingData& td) @@ -404,7 +381,7 @@ void Foam::Cloud<ParticleType>::move(TrackingData& td) // processor patches for all the processors labelListList allNTrans(Pstream::nProcs()); allNTrans[Pstream::myProcNo()] = nsTransPs; - combineReduce(allNTrans, combineNsTransPs()); + combineReduce(allNTrans, UPstream::listEq()); transfered = false; diff --git a/src/lagrangian/dieselSpray/spray/spray.H b/src/lagrangian/dieselSpray/spray/spray.H index 5c641ec84e852375028118b730d930626a7ac6a7..b2b7f9b2519a787d7126f3a9d088d4c0d7970b49 100644 --- a/src/lagrangian/dieselSpray/spray/spray.H +++ b/src/lagrangian/dieselSpray/spray/spray.H @@ -264,11 +264,11 @@ public: inline const List<label>& gasToLiquidIndex() const; inline const List<bool>& isLiquidFuel() const; - inline const bool& twoD() const; + inline bool twoD() const; inline const vector& axisOfSymmetry() const; inline const vector& axisOfWedge() const; inline const vector& axisOfWedgeNormal() const; - inline const scalar& angleOfWedge() const; + inline scalar angleOfWedge() const; inline const interpolation<vector>& UInterpolator() const; inline const interpolation<scalar>& rhoInterpolator() const; @@ -284,9 +284,9 @@ public: inline PtrList<scalarField>& srhos(); inline const PtrList<scalarField>& srhos() const; - inline const scalar& ambientPressure() const; + inline scalar ambientPressure() const; - inline const scalar& ambientTemperature() const; + inline scalar ambientTemperature() const; // Check diff --git a/src/lagrangian/dieselSpray/spray/sprayI.H b/src/lagrangian/dieselSpray/spray/sprayI.H index 5a6ce977cc8d68511372104ae72a372882782567..5bcb8fea44d0b44654aa452808c540e5596e3037 100644 --- a/src/lagrangian/dieselSpray/spray/sprayI.H +++ b/src/lagrangian/dieselSpray/spray/sprayI.H @@ -276,7 +276,7 @@ inline const List<bool>& spray::isLiquidFuel() const } -inline const bool& spray::twoD() const +inline bool spray::twoD() const { return twoD_; } @@ -300,7 +300,7 @@ inline const vector& spray::axisOfWedgeNormal() const } -inline const scalar& spray::angleOfWedge() const +inline scalar spray::angleOfWedge() const { return angleOfWedge_; } @@ -366,13 +366,13 @@ inline const PtrList<scalarField>& spray::srhos() const } -inline const scalar& spray::ambientPressure() const +inline scalar spray::ambientPressure() const { return ambientPressure_; } -inline const scalar& spray::ambientTemperature() const +inline scalar spray::ambientTemperature() const { return ambientTemperature_; } diff --git a/src/lagrangian/intermediate/Make/files b/src/lagrangian/intermediate/Make/files index 7c95a699aaffb4e3adba9520322a8747c7e90023..3fb53109fe34caceb485328cbba62fa1ed825dd6 100644 --- a/src/lagrangian/intermediate/Make/files +++ b/src/lagrangian/intermediate/Make/files @@ -54,6 +54,7 @@ $(REACTINGMPPARCEL)/makeBasicReactingMultiphaseParcelSubmodels.C /* bolt-on models */ submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C submodels/addOns/radiation/scatter/cloudScatter/cloudScatter.C +submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.C /* data entries */ diff --git a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C index 1e873603678d78c72f169d1c194c3a2e1c727177..c240c899c07283b44c772d9f95f89cb03ecac114 100644 --- a/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/ThermoCloud/ThermoCloud.C @@ -84,7 +84,7 @@ Foam::ThermoCloud<ParcelType>::ThermoCloud false ), this->mesh(), - dimensionedScalar("zero", dimensionSet(1, 2, -2, 0, 0), 0.0) + dimensionedScalar("zero", dimEnergy, 0.0) ), hcTrans_ ( @@ -98,7 +98,7 @@ Foam::ThermoCloud<ParcelType>::ThermoCloud false ), this->mesh(), - dimensionedScalar("zero", dimensionSet(1, 2, -2, 0, 0), 0.0) + dimensionedScalar("zero", dimEnergy, 0.0) ) { if (readFields) diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index 1ae536e4db9b509427752e0e380e3cea5c55dd19..8c020d3739a43ed3aaa180948c419632fa6fa550 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -286,7 +286,13 @@ bool Foam::KinematicParcel<ParcelType>::hitPatch ParcelType& p = static_cast<ParcelType&>(*this); td.cloud().postProcessing().postPatch(p, patchI); - return td.cloud().patchInteraction().correct(pp, this->face(), U_); + return td.cloud().patchInteraction().correct + ( + pp, + this->face(), + td.keepParticle, + U_ + ); } diff --git a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C index f5975720e460357323ad33bc6da09682f785c557..6729cab4c2e9932765ee6bc60bcd9034cd19b160 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ReactingParcel/ReactingParcel.C @@ -121,7 +121,7 @@ void Foam::ReactingParcel<ParcelType>::correctSurfaceValues return; } - // Far field gas molar fractions + // Far field carrier molar fractions scalarField Xinf(Y_.size()); forAll(Xinf, i) @@ -135,7 +135,7 @@ void Foam::ReactingParcel<ParcelType>::correctSurfaceValues // Molar fraction of far field species at particle surface const scalar Xsff = 1.0 - min(sum(Cs)*specie::RR*this->T_/pc_, 1.0); - // Surface gas total molar concentration + // Surface carrier total molar concentration const scalar CsTot = pc_/(specie::RR*this->T_); // Surface carrier composition (molar fraction) @@ -171,10 +171,10 @@ void Foam::ReactingParcel<ParcelType>::correctSurfaceValues cbrt(td.cloud().mcCarrierThermo().speciesData()[i].W()); rhos += Xs[i]*td.cloud().mcCarrierThermo().speciesData()[i].W(); - cps += Xs[i]*td.cloud().mcCarrierThermo().speciesData()[i].Cp(T); mus += Ys[i]*sqrtW*td.cloud().mcCarrierThermo().speciesData()[i].mu(T); kappa += Ys[i]*cbrtW*td.cloud().mcCarrierThermo().speciesData()[i].kappa(T); + cps += Xs[i]*td.cloud().mcCarrierThermo().speciesData()[i].Cp(T); sumYiSqrtW += Ys[i]*sqrtW; sumYiCbrtW += Ys[i]*cbrtW; @@ -417,7 +417,7 @@ void Foam::ReactingParcel<ParcelType>::calcPhaseChange const scalarField& YComponents, scalarField& dMassPC, scalar& Sh, - scalar& dhsTrans, + scalar& dhsTrans, // TODO: not used scalar& N, scalar& NCpW, scalarField& Cs @@ -462,15 +462,21 @@ void Foam::ReactingParcel<ParcelType>::calcPhaseChange { const label idc = td.cloud().composition().localToGlobalCarrierId(idPhase, i); - const scalar hv = td.cloud().mcCarrierThermo().speciesData()[idc].H(T); - const label idl = td.cloud().composition().globalIds(idPhase)[i]; + + const scalar hv = td.cloud().mcCarrierThermo().speciesData()[idc].H(Ts); const scalar hl = - td.cloud().composition().liquids().properties()[idl].h(pc_, T); + td.cloud().composition().liquids().properties()[idl].h(pc_, Ts); - // Enthalphy transfer to carrier phase + // Enthalphy transfer to carrier phase - method 1 using enthalpy diff Sh += dMassPC[i]*(hl - hv)/dt; + // Enthalphy transfer to carrier phase - method 2 using latent heat +// const scalar hl = +// td.cloud().composition().liquids().properties()[idl].hl(pc_, Ts); +// Sh -= dMassPC[i]*hl/dt; + + // Update particle surface thermo properties const scalar Dab = td.cloud().composition().liquids().properties()[idl].D(pc_, Ts, Wc); diff --git a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C index 109faea9a79f26aa17f00aa9d0d00976ca2fe3a9..d282da9e6afb7e6db00e73af2c8148f75a3b9420 100644 --- a/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/ThermoParcel/ThermoParcel.C @@ -233,7 +233,7 @@ Foam::scalar Foam::ThermoParcel<ParcelType>::calcHeatTransfer if (mag(htc) < ROOTVSMALL && !td.cloud().radiation()) { - return T + dt*Sh/(this->volume(d)*rho*cp); + return max(T + dt*Sh/(this->volume(d)*rho*cp), td.constProps().TMin()); } const scalar As = this->areaS(d); @@ -256,9 +256,11 @@ Foam::scalar Foam::ThermoParcel<ParcelType>::calcHeatTransfer IntegrationScheme<scalar>::integrationResult Tres = td.cloud().TIntegrator().integrate(T, dt, ap, bp); - dhsTrans += dt*htc*As*(Tres.average() - Tc_); + scalar Tnew = max(Tres.value(), td.constProps().TMin()); - return Tres.value(); + dhsTrans += dt*htc*As*(0.5*(T + Tnew) - Tc_); + + return Tnew; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H index dc3b9ff61b2661400ea7c4919e5ca7f183359f20..bd2521eff9d6159c9aea8c34797a487954bfe90c 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H @@ -118,7 +118,7 @@ protected: scalar volumeTotal_; //- Total mass to inject [kg] - const scalar massTotal_; + scalar massTotal_; //- Total mass injected to date [kg] scalar massInjected_; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C index b79a8a1af1052c65079478035175df424ae2e24b..4e88b90bfebf896aab6bdad356bda3f6dfd301e3 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/PatchInjection/PatchInjection.C @@ -124,11 +124,12 @@ Foam::PatchInjection<CloudType>::PatchInjection label patchSize = cellOwners_.size(); label totalPatchSize = patchSize; - reduce(totalPatchSize, sumOp<scalar>()); - fraction_ = patchSize/totalPatchSize; + reduce(totalPatchSize, sumOp<label>()); + fraction_ = scalar(patchSize)/totalPatchSize; - // Set total volume to inject + // Set total volume/mass to inject this->volumeTotal_ = fraction_*volumeFlowRate_().integrate(0.0, duration_); + this->massTotal_ *= fraction_; } @@ -165,10 +166,19 @@ void Foam::PatchInjection<CloudType>::setPositionAndCell label& cellOwner ) { - label cellI = this->owner().rndGen().integer(0, cellOwners_.size() - 1); + if (cellOwners_.size() > 0) + { + label cellI = this->owner().rndGen().integer(0, cellOwners_.size() - 1); - cellOwner = cellOwners_[cellI]; - position = this->owner().mesh().C()[cellOwner]; + cellOwner = cellOwners_[cellI]; + position = this->owner().mesh().C()[cellOwner]; + } + else + { + cellOwner = -1; + // dummy position + position = pTraits<vector>::max; + } } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C index ffe1f09631471a82d42072887224ffc5d5313dbf..3beaa8abafa9b792962bafccc295251d81125557 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.C @@ -26,7 +26,7 @@ License #include "LocalInteraction.H" -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // template <class CloudType> Foam::label Foam::LocalInteraction<CloudType>::applyToPatch @@ -46,7 +46,7 @@ Foam::label Foam::LocalInteraction<CloudType>::applyToPatch } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // template <class CloudType> Foam::LocalInteraction<CloudType>::LocalInteraction @@ -62,6 +62,7 @@ Foam::LocalInteraction<CloudType>::LocalInteraction const polyMesh& mesh = cloud.mesh(); const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); + // check that user patches are valid region patches forAll(patchData_, patchI) { const word& patchName = patchData_[patchI].patchName(); @@ -70,7 +71,7 @@ Foam::LocalInteraction<CloudType>::LocalInteraction { FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)") << "Patch " << patchName << " not found. Available patches " - << "are: " << bMesh.names() << exit(FatalError); + << "are: " << bMesh.names() << nl << exit(FatalError); } } @@ -95,6 +96,26 @@ Foam::LocalInteraction<CloudType>::LocalInteraction << "interaction. Please specify data for patches:" << nl << badWalls << nl << exit(FatalError); } + + // check that interactions are valid/specified + forAll(patchData_, patchI) + { + const word& interactionTypeName = + patchData_[patchI].interactionTypeName(); + const typename PatchInteractionModel<CloudType>::interactionType& it = + this->wordToInteractionType(interactionTypeName); + + if (it == PatchInteractionModel<CloudType>::itOther) + { + const word& patchName = patchData_[patchI].patchName(); + FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)") + << "Unknown patch interaction type " + << interactionTypeName << " for patch " << patchName + << ". Valid selections are:" + << this->PatchInteractionModel<CloudType>::interactionTypeNames_ + << nl << exit(FatalError); + } + } } @@ -105,7 +126,7 @@ Foam::LocalInteraction<CloudType>::~LocalInteraction() {} -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // template<class CloudType> bool Foam::LocalInteraction<CloudType>::active() const @@ -119,6 +140,7 @@ bool Foam::LocalInteraction<CloudType>::correct ( const polyPatch& pp, const label faceId, + bool& keepParticle, vector& U ) const { @@ -126,19 +148,65 @@ bool Foam::LocalInteraction<CloudType>::correct if (patchI >= 0) { - vector nw = pp.faceAreas()[pp.whichFace(faceId)]; - nw /= mag(nw); + typename PatchInteractionModel<CloudType>::interactionType it = + this->wordToInteractionType + ( + patchData_[patchI].interactionTypeName() + ); - scalar Un = U & nw; - vector Ut = U - Un*nw; - - if (Un > 0) + switch (it) { - U -= (1.0 + patchData_[patchI].e())*Un*nw; + case PatchInteractionModel<CloudType>::itEscape: + { + keepParticle = false; + U = vector::zero; + break; + } + case PatchInteractionModel<CloudType>::itStick: + { + keepParticle = true; + U = vector::zero; + break; + } + case PatchInteractionModel<CloudType>::itRebound: + { + keepParticle = true; + + vector nw = pp.faceAreas()[pp.whichFace(faceId)]; + nw /= mag(nw); + + scalar Un = U & nw; + vector Ut = U - Un*nw; + + if (Un > 0) + { + U -= (1.0 + patchData_[patchI].e())*Un*nw; + } + + U -= patchData_[patchI].mu()*Ut; + + break; + } + default: + { + FatalErrorIn + ( + "bool LocalInteraction<CloudType>::correct" + "(" + "const polyPatch&, " + "const label, " + "bool&, " + "vector&" + ") const" + ) << "Unknown interaction type " + << patchData_[patchI].interactionTypeName() + << "(" << it << ") for patch " + << patchData_[patchI].patchName() + << ". Valid selections are:" << this->interactionTypeNames_ + << endl << abort(FatalError); + } } - U -= patchData_[patchI].mu()*Ut; - return true; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H index 49d36e9c6d82eab8c15e1aeef2d5b0ed6fa58446..902c4316e56de733e1d49ad90655bf7da342c888 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/LocalInteraction.H @@ -34,7 +34,7 @@ Description #define LocalInteraction_H #include "PatchInteractionModel.H" -#include "dictionaryEntry.H" +#include "patchInteractionData.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -49,78 +49,6 @@ class LocalInteraction : public PatchInteractionModel<CloudType> { - class patchInteractionData - { - // Private data - - //- Patch name - word patchName_; - - //- Elasticity coefficient - scalar e_; - - //- Restitution coefficient - scalar mu_; - - - public: - - //- Construct null - patchInteractionData() - : - patchName_("unknownPatch"), - e_(0.0), - mu_(0.0) - {} - - //- Construct from dictionary - patchInteractionData(const dictionary& dict); - - // Member functions - - // Access - - //- Return const access to the patch name - const word& patchName() const - { - return patchName_; - } - - //- Return const access to the elasticity coefficient - scalar e() const - { - return e_; - } - - //- Return const access to the restitution coefficient - scalar mu() const - { - return mu_; - } - - - // I-O - - //- Istream operator - friend Istream& operator>>(Istream& is, patchInteractionData& pid) - { - is.check - ( - "Istream& operator>>" - "(Istream&, patchInteractionData&)" - ); - - const dictionaryEntry entry(dictionary::null, is); - - pid.patchName_ = entry.keyword(); - entry.lookup("e") >> pid.e_; - entry.lookup("mu") >> pid.mu_; - - return is; - } - }; - - // Private data //- List of participating patches @@ -164,6 +92,7 @@ public: ( const polyPatch& pp, const label faceId, + bool& keepParticle, vector& U ) const; }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.C new file mode 100644 index 0000000000000000000000000000000000000000..f5569fa94d3cb26b4665eb8ac4e30ccdd954e9f5 --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.C @@ -0,0 +1,89 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "patchInteractionData.H" +#include "dictionaryEntry.H" +#include "PatchInteractionModel.H" + +// * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // + +Foam::patchInteractionData::patchInteractionData() +: + interactionTypeName_("unknownInteractionTypeName"), + patchName_("unknownPatch"), + e_(0.0), + mu_(0.0) +{} + + +// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // + +const Foam::word& Foam::patchInteractionData::interactionTypeName() const +{ + return interactionTypeName_; +} + + +const Foam::word& Foam::patchInteractionData::patchName() const +{ + return patchName_; +} + + +Foam::scalar Foam::patchInteractionData::e() const +{ + return e_; +} + + +Foam::scalar Foam::patchInteractionData::mu() const +{ + return mu_; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Istream& Foam::operator>> +( + Istream& is, + patchInteractionData& pid +) +{ + is.check("Istream& operator>>(Istream&, patchInteractionData&)"); + + const dictionaryEntry entry(dictionary::null, is); + + pid.patchName_ = entry.keyword(); + entry.lookup("type") >> pid.interactionTypeName_; + pid.e_ = entry.lookupOrDefault<scalar>("e", 1.0); + pid.mu_ = entry.lookupOrDefault<scalar>("mu", 0.0); + + return is; +} + + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.H new file mode 100644 index 0000000000000000000000000000000000000000..d53bb3dcf607428977a42d24bca206fdb5dd85af --- /dev/null +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/LocalInteraction/patchInteractionData.H @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::patchInteractionData + +Description + Helper class for the LocalInteraction patch interaction model + +\*---------------------------------------------------------------------------*/ + +#ifndef patchInteractionData_H +#define patchInteractionData_H + +#include "Istream.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +/*---------------------------------------------------------------------------*\ + Class patchInteractionData Declaration +\*---------------------------------------------------------------------------*/ + +// Forward declaration of classes +class patchInteractionData; + +// Forward declaration of friend functions +Istream& operator>> +( + Istream& is, + patchInteractionData& pid +); + + +class patchInteractionData +{ + // Private data + + //- Interaction type name + word interactionTypeName_; + + //- Patch name + word patchName_; + + //- Elasticity coefficient + scalar e_; + + //- Restitution coefficient + scalar mu_; + + +public: + + // Constructor + + //- Construct null + patchInteractionData(); + + + // Member functions + + // Access + + //- Return const access to the interaction type name + const word& interactionTypeName() const; + + //- Return const access to the patch name + const word& patchName() const; + + //- Return const access to the elasticity coefficient + scalar e() const; + + //- Return const access to the restitution coefficient + scalar mu() const; + + + // I-O + + //- Istream operator + friend Istream& operator>> + ( + Istream& is, + patchInteractionData& pid + ); +/* { + is.check + ( + "Istream& operator>>" + "(Istream&, patchInteractionData&)" + ); + + const dictionaryEntry entry(dictionary::null, is); + + pid.patchName_ = entry.keyword(); + entry.lookup("type") >> pid.interactionTypeName_; + pid.e_ = entry.lookupOrDefault<scalar>("e", 1.0); + pid.mu_ = entry.lookupOrDefault<scalar>("mu", 0.0); + + if + ( + PatchInteractionModel<CloudType>::wordToInteractionType + ( + pid.interactionTypeName_ + ) + == PatchInteractionModel<CloudType>::itOther) + { + FatalErrorIn + ( + "friend Istream& operator>>" + "(" + "Istream&, " + "patchInteractionData&" + ")" + ) << "Unknown patch interaction type " + << pid.interactionTypeName_ + << ". Valid selections are:" + << PatchInteractionModel<CloudType>:: + interactionTypeNames_ + << endl << abort(FatalError); + } + + return is; + } +*/}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C index 117e6005c8c98cd61f275cd512c8e8ac281070a4..873d5fb34611db8528ceb57e5af007c9fc711ccb 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.C @@ -26,6 +26,76 @@ License #include "PatchInteractionModel.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +template<class CloudType> +Foam::wordList Foam::PatchInteractionModel<CloudType>::interactionTypeNames_ +( + IStringStream + ( + "(rebound stick escape)" + )() +); + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template<class CloudType> +Foam::word Foam::PatchInteractionModel<CloudType>::interactionTypeToWord +( + const interactionType& itEnum +) +{ + switch (itEnum) + { + case itRebound: + { + return "rebound"; + break; + } + case itStick: + { + return "stick"; + break; + } + case itEscape: + { + return "escape"; + break; + } + default: + { + return "other"; + } + } +} + + +template<class CloudType> +typename Foam::PatchInteractionModel<CloudType>::interactionType +Foam::PatchInteractionModel<CloudType>::wordToInteractionType +( + const word& itWord +) +{ + if (itWord == "rebound") + { + return itRebound; + } + else if (itWord == "stick") + { + return itStick; + } + else if (itWord == "escape") + { + return itEscape; + } + else + { + return itOther; + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template<class CloudType> diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H index 986d30d3a1c20d513a170fe4d03096351f8fa790..cf9eb2b05cd7a77875db93744c98c7f04410d566 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/PatchInteractionModel/PatchInteractionModel.H @@ -40,6 +40,7 @@ SourceFiles #include "IOdictionary.H" #include "autoPtr.H" #include "runTimeSelectionTables.H" +#include "polyPatch.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,6 +54,24 @@ namespace Foam template<class CloudType> class PatchInteractionModel { +public: + + // Public enumerations + + // Interaction types + enum interactionType + { + itRebound, + itStick, + itEscape, + itOther + }; + + static wordList interactionTypeNames_; + + +private: + // Private data //- The cloud dictionary @@ -121,6 +140,12 @@ public: // Member Functions + //- Convert interaction result to word + static word interactionTypeToWord(const interactionType& itEnum); + + //- Convert word to interaction result + static interactionType wordToInteractionType(const word& itWord); + //- Flag to indicate whether model activates patch interaction model virtual bool active() const = 0; @@ -130,6 +155,7 @@ public: ( const polyPatch& pp, const label faceId, + bool& keepParticle, vector& U ) const = 0; }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C index e5cfdd3540105e38d9f32f211a131923642faadb..7c62bfda6eedf9e11c408c455038146cde18bf50 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.C @@ -61,22 +61,22 @@ bool Foam::Rebound<CloudType>::correct ( const polyPatch& pp, const label faceId, + bool& keepParticle, vector& U ) const { + keepParticle = true; + vector nw = pp.faceAreas()[pp.whichFace(faceId)]; nw /= mag(nw); scalar Un = U & nw; - vector Ut = U - Un*nw; if (Un > 0.0) { U -= UFactor_*2.0*Un*nw; } - U -= Ut; - return true; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H index 7e3126996f92760256966da6945c608d127832bf..3980ff9c4d9c08b8885d12fd8454612c9faf87d2 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/Rebound/Rebound.H @@ -82,6 +82,7 @@ public: ( const polyPatch& pp, const label faceId, + bool& keepParticle, vector& U ) const; }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C index f87c0dd08b927c739ee6b9ca9592f98a8df8dbda..fcf8f04a2fa66c993d5fe4f179705d5a461fa198 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C @@ -36,9 +36,45 @@ Foam::StandardWallInteraction<CloudType>::StandardWallInteraction ) : PatchInteractionModel<CloudType>(dict, cloud, typeName), - e_(dimensionedScalar(this->coeffDict().lookup("e")).value()), - mu_(dimensionedScalar(this->coeffDict().lookup("mu")).value()) -{} + interactionType_ + ( + this->wordToInteractionType(this->coeffDict().lookup("type")) + ), + e_(0.0), + mu_(0.0) +{ + switch (interactionType_) + { + case PatchInteractionModel<CloudType>::itOther: + { + word interactionTypeName(this->coeffDict().lookup("type")); + + FatalErrorIn + ( + "StandardWallInteraction<CloudType>::StandardWallInteraction" + "(" + "const dictionary&, " + "CloudType& cloud" + ")" + ) << "Unknown interaction result type " + << interactionTypeName + << ". Valid selections are:" << this->interactionTypeNames_ + << endl << exit(FatalError); + + break; + } + case PatchInteractionModel<CloudType>::itRebound: + { + e_ = this->coeffDict().lookupOrDefault("e", 1.0); + mu_ = this->coeffDict().lookupOrDefault("mu", 0.0); + break; + } + default: + { + // do nothing + } + } +} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -62,24 +98,63 @@ bool Foam::StandardWallInteraction<CloudType>::correct ( const polyPatch& pp, const label faceId, + bool& keepParticle, vector& U ) const { if (isA<wallPolyPatch>(pp)) { - vector nw = pp.faceAreas()[pp.whichFace(faceId)]; - nw /= mag(nw); - - scalar Un = U & nw; - vector Ut = U - Un*nw; - - if (Un > 0) + switch (interactionType_) { - U -= (1.0 + e_)*Un*nw; + case PatchInteractionModel<CloudType>::itEscape: + { + keepParticle = false; + U = vector::zero; + break; + } + case PatchInteractionModel<CloudType>::itStick: + { + keepParticle = true; + U = vector::zero; + break; + } + case PatchInteractionModel<CloudType>::itRebound: + { + keepParticle = true; + + vector nw = pp.faceAreas()[pp.whichFace(faceId)]; + nw /= mag(nw); + + scalar Un = U & nw; + vector Ut = U - Un*nw; + + if (Un > 0) + { + U -= (1.0 + e_)*Un*nw; + } + + U -= mu_*Ut; + + break; + } + default: + { + FatalErrorIn + ( + "bool StandardWallInteraction<CloudType>::correct" + "(" + "const polyPatch&, " + "const label, " + "bool&, " + "vector&" + ") const" + ) << "Unknown interaction type " + << this->interactionTypeToWord(interactionType_) + << "(" << interactionType_ << ")" << endl + << abort(FatalError); + } } - U -= mu_*Ut; - return true; } diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H index 3e2175e4698cbbf05c5a9a7175469ae12403a4ee..ab1f198bdc96ef6b97c16f58ec3c4ed276d69fc3 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.H @@ -26,7 +26,19 @@ Class Foam::StandardWallInteraction Description - Wall interaction based on restitution and elasticity coefficients + Wall interaction model. Three choices: + - rebound - optionally specify elasticity and resitution coefficients + - stick - particles assigined zero velocity + - escape - remove particle from the domain + + Example usage: + + StandardWallInteractionCoeffs + { + type rebound; // stick, escape + e 1; // optional - elasticity coeff + mu 0; // optional - restitution coeff + } \*---------------------------------------------------------------------------*/ @@ -40,7 +52,7 @@ Description namespace Foam { /*---------------------------------------------------------------------------*\ - Class StandardWallInteraction Declaration + Class StandardWallInteraction Declaration \*---------------------------------------------------------------------------*/ template<class CloudType> @@ -48,13 +60,19 @@ class StandardWallInteraction : public PatchInteractionModel<CloudType> { - // Private data +protected: + + // Protected data + + //- Interaction type + typename PatchInteractionModel<CloudType>::interactionType + interactionType_; - //- Elasticity - const scalar e_; + //- Elasticity coefficient + scalar e_; //- Restitution coefficient - const scalar mu_; + scalar mu_; public: @@ -84,6 +102,7 @@ public: ( const polyPatch& pp, const label faceId, + bool& keepParticle, vector& U ) const; }; diff --git a/src/lagrangian/intermediate/submodels/Reacting/PhaseChangeModel/LiquidEvaporation/LiquidEvaporation.C b/src/lagrangian/intermediate/submodels/Reacting/PhaseChangeModel/LiquidEvaporation/LiquidEvaporation.C index d763866a49ca60bcec630bf42a356009320bf166..3927ad774005a6f1ffaf3f565ad0dd2a509632e7 100644 --- a/src/lagrangian/intermediate/submodels/Reacting/PhaseChangeModel/LiquidEvaporation/LiquidEvaporation.C +++ b/src/lagrangian/intermediate/submodels/Reacting/PhaseChangeModel/LiquidEvaporation/LiquidEvaporation.C @@ -161,7 +161,7 @@ void Foam::LiquidEvaporation<CloudType>::calculate // vapour diffusivity [m2/s] scalar Dab = liquids_->properties()[lid].D(pc, Ts); - // Saturation pressure for species i [pa] + // saturation pressure for species i [pa] // - carrier phase pressure assumed equal to the liquid vapour pressure // close to the surface // NOTE: if pSat > pc then particle is superheated diff --git a/src/lagrangian/molecularDynamics/molecule/interactionLists/referredCell/referredCell.H b/src/lagrangian/molecularDynamics/molecule/interactionLists/referredCell/referredCell.H index 666b4f9268297675083c85fb810e85723951d14f..cc553de42302c63daa5b5f3dcd8b43c5e3a29c7e 100644 --- a/src/lagrangian/molecularDynamics/molecule/interactionLists/referredCell/referredCell.H +++ b/src/lagrangian/molecularDynamics/molecule/interactionLists/referredCell/referredCell.H @@ -170,7 +170,7 @@ public: // Member Functions - //- Take this referredCell object that has already had it's transform + //- Take this referredCell object that has already had its transform // calculated and refer it on again, retaining same source info. referredCell reRefer ( diff --git a/src/lagrangian/molecularDynamics/potential/tetherPotential/derived/pitchForkRing/pitchForkRing.C b/src/lagrangian/molecularDynamics/potential/tetherPotential/derived/pitchForkRing/pitchForkRing.C index 8a3a081f6fc6bbdcf1e8cdb39df46f233dc97b2c..b94a4f3a103c12bdc9893d6ec92fac447f86f45f 100644 --- a/src/lagrangian/molecularDynamics/potential/tetherPotential/derived/pitchForkRing/pitchForkRing.C +++ b/src/lagrangian/molecularDynamics/potential/tetherPotential/derived/pitchForkRing/pitchForkRing.C @@ -71,9 +71,10 @@ scalar pitchForkRing::energy(const vector r) const { scalar p = sqrt(r.x()*r.x() + r.y()*r.y()); - scalar pMinusRSqr = (p - rOrbit_)*(p - rOrbit_); + scalar pMinusRSqr = sqr(p - rOrbit_); - return -0.5 * mu_ * pMinusRSqr + return + -0.5 * mu_ * pMinusRSqr + 0.25 * pMinusRSqr * pMinusRSqr + 0.5 * alpha_ * r.z() * r.z(); } @@ -87,9 +88,9 @@ vector pitchForkRing::force(const vector r) const return vector ( - (mu_ - pMinusR * pMinusR) * pMinusR * r.x()/p, - (mu_ - pMinusR * pMinusR) * pMinusR * r.y()/p, - -alpha_ * r.z() + (mu_ - sqr(pMinusR)) * pMinusR * r.x()/(p + VSMALL), + (mu_ - sqr(pMinusR)) * pMinusR * r.y()/(p + VSMALL), + - alpha_ * r.z() ); } diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H index 512766c53937a9739df92997c99dfcc5cce41677..fa02d3d0eef9d5278ff529cabf34c26401b89394 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriver.H @@ -396,7 +396,7 @@ class autoLayerDriver const PackedBoolList& isMasterEdge, const labelList& meshEdges, const scalarField& fieldMin, - const label& nSmoothDisp, + const label nSmoothDisp, scalarField& field ) const; diff --git a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C index cc88231b745637041d677b73ae6b6c1d92167b63..8f47f9de8cec7d1cbc0f99b3228abc2084ff41fb 100644 --- a/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C +++ b/src/mesh/autoMesh/autoHexMesh/autoHexMeshDriver/autoLayerDriverShrink.C @@ -94,7 +94,7 @@ void Foam::autoLayerDriver::smoothField const PackedBoolList& isMasterEdge, const labelList& meshEdges, const scalarField& fieldMin, - const label& nSmoothDisp, + const label nSmoothDisp, scalarField& field ) const { diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.C b/src/mesh/blockMesh/blockMesh/blockMesh.C index 4d499ea943229e5660ab8798f71640345cba17bd..1ed0d44a7e03ce9d8575ce2b876a73bc683c59bf 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.C +++ b/src/mesh/blockMesh/blockMesh/blockMesh.C @@ -78,6 +78,12 @@ const Foam::polyMesh& Foam::blockMesh::topology() const } +Foam::scalar Foam::blockMesh::scaleFactor() const +{ + return scaleFactor_; +} + + const Foam::pointField& Foam::blockMesh::points() const { if (points_.empty()) diff --git a/src/mesh/blockMesh/blockMesh/blockMesh.H b/src/mesh/blockMesh/blockMesh/blockMesh.H index 6e67506a798f7d157a01f2c6ed63355e80bc5325..0c423a9b8325103c0053012963c1259a408a62c7 100644 --- a/src/mesh/blockMesh/blockMesh/blockMesh.H +++ b/src/mesh/blockMesh/blockMesh/blockMesh.H @@ -144,6 +144,7 @@ public: // Access //- Reference to point field defining the block mesh + // these points have not been scaled by scaleFactor const pointField& blockPointField() const; const polyMesh& topology() const; @@ -153,6 +154,11 @@ public: return edges_; } + //- The scaling factor used to convert to meters + scalar scaleFactor() const; + + //- The points for the entire mesh + // these points have been scaled by scaleFactor const pointField& points() const; const cellShapeList& cells() const; diff --git a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C index 97ad739d60af056510d09f83571f95a673cdd2f0..533054e3c2c9d021b339fc396a78233086641a02 100644 --- a/src/mesh/blockMesh/blockMesh/blockMeshTopology.C +++ b/src/mesh/blockMesh/blockMesh/blockMeshTopology.C @@ -313,14 +313,10 @@ Foam::polyMesh* Foam::blockMesh::createTopology(IOdictionary& dict) Info<< "Creating topology mesh" << endl; } - PtrList<cellShape> tmpBlockShapes(blocks.size()); + cellShapeList tmpBlockShapes(blocks.size()); forAll(blocks, blockI) { - tmpBlockShapes.set - ( - blockI, - new cellShape(blocks[blockI].blockShape()) - ); + tmpBlockShapes[blockI] = cellShape(blocks[blockI].blockShape()); if (tmpBlockShapes[blockI].mag(blockPointField_) < 0.0) { diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.C b/src/mesh/blockMesh/curvedEdges/BSpline.C index 56e829eda523e433fa15861b86f67b647b70a828..3e166f25cb9650f17a5271df613e47cad7db686e 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.C +++ b/src/mesh/blockMesh/curvedEdges/BSpline.C @@ -38,74 +38,70 @@ Foam::pointField Foam::BSpline::findKnots const vector& sndend ) { - label newnKnots(allknots.size() + 2); - label NKnots(allknots.size()); - pointField newknots(newnKnots); + const label NKnots = allknots.size(); // set up 1/6 and 2/3 which are the matrix elements throughout most // of the matrix - register scalar oneSixth = 1.0/6.0; - register scalar twoThird = 2.0/3.0; + register const scalar oneSixth = 1.0/6.0; + register const scalar twoThird = 2.0/3.0; - simpleMatrix<vector> M(newnKnots); + simpleMatrix<vector> M(NKnots+2, 0, vector::zero); // set up the matrix - M[0][0] = -0.5*scalar(NKnots - 1); M[0][2] = 0.5*scalar(NKnots - 1); - for (register label i=1; i<newnKnots-1; i++) + for (register label i = 1; i <= NKnots; i++) { M[i][i-1] = oneSixth; M[i][i] = twoThird; M[i][i+1] = oneSixth; } - M[newnKnots - 1][newnKnots - 3] = -0.5*scalar(NKnots - 1); - M[newnKnots - 1][newnKnots - 1] = 0.5*scalar(NKnots - 1); + M[NKnots+1][NKnots-1] = -0.5*scalar(NKnots - 1); + M[NKnots+1][NKnots+1] = 0.5*scalar(NKnots - 1); // set up the vector - - for (label i=1; i<=NKnots; i++) + for (register label i = 1; i <= NKnots; i++) { M.source()[i] = allknots[i-1]; } - // set the gradients at the two ends + // set the gradients at the ends: - if (mag(fstend)<1e-8) + if (mag(fstend) < 1e-8) { - // set to the default : forward differences on the end knots + // default : forward differences on the end knots M.source()[0] = allknots[1] - allknots[0]; M.source()[0] /= mag(M.source()[0]); + } + else + { + // use the gradient vector provided + M.source()[0] = fstend/mag(fstend); + } + if (mag(sndend)<1e-8) + { + // default : forward differences on the end knots M.source()[NKnots+1] = M.source()[NKnots-1] - M.source()[NKnots]; M.source()[NKnots+1] /= mag(M.source()[NKnots+1]); } else { - // set to the gradient vectors provided - M.source()[0] = fstend/mag(fstend); + // use the gradient vector provided M.source()[NKnots+1] = sndend/mag(sndend); } - // invert the equation to find the control knots - - newknots = M.solve(); - return newknots; + // invert the equation to find the control knots + return M.solve(); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::BSpline::BSpline(const pointField& Knots) -: - spline(findKnots(Knots)) -{} - - Foam::BSpline::BSpline ( const pointField& Knots, diff --git a/src/mesh/blockMesh/curvedEdges/BSpline.H b/src/mesh/blockMesh/curvedEdges/BSpline.H index d906e05aa477e33923782889d9c20e2af3477f08..ace98b4e21097bd7e0f90be743683601810a9974 100644 --- a/src/mesh/blockMesh/curvedEdges/BSpline.H +++ b/src/mesh/blockMesh/curvedEdges/BSpline.H @@ -56,8 +56,8 @@ class BSpline pointField findKnots ( const pointField&, - const vector& fstend = vector::zero, - const vector& sndend = vector::zero + const vector& fstend, + const vector& sndend ); //- Disallow default bitwise copy construct @@ -71,15 +71,12 @@ public: // Constructors - //- Construct from components - BSpline(const pointField& knots); - //- Construct from components BSpline ( const pointField& knots, - const vector& fstend, - const vector& sndend + const vector& fstend = vector::zero, + const vector& sndend = vector::zero ); diff --git a/src/mesh/blockMesh/curvedEdges/arcEdge.C b/src/mesh/blockMesh/curvedEdges/arcEdge.C index bb7b3b7a8cbfb840b6fa11b73516f4b7e37f7a0f..afb62a8f8b437daaf7ba5fa734d6b07b653ba1f2 100644 --- a/src/mesh/blockMesh/curvedEdges/arcEdge.C +++ b/src/mesh/blockMesh/curvedEdges/arcEdge.C @@ -75,7 +75,7 @@ Foam::cylindricalCS Foam::arcEdge::calcAngle() angle_ = radToDeg(acos(tmp)); // check if the vectors define an exterior or an interior arcEdge - if (((r1 ^ r2)&(r1 ^ r3)) < 0.0) + if (((r1 ^ r2)&(r1 ^ r3)) < 0.0) { angle_ = 360.0 - angle_; } diff --git a/src/mesh/blockMesh/curvedEdges/lineDivide.C b/src/mesh/blockMesh/curvedEdges/lineDivide.C index ef47bff078f08c4c6d3dbee32286111c57a4f1ab..b18933fba609c92a118f0f5bb16d552bf6ac2e31 100644 --- a/src/mesh/blockMesh/curvedEdges/lineDivide.C +++ b/src/mesh/blockMesh/curvedEdges/lineDivide.C @@ -36,7 +36,7 @@ Foam::lineDivide::lineDivide ( const curvedEdge& cedge, const label ndiv, - const scalar& xratio + const scalar xratio ) : points_(ndiv + 1), diff --git a/src/mesh/blockMesh/curvedEdges/lineDivide.H b/src/mesh/blockMesh/curvedEdges/lineDivide.H index 8a4c052abab6236cf85129994dd4121df30ad728..37f1d9ba5c3670ea55ecb7295bf11acc8db9f129 100644 --- a/src/mesh/blockMesh/curvedEdges/lineDivide.H +++ b/src/mesh/blockMesh/curvedEdges/lineDivide.H @@ -67,7 +67,7 @@ public: ( const curvedEdge&, const label ndiv, - const scalar& xratio = 1.0 + const scalar xratio = 1.0 ); diff --git a/src/mesh/blockMesh/curvedEdges/polySplineEdge.C b/src/mesh/blockMesh/curvedEdges/polySplineEdge.C index 841f6f986a2cdce4b406872b40a4215f5f7fbd38..8e4f0f90b3c324888d95bb7c0de7de2f44879664 100644 --- a/src/mesh/blockMesh/curvedEdges/polySplineEdge.C +++ b/src/mesh/blockMesh/curvedEdges/polySplineEdge.C @@ -36,20 +36,6 @@ namespace Foam addToRunTimeSelectionTable(curvedEdge, polySplineEdge, Istream); } - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - //! @cond fileScope - inline label nsize(const label otherKnotsSize, const label nBetweenKnots) - { - return otherKnotsSize*(1 + nBetweenKnots) + nBetweenKnots + 2; - } - //! @endcond fileScope -} - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // // intervening : returns a list of the points making up the polyLineEdge @@ -68,18 +54,25 @@ Foam::pointField Foam::polySplineEdge::intervening const vector& sndend ) { - BSpline spl(knotlist(points_, start_, end_, otherknots), fstend, sndend); - - label nSize(nsize(otherknots.size(), nBetweenKnots)); + BSpline spl + ( + knotlist(points_, start_, end_, otherknots), + fstend, + sndend + ); - pointField ans(nSize); + const label nSize + ( + otherknots.size() * (1 + nBetweenKnots) + nBetweenKnots + 2 + ); - label N = spl.nKnots(); - scalar init = 1.0/(N - 1); - scalar interval = (N - scalar(3))/N; + const label NKnots = spl.nKnots(); + const scalar init = 1.0/(NKnots - 1); + scalar interval = (NKnots - scalar(3.0))/NKnots; interval /= otherknots.size() + 1; interval /= nBetweenKnots + 1; + pointField ans(nSize); ans[0] = points_[start_]; register scalar index(init); @@ -135,17 +128,8 @@ Foam::polySplineEdge::polySplineEdge vector fstend(is); vector sndend(is); - controlPoints_.setSize(nsize(otherKnots_.size(), nInterKnots)); - // why does this need to be here (to avoid a crash)? - // 'intervening' uses BSpline to solve the new points - // it seems to be going badly there - distances_.setSize(controlPoints_.size()); - controlPoints_ = intervening(otherKnots_, nInterKnots, fstend, sndend); calcDistances(); - - // Info<< "polyLine[" << start_ << " " << end_ - // << "] controlPoints " << controlPoints_ << endl; } diff --git a/src/mesh/blockMesh/curvedEdges/spline.C b/src/mesh/blockMesh/curvedEdges/spline.C index 871c7f7db4007acde385443347701e32e3b83426..cddf6fa8edaad6653612d396760d69ad009820d5 100644 --- a/src/mesh/blockMesh/curvedEdges/spline.C +++ b/src/mesh/blockMesh/curvedEdges/spline.C @@ -26,17 +26,9 @@ License #include "spline.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::spline::spline(const pointField& knotPoints) -: - knots_(knotPoints) -{} - +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -Foam::scalar Foam::spline::B(const scalar& tau) const +Foam::scalar Foam::spline::B(const scalar tau) { if (tau <= -2.0 || tau >= 2.0) { @@ -44,7 +36,7 @@ Foam::scalar Foam::spline::B(const scalar& tau) const } else if (tau <= -1.0) { - return pow((2.0 + tau),3.0)/6.0; + return pow((2.0 + tau), 3.0)/6.0; } else if (tau <= 0.0) { @@ -56,11 +48,11 @@ Foam::scalar Foam::spline::B(const scalar& tau) const } else if (tau <= 2.0) { - return pow((2.0 - tau),3.0)/6.0; + return pow((2.0 - tau), 3.0)/6.0; } else { - FatalErrorIn("spline::B(const scalar&)") + FatalErrorIn("spline::B(const scalar)") << "Programming error???, " << "tau = " << tau << abort(FatalError); @@ -70,13 +62,23 @@ Foam::scalar Foam::spline::B(const scalar& tau) const } -Foam::vector Foam::spline::position(const scalar mu1) const +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::spline::spline(const pointField& knotPoints) +: + knots_(knotPoints) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::vector Foam::spline::position(const scalar mu) const { vector loc(vector::zero); - for (register label i=0; i<knots_.size(); i++) + for (register label i=0; i < knots_.size(); i++) { - loc += B((knots_.size() - 1)*mu1 - i)*knots_[i]; + loc += B((knots_.size() - 1)*mu - i)*knots_[i]; } return loc; diff --git a/src/mesh/blockMesh/curvedEdges/spline.H b/src/mesh/blockMesh/curvedEdges/spline.H index 580877068219ab89c22431ae12699b3d1ce294c4..74e73afdc652c00efe762d0d72b75cbb23ca7800 100644 --- a/src/mesh/blockMesh/curvedEdges/spline.H +++ b/src/mesh/blockMesh/curvedEdges/spline.H @@ -27,6 +27,7 @@ Class Description Define a basic spline on nKnots knots. + The spline does not go anywhere near these knots (will act as a base type for various splines that will have real uses) @@ -59,7 +60,7 @@ class spline // Private Member Functions //- Blending function for constructing spline - scalar B(const scalar&) const; + static scalar B(const scalar); //- Disallow default bitwise copy construct spline(const spline&); diff --git a/src/meshTools/octree/treeBoundBox.C b/src/meshTools/octree/treeBoundBox.C index 6133bc3106f9c3e8e07edd53b0d3e7a639211bda..e93e7b9f65e4a144e2fbee74bfc80dad8e0263bd 100644 --- a/src/meshTools/octree/treeBoundBox.C +++ b/src/meshTools/octree/treeBoundBox.C @@ -85,7 +85,8 @@ const Foam::label edgesArray[12][2] = const Foam::edgeList Foam::treeBoundBox::edges ( - initListList<edge, label, 12, 2>(edgesArray) + //initListList<edge, label, 12, 2>(edgesArray) + calcEdges(edgesArray) ); @@ -97,6 +98,18 @@ const Foam::FixedList<Foam::vector, 6> Foam::treeBoundBox::faceNormals // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // +Foam::edgeList Foam::treeBoundBox::calcEdges(const label edgesArray[12][2]) +{ + edgeList edges(12); + forAll(edges, edgeI) + { + edges[edgeI][0] = edgesArray[edgeI][0]; + edges[edgeI][1] = edgesArray[edgeI][1]; + } + return edges; +} + + Foam::FixedList<Foam::vector, 6> Foam::treeBoundBox::calcFaceNormals() { FixedList<vector, 6> normals; diff --git a/src/meshTools/octree/treeBoundBox.H b/src/meshTools/octree/treeBoundBox.H index 69791e04a85b8ddac668cc924a0f46f48b67a5b4..01660d618d33e5eb05d6e9a101519dc51d6f4858 100644 --- a/src/meshTools/octree/treeBoundBox.H +++ b/src/meshTools/octree/treeBoundBox.H @@ -80,6 +80,9 @@ class treeBoundBox private: + //- To initialise edges. + static edgeList calcEdges(const label[12][2]); + //- To initialise faceNormals. static FixedList<vector, 6> calcFaceNormals(); @@ -158,10 +161,6 @@ public: static const FixedList<vector, 6> faceNormals; - //- Face on which neighbour is - static direction neighbourFaceBits(const label&); - - // Constructors //- Construct null setting points to zero diff --git a/src/meshTools/searchableSurface/searchableSurfaceCollection.C b/src/meshTools/searchableSurface/searchableSurfaceCollection.C index 306e78df25fd8242892b219ae4a9e63daf633be0..ba1dd32988e47a2aa53eb001e1014ad1686f83d2 100644 --- a/src/meshTools/searchableSurface/searchableSurfaceCollection.C +++ b/src/meshTools/searchableSurface/searchableSurfaceCollection.C @@ -464,7 +464,10 @@ void Foam::searchableSurfaceCollection::getRegion labelList surfRegion; subGeom_[surfI].getRegion ( - UIndirectList<pointIndexHit>(info, indices), + List<pointIndexHit> + ( + UIndirectList<pointIndexHit>(info, indices) + ), surfRegion ); forAll(indices, i) @@ -528,7 +531,10 @@ void Foam::searchableSurfaceCollection::getNormal vectorField surfNormal; subGeom_[surfI].getNormal ( - UIndirectList<pointIndexHit>(info, indices), + List<pointIndexHit> + ( + UIndirectList<pointIndexHit>(info, indices) + ), surfNormal ); forAll(indices, i) diff --git a/src/postProcessing/functionObjects/field/Make/files b/src/postProcessing/functionObjects/field/Make/files index e950e4d4d5d50e162e74db3535bfb5764db6e0bc..6195b98a41140e7ae2da1b28c53aecf338ae50b0 100644 --- a/src/postProcessing/functionObjects/field/Make/files +++ b/src/postProcessing/functionObjects/field/Make/files @@ -7,10 +7,10 @@ fieldMinMax/fieldMinMax.C fieldMinMax/fieldMinMaxFunctionObject.C fieldValues/fieldValue/fieldValue.C -fieldValues/face/faceSource.C -fieldValues/face/faceSourceFunctionObject.C -fieldValues/cell/cellSource.C -fieldValues/cell/cellSourceFunctionObject.C +fieldValues/faceSource/faceSource.C +fieldValues/faceSource/faceSourceFunctionObject.C +fieldValues/cellSource/cellSource.C +fieldValues/cellSource/cellSourceFunctionObject.C streamLine/streamLine.C streamLine/streamLineParticle.C diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/IOcellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/IOcellSource.H similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/cell/IOcellSource.H rename to src/postProcessing/functionObjects/field/fieldValues/cellSource/IOcellSource.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.C rename to src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.C diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/cell/cellSource.H rename to src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSource.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.C rename to src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.C diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceFunctionObject.H rename to src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceFunctionObject.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceI.H b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceI.H similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceI.H rename to src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceI.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/cell/cellSourceTemplates.C rename to src/postProcessing/functionObjects/field/fieldValues/cellSource/cellSourceTemplates.C diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/IOfaceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/IOfaceSource.H similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/face/IOfaceSource.H rename to src/postProcessing/functionObjects/field/fieldValues/faceSource/IOfaceSource.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C similarity index 82% rename from src/postProcessing/functionObjects/field/fieldValues/face/faceSource.C rename to src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C index 76c1ac9515c7ee3d849cd333e2d32687bf32ca83..710e346ed5dc236baba9ab65fb11a6df968bd94e 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.C @@ -50,10 +50,13 @@ namespace Foam fieldValues::faceSource::sourceTypeNames_; template<> - const char* NamedEnum<fieldValues::faceSource::operationType, 4>:: - names[] = {"none", "sum", "areaAverage", "areaIntegrate"}; + const char* NamedEnum<fieldValues::faceSource::operationType, 5>:: + names[] = + { + "none", "sum", "areaAverage", "areaIntegrate", "weightedAverage" + }; - const NamedEnum<fieldValues::faceSource::operationType, 4> + const NamedEnum<fieldValues::faceSource::operationType, 5> fieldValues::faceSource::operationTypeNames_; } @@ -68,7 +71,9 @@ void Foam::fieldValues::faceSource::setFaceZoneFaces() if (zoneId < 0) { FatalErrorIn("faceSource::faceSource::setFaceZoneFaces()") - << "Unknown face zone name: " << sourceName_ + << type() << " " << name_ << ": " + << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl + << " Unknown face zone name: " << sourceName_ << ". Valid face zones are: " << mesh().faceZones().names() << nl << exit(FatalError); } @@ -164,7 +169,9 @@ void Foam::fieldValues::faceSource::setPatchFaces() if (patchId < 0) { FatalErrorIn("faceSource::constructFaceAddressing()") - << "Unknown patch name: " << sourceName_ + << type() << " " << name_ << ": " + << sourceTypeNames_[source_] << "(" << sourceName_ << "):" << nl + << " Unknown patch name: " << sourceName_ << ". Valid patch names are: " << mesh().boundaryMesh().names() << nl << exit(FatalError); @@ -197,7 +204,7 @@ void Foam::fieldValues::faceSource::setPatchFaces() // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::fieldValues::faceSource::initialise() +void Foam::fieldValues::faceSource::initialise(const dictionary& dict) { switch (source_) { @@ -214,15 +221,40 @@ void Foam::fieldValues::faceSource::initialise() default: { FatalErrorIn("faceSource::constructFaceAddressing()") - << "Unknown source type. Valid source types are:" + << type() << " " << name_ << ": " + << sourceTypeNames_[source_] << "(" << sourceName_ << "):" + << nl << " Unknown source type. Valid source types are:" << sourceTypeNames_ << nl << exit(FatalError); } } Info<< type() << " " << name_ << ":" << nl - << " total faces = " << faceId_.size() << nl - << " total area = " << sum(filterField(mesh().magSf())) - << nl << endl; + << " total faces = " << faceId_.size() << nl + << " total area = " << sum(filterField(mesh().magSf())) << nl; + + if (operation_ == opWeightedAverage) + { + dict.lookup("weightField") >> weightFieldName_; + if + ( + obr().foundObject<volScalarField>(weightFieldName_) + || obr().foundObject<surfaceScalarField>(weightFieldName_) + ) + { + Info<< " weight field = " << weightFieldName_; + } + else + { + FatalErrorIn("faceSource::constructFaceAddressing()") + << type() << " " << name_ << ": " + << sourceTypeNames_[source_] << "(" << sourceName_ << "):" + << nl << " Weight field " << weightFieldName_ + << " must be either a " << volScalarField::typeName << " or " + << surfaceScalarField::typeName << nl << exit(FatalError); + } + } + + Info<< nl << endl; } @@ -302,12 +334,13 @@ Foam::fieldValues::faceSource::faceSource faceId_(), facePatchId_(), flipMap_(), - outputFilePtr_(NULL) + outputFilePtr_(NULL), + weightFieldName_("undefinedWeightedFieldName") { - initialise(); - if (active_) { + initialise(dict); + // Create the output file if not already created makeFile(); } @@ -327,7 +360,7 @@ void Foam::fieldValues::faceSource::read(const dictionary& dict) if (active_) { fieldValue::read(dict); - initialise(); + initialise(dict); } } diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H similarity index 93% rename from src/postProcessing/functionObjects/field/fieldValues/face/faceSource.H rename to src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H index fa89fcdd6c58db55621872a90e47f3444fe9c8d3..3509d733cd0f61388dfb649f0c5de68735fc32c4 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/face/faceSource.H +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSource.H @@ -39,7 +39,7 @@ Description valueOutput true; // Write values at run-time output times? source faceZone; // Type of face source: faceZone, patch sourceName f0; - operation sum; // none, sum, areaAverage, areaIntegrate + operation sum; fields ( p @@ -48,6 +48,13 @@ Description ); } + where operation is one of: + - none + - sum + - areaAverage + - areaIntegrate + - weightedAverage + SourceFiles faceSource.C @@ -100,11 +107,12 @@ public: opNone, opSum, opAreaAverage, - opAreaIntegrate + opAreaIntegrate, + opWeightedAverage }; //- Operation type names - static const NamedEnum<operationType, 4> operationTypeNames_; + static const NamedEnum<operationType, 5> operationTypeNames_; private: @@ -143,11 +151,14 @@ protected: //- Output file pointer autoPtr<OFstream> outputFilePtr_; + //- Weight field name - only used for opWeightedAverage mode + word weightFieldName_; + // Protected member functions //- Initialise, e.g. face addressing - void initialise(); + void initialise(const dictionary& dict); //- Insert field values into values list template<class Type> diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.C rename to src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.C diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/face/faceSourceFunctionObject.H rename to src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceFunctionObject.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceI.H b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceI.H similarity index 100% rename from src/postProcessing/functionObjects/field/fieldValues/face/faceSourceI.H rename to src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceI.H diff --git a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceTemplates.C b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C similarity index 82% rename from src/postProcessing/functionObjects/field/fieldValues/face/faceSourceTemplates.C rename to src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C index ced2ee82eed1841f7dfd3c02fa8a2d99895348a2..d7609573a72cb18d4b7cbeb6c0cee65e67459654 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/face/faceSourceTemplates.C +++ b/src/postProcessing/functionObjects/field/fieldValues/faceSource/faceSourceTemplates.C @@ -129,6 +129,47 @@ Type Foam::fieldValues::faceSource::processValues result = sum(values*filterField(mesh().magSf())); break; } + case opWeightedAverage: + { + if (mesh().foundObject<volScalarField>(weightFieldName_)) + { + tmp<scalarField> wField = + filterField + ( + mesh().lookupObject<volScalarField>(weightFieldName_) + ); + result = sum(values*wField())/sum(wField()); + } + else if (mesh().foundObject<surfaceScalarField>(weightFieldName_)) + { + tmp<scalarField> wField = + filterField + ( + mesh().lookupObject<surfaceScalarField> + ( + weightFieldName_ + ) + ); + result = sum(values*wField())/sum(wField()); + } + else + { + FatalErrorIn + ( + "fieldValues::faceSource::processValues" + "(" + "List<Type>&" + ") const" + ) << type() << " " << name_ << ": " + << sourceTypeNames_[source_] << "(" << sourceName_ << "):" + << nl + << " Weight field " << weightFieldName_ + << " must be either a " << volScalarField::typeName + << " or " << surfaceScalarField::typeName << nl + << abort(FatalError); + } + break; + } default: { // Do nothing diff --git a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H index cdedaae131a9f65b5a03971f02a193bf876b4d2d..3d862b1f6be9303ec7ba21fb5d524943ad93ba04 100644 --- a/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H +++ b/src/postProcessing/functionObjects/field/fieldValues/fieldValue/fieldValue.H @@ -137,7 +137,7 @@ public: //- Return the output field values flag const Switch& valueOutput() const; - //- Helper funvction to return the reference to the mesh + //- Helper function to return the reference to the mesh const fvMesh& mesh() const; diff --git a/src/sampling/sampledSet/sampledSets/sampledSets.C b/src/sampling/sampledSet/sampledSets/sampledSets.C index 4d71403277a790c84179c0f5612cbff226f6754e..a964cab15293f9e5ccbf107391496604eccee903 100644 --- a/src/sampling/sampledSet/sampledSets/sampledSets.C +++ b/src/sampling/sampledSet/sampledSets/sampledSets.C @@ -212,7 +212,7 @@ void Foam::sampledSets::combineSampledSets ( samplePts.name(), samplePts.axis(), - UIndirectList<point>(allPts, indexSets[seti]), + List<point>(UIndirectList<point>(allPts, indexSets[seti])), refPt ) ); diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C index a5c613b15d50e97c39a9ae21b0df2ea53eb76d22..49e088bb8348ac5c8533d9507437dee651f1d2c1 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C @@ -249,7 +249,7 @@ void Foam::dxSurfaceWriter<Type>::write const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose ) const diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H index fcce2e6af2ee5b1ad358795a1ca73227247b9785..8dc9164ec204a1f82c26dca5d8e4488c8fe37803 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H @@ -88,7 +88,7 @@ public: const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose = false ) const; diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C index 0d68df2044d9e0ad8337a0791cccf9114ec814c5..7f617911c600afd7bbd9d0df19054b82715017fb 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C @@ -84,7 +84,7 @@ void Foam::foamFileSurfaceWriter<Type>::write const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose ) const diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H index 207f36c9621020296262e6f18625f461b36e5734..8ef12cda31e7989a5bb28991d95dba39277f645c 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H @@ -95,7 +95,7 @@ public: const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose = false ) const; diff --git a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C b/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C index 1409750c05772cca7c73ec0eb916bbbf4423d1a4..56fcaad3210ddc5624f213b164f5a82fea107778 100644 --- a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C @@ -53,7 +53,7 @@ void Foam::nullSurfaceWriter<Type>::write const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose ) const diff --git a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H b/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H index 24a3f70d4c7ac906fe41250df33ed60d92fb9cf3..475617d48be71d075f62307f24aaef1413266580 100644 --- a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H @@ -80,7 +80,7 @@ public: const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose = false ) const; diff --git a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H index ceeec731a7bb8d76ea11206a2def914a8aa83262..e0dd1dc596138c382528bb50ae6354120904b0c6 100644 --- a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H @@ -102,7 +102,7 @@ public: const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose = false ) const diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C index bab2ad38f38801f6367192791ed7bef9701b095a..c916fe16c3c11d1892b805a9886be0840d0a4fe3 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C @@ -65,7 +65,7 @@ void Foam::rawSurfaceWriter<Type>::writeGeometry template<class Type> void Foam::rawSurfaceWriter<Type>::writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const scalarField& values, @@ -101,7 +101,7 @@ void Foam::rawSurfaceWriter<Type>::writeData template<class Type> void Foam::rawSurfaceWriter<Type>::writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const vectorField& values, @@ -144,7 +144,7 @@ void Foam::rawSurfaceWriter<Type>::writeData template<class Type> void Foam::rawSurfaceWriter<Type>::writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const sphericalTensorField& values, @@ -183,7 +183,7 @@ void Foam::rawSurfaceWriter<Type>::writeData template<class Type> void Foam::rawSurfaceWriter<Type>::writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const symmTensorField& values, @@ -232,7 +232,7 @@ void Foam::rawSurfaceWriter<Type>::writeData template<class Type> void Foam::rawSurfaceWriter<Type>::writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const tensorField& values, @@ -344,7 +344,7 @@ namespace Foam const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<bool>& values, const bool verbose ) const @@ -359,7 +359,7 @@ void Foam::rawSurfaceWriter<Type>::write const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose ) const diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H index fc9fc0804ad3af8663f5377d5d92ce97f628be88..353399c8934a5cf5795e93e95b01c0f7419b7a71 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H @@ -70,7 +70,7 @@ class rawSurfaceWriter static void writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const scalarField& values, @@ -79,7 +79,7 @@ class rawSurfaceWriter static void writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const vectorField& values, @@ -88,7 +88,7 @@ class rawSurfaceWriter static void writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const sphericalTensorField& values, @@ -97,7 +97,7 @@ class rawSurfaceWriter static void writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const symmTensorField& values, @@ -106,7 +106,7 @@ class rawSurfaceWriter static void writeData ( - const fileName& fieldName, + const word& fieldName, const pointField& points, const faceList& faces, const tensorField& values, @@ -152,7 +152,7 @@ public: const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose = false ) const; diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.H b/src/sampling/sampledSurface/writers/surfaceWriter.H index b645c522ef84ed0d5f1284bc35721dd0c852855e..0bee6afe8a774bbf2f26222315f20cd17536fd3f 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.H +++ b/src/sampling/sampledSurface/writers/surfaceWriter.H @@ -128,7 +128,7 @@ public: const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const fileName& fieldName, // name of field + const word& fieldName, // name of field const Field<Type>& values, const bool verbose = false ) const = 0; diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C index ff4766a3253368a19278bb8f4b675a8d18bf9ee1..5967a542114c940219a8a10216d05be197455686 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C @@ -109,7 +109,7 @@ namespace Foam } } - const scalar& v = values[elemI]; + const scalar v = values[elemI]; os << float(v); } os << nl; @@ -266,7 +266,7 @@ void Foam::vtkSurfaceWriter<Type>::write const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose ) const diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H index 1b8736f103afc32957783e0128307239b0626e90..da0c3ef5898406c200bda729f651dacce1fb9db1 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H @@ -97,7 +97,7 @@ public: const fileName& surfaceName, const pointField& points, const faceList& faces, - const fileName& fieldName, + const word& fieldName, const Field<Type>& values, const bool verbose = false ) const; diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.C b/src/surfMesh/MeshedSurface/MeshedSurface.C index 8bcab42089f7936519567d3e0c9ce922decee5cc..1c1622c0ebb13898bb5e6d34a6ed6c5b5f446d1e 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.C +++ b/src/surfMesh/MeshedSurface/MeshedSurface.C @@ -507,7 +507,7 @@ void Foam::MeshedSurface<Face>::movePoints(const pointField& newPoints) template<class Face> -void Foam::MeshedSurface<Face>::scalePoints(const scalar& scaleFactor) +void Foam::MeshedSurface<Face>::scalePoints(const scalar scaleFactor) { // avoid bad scaling if (scaleFactor > 0 && scaleFactor != 1.0) diff --git a/src/surfMesh/MeshedSurface/MeshedSurface.H b/src/surfMesh/MeshedSurface/MeshedSurface.H index 5677233e0bcf8fb35056a81c04b1fcc0d82a507d..ea7125fa833b780b6634b4ecd3b56854fccf26ff 100644 --- a/src/surfMesh/MeshedSurface/MeshedSurface.H +++ b/src/surfMesh/MeshedSurface/MeshedSurface.H @@ -338,7 +338,7 @@ public: virtual void movePoints(const pointField&); //- Scale points. A non-positive factor is ignored - virtual void scalePoints(const scalar&); + virtual void scalePoints(const scalar); //- Reset primitive data (points, faces and zones) // Note, optimized to avoid overwriting data (with Xfer::null) diff --git a/src/thermophysicalModels/basic/basicThermo/basicThermo.C b/src/thermophysicalModels/basic/basicThermo/basicThermo.C index 4a1e7f19f9422250e8336734715cceb9d97dc5ac..3de20158ad0c345b33e5dd237166c761e0af03e9 100644 --- a/src/thermophysicalModels/basic/basicThermo/basicThermo.C +++ b/src/thermophysicalModels/basic/basicThermo/basicThermo.C @@ -143,6 +143,7 @@ void Foam::basicThermo::eBoundaryCorrection(volScalarField& e) } } + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::basicThermo::basicThermo(const fvMesh& mesh) diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H index 654b5c1af6e2b049a35324cf54e5309bccd6c6ca..725ca85df22258892d208a8112f9c5c4244df041 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedEnthalpy/fixedEnthalpyFvPatchScalarField.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class fixedEnthalpyFvPatchScalarField Declaration + Class fixedEnthalpyFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class fixedEnthalpyFvPatchScalarField diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedInternalEnergy/fixedInternalEnergyFvPatchScalarField.H b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedInternalEnergy/fixedInternalEnergyFvPatchScalarField.H index f2ba6cfe56afa6ba0c71fd77db4a7bb01c0ca5ed..c3cde145949bd1b55a4edcc0c631acdf3fedbe37 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/fixedInternalEnergy/fixedInternalEnergyFvPatchScalarField.H +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/fixedInternalEnergy/fixedInternalEnergyFvPatchScalarField.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class fixedInternalEnergyFvPatchScalarField Declaration + Class fixedInternalEnergyFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class fixedInternalEnergyFvPatchScalarField diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.H b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.H index 7b40f74e4bd09a91e1594bc88db835ebbe94f900..697baf769693e9af5be8c679665b425431a77ad0 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.H +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientEnthalpy/gradientEnthalpyFvPatchScalarField.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class gradientEnthalpyFvPatchScalarField Declaration + Class gradientEnthalpyFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class gradientEnthalpyFvPatchScalarField diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.C index ffcb2fbeff40bf11aae2506596c6d5cee23310cc..a8822eb38a993fb7f12ed640b110a3df6c7c6e1e 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.C @@ -37,7 +37,8 @@ namespace Foam // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarField +gradientInternalEnergyFvPatchScalarField:: +gradientInternalEnergyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF @@ -47,7 +48,8 @@ gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarFie {} -gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarField +gradientInternalEnergyFvPatchScalarField:: +gradientInternalEnergyFvPatchScalarField ( const gradientInternalEnergyFvPatchScalarField& ptf, const fvPatch& p, @@ -59,7 +61,8 @@ gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarFie {} -gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarField +gradientInternalEnergyFvPatchScalarField:: +gradientInternalEnergyFvPatchScalarField ( const fvPatch& p, const DimensionedField<scalar, volMesh>& iF, @@ -70,7 +73,8 @@ gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarFie {} -gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarField +gradientInternalEnergyFvPatchScalarField:: +gradientInternalEnergyFvPatchScalarField ( const gradientInternalEnergyFvPatchScalarField& tppsf ) @@ -79,7 +83,8 @@ gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarFie {} -gradientInternalEnergyFvPatchScalarField::gradientInternalEnergyFvPatchScalarField +gradientInternalEnergyFvPatchScalarField:: +gradientInternalEnergyFvPatchScalarField ( const gradientInternalEnergyFvPatchScalarField& tppsf, const DimensionedField<scalar, volMesh>& iF @@ -102,10 +107,10 @@ void gradientInternalEnergyFvPatchScalarField::updateCoeffs() ( "thermophysicalProperties" ); - + const label patchi = patch().index(); - fvPatchScalarField& Tw = + fvPatchScalarField& Tw = const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]); Tw.evaluate(); @@ -123,7 +128,11 @@ void gradientInternalEnergyFvPatchScalarField::updateCoeffs() // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -makePatchTypeField(fvPatchScalarField, gradientInternalEnergyFvPatchScalarField); +makePatchTypeField +( + fvPatchScalarField, + gradientInternalEnergyFvPatchScalarField +); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.H b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.H index 2862f5d40d88de3d282a81bd9bd8ffa1aa0c6d64..901b212e12ac6144b3d598a44edb0a13144450b8 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.H +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/gradientInternalEnergy/gradientInternalEnergyFvPatchScalarField.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class gradientInternalEnergyFvPatchScalarField Declaration + Class gradientInternalEnergyFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class gradientInternalEnergyFvPatchScalarField diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.C b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.C index e084cc0301b8b6756f668bf05981ae0578f5b6d9..1fea21e4c174971cd8db53781965fd1313f9013a 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.C +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.C @@ -106,7 +106,7 @@ void mixedInternalEnergyFvPatchScalarField::updateCoeffs() ( "thermophysicalProperties" ); - + const label patchi = patch().index(); mixedFvPatchScalarField& Tw = refCast<mixedFvPatchScalarField> @@ -118,7 +118,8 @@ void mixedInternalEnergyFvPatchScalarField::updateCoeffs() valueFraction() = Tw.valueFraction(); refValue() = thermo.e(Tw.refValue(), patchi); - refGrad() = thermo.Cv(Tw, patchi)*Tw.refGrad() + refGrad() = + thermo.Cv(Tw, patchi)*Tw.refGrad() + patch().deltaCoeffs()* ( thermo.e(Tw, patchi) diff --git a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.H b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.H index 38566fc5d282e42c24c630a052944047cd2c9aa5..b456ebb1d3fb76d54cbb94a42b80326ce2935664 100644 --- a/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.H +++ b/src/thermophysicalModels/basic/derivedFvPatchFields/mixedInternalEnergy/mixedInternalEnergyFvPatchScalarField.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class mixedInternalEnergyFvPatchScalarField Declaration + Class mixedInternalEnergyFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class mixedInternalEnergyFvPatchScalarField diff --git a/src/thermophysicalModels/basic/mixtures/pureMixture/pureMixture.H b/src/thermophysicalModels/basic/mixtures/pureMixture/pureMixture.H index 43240e4c9b2681e9d24c334c2f52cd09571ae0f1..601b86eff9a44365191547b2e14e285dc508650d 100644 --- a/src/thermophysicalModels/basic/mixtures/pureMixture/pureMixture.H +++ b/src/thermophysicalModels/basic/mixtures/pureMixture/pureMixture.H @@ -44,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class pureMixture Declaration + Class pureMixture Declaration \*---------------------------------------------------------------------------*/ template<class ThermoType> @@ -76,9 +76,8 @@ public: pureMixture(const dictionary&, const fvMesh&); - // Destructor - - ~pureMixture(); + //- Destructor + virtual ~pureMixture(); // Member functions diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H index ac8c10e086fcb6a8eebbc8ad39701c28c6438477..08f30d0637d1ffbf67f4a98e070c5341c4b1c376 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/ODEChemistryModel/ODEChemistryModel.H @@ -168,7 +168,7 @@ public: // Chemistry model functions (overriding abstract functions in - // chemistryModel.H) + // basicChemistryModel.H) //- Return const access to the chemical source terms inline tmp<volScalarField> RR(const label i) const; diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C index 95cfc763881b4ae68bb1e1db21e0402501299a55..5ae636eb0798ccad5ab8dbc937736a8023d44894 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/EulerImplicit/EulerImplicit.C @@ -63,11 +63,8 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve const scalar dt ) const { - scalar pf, cf, pr, cr; - label lRef, rRef; - - label nSpecie = this->model_.nSpecie(); - simpleMatrix<scalar> RR(nSpecie); + const label nSpecie = this->model_.nSpecie(); + simpleMatrix<scalar> RR(nSpecie, 0, 0); for (label i=0; i<nSpecie; i++) { @@ -83,6 +80,9 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve { const Reaction<ThermoType>& R = this->model_.reactions()[i]; + scalar pf, cf, pr, cr; + label lRef, rRef; + scalar omegai = this->model_.omega ( R, c, T, p, pf, cf, lRef, pr, cr, rRef @@ -116,8 +116,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve RR[si][lRef] -= sr*pf*corr; RR[si][rRef] += sr*pr*corr; } - - } // end for(label i... + } for (label i=0; i<nSpecie; i++) @@ -133,7 +132,7 @@ Foam::scalar Foam::EulerImplicit<CompType, ThermoType>::solve // estimate the next time step scalar tMin = GREAT; - label nEqns = this->model_.nEqns(); + const label nEqns = this->model_.nEqns(); scalarField c1(nEqns, 0.0); for (label i=0; i<nSpecie; i++) diff --git a/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C b/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C index d929c5aea2e12a3d426441418db6319ffead318c..cbffe753c68f6b49e68f3c983f62fdea4eb709c6 100644 --- a/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C +++ b/src/thermophysicalModels/chemistryModel/chemistrySolver/sequential/sequential.C @@ -111,8 +111,7 @@ Foam::scalar Foam::sequential<CompType, ThermoType>::solve c[si] += dt*sr*omeg; c[si] = max(0.0, c[si]); } - - } // end for (label i... + } return cTauChem_/tChemInv; } diff --git a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H index 43ea40834915278bfbbd973f5cf46235f0f1e89c..4cd9b983cd83ccbe4371df66290c2c22c58cab1f 100644 --- a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H +++ b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixture.H @@ -116,19 +116,13 @@ public: // Constructors //- Construct from dictionary - liquidMixture - ( - const dictionary& - ); + liquidMixture(const dictionary&); // Selectors //- Select construct from dictionary - static autoPtr<liquidMixture> New - ( - const dictionary& - ); + static autoPtr<liquidMixture> New(const dictionary&); // Member Functions diff --git a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixtureIO.C b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixtureIO.C index 9677a4bfc7952df883dd84b5a528b286eef24b81..dfac21d6d26509346d90b7f7b8382fdf6e25b184 100644 --- a/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixtureIO.C +++ b/src/thermophysicalModels/liquidMixture/liquidMixture/liquidMixtureIO.C @@ -25,9 +25,7 @@ License \*---------------------------------------------------------------------------*/ #include "liquidMixture.H" -#include "IOstreams.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +//#include "IOstreams.H" // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // /* diff --git a/src/thermophysicalModels/liquids/C7H16/C7H16.C b/src/thermophysicalModels/liquids/C7H16/C7H16.C index 846671927b899f9d641a205856cfa24f11423c23..437a2a75d86f28f66531b5185c13ba77cd4b6d77 100644 --- a/src/thermophysicalModels/liquids/C7H16/C7H16.C +++ b/src/thermophysicalModels/liquids/C7H16/C7H16.C @@ -65,7 +65,15 @@ Foam::C7H16::C7H16() 182.274175063868, -254.530511150515 ), - h_(-3.1469964e+6,7.3072e+3,-3.52884e+1,1.10637e-1,-1.634831e-4,9.64941e-8), + h_ + ( + -3.1469964e+6, + 7.3072e+3, + -3.52884e+1, + 1.10637e-1, + -1.634831e-4, + 9.64941e-8 + ), cpg_(1199.05392998284, 3992.85457666361, 1676.6, 2734.42177956968, 756.4), B_ ( @@ -80,7 +88,7 @@ Foam::C7H16::C7H16() K_(0.215, -0.000303, 0.0, 0.0, 0.0, 0.0), Kg_(-0.070028, 0.38068, -7049.9, -2400500.0), sigma_(540.20, 0.054143, 1.2512, 0.0, 0.0, 0.0), - D_(147.18, 20.1, 100.204, 28.0) // note: Same as C7H16 + D_(147.18, 20.1, 100.204, 28.0) {} diff --git a/src/thermophysicalModels/liquids/C7H16/C7H16.H b/src/thermophysicalModels/liquids/C7H16/C7H16.H index b186035160aeb18bdf4bf2b334433e4fd0a75cef..e74e26a3f12cfc0960a22b5aeffff25658da59d1 100644 --- a/src/thermophysicalModels/liquids/C7H16/C7H16.H +++ b/src/thermophysicalModels/liquids/C7H16/C7H16.H @@ -126,7 +126,7 @@ public: //- Liquid heat capacity [J/(kg K)] inline scalar cp(scalar p, scalar T) const; - //- Liquid Enthalpy [J/(kg)] + //- Liquid Enthalpy [J/kg] inline scalar h(scalar p, scalar T) const; //- Ideal gas heat capacity [J/(kg K)] diff --git a/src/thermophysicalModels/liquids/liquid/liquid.H b/src/thermophysicalModels/liquids/liquid/liquid.H index c0f52c11c374a0b4468def339a5778fd3d5ba656..9693fb9eaf5960e65c8a6e6e1caac523ed552a48 100644 --- a/src/thermophysicalModels/liquids/liquid/liquid.H +++ b/src/thermophysicalModels/liquids/liquid/liquid.H @@ -219,7 +219,7 @@ public: //- Liquid heat capacity [J/(kg K)] virtual scalar cp(scalar p, scalar T) const = 0; - //- Liquid h [J/kg] + //- Liquid enthalpy [J/kg] - reference to 298.15 K virtual scalar h(scalar p, scalar T) const = 0; //- Ideal gas heat capacity [J/(kg K)] diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H index f7faa3f1d020cb69358f6c8df616e7876c1950af..23f83c84608ebf2acef2b42b9220f39e0ccb45c3 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiation/MarshakRadiationMixedFvPatchScalarField.H @@ -148,7 +148,7 @@ public: } //- Return the emissivity - const scalar& emissivity() const + scalar emissivity() const { return emissivity_; } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H index 49fc1bed675496dac23eea1853fbe42f6fdcbbf7..9d332d3293eb1b088e69bd2abc2e4a0faff70583 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/MarshakRadiationFixedT/MarshakRadiationFixedTMixedFvPatchScalarField.H @@ -148,7 +148,7 @@ public: } //- Return the emissivity - const scalar& emissivity() const + scalar emissivity() const { return emissivity_; } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C index 42f3ec841d08730c21648297fc46d1bc78c2b8fc..f8e63679a2a684bbd449f93d81f675ded983a9d9 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.C @@ -81,23 +81,28 @@ greyDiffusiveRadiationMixedFvPatchScalarField TName_(dict.lookup("T")), emissivity_(readScalar(dict.lookup("emissivity"))) { - const scalarField& Tp = - patch().lookupPatchField<volScalarField, scalar>(TName_); - - refValue() = - emissivity_*4.0*physicoChemical::sigma.value()*pow4(Tp)/pi; - - refGrad() = 0.0; - if (dict.found("value")) { fvPatchScalarField::operator= ( scalarField("value", dict, p.size()) ); + refValue() = scalarField("refValue", dict, p.size()); + refGrad() = scalarField("refGradient", dict, p.size()); + valueFraction() = scalarField("valueFraction", dict, p.size()); } else { + // No value given. Restart as fixedValue b.c. + + const scalarField& Tp = + patch().lookupPatchField<volScalarField, scalar>(TName_); + + refValue() = + emissivity_*4.0*physicoChemical::sigma.value()*pow4(Tp)/pi; + refGrad() = 0.0; + valueFraction() = 1.0; + fvPatchScalarField::operator=(refValue()); } } @@ -220,10 +225,9 @@ void Foam::radiation::greyDiffusiveRadiationMixedFvPatchScalarField::write Ostream& os ) const { - fvPatchScalarField::write(os); + mixedFvPatchScalarField::write(os); os.writeKeyword("T") << TName_ << token::END_STATEMENT << nl; os.writeKeyword("emissivity") << emissivity_ << token::END_STATEMENT << nl; - writeEntry("value", os); } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H index cad873ab725423ad055a576793f9c4149a356dc6..c4e6fab850c991a09df380f92cf0b5409173dd94 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/greyDiffusiveRadiation/greyDiffusiveRadiationMixedFvPatchScalarField.H @@ -147,7 +147,7 @@ public: } //- Return the emissivity - const scalar& emissivity() const + scalar emissivity() const { return emissivity_; } diff --git a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H index 60ba567ba33882f6eb5b66fc843617c62e418982..df407f1226d1c39e4a0c5f8e56df681e5ff4140a 100644 --- a/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H +++ b/src/thermophysicalModels/radiation/derivedFvPatchFields/wideBandDiffusiveRadiation/wideBandDiffusiveRadiationMixedFvPatchScalarField.H @@ -147,7 +147,7 @@ public: } //- Return the emissivity - const scalar& emissivity() const + scalar emissivity() const { return emissivity_; } diff --git a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C index 0247c643dfa4cbf72007e90d98979d969ca9f44a..ea80e5645d6231e06ebb59c409c7316ba02bb658 100644 --- a/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C +++ b/src/thermophysicalModels/reactionThermo/mixtures/reactingMixture/reactingMixture.C @@ -49,7 +49,10 @@ Foam::reactingMixture<ThermoType>::reactingMixture ), PtrList<Reaction<ThermoType> > ( - autoPtr<chemistryReader<ThermoType> >::operator()().reactions(), + PtrList<Reaction<ThermoType> > + ( + autoPtr<chemistryReader<ThermoType> >::operator()().reactions() + ), this->species_ ) { diff --git a/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H b/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H index 4524857911bd49abab7519d8cf12268196bcf5cd..24e96ee02718375030ad407e7d50695de0e5754c 100644 --- a/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H +++ b/src/thermophysicalModels/solidMixture/solidMixture/solidMixture.H @@ -64,19 +64,13 @@ public: // Constructors //- Construct from dictionary - solidMixture - ( - const dictionary& - ); + solidMixture(const dictionary&); // Selectors //- Select construct from dictionary - static autoPtr<solidMixture> New - ( - const dictionary& - ); + static autoPtr<solidMixture> New(const dictionary&); // Member Functions @@ -101,17 +95,11 @@ public: //- Calculate the mixture density [kg/m^3] as a function of // volume fractions - scalar rho - ( - const scalarField& X - ) const; + scalar rho(const scalarField& X) const; //- Calculate the mixture heat capacity [J/(kg K)] as a function // of mass fractions - scalar cp - ( - const scalarField& Y - ) const; + scalar cp(const scalarField& Y) const; }; diff --git a/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.H b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.H index 27190fd833bfdedf79961cfb0b7467faaf42e84f..3c66e03d4232c1836b66151a49a8506edf11fc27 100644 --- a/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.H +++ b/src/thermophysicalModels/specie/equationOfState/icoPolynomial/icoPolynomial.H @@ -99,7 +99,7 @@ class icoPolynomial { // Private data - //- Density + //- Density [kg/m^3] Polynomial<PolySize> rhoPolynomial_; diff --git a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C index 7264041083d36774276d22b4cd14214dd4d6debc..497dc7c757bf83f5f466a6030efc32851bc91e0e 100644 --- a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C +++ b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C @@ -40,8 +40,11 @@ Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo Sf_(readScalar(is)), cpPolynomial_("cpPolynomial", is), dhPolynomial_(cpPolynomial_.integrate()), - sPolynomial_(cpPolynomial_.integrateMinus1()) -{} + dsPolynomial_(cpPolynomial_.integrateMinus1()) +{ + // Offset dh poly so that it is relative to the enthalpy at Tstd + dhPolynomial_[0] -= dhPolynomial_.evaluate(specie::Tstd); +} // * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * // @@ -58,7 +61,7 @@ Foam::Ostream& Foam::operator<< << pt.Sf_ << tab << pt.cpPolynomial_ << tab << pt.dhPolynomial_ << tab - << pt.sPolynomial; + << pt.dsPolynomial; os.check ( diff --git a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.H b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.H index ec3c752f24bc7273dfd7b9460f7429fd6018b603..a15d05adfe11822dae04268d061233c0cb96f28f 100644 --- a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.H +++ b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.H @@ -106,14 +106,14 @@ class hPolynomialThermo //- Standard entropy [J/(kg.K)] scalar Sf_; - //- Specific heat at constant pressure + //- Specific heat at constant pressure [J/(kg.K)] Polynomial<PolySize> cpPolynomial_; - //- Enthalpy - derived from cp + //- Enthalpy - derived from cp [J/kg] - relative to Tstd typename Polynomial<PolySize>::intPolyType dhPolynomial_; - //- Entropy - derived from cp - Polynomial<PolySize> sPolynomial_; + //- Entropy - derived from cp [J/(kg.K)] + Polynomial<PolySize> dsPolynomial_; // Private member functions @@ -125,8 +125,8 @@ class hPolynomialThermo const scalar Hf, const scalar Sf, const Polynomial<PolySize>& cpPoly, - const typename Polynomial<PolySize>::intPolyType& hPoly, - const Polynomial<PolySize>& sPoly + const typename Polynomial<PolySize>::intPolyType& dhPoly, + const Polynomial<PolySize>& dsPoly ); diff --git a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermoI.H b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermoI.H index 1382c6f3ecea86c65370e60741630ad03d3eabab..21e2171ec060931aa865e224ad69e953b835d473 100644 --- a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermoI.H +++ b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermoI.H @@ -36,7 +36,7 @@ inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo const scalar Sf, const Polynomial<PolySize>& cpPoly, const typename Polynomial<PolySize>::intPolyType& dhPoly, - const Polynomial<PolySize>& sPoly + const Polynomial<PolySize>& dsPoly ) : EquationOfState(pt), @@ -44,7 +44,7 @@ inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo Sf_(Sf), cpPolynomial_(cpPoly), dhPolynomial_(dhPoly), - sPolynomial_(sPoly) + dsPolynomial_(dsPoly) {} @@ -62,7 +62,7 @@ inline Foam::hPolynomialThermo<EquationOfState, PolySize>::hPolynomialThermo Sf_(pt.Sf_), cpPolynomial_(pt.cpPolynomial_), dhPolynomial_(pt.dhPolynomial_), - sPolynomial_(pt.sPolynomial_) + dsPolynomial_(pt.dsPolynomial_) {} @@ -112,7 +112,7 @@ inline Foam::scalar Foam::hPolynomialThermo<EquationOfState, PolySize>::s const scalar T ) const { - return (sPolynomial_.evaluate(T) + Sf_)*this->W(); + return (dsPolynomial_.evaluate(T) + Sf_)*this->W(); } @@ -135,7 +135,7 @@ inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator+= Sf_ = molr1*Sf_ + molr2*pt.Sf_; cpPolynomial_ = molr1*cpPolynomial_ + molr2*pt.cpPolynomial_; dhPolynomial_ = molr1*dhPolynomial_ + molr2*pt.dhPolynomial_; - sPolynomial_ = molr1*sPolynomial_ + molr2*pt.sPolynomial_; + dsPolynomial_ = molr1*dsPolynomial_ + molr2*pt.dsPolynomial_; } @@ -153,10 +153,10 @@ inline void Foam::hPolynomialThermo<EquationOfState, PolySize>::operator-= scalar molr2 = pt.nMoles()/this->nMoles(); Hf_ = molr1*Hf_ - molr2*pt.Hf_; - Sf_ = molr1*Hf_ - molr2*pt.Sf_; + Sf_ = molr1*Sf_ - molr2*pt.Sf_; cpPolynomial_ = molr1*cpPolynomial_ - molr2*pt.cpPolynomial_; dhPolynomial_ = molr1*dhPolynomial_ - molr2*pt.dhPolynomial_; - sPolynomial_ = molr1*sPolynomial_ - molr2*pt.sPolynomial_; + dsPolynomial_ = molr1*dsPolynomial_ - molr2*pt.dsPolynomial_; } @@ -184,7 +184,7 @@ inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator+ molr1*pt1.Sf_ + molr2*pt2.Sf_, molr1*pt1.cpPolynomial_ + molr2*pt2.cpPolynomial_, molr1*pt1.dhPolynomial_ + molr2*pt2.dhPolynomial_, - molr1*pt1.sPolynomial_ + molr2*pt2.sPolynomial_ + molr1*pt1.dsPolynomial_ + molr2*pt2.dsPolynomial_ ); } @@ -211,7 +211,7 @@ inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator- molr1*pt1.Sf_ - molr2*pt2.Sf_, molr1*pt1.cpPolynomial_ - molr2*pt2.cpPolynomial_, molr1*pt1.dhPolynomial_ - molr2*pt2.dhPolynomial_, - molr1*pt1.sPolynomial_ - molr2*pt2.sPolynomial_ + molr1*pt1.dsPolynomial_ - molr2*pt2.dsPolynomial_ ); } @@ -230,7 +230,7 @@ inline Foam::hPolynomialThermo<EquationOfState, PolySize> Foam::operator* pt.Sf_, pt.cpPolynomial_, pt.dhPolynomial_, - pt.sPolynomial_ + pt.dsPolynomial_ ); } diff --git a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H index ac91a3eef9bed458f26f3e6ef21f9842c1fd3d3d..5d68ecf6710789f42fb4c2c1489bfda036e743a1 100644 --- a/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H +++ b/src/thermophysicalModels/specie/thermo/janaf/janafThermoI.H @@ -56,7 +56,7 @@ inline Foam::janafThermo<equationOfState>::janafThermo template<class equationOfState> inline void Foam::janafThermo<equationOfState>::checkT(const scalar T) const { - if (T < Tlow_ || T > Thigh_) + if (T < Tlow_ || T > Thigh_) { FatalErrorIn ( @@ -153,7 +153,7 @@ template<class equationOfState> inline Foam::scalar Foam::janafThermo<equationOfState>::hc() const { const coeffArray& a = lowCpCoeffs_; - const scalar& Tstd = specie::Tstd; + const scalar Tstd = specie::Tstd; return this->RR* ( ( diff --git a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H index 0aebfe7aba72b7a6220cf25aa61b2144fa603a5b..560f8f4145f7e9faed0f176f3a8946a1ae752e9c 100644 --- a/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H +++ b/src/thermophysicalModels/specie/thermo/specieThermo/specieThermo.H @@ -131,23 +131,23 @@ public: // Member Functions - // Fundamaental properties + // Fundamental properties // (These functions must be provided in derived types) // Heat capacity at constant pressure [J/(kmol K)] - //scalar cp(const scalar) const; + // scalar cp(const scalar) const; // Enthalpy [J/kmol] - //scalar h(const scalar) const; + // scalar h(const scalar) const; // Sensible enthalpy [J/kmol] - //scalar hs(const scalar) const; + // scalar hs(const scalar) const; // Chemical enthalpy [J/kmol] - //scalar hc(const scalar) const; + // scalar hc(const scalar) const; // Entropy [J/(kmol K)] - //scalar s(const scalar) const; + // scalar s(const scalar) const; // Calculate and return derived properties diff --git a/src/thermophysicalModels/thermalPorousZone/thermalPorousZone/thermalPorousZone.C b/src/thermophysicalModels/thermalPorousZone/thermalPorousZone/thermalPorousZone.C index e9083bc13b95e4c8fa01f9fb516abbce9a6098ce..b4c76b78e9b90b63a2eb952902a69d415d97dd82 100644 --- a/src/thermophysicalModels/thermalPorousZone/thermalPorousZone/thermalPorousZone.C +++ b/src/thermophysicalModels/thermalPorousZone/thermalPorousZone/thermalPorousZone.C @@ -55,9 +55,9 @@ Foam::thermalPorousZone::thermalPorousZone ( "thermalPorousZone::thermalPorousZone" "(" - "const word& name, " - "const fvMesh& mesh, " - "const dictionary& dict" + "const word& name, " + "const fvMesh& mesh, " + "const dictionary& dict" ")", *dictPtr ) << "thermalModel " << thermalModel << " is not supported" << nl diff --git a/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H b/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H index 506aac64c7fe149b2687d6419878b017e9099ffa..4e970ae2d0bdf3100775b69dbffb2d1dedb7e759 100644 --- a/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H +++ b/src/thermophysicalModels/thermophysicalFunctions/APIfunctions/APIdiffCoefFunc/APIdiffCoefFunc.H @@ -79,7 +79,7 @@ public: wf_(wf), wa_(wa), alpha_(sqrt(1/wf_ + 1/wa_)), - beta_(sqr((cbrt(a_) + cbrt(b_)))) + beta_(sqr(cbrt(a_) + cbrt(b_))) {} //- Construct from Istream diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C index dce98aa4af56d2c94e3dade9e64cb93a1a2baf95..959c4540a56fa64eb039bee701b72701343ac570 100644 --- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C +++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.C @@ -52,8 +52,8 @@ namespace Foam Foam::tmp<Foam::scalarField> Foam::movingConeTopoFvMesh::vertexMarkup ( const pointField& p, - const scalar& curLeft, - const scalar& curRight + const scalar curLeft, + const scalar curRight ) const { Info<< "Updating vertex markup. curLeft: " diff --git a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.H b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.H index c4394a58883cd5633c53fbad3262abde74742074..36e6ccaf501f0851fbd4ede584b5866b7cb80071 100644 --- a/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.H +++ b/src/topoChangerFvMesh/movingConeTopoFvMesh/movingConeTopoFvMesh.H @@ -98,8 +98,8 @@ class movingConeTopoFvMesh tmp<scalarField> vertexMarkup ( const pointField& p, - const scalar& curLeft, - const scalar& curRight + const scalar curLeft, + const scalar curRight ) const; diff --git a/src/transportModels/interfaceProperties/interfaceCompression/interfaceCompression.H b/src/transportModels/interfaceProperties/interfaceCompression/interfaceCompression.H index 2e08e636350f845767cda6c5a8735d2200996193..1f6f45dfc01be9b8de7cd99f59c3eac2b2a87a30 100644 --- a/src/transportModels/interfaceProperties/interfaceCompression/interfaceCompression.H +++ b/src/transportModels/interfaceProperties/interfaceCompression/interfaceCompression.H @@ -60,10 +60,10 @@ public: ( const scalar cdWeight, const scalar faceFlux, - const scalar& phiP, - const scalar& phiN, + const scalar phiP, + const scalar phiN, const vector&, - const scalar& + const scalar ) const { // Quadratic compression scheme diff --git a/src/triSurface/triSurface/triSurface.C b/src/triSurface/triSurface/triSurface.C index 3b8d2f9d5feaed1a8f4d2999b33204cc2726d5e1..65258557e88735c759ecbb66d550994bfae5d2d5 100644 --- a/src/triSurface/triSurface/triSurface.C +++ b/src/triSurface/triSurface/triSurface.C @@ -33,8 +33,6 @@ License #include "SortableList.H" #include "PackedBoolList.H" -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { @@ -783,7 +781,6 @@ const Foam::labelList& Foam::triSurface::edgeOwner() const } -//- Move points void Foam::triSurface::movePoints(const pointField& newPoints) { // Remove all geometry dependent data @@ -797,8 +794,7 @@ void Foam::triSurface::movePoints(const pointField& newPoints) } -// scale points -void Foam::triSurface::scalePoints(const scalar& scaleFactor) +void Foam::triSurface::scalePoints(const scalar scaleFactor) { // avoid bad scaling if (scaleFactor > 0 && scaleFactor != 1.0) diff --git a/src/triSurface/triSurface/triSurface.H b/src/triSurface/triSurface/triSurface.H index 9ee5b5ca4d9ee85e2bf1b392feba92928f7aa2ff..7ef87db1ab64a528b329d2b733079a37d91022de 100644 --- a/src/triSurface/triSurface/triSurface.H +++ b/src/triSurface/triSurface/triSurface.H @@ -324,7 +324,7 @@ public: virtual void movePoints(const pointField&); //- Scale points. A non-positive factor is ignored - virtual void scalePoints(const scalar&); + virtual void scalePoints(const scalar); //- Check/remove duplicate/degenerate triangles void checkTriangles(const bool verbose); diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutURoughWallFunction/mutURoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutURoughWallFunction/mutURoughWallFunctionFvPatchScalarField.H index 67279322ee56d3d8ff6028182dd7e0f015c3a7d3..50744f6e1c656bf282db0e45d6d1740d7867b227 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutURoughWallFunction/mutURoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutURoughWallFunction/mutURoughWallFunctionFvPatchScalarField.H @@ -154,7 +154,7 @@ public: // Access //- Return the roughness height scale - const scalar& roughnessHeight() const + scalar roughnessHeight() const { return roughnessHeight_; } @@ -166,7 +166,7 @@ public: } //- Return the roughness constant scale - const scalar& roughnessConstant() const + scalar roughnessConstant() const { return roughnessConstant_; } @@ -178,7 +178,7 @@ public: } //- Return the roughness scale factor - const scalar& roughnessFactor() const + scalar roughnessFactor() const { return roughnessFactor_; } diff --git a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkRoughWallFunction/mutkRoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkRoughWallFunction/mutkRoughWallFunctionFvPatchScalarField.H index 479fd7b9ab2d688194167553c12d9c8c63e9f005..1b312552618c5aeee6808ebfc38bbd9da1829f67 100644 --- a/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkRoughWallFunction/mutkRoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions/mutkRoughWallFunction/mutkRoughWallFunctionFvPatchScalarField.H @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Class - Foam::compressible::RASModels::nutRoughWallFunctionFvPatchScalarField + Foam::compressible::RASModels::mutRoughWallFunctionFvPatchScalarField Description Boundary condition for turbulent (kinematic) viscosity when using wall diff --git a/src/turbulenceModels/incompressible/RAS/Make/files b/src/turbulenceModels/incompressible/RAS/Make/files index d81b1735b82d5309188e066eeb0f5fb3aba130f3..394e7391a75965341d8875f8288313646ff8af7a 100644 --- a/src/turbulenceModels/incompressible/RAS/Make/files +++ b/src/turbulenceModels/incompressible/RAS/Make/files @@ -26,6 +26,7 @@ $(nutWallFunctions)/nutkWallFunction/nutkWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C +$(nutWallFunctions)/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions $(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H index 1fbb24f9c58ca4fbb89d423eeee12279345b19e7..b3098318f22bb0fcea79402e7eeadf7c35f8372e 100644 --- a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutURoughWallFunction/nutURoughWallFunctionFvPatchScalarField.H @@ -152,7 +152,7 @@ public: // Access //- Return the roughness height - const scalar& roughnessHeight() const + scalar roughnessHeight() const { return roughnessHeight_; } @@ -165,7 +165,7 @@ public: //- Return the roughness constant scale - const scalar& roughnessConstant() const + scalar roughnessConstant() const { return roughnessConstant_; } @@ -177,7 +177,7 @@ public: } //- Return the roughness scale factor - const scalar& roughnessFactor() const + scalar roughnessFactor() const { return roughnessFactor_; } diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C new file mode 100644 index 0000000000000000000000000000000000000000..a3dfb6dedac9eaa04c9c839b1756a0a5908f5e5f --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C @@ -0,0 +1,215 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "nutUTabulatedWallFunctionFvPatchScalarField.H" +#include "RASModel.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcNut() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + const scalarField magGradU = mag(Uw.snGrad()) + ROOTVSMALL; + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + + return + max + ( + scalar(0), + sqr(magUp/(calcUPlus(magUp*y/nuw) + ROOTVSMALL))/magGradU - nuw + ); +} + + +tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::calcUPlus +( + const scalarField& Rey +) const +{ + tmp<scalarField> tuPlus(new scalarField(patch().size(), 0.0)); + scalarField& uPlus = tuPlus(); + + forAll(uPlus, faceI) + { + uPlus[faceI] = uPlusTable_.interpolateLog10(Rey[faceI]); + } + + return tuPlus; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +nutUTabulatedWallFunctionFvPatchScalarField:: +nutUTabulatedWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF +) +: + nutkWallFunctionFvPatchScalarField(p, iF), + uPlusTableName_("undefined-uPlusTableName"), + uPlusTable_ + ( + IOobject + ( + uPlusTableName_, + patch().boundaryMesh().mesh().time().constant(), + patch().boundaryMesh().mesh(), + IOobject::NO_READ, + IOobject::NO_WRITE, + false + ), + false + ) +{} + + +nutUTabulatedWallFunctionFvPatchScalarField:: +nutUTabulatedWallFunctionFvPatchScalarField +( + const nutUTabulatedWallFunctionFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const fvPatchFieldMapper& mapper +) +: + nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper), + uPlusTableName_(ptf.uPlusTableName_), + uPlusTable_(ptf.uPlusTable_) +{} + + +nutUTabulatedWallFunctionFvPatchScalarField:: +nutUTabulatedWallFunctionFvPatchScalarField +( + const fvPatch& p, + const DimensionedField<scalar, volMesh>& iF, + const dictionary& dict +) +: + nutkWallFunctionFvPatchScalarField(p, iF, dict), + uPlusTableName_(dict.lookup("uPlusTable")), + uPlusTable_ + ( + IOobject + ( + uPlusTableName_, + patch().boundaryMesh().mesh().time().constant(), + patch().boundaryMesh().mesh(), + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + true + ) +{} + + +nutUTabulatedWallFunctionFvPatchScalarField:: +nutUTabulatedWallFunctionFvPatchScalarField +( + const nutUTabulatedWallFunctionFvPatchScalarField& wfpsf +) +: + nutkWallFunctionFvPatchScalarField(wfpsf), + uPlusTableName_(wfpsf.uPlusTableName_), + uPlusTable_(wfpsf.uPlusTable_) +{} + + +nutUTabulatedWallFunctionFvPatchScalarField:: +nutUTabulatedWallFunctionFvPatchScalarField +( + const nutUTabulatedWallFunctionFvPatchScalarField& wfpsf, + const DimensionedField<scalar, volMesh>& iF +) +: + nutkWallFunctionFvPatchScalarField(wfpsf, iF), + uPlusTableName_(wfpsf.uPlusTableName_), + uPlusTable_(wfpsf.uPlusTable_) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +tmp<scalarField> nutUTabulatedWallFunctionFvPatchScalarField::yPlus() const +{ + const label patchI = patch().index(); + + const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties"); + const scalarField& y = rasModel.y()[patchI]; + const fvPatchVectorField& Uw = rasModel.U().boundaryField()[patchI]; + const scalarField magUp = mag(Uw.patchInternalField() - Uw); + const scalarField& nuw = rasModel.nu().boundaryField()[patchI]; + const scalarField Rey = magUp*y/nuw; + + return Rey/(calcUPlus(Rey) + ROOTVSMALL); +} + + +void nutUTabulatedWallFunctionFvPatchScalarField::write(Ostream& os) const +{ + fvPatchField<scalar>::write(os); +// writeLocalEntries(os); // not applicable to this nut BC + os.writeKeyword("uPlusTable") << uPlusTableName_ + << token::END_STATEMENT << nl; + writeEntry("value", os); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + nutUTabulatedWallFunctionFvPatchScalarField +); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H new file mode 100644 index 0000000000000000000000000000000000000000..35aa55b0326d74f644f8c93b0324b28a29bc8e3f --- /dev/null +++ b/src/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.H @@ -0,0 +1,177 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::incompressible::RASModels::nutUTabulatedWallFunctionFvPatchScalarField + +Description + Wall function boundary condition for turbulence kinematic viscosity. Uses a + table to return the value of U+ as a function of near-wall Reynolds number. + + Note: the tables are not registered since the same table object may be used + for more than one patch. + +SourceFiles + nutUTabulatedWallFunctionFvPatchScalarField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef nutUTabulatedWallFunctionFvPatchScalarField_H +#define nutUTabulatedWallFunctionFvPatchScalarField_H + +#include "nutkWallFunctionFvPatchScalarField.H" +#include "uniformInterpolationTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace incompressible +{ +namespace RASModels +{ + +/*---------------------------------------------------------------------------*\ + Class nutUTabulatedWallFunctionFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class nutUTabulatedWallFunctionFvPatchScalarField +: + public nutkWallFunctionFvPatchScalarField +{ +protected: + + // Protected data + + //- Name of u+ table + word uPlusTableName_; + + //- U+ table + uniformInterpolationTable<scalar> uPlusTable_; + + + // Protected member functions + + //- Calculate the turbulence viscosity + virtual tmp<scalarField> calcNut() const; + + //- Calculate wall u+ from table + virtual tmp<scalarField> calcUPlus(const scalarField& Rey) const; + + +public: + + //- Runtime type information + TypeName("nutTabulatedWallFunction"); + + + // Constructors + + //- Construct from patch and internal field + nutUTabulatedWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>& + ); + + //- Construct from patch, internal field and dictionary + nutUTabulatedWallFunctionFvPatchScalarField + ( + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const dictionary& + ); + + //- Construct by mapping given + // nutUTabulatedWallFunctionFvPatchScalarField + // onto a new patch + nutUTabulatedWallFunctionFvPatchScalarField + ( + const nutUTabulatedWallFunctionFvPatchScalarField&, + const fvPatch&, + const DimensionedField<scalar, volMesh>&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + nutUTabulatedWallFunctionFvPatchScalarField + ( + const nutUTabulatedWallFunctionFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp<fvPatchScalarField> clone() const + { + return tmp<fvPatchScalarField> + ( + new nutUTabulatedWallFunctionFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + nutUTabulatedWallFunctionFvPatchScalarField + ( + const nutUTabulatedWallFunctionFvPatchScalarField&, + 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 nutUTabulatedWallFunctionFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Calculate and return the yPlus at the boundary + virtual tmp<scalarField> yPlus() const; + + + // I-O + + //- Write + virtual void write(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace RASModels +} // End namespace incompressible +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean index 0d6bac1543e27210cb3461ce34fee8f4883b471e..f236efc56e2a5d2a74fc710122529fa070e27d4c 100755 --- a/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean +++ b/tutorials/incompressible/boundaryFoam/boundaryWallFunctionsProfile/Allclean @@ -7,5 +7,3 @@ cleanCase rm -rf logs rm -f *.eps yPlus_vs_uPlus - -echo "done" diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/0 b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/0 new file mode 120000 index 0000000000000000000000000000000000000000..f1c4a884b51ae4171513426c3b7f5f585d0d889e --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/0 @@ -0,0 +1 @@ +../angledDuctImplicit/0 \ No newline at end of file diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/constant b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/constant new file mode 120000 index 0000000000000000000000000000000000000000..28205c782b36471b118c5be2948a56e345961ad4 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/constant @@ -0,0 +1 @@ +../angledDuctImplicit/constant \ No newline at end of file diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/controlDict b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..9ffe4063cf457efe9e2a167ad38617dc42f6dd8b --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/controlDict @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application rhoPorousSimpleFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 200; + +deltaT 1; + +writeControl timeStep; + +writeInterval 10; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +graphFormat raw; + +runTimeModifiable yes; + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/fvSchemes b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..a70c35e1bf81ab94f439453dfac9b9349f09bcae --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/fvSchemes @@ -0,0 +1,64 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; + grad(U) Gauss linear; + grad(p) Gauss linear; +} + +divSchemes +{ + div(phi,U) Gauss upwind; + div((nuEff*dev(grad(U).T()))) Gauss linear; + div(phi,epsilon) Gauss upwind; + div(phi,k) Gauss upwind; +} + +laplacianSchemes +{ + laplacian(nuEff,U) Gauss linear corrected; + laplacian(rAU,p) Gauss linear corrected; + laplacian(DepsilonEff,epsilon) Gauss linear corrected; + laplacian(DkEff,k) Gauss linear corrected; + laplacian(1,p) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p ; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/fvSolution b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..b7d4dbd573caabf8c8e753563360f72f2c29af0b --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctExplicit/system/fvSolution @@ -0,0 +1,65 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver GAMG; + tolerance 1e-08; + relTol 0.05; + smoother GaussSeidel; + cacheAgglomeration off; + nCellsInCoarsestLevel 20; + agglomerator faceAreaPair; + mergeLevels 1; + } + + U + { + solver smoothSolver; + smoother GaussSeidel; + nSweeps 2; + tolerance 1e-06; + relTol 0.1; + } + + "(k|epsilon)" + { + solver smoothSolver; + smoother GaussSeidel; + nSweeps 2; + tolerance 1e-07; + relTol 0.1; + } +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + p 0.3; + U 0.7; + k 0.9; + epsilon 0.9; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/T b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/T new file mode 100644 index 0000000000000000000000000000000000000000..e1df94398773b013813d4f9f37769c8587889a1c --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/T @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 293; + +boundaryField +{ + + front + { + type zeroGradient; + } + back + { + type zeroGradient; + } + wall + { + type zeroGradient; + } + porosityWall + { + type zeroGradient; + } + + inlet + { + type fixedValue; + value $internalField; + } + outlet + { + type inletOutlet; + value $internalField; + inletValue $internalField; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/U b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/U new file mode 100644 index 0000000000000000000000000000000000000000..88f509425865e94093e76cca468b5839e437ab77 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/U @@ -0,0 +1,57 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + front + { + type fixedValue; + value uniform (0 0 0); + } + back + { + type fixedValue; + value uniform (0 0 0); + } + wall + { + type fixedValue; + value uniform (0 0 0); + } + porosityWall + { + type slip; + value uniform (0 0 0); + } + inlet + { + type flowRateInletVelocity; + flowRate 0.1; + value uniform (0 0 0); + } + outlet + { + type inletOutlet; + value uniform (0 0 0); + inletValue uniform (0 0 0); + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/epsilon b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..d43279e3d7b721b6783cb6f10ccc0c884fde38c0 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/epsilon @@ -0,0 +1,64 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -3 0 0 0 0 ]; + +internalField uniform 200; + +boundaryField +{ + front + { + type epsilonWallFunction; + value uniform 200; + } + + back + { + type epsilonWallFunction; + value uniform 200; + } + + wall + { + type epsilonWallFunction; + value uniform 200; + } + + porosityWall + { + type epsilonWallFunction; + value uniform 200; + } + + inlet + { + type turbulentMixingLengthDissipationRateInlet; + mixingLength 0.005; + value uniform 200; + } + + outlet + { + type inletOutlet; + inletValue uniform 200; + value uniform 200; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/k b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/k new file mode 100644 index 0000000000000000000000000000000000000000..8a7e20d154faf52c2bf200cd7c0bf3e66f42d817 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/k @@ -0,0 +1,64 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [ 0 2 -2 0 0 0 0 ]; + +internalField uniform 1; + +boundaryField +{ + front + { + type kqRWallFunction; + value uniform 1; + } + + back + { + type kqRWallFunction; + value uniform 1; + } + + wall + { + type kqRWallFunction; + value uniform 1; + } + + porosityWall + { + type kqRWallFunction; + value uniform 1; + } + + inlet + { + type turbulentIntensityKineticEnergyInlet; + intensity 0.05; + value uniform 1; + } + + outlet + { + type inletOutlet; + inletValue uniform 1; + value uniform 1; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/nut b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/nut new file mode 100644 index 0000000000000000000000000000000000000000..de1c9477df5f7ccb984f523c27282804fe92337f --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/nut @@ -0,0 +1,62 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + front + { + type nutWallFunction; + value uniform 0; + } + + back + { + type nutWallFunction; + value uniform 0; + } + + wall + { + type nutWallFunction; + value uniform 0; + } + + porosityWall + { + type nutWallFunction; + value uniform 0; + } + + inlet + { + type calculated; + value uniform 0; + } + + outlet + { + type calculated; + value uniform 0; + } +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/p b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/p new file mode 100644 index 0000000000000000000000000000000000000000..4794b84b189f7020d3f1bc09e5d43bbf914d7b45 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/0/p @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + front + { + type zeroGradient; + } + back + { + type zeroGradient; + } + wall + { + type zeroGradient; + } + porosityWall + { + type zeroGradient; + } + + inlet + { + type zeroGradient; + } + outlet + { + type fixedValue; + value $internalField; + } +} + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/RASProperties b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/RASProperties new file mode 100644 index 0000000000000000000000000000000000000000..48cf724e269cffbb00c1dc8bcf837a8a6af5543d --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/RASProperties @@ -0,0 +1,25 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "constant"; + object RASProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +RASModel kEpsilon; + +turbulence on; + +printCoeffs on; + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..0438819b2509cf399923c3a2ce92ea0999735aea --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict @@ -0,0 +1,123 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// block definition for a porosity with an angled inlet/outlet +// the porosity is not aligned with the main axes +// + +convertToMeters 0.001; + +vertices +( + // inlet region + ( -150 0 -25 ) // pt 0 (in1b) + ( -150 35.35533906 -25 ) // pt 1 (in2b) + ( -150 0 25 ) // pt 2 (in1f) + ( -150 35.35533906 25 ) // pt 3 (in2f) + + // join inlet->outlet + ( 0 0 -25 ) // pt 4 (join1b) + ( -35.35533906 35.35533906 -25 ) // pt 5 (join2b) + ( 0 0 25 ) // pt 6 (join1f) + ( -35.35533906 35.35533906 25 ) // pt 7 (join2f) + + // porosity ends ->outlet + ( 70.71067812 70.71067812 -25 ) // pt 8 (poro1b) + ( 35.35533906 106.06601718 -25 ) // pt 9 (poro2b) + ( 70.71067812 70.71067812 25 ) // pt 10 (poro1f) + ( 35.35533906 106.06601718 25 ) // pt 11 (poro2f) + + // outlet + ( 141.42135624 141.42135624 -25 ) // pt 12 (out1b) + ( 106.06601718 176.7766953 -25 ) // pt 13 (out2b) + ( 141.42135624 141.42135624 25 ) // pt 14 (out1f) + ( 106.06601718 176.7766953 25 ) // pt 15 (out2f) +); + +blocks +( + // inlet block + hex (0 4 5 1 2 6 7 3) + inlet ( 15 20 20 ) simpleGrading (1 1 1) + + // porosity block + hex (4 8 9 5 6 10 11 7) + porosity ( 20 20 20 ) simpleGrading (1 1 1) + + // outlet block + hex (8 12 13 9 10 14 15 11) + outlet ( 20 20 20 ) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + // is there no way of defining all my 'defaultFaces' to be 'wall'? + wall front + ( + // inlet block + (2 6 7 3) + // outlet block + (10 14 15 11) + ) + + wall back + ( + // inlet block + (1 5 4 0) + // outlet block + (9 13 12 8) + ) + + wall wall + ( + // inlet block + (2 0 4 6) + (7 5 1 3) + // outlet block + (10 8 12 14) + (15 13 9 11) + ) + + wall porosityWall + ( + // porosity block + (6 10 11 7) + // porosity block + (5 9 8 4) + // porosity block + (6 4 8 10) + (11 9 5 7) + ) + + patch inlet + ( + (3 1 0 2) + ) + + patch outlet + ( + (15 13 12 14) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict.m4 b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict.m4 new file mode 100644 index 0000000000000000000000000000000000000000..6d6d0669392b2396160799c4747d2e9f6c2c54d2 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/blockMeshDict.m4 @@ -0,0 +1,165 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + `format' ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// block definition for a porosity with an angled inlet/outlet +// the porosity is not aligned with the main axes +// +dnl> ----------------------------------------------------------------- +dnl> <STANDARD DEFINTIONS> +dnl> +changecom(//)changequote([,]) dnl> +define(calc, [esyscmd(perl -e 'print ($1)')]) dnl> +define(VCOUNT, 0) dnl> +define(vlabel, [[// ]pt VCOUNT ($1) define($1, VCOUNT)define([VCOUNT], incr(VCOUNT))]) dnl> +dnl> +define(hex2D, hex ($1b $2b $3b $4b $1f $2f $3f $4f)) dnl> +define(quad2D, ($1f $1b $2b $2f)) dnl> +define(frontQuad, ($1f $2f $3f $4f)) dnl> +define(backQuad, ($4b $3b $2b $1b)) dnl> +dnl> +dnl> </STANDARD DEFINTIONS> +dnl> ----------------------------------------------------------------- +dnl> +define(ncells, 20) dnl> +define(ninlet, 15) dnl> +define(nporo, 20) dnl> +define(noutlet, 20) dnl> +dnl> +define(x0,0) dnl> +define(y0,0) dnl> +define(y0,0) dnl> +define(Cos,0.7071067812) dnl> == cos(45) +define(Sin,0.7071067812) dnl> == sin(45) +dnl> +define(width,50) dnl> +define(zBack,calc(-width/2)) dnl> +define(zFront,calc(width/2)) dnl> +define(leninlet,150)dnl> +define(lenporo,100)dnl> +define(lenoutlet,100)dnl> +dnl> +define(xhyp,calc(Sin*width)) dnl> +define(yhyp,calc(Cos*width)) dnl> +define(xinlet,leninlet)dnl> +define(xporo,calc(Cos*lenporo)) dnl> +define(yporo,calc(Sin*lenporo)) dnl> +define(xoutlet,calc(xporo + Cos*lenoutlet)) dnl> +define(youtlet,calc(yporo + Sin*lenoutlet)) dnl> +dnl> + +convertToMeters 0.001; + +vertices +( + // inlet region + ( -xinlet y0 zBack ) vlabel(in1b) + ( -xinlet yhyp zBack ) vlabel(in2b) + ( -xinlet y0 zFront ) vlabel(in1f) + ( -xinlet yhyp zFront ) vlabel(in2f) + + // join inlet->outlet + ( x0 y0 zBack ) vlabel(join1b) + ( -xhyp yhyp zBack ) vlabel(join2b) + ( x0 y0 zFront ) vlabel(join1f) + ( -xhyp yhyp zFront ) vlabel(join2f) + + // porosity ends ->outlet + ( xporo yporo zBack ) vlabel(poro1b) + ( calc(xporo - xhyp) calc(yporo + yhyp) zBack ) vlabel(poro2b) + ( xporo yporo zFront ) vlabel(poro1f) + ( calc(xporo - xhyp) calc(yporo + yhyp) zFront ) vlabel(poro2f) + + // outlet + ( xoutlet youtlet zBack ) vlabel(out1b) + ( calc(xoutlet - xhyp) calc(youtlet + yhyp) zBack ) vlabel(out2b) + ( xoutlet youtlet zFront ) vlabel(out1f) + ( calc(xoutlet - xhyp) calc(youtlet + yhyp) zFront ) vlabel(out2f) +); + +blocks +( + // inlet block + hex2D(in1, join1, join2, in2) + inlet ( ninlet ncells ncells ) simpleGrading (1 1 1) + + // porosity block + hex2D(join1, poro1, poro2, join2) + porosity ( nporo ncells ncells ) simpleGrading (1 1 1) + + // outlet block + hex2D(poro1, out1, out2, poro2) + outlet ( noutlet ncells ncells ) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + // is there no way of defining all my 'defaultFaces' to be 'wall'? + wall front + ( + // inlet block + frontQuad(in1, join1, join2, in2) + // outlet block + frontQuad(poro1, out1, out2, poro2) + ) + + wall back + ( + // inlet block + backQuad(in1, join1, join2, in2) + // outlet block + backQuad(poro1, out1, out2, poro2) + ) + + wall wall + ( + // inlet block + quad2D(in1, join1) + quad2D(join2, in2) + // outlet block + quad2D(poro1, out1) + quad2D(out2, poro2) + ) + + wall porosityWall + ( + // porosity block + frontQuad(join1, poro1, poro2, join2) + // porosity block + backQuad(join1, poro1, poro2, join2) + // porosity block + quad2D(join1, poro1) + quad2D(poro2, join2) + ) + + patch inlet + ( + quad2D(in2, in1) + ) + + patch outlet + ( + quad2D(out2, out1) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/boundary b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/boundary new file mode 100644 index 0000000000000000000000000000000000000000..948cb99e4312759b00458320d02423017267fd81 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/polyMesh/boundary @@ -0,0 +1,58 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6.x | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +6 +( + front + { + type wall; + nFaces 700; + startFace 63400; + } + back + { + type wall; + nFaces 700; + startFace 64100; + } + wall + { + type wall; + nFaces 1400; + startFace 64800; + } + porosityWall + { + type wall; + nFaces 1600; + startFace 66200; + } + inlet + { + type patch; + nFaces 400; + startFace 67800; + } + outlet + { + type patch; + nFaces 400; + startFace 68200; + } +) + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/porousZones b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/porousZones new file mode 100644 index 0000000000000000000000000000000000000000..634799837eaf7009528df07d027deafc7c6cc1f4 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/porousZones @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object porousZones; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +1 +( + porosity + { + coordinateSystem + { + e1 (0.70710678 0.70710678 0); + e2 (0 0 1); + } + + Darcy + { + d d [0 -2 0 0 0 0 0] (5e7 -1000 -1000); + f f [0 -1 0 0 0 0 0] (0 0 0); + } + } +) + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/transportProperties b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..7f3bedaae59eebf8d32dd99ac2f9c8ff8adf77a6 --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/constant/transportProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +transportModel Newtonian; + +nu nu [0 2 -1 0 0 0 0] 1.5e-05; + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/controlDict b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..88d62b98cc2648330cce6426b6043397caed194d --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/controlDict @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application rhoPorousSimpleFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 100; + +deltaT 1; + +writeControl timeStep; + +writeInterval 10; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression uncompressed; + +timeFormat general; + +timePrecision 6; + +graphFormat raw; + +runTimeModifiable yes; + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/fvSchemes b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..a70c35e1bf81ab94f439453dfac9b9349f09bcae --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/fvSchemes @@ -0,0 +1,64 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; + grad(U) Gauss linear; + grad(p) Gauss linear; +} + +divSchemes +{ + div(phi,U) Gauss upwind; + div((nuEff*dev(grad(U).T()))) Gauss linear; + div(phi,epsilon) Gauss upwind; + div(phi,k) Gauss upwind; +} + +laplacianSchemes +{ + laplacian(nuEff,U) Gauss linear corrected; + laplacian(rAU,p) Gauss linear corrected; + laplacian(DepsilonEff,epsilon) Gauss linear corrected; + laplacian(DkEff,k) Gauss linear corrected; + laplacian(1,p) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p ; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/fvSolution b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..f5f9feafa8b313dea68bfc6599515ae1f6b7b6ec --- /dev/null +++ b/tutorials/incompressible/porousSimpleFoam/angledDuctImplicit/system/fvSolution @@ -0,0 +1,57 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + p + { + solver GAMG; + tolerance 1e-08; + relTol 0.05; + smoother GaussSeidel; + cacheAgglomeration off; + nCellsInCoarsestLevel 20; + agglomerator faceAreaPair; + mergeLevels 1; + } + + "(k|epsilon)" + { + solver smoothSolver; + smoother GaussSeidel; + nSweeps 2; + tolerance 1e-07; + relTol 0.1; + } +} + +SIMPLE +{ + nUCorrectors 2; + nNonOrthogonalCorrectors 0; +} + +relaxationFactors +{ + p 0.3; + U 0.7; + k 0.9; + epsilon 0.9; +} + + +// ************************************************************************* // diff --git a/tutorials/incompressible/simpleFoam/airFoil2D/Allclean b/tutorials/incompressible/simpleFoam/airFoil2D/Allclean index f73c44df8a80af20311035b269db90ae9d88b7ea..35e38c65c54b6620f679d4494c76cc03f97cdd57 100755 --- a/tutorials/incompressible/simpleFoam/airFoil2D/Allclean +++ b/tutorials/incompressible/simpleFoam/airFoil2D/Allclean @@ -3,4 +3,4 @@ # Clean time folders only rm -rf *[1-9]* -rm log.* +rm -f log.* 2>/dev/null diff --git a/tutorials/incompressible/simpleFoam/motorBike/constant/polyMesh/boundary b/tutorials/incompressible/simpleFoam/motorBike/constant/polyMesh/boundary index b79c6ad432aaa5f1f3da3b5a4b9561d698e8cdb5..3c2a064fff04bf911ac962c8708db1b970fd7998 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/constant/polyMesh/boundary +++ b/tutorials/incompressible/simpleFoam/motorBike/constant/polyMesh/boundary @@ -21,433 +21,433 @@ FoamFile { type patch; nFaces 320; - startFace 1016586; + startFace 1016673; } inlet { type patch; nFaces 64; - startFace 1016906; + startFace 1016993; } outlet { type patch; nFaces 64; - startFace 1016970; + startFace 1017057; } lowerWall { type wall; nFaces 5330; - startFace 1017034; + startFace 1017121; } upperWall { type patch; nFaces 160; - startFace 1022364; + startFace 1022451; } motorBike_frt-fairing:001%1 { type wall; nFaces 6626; - startFace 1022524; + startFace 1022611; } motorBike_windshield:002%2 { type wall; nFaces 50; - startFace 1029150; + startFace 1029237; } motorBike_rr-wh-rim:005%5 { type wall; nFaces 181; - startFace 1029200; + startFace 1029287; } motorBike_rr-wh-rim:010%10 { type wall; nFaces 340; - startFace 1029381; + startFace 1029468; } motorBike_fr-wh-rim:011%11 { type wall; nFaces 474; - startFace 1029721; + startFace 1029808; } motorBike_fr-wh-brake-disk:012%12 { type wall; nFaces 54; - startFace 1030195; + startFace 1030282; } motorBike_frame:016-shadow%13 { type wall; nFaces 131; - startFace 1030249; + startFace 1030336; } motorBike_rear-susp:014%14 { type wall; nFaces 1073; - startFace 1030380; + startFace 1030467; } motorBike_rear-susp:014-shadow%15 { type wall; nFaces 159; - startFace 1031453; + startFace 1031540; } motorBike_frame:016%16 { type wall; nFaces 20; - startFace 1031612; + startFace 1031699; } motorBike_rr-wh-rim:005-shadow%17 { type wall; nFaces 25; - startFace 1031632; + startFace 1031719; } motorBike_rr-wh-chain-hub:022%22 { type wall; nFaces 141; - startFace 1031657; + startFace 1031744; } motorBike_rearseat%24 { type wall; nFaces 432; - startFace 1031798; + startFace 1031885; } motorBike_frt-fairing%25 { type wall; nFaces 626; - startFace 1032230; + startFace 1032317; } motorBike_windshield%26 { type wall; nFaces 428; - startFace 1032856; + startFace 1032943; } motorBike_headlights%27 { type wall; nFaces 161; - startFace 1033284; + startFace 1033371; } motorBike_driversseat%28 { type wall; nFaces 367; - startFace 1033445; + startFace 1033532; } motorBike_rear-body%29 { type wall; nFaces 2076; - startFace 1033812; + startFace 1033899; } motorBike_fuel-tank%30 { type wall; nFaces 912; - startFace 1035888; + startFace 1035975; } motorBike_exhaust%31 { type wall; nFaces 2391; - startFace 1036800; + startFace 1036887; } motorBike_rr-wh-rim%32 { type wall; nFaces 1430; - startFace 1039191; + startFace 1039278; } motorBike_fr-mud-guard%33 { type wall; nFaces 767; - startFace 1040621; + startFace 1040708; } motorBike_fr-wh-rim%34 { type wall; nFaces 592; - startFace 1041388; + startFace 1041475; } motorBike_fr-wh-brake-disk%35 { type wall; nFaces 533; - startFace 1041980; + startFace 1042067; } motorBike_fr-brake-caliper%36 { type wall; nFaces 164; - startFace 1042513; + startFace 1042600; } motorBike_fr-wh-tyre%37 { type wall; nFaces 1118; - startFace 1042677; + startFace 1042764; } motorBike_hbars%38 { type wall; nFaces 535; - startFace 1043795; + startFace 1043882; } motorBike_fr-forks%39 { type wall; nFaces 1144; - startFace 1044330; + startFace 1044417; } motorBike_chain%40 { type wall; nFaces 474; - startFace 1045474; + startFace 1045561; } motorBike_rr-wh-tyre%41 { type wall; nFaces 1785; - startFace 1045948; + startFace 1046035; } motorBike_square-dial%42 { type wall; nFaces 6; - startFace 1047733; + startFace 1047820; } motorBike_round-dial%43 { type wall; nFaces 18; - startFace 1047739; + startFace 1047826; } motorBike_dial-holder%44 { type wall; nFaces 87; - startFace 1047757; + startFace 1047844; } motorBike_rear-susp%45 { type wall; nFaces 1787; - startFace 1047844; + startFace 1047931; } motorBike_rear-brake-lights%46 { type wall; nFaces 54; - startFace 1049631; + startFace 1049718; } motorBike_rear-light-bracket%47 { type wall; nFaces 163; - startFace 1049685; + startFace 1049772; } motorBike_frame%48 { type wall; nFaces 2040; - startFace 1049848; + startFace 1049935; } motorBike_rear-mud-guard%49 { type wall; nFaces 804; - startFace 1051888; + startFace 1051975; } motorBike_rear-susp-spring-damp%50 { type wall; nFaces 125; - startFace 1052692; + startFace 1052779; } motorBike_fairing-inner-plate%51 { type wall; nFaces 446; - startFace 1052817; + startFace 1052904; } motorBike_clutch-housing%52 { type wall; nFaces 966; - startFace 1053263; + startFace 1053350; } motorBike_radiator%53 { type wall; nFaces 48; - startFace 1054229; + startFace 1054316; } motorBike_water-pipe%54 { type wall; nFaces 103; - startFace 1054277; + startFace 1054364; } motorBike_water-pump%55 { type wall; nFaces 74; - startFace 1054380; + startFace 1054467; } motorBike_engine%56 { type wall; nFaces 2384; - startFace 1054454; + startFace 1054541; } motorBike_rear-shock-link%57 { type wall; nFaces 29; - startFace 1056838; + startFace 1056925; } motorBike_rear-brake-fluid-pot-bracket%58 { type wall; nFaces 59; - startFace 1056867; + startFace 1056954; } motorBike_rear-brake-fluid-pot%59 { type wall; nFaces 53; - startFace 1056926; + startFace 1057013; } motorBike_footpeg%60 { type wall; nFaces 87; - startFace 1056979; + startFace 1057066; } motorBike_rr-wh-chain-hub%61 { type wall; nFaces 145; - startFace 1057066; + startFace 1057153; } motorBike_rear-brake-caliper%62 { type wall; nFaces 142; - startFace 1057211; + startFace 1057298; } motorBike_rider-helmet%65 { type wall; nFaces 583; - startFace 1057353; + startFace 1057440; } motorBike_rider-visor%66 { type wall; nFaces 95; - startFace 1057936; + startFace 1058023; } motorBike_rider-boots%67 { type wall; nFaces 1025; - startFace 1058031; + startFace 1058118; } motorBike_rider-gloves%68 { type wall; nFaces 320; - startFace 1059056; + startFace 1059143; } motorBike_rider-body%69 { type wall; nFaces 4555; - startFace 1059376; + startFace 1059463; } motorBike_frame:0%70 { type wall; nFaces 37; - startFace 1063931; + startFace 1064018; } motorBike_frt-fairing:001-shadow%74 { type wall; nFaces 1274; - startFace 1063968; + startFace 1064055; } motorBike_windshield-shadow%75 { type wall; nFaces 101; - startFace 1065242; + startFace 1065329; } motorBike_fr-mud-guard-shadow%81 { type wall; nFaces 129; - startFace 1065343; + startFace 1065430; } motorBike_fr-wh-brake-disk-shadow%83 { type wall; nFaces 77; - startFace 1065472; + startFace 1065559; } motorBike_rear-mud-guard-shadow%84 { type wall; nFaces 138; - startFace 1065549; + startFace 1065636; } motorBike_rear-susp-spring-damp-shadow%85 { type wall; nFaces 15; - startFace 1065687; + startFace 1065774; } motorBike_radiator-shadow%86 { type wall; nFaces 12; - startFace 1065702; + startFace 1065789; } motorBike_rear-shock-link-shadow%87 { type wall; nFaces 7; - startFace 1065714; + startFace 1065801; } motorBike_rear-brake-fluid-pot-bracket-shadow%88 { type wall; nFaces 6; - startFace 1065721; + startFace 1065808; } motorBike_rr-wh-chain-hub-shadow%89 { type wall; nFaces 24; - startFace 1065727; + startFace 1065814; } ) diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/fvSchemes b/tutorials/incompressible/simpleFoam/motorBike/system/fvSchemes index 50814119794de05fc809e924e6aac45e5589974c..72974933474f1f84d9bca41ef9f42a67048fd18b 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/fvSchemes +++ b/tutorials/incompressible/simpleFoam/motorBike/system/fvSchemes @@ -24,13 +24,13 @@ gradSchemes default Gauss linear; grad(p) Gauss linear; grad(U) Gauss linear; -// grad(U) cellLimited Gauss linear 1; + //grad(U) cellLimited Gauss linear 1; } divSchemes { default none; - div(phi,U) Gauss linearUpwindV Gauss linear; + div(phi,U) Gauss linearUpwind grad(U); div(phi,k) Gauss upwind; div(phi,omega) Gauss upwind; div((nuEff*dev(grad(U).T()))) Gauss linear; @@ -39,8 +39,8 @@ divSchemes laplacianSchemes { default Gauss linear corrected; -// default Gauss linear limited 0.5; -// default Gauss linear limited 0.333; + //default Gauss linear limited 0.5; + //default Gauss linear limited 0.333; } interpolationSchemes diff --git a/tutorials/incompressible/simpleFoam/motorBike/system/fvSolution b/tutorials/incompressible/simpleFoam/motorBike/system/fvSolution index 3b0a3e35b679d7ba421255aaa4b43dfc003b8fe0..e99098b5b9c395c01a65884467579249c4e1dfa4 100644 --- a/tutorials/incompressible/simpleFoam/motorBike/system/fvSolution +++ b/tutorials/incompressible/simpleFoam/motorBike/system/fvSolution @@ -71,4 +71,9 @@ relaxationFactors omega 0.7; } +cache +{ + grad(U); +} + // ************************************************************************* // diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties index f2705462014214ecc6692f75f8af506f2fdfcf26..ef1151639172571123055850ae91da79c35fc4a9 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties @@ -107,8 +107,9 @@ ManualInjectionCoeffs StandardWallInteractionCoeffs { - e e [ 0 0 0 0 0 ] 1; - mu mu [ 0 0 0 0 0 ] 0; + type rebound; + e 1; + mu 0; } RanzMarshallCoeffs diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties index a17be1e36fc1e53d5457c41a2386aab25cbb11fa..f4cf89a7005cb86b30c46b20a8fac62d71adf3bf 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties @@ -92,8 +92,9 @@ ManualInjectionCoeffs StandardWallInteractionCoeffs { - e e [ 0 0 0 0 0 ] 1; - mu mu [ 0 0 0 0 0 ] 0; + type rebound; + e 1; + mu 0; } RanzMarshallCoeffs diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties index 5c99dbf5542072739a0924f57f0b9595a3de4a82..b1b89e17eb08dd6fd511ab06326e1c3126dfe826 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/reactingCloud1Properties @@ -110,8 +110,7 @@ ReactingLookupTableInjectionCoeffs StandardWallInteractionCoeffs { - e e [ 0 0 0 0 0 ] 1; - mu mu [ 0 0 0 0 0 ] 0; + type rebound; } LocalInteractionCoeffs @@ -120,13 +119,11 @@ LocalInteractionCoeffs ( walls { - e 1; - mu 0; + type rebound; } cycLeft { - e 1; - mu 0; + type rebound; } ); } diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/thermo.incompressiblePoly b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/thermo.incompressiblePoly index 4ca40c05fb3aacf603b749e1f3630ca8cb5bc778..6b8aeb6dcfafe9c616d27d0b6a37ff52021f3aa7 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/thermo.incompressiblePoly +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/thermo.incompressiblePoly @@ -1,5 +1,6 @@ ( -N2 N2 1 28.0134 + // Nitrogen + N2 N2 1 28.0134 rhoPolynomial ( 3.88E+000 @@ -11,8 +12,8 @@ N2 N2 1 28.0134 0 0 ) - 0.0 // Heat of formation - 0.0 // Standard entropy + 0.0 // Heat of formation [J/kg] + 6840 // Standard entropy [J/kg/K] cpPolynomial ( 2.75E+004 @@ -46,7 +47,9 @@ N2 N2 1 28.0134 0 0 ) -O2 O2 1 31.9988 + + // Oxygen + O2 O2 1 31.9988 rhoPolynomial ( 4.43E+000 @@ -58,8 +61,8 @@ O2 O2 1 31.9988 0 0 ) - 0.0 // Heat of formation - 0.0 // Standard entropy + 0.0 // Heat of formation [J/kg] + 6408 // Standard entropy [J/kg/K] cpPolynomial ( 2.67E+004 @@ -93,7 +96,9 @@ O2 O2 1 31.9988 0 0 ) -H2O H2O 1 18.0153 + + // Water vapour + H2O H2O 1 18.0153 rhoPolynomial ( 2.49E+000 @@ -105,8 +110,8 @@ H2O H2O 1 18.0153 0 0 ) - -241.8 // Heat of formation - 0.0 // Standard entropy + -1.3423e07 // Heat of formation [J/kg] + 1.0482e04 // Standard entropy [J/kg/K] cpPolynomial ( 2.85E+004 diff --git a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties index 95f4df9ceb8cdc098a8253c8168dba6f84649390..97619b95a78721d476e1ff9c26bfef1f8d3ce3bc 100644 --- a/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/evaporationTest/constant/reactingCloud1Properties @@ -99,8 +99,7 @@ ManualInjectionCoeffs StandardWallInteractionCoeffs { - e e [ 0 0 0 0 0 ] 1; - mu mu [ 0 0 0 0 0 ] 0; + type rebound; } RanzMarshallCoeffs diff --git a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties index f88d7e10904b8d2a9817df191b5489a0bdbe4301..469aaa10f6431a31a4cf20109b4a06b51c22fa30 100644 --- a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties +++ b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/kinematicCloud1Properties @@ -104,8 +104,7 @@ ConeInjectionCoeffs StandardWallInteractionCoeffs { - e e [ 0 0 0 0 0 ] 1; - mu mu [ 0 0 0 0 0 ] 0; + type rebound; } diff --git a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties index 67823f6aab654ef1a87e8869f8d934cb94b16e28..59402e4ea38faff55ca428753b2fda62341c3395 100644 --- a/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties +++ b/tutorials/lagrangian/rhoPisoTwinParcelFoam/simplifiedSiwek/constant/thermoCloud1Properties @@ -92,8 +92,7 @@ ManualInjectionCoeffs StandardWallInteractionCoeffs { - e e [ 0 0 0 0 0 ] 1; - mu mu [ 0 0 0 0 0 ] 0; + type rebound; } RanzMarshallCoeffs diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/U b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/U new file mode 100644 index 0000000000000000000000000000000000000000..2eee81b3a0d74c066ef53838efb6298e41d2bc8a --- /dev/null +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/U @@ -0,0 +1,42 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + stationaryWalls + { + type fixedValue; + value uniform (0 0 0); + } + atmosphere + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } + floatingObject + { + type movingWallVelocity; + value uniform (0 0 0); + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/alpha1 b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/alpha1 new file mode 100644 index 0000000000000000000000000000000000000000..8b3768458dcd903da0e526c0c8a44df4f5ab6329 --- /dev/null +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/alpha1 @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object alpha1; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + stationaryWalls + { + type zeroGradient; + } + atmosphere + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + floatingObject + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/epsilon b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/epsilon new file mode 100644 index 0000000000000000000000000000000000000000..849d3713a5f662ec9a6cb5aadcc61521fde2fab5 --- /dev/null +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/epsilon @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + stationaryWalls + { + type epsilonWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 0.1; + } + atmosphere + { + type inletOutlet; + inletValue uniform 0.1; + value uniform 0.1; + } + floatingObject + { + type epsilonWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 0.1; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/k b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/k new file mode 100644 index 0000000000000000000000000000000000000000..84563be30c3703daa0ebae0b1e307bbeab826a75 --- /dev/null +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/k @@ -0,0 +1,43 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform 0.1; + +boundaryField +{ + stationaryWalls + { + type kqRWallFunction; + value uniform 0.1; + } + atmosphere + { + type inletOutlet; + inletValue uniform 0.1; + value uniform 0.1; + } + floatingObject + { + type kqRWallFunction; + value uniform 0.1; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/nut b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/nut new file mode 100644 index 0000000000000000000000000000000000000000..a86c3e35e008a370381b517395b721d5b80247f3 --- /dev/null +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/nut @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + stationaryWalls + { + type nutkWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 0; + } + atmosphere + { + type calculated; + value uniform 0; + } + floatingObject + { + type nutkWallFunction; + Cmu 0.09; + kappa 0.41; + E 9.8; + value uniform 0; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/p b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/p new file mode 100644 index 0000000000000000000000000000000000000000..b5127205565f8a4d0e734bf5f989b385e51ff768 --- /dev/null +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/p @@ -0,0 +1,46 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object pd; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + stationaryWalls + { + type buoyantPressure; + value uniform 0; + } + atmosphere + { + type totalPressure; + p0 uniform 0; + U U; + phi phi; + rho rho; + psi none; + gamma 1; + value uniform 0; + } + floatingObject + { + type buoyantPressure; + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement new file mode 100644 index 0000000000000000000000000000000000000000..711e09e22d868ecb68ee12141b909f673409fab7 --- /dev/null +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/0.org/pointDisplacement @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class pointVectorField; + location "0.01"; + object pointDisplacement; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 0 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + stationaryWalls + { + type fixedValue; + value uniform (0 0 0); + } + atmosphere + { + type fixedValue; + value uniform (0 0 0); + } + floatingObject + { + type sixDoFRigidBodyDisplacement; + centreOfMass (0.5 0.5 0.5); + momentOfInertia (0.08622222 0.8622222 0.144); + mass 9.6; + rhoInf 1; + Q (1 0 0 0 1 0 0 0 1); + v (0 0 0); + a (0 0 0); + pi (0 0 0); + tau (0 0 0); + value uniform (0 0 0); + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interDyMFoam/ras/floatingObject/Allrun b/tutorials/multiphase/interDyMFoam/ras/floatingObject/Allrun index 1bece85bd98222c0358d809de9c9d3033aeda6c4..7c7ab52940262234486363281c2195f97e86b06e 100755 --- a/tutorials/multiphase/interDyMFoam/ras/floatingObject/Allrun +++ b/tutorials/multiphase/interDyMFoam/ras/floatingObject/Allrun @@ -20,7 +20,7 @@ makeMeshByCellSet() runApplication blockMesh makeMeshByCellSet 1 2 runApplication subsetMesh -overwrite c0 -patch floatingObject -cp -r 0.orig 0 > /dev/null 2>&1 +cp -r 0.org 0 > /dev/null 2>&1 runApplication setFields runApplication $application diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/U b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/U new file mode 100644 index 0000000000000000000000000000000000000000..26852141c2105c1e29071bcfc24a91c920937a02 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/U @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + leftWall + { + type fixedValue; + value uniform (0 0 0); + } + rightWall + { + type fixedValue; + value uniform (0 0 0); + } + lowerWall + { + type fixedValue; + value uniform (0 0 0); + } + atmosphere + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } + defaultFaces + { + type empty; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha1.org b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha1.org new file mode 100644 index 0000000000000000000000000000000000000000..f0bdefa8cddb1ae29fe7f3c675625c288f9a509e --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha1.org @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha1; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + atmosphere + { + type inletOutlet; + inletValue uniform 1; + value uniform 1; + } + + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha2.org b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha2.org new file mode 100644 index 0000000000000000000000000000000000000000..122e71dacedafedd83ea01b45380bc03d789950a --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha2.org @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha2; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + atmosphere + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha3.org b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha3.org new file mode 100644 index 0000000000000000000000000000000000000000..f3d69ec08266a13c1c1f9ce2a80b2f1bdb6655cd --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/alpha3.org @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha3; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type zeroGradient; + } + + rightWall + { + type zeroGradient; + } + + lowerWall + { + type zeroGradient; + } + + atmosphere + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/p b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/p new file mode 100644 index 0000000000000000000000000000000000000000..b77bfe911838f761d5818a97593e1a4652949d22 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/0/p @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + leftWall + { + type buoyantPressure; + value uniform 0; + } + + rightWall + { + type buoyantPressure; + value uniform 0; + } + + lowerWall + { + type buoyantPressure; + value uniform 0; + } + + atmosphere + { + type totalPressure; + p0 uniform 0; + U U; + phi phi; + rho rho; + psi none; + gamma 1; + value uniform 0; + } + + defaultFaces + { + type empty; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allclean b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allclean new file mode 100755 index 0000000000000000000000000000000000000000..cff4dbd23191f6a4ca343bf6898b0762ed0cce6d --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allclean @@ -0,0 +1,4 @@ +#!/bin/sh + +foamCleanTutorials cases +rm -rf 0/alpha[1-3].gz diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun new file mode 100755 index 0000000000000000000000000000000000000000..15f6fafd90d19159e7c83d7192668c297d0e6798 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/Allrun @@ -0,0 +1,10 @@ +#!/bin/sh +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication blockMesh +cp 0/alpha1.org 0/alpha1 +cp 0/alpha2.org 0/alpha2 +cp 0/alpha3.org 0/alpha3 +runApplication setFields +runApplication interMixingFoam diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/dynamicMeshDict b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/dynamicMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..8fa634496563aaf871d8be56a7d7a1159758692c --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/dynamicMeshDict @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object dynamicMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dynamicFvMesh staticFvMesh; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/g b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/g new file mode 100644 index 0000000000000000000000000000000000000000..27d4d324881b52b2a37d45b4cfbed46ed94d8051 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 -9.81 0 ); + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/polyMesh/blockMeshDict b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/polyMesh/blockMeshDict new file mode 100644 index 0000000000000000000000000000000000000000..a2553926d290a80076f1bf827324fd256d933b53 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/polyMesh/blockMeshDict @@ -0,0 +1,92 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 0.146; + +vertices +( + (0 0 0) + (2 0 0) + (2.16438 0 0) + (4 0 0) + (0 0.32876 0) + (2 0.32876 0) + (2.16438 0.32876 0) + (4 0.32876 0) + (0 4 0) + (2 4 0) + (2.16438 4 0) + (4 4 0) + (0 0 0.1) + (2 0 0.1) + (2.16438 0 0.1) + (4 0 0.1) + (0 0.32876 0.1) + (2 0.32876 0.1) + (2.16438 0.32876 0.1) + (4 0.32876 0.1) + (0 4 0.1) + (2 4 0.1) + (2.16438 4 0.1) + (4 4 0.1) +); + +blocks +( + hex (0 1 5 4 12 13 17 16) (23 8 1) simpleGrading (1 1 1) + hex (2 3 7 6 14 15 19 18) (19 8 1) simpleGrading (1 1 1) + hex (4 5 9 8 16 17 21 20) (23 42 1) simpleGrading (1 1 1) + hex (5 6 10 9 17 18 22 21) (4 42 1) simpleGrading (1 1 1) + hex (6 7 11 10 18 19 23 22) (19 42 1) simpleGrading (1 1 1) +); + +edges +( +); + +patches +( + wall leftWall + ( + (0 12 16 4) + (4 16 20 8) + ) + wall rightWall + ( + (7 19 15 3) + (11 23 19 7) + ) + wall lowerWall + ( + (0 1 13 12) + (1 5 17 13) + (5 6 18 17) + (2 14 18 6) + (2 3 15 14) + ) + patch atmosphere + ( + (8 20 21 9) + (9 21 22 10) + (10 22 23 11) + ) +); + +mergePatchPairs +( +); + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/polyMesh/boundary b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/polyMesh/boundary new file mode 100644 index 0000000000000000000000000000000000000000..cfd3f8c4d431b8e5a2ab2b5035b4d4f6747f6b36 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/polyMesh/boundary @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6.x | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class polyBoundaryMesh; + location "constant/polyMesh"; + object boundary; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +5 +( + leftWall + { + type wall; + nFaces 50; + startFace 4432; + } + rightWall + { + type wall; + nFaces 50; + startFace 4482; + } + lowerWall + { + type wall; + nFaces 62; + startFace 4532; + } + atmosphere + { + type patch; + nFaces 46; + startFace 4594; + } + defaultFaces + { + type empty; + nFaces 4536; + startFace 4640; + } +) + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/transportProperties b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/transportProperties new file mode 100644 index 0000000000000000000000000000000000000000..3cada9d4de2381a5996e8ef87393adffd7f10119 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/transportProperties @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Air +phase1 +{ + transportModel Newtonian; + nu nu [0 2 -1 0 0 0 0] 1.48e-05; + rho rho [1 -3 0 0 0 0 0] 1; +} + +// Other Liquid +phase2 +{ + transportModel Newtonian; + nu nu [0 2 -1 0 0 0 0] 1e-6; + rho rho [1 -3 0 0 0 0 0] 1010; +} + +// Water +phase3 +{ + transportModel Newtonian; + nu nu [0 2 -1 0 0 0 0] 1e-6; + rho rho [1 -3 0 0 0 0 0] 1000; +} + +// Surface tension coefficients +sigma12 sigma12 [1 0 -2 0 0 0 0] 0.05; +sigma13 sigma13 [1 0 -2 0 0 0 0] 0.04; + +// Diffusivity between miscible phases +D23 D23 [0 2 -1 0 0 0 0] 3e-09; + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/turbulenceProperties b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/turbulenceProperties new file mode 100644 index 0000000000000000000000000000000000000000..9cfc50a3d927937cf2ce96c64d3c9d6bd3144e2c --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/constant/turbulenceProperties @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/controlDict b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/controlDict new file mode 100644 index 0000000000000000000000000000000000000000..a6f556508b1043f8de1653b692df0c37a7050d82 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/controlDict @@ -0,0 +1,55 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 2; + +deltaT 0.001; + +writeControl adjustableRunTime; + +writeInterval 0.05; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression compressed; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.5; + +maxDeltaT 1; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/decomposeParDict b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/decomposeParDict new file mode 100644 index 0000000000000000000000000000000000000000..f1482468d421307958abf604cda46138a6feee91 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/decomposeParDict @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 4; + +method simple; + +simpleCoeffs +{ + n ( 2 2 1 ); + delta 0.001; +} + +hierarchicalCoeffs +{ + n ( 1 1 1 ); + delta 0.001; + order xyz; +} + +metisCoeffs +{ + processorWeights ( 1 1 1 1 ); +} + +manualCoeffs +{ + dataFile ""; +} + +distributed no; + +roots ( ); + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/fvSchemes b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/fvSchemes new file mode 100644 index 0000000000000000000000000000000000000000..bc9a0699584078169b5ede5cde5d4a94eac8c86d --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/fvSchemes @@ -0,0 +1,59 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rho*phi,U) Gauss limitedLinearV 1; + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss interfaceCompression; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p; + pcorr; + "alpha."; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/fvSolution b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/fvSolution new file mode 100644 index 0000000000000000000000000000000000000000..f2543e14e1d63795f0d15e7deb675f27b1affb02 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/fvSolution @@ -0,0 +1,73 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha." + { + solver smoothSolver; + smoother GaussSeidel; + tolerance 1e-06; + relTol 0; + nSweeps 1; + } + + pcorr + { + solver PCG; + preconditioner DIC; + tolerance 1e-10; + relTol 0; + } + + p + { + solver PCG; + preconditioner DIC; + tolerance 1e-07; + relTol 0.05; + } + + pFinal + { + solver PCG; + preconditioner DIC; + tolerance 1e-07; + relTol 0; + } + + U + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-06; + relTol 0; + } +} + +PISO +{ + momentumPredictor no; + nCorrectors 3; + nNonOrthogonalCorrectors 0; + nAlphaCorr 1; + nAlphaSubCycles 2; + cAlpha 1; +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/setFieldsDict b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/setFieldsDict new file mode 100644 index 0000000000000000000000000000000000000000..51ad3170f569e195dd9a8613a81f53657a277b86 --- /dev/null +++ b/tutorials/multiphase/interMixingFoam/laminar/damBreak/system/setFieldsDict @@ -0,0 +1,50 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.6 | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha1 0 + volScalarFieldValue alpha2 1 + volScalarFieldValue alpha3 0 +); + +regions +( + boxToCell + { + box (0 0 -1) (0.1461 0.292 1); + fieldValues + ( + volScalarFieldValue alpha1 0 + volScalarFieldValue alpha2 0 + volScalarFieldValue alpha3 1 + ); + } + boxToCell + { + box (0.1461 0.05 -1) (1 1 1); + fieldValues + ( + volScalarFieldValue alpha1 1 + volScalarFieldValue alpha2 0 + volScalarFieldValue alpha3 0 + ); + } +); + + +// ************************************************************************* // diff --git a/tutorials/multiphase/settlingFoam/ras/tank3D/Allclean b/tutorials/multiphase/settlingFoam/ras/tank3D/Allclean index f73c44df8a80af20311035b269db90ae9d88b7ea..35e38c65c54b6620f679d4494c76cc03f97cdd57 100755 --- a/tutorials/multiphase/settlingFoam/ras/tank3D/Allclean +++ b/tutorials/multiphase/settlingFoam/ras/tank3D/Allclean @@ -3,4 +3,4 @@ # Clean time folders only rm -rf *[1-9]* -rm log.* +rm -f log.* 2>/dev/null