diff --git a/applications/solvers/combustion/fireFoam/Make/options b/applications/solvers/combustion/fireFoam/Make/options index c243c07e3d..93bda97926 100644 --- a/applications/solvers/combustion/fireFoam/Make/options +++ b/applications/solvers/combustion/fireFoam/Make/options @@ -49,7 +49,9 @@ EXE_LIBS = \ -lregionModels \ -lradiationModels \ -lsurfaceFilmModels \ + -lsurfaceFilmDerivedFvPatchFields \ -lpyrolysisModels \ -lregionCoupling \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lODE diff --git a/applications/solvers/lagrangian/DPMFoam/Allwclean b/applications/solvers/lagrangian/DPMFoam/Allwclean new file mode 100755 index 0000000000..25d0b2955f --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/Allwclean @@ -0,0 +1,8 @@ +#!/bin/sh + +cd ${0%/*} || exit 1 +set -x + +wclean DPMTurbulenceModels +wclean +wclean MPPICFoam diff --git a/applications/solvers/lagrangian/DPMFoam/Allwmake b/applications/solvers/lagrangian/DPMFoam/Allwmake new file mode 100755 index 0000000000..6308a7052b --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/Allwmake @@ -0,0 +1,8 @@ +#!/bin/sh + +cd ${0%/*} || exit 1 +set -x + +wmake DPMTurbulenceModels +wmake +wmake MPPICFoam diff --git a/applications/solvers/lagrangian/DPMFoam/CourantNo.H b/applications/solvers/lagrangian/DPMFoam/CourantNo.H new file mode 100644 index 0000000000..9ff53ed401 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/CourantNo.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Global + CourantNo + +Description + Calculates and outputs the mean and maximum Courant Numbers. + +\*---------------------------------------------------------------------------*/ + +scalar CoNum = 0.0; +scalar meanCoNum = 0.0; + +if (mesh.nInternalFaces()) +{ + scalarField sumPhi + ( + fvc::surfaceSum(mag(phic))().internalField() + ); + + CoNum = 0.5*gMax(sumPhi/mesh.V().field())*runTime.deltaTValue(); + + meanCoNum = + 0.5*(gSum(sumPhi)/gSum(mesh.V().field()))*runTime.deltaTValue(); +} + +Info<< "Courant Number mean: " << meanCoNum + << " max: " << CoNum << endl; + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/DPMFoam/DPMFoam.C b/applications/solvers/lagrangian/DPMFoam/DPMFoam.C new file mode 100644 index 0000000000..9c97968c1c --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/DPMFoam.C @@ -0,0 +1,143 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + DPMFoam + +Description + Transient solver for the coupled transport of a single kinematic particle + could including the effect of the volume fraction of particles on the + continuous phase. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "PhaseIncompressibleTurbulenceModel.H" +#include "pimpleControl.H" +#include "fixedFluxPressureFvPatchScalarField.H" + +#ifdef MPPIC + #include "basicKinematicMPPICCloud.H" + #define basicKinematicTypeCloud basicKinematicMPPICCloud +#else + #include "basicKinematicCollidingCloud.H" + #define basicKinematicTypeCloud basicKinematicCollidingCloud +#endif + +int main(int argc, char *argv[]) +{ + argList::addOption + ( + "cloudName", + "name", + "specify alternative cloud name. default is 'kinematicCloud'" + ); + + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "readGravitationalAcceleration.H" + #include "createFields.H" + #include "initContinuityErrs.H" + + pimpleControl pimple(mesh); + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readTimeControls.H" + #include "CourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + continuousPhaseTransport.correct(); + muc = rhoc*continuousPhaseTransport.nu(); + + Info<< "Evolving " << kinematicCloud.name() << endl; + kinematicCloud.evolve(); + + // Update continuous phase volume fraction field + alphac = max(1.0 - kinematicCloud.theta(), alphacMin); + alphac.correctBoundaryConditions(); + alphacf = fvc::interpolate(alphac); + alphaPhic = alphacf*phic; + + fvVectorMatrix cloudSU(kinematicCloud.SU(Uc)); + volVectorField cloudVolSUSu + ( + IOobject + ( + "cloudVolSUSu", + runTime.timeName(), + mesh + ), + mesh, + dimensionedVector + ( + "0", + cloudSU.dimensions()/dimVolume, + vector::zero + ), + zeroGradientFvPatchVectorField::typeName + ); + + cloudVolSUSu.internalField() = - cloudSU.source()/mesh.V(); + cloudVolSUSu.correctBoundaryConditions(); + cloudSU.source() = vector::zero; + + // --- Pressure-velocity PIMPLE corrector loop + while (pimple.loop()) + { + #include "UcEqn.H" + + // --- PISO loop + while (pimple.correct()) + { + #include "pEqn.H" + } + + if (pimple.turbCorr()) + { + continuousPhaseTurbulence->correct(); + } + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/DPMTurbulenceModels.C b/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/DPMTurbulenceModels.C new file mode 100644 index 0000000000..1aeca77957 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/DPMTurbulenceModels.C @@ -0,0 +1,61 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "PhaseIncompressibleTurbulenceModel.H" +#include "singlePhaseTransportModel.H" +#include "addToRunTimeSelectionTable.H" +#include "makeTurbulenceModel.H" + +#include "laminar.H" +#include "RASModel.H" +#include "LESModel.H" + +makeBaseTurbulenceModel +( + volScalarField, + geometricOneField, + incompressibleTurbulenceModel, + PhaseIncompressibleTurbulenceModel, + singlePhaseTransportModel +); + +#define makeRASModel(Type) \ + makeTemplatedTurbulenceModel \ + (singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, RAS, Type) + +#define makeLESModel(Type) \ + makeTemplatedTurbulenceModel \ + (singlePhaseTransportModelPhaseIncompressibleTurbulenceModel, LES, Type) + +#include "kEpsilon.H" +makeRASModel(kEpsilon); + +#include "Smagorinsky.H" +makeLESModel(Smagorinsky); + +#include "kEqn.H" +makeLESModel(kEqn); + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/Make/files b/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/Make/files new file mode 100644 index 0000000000..3b6b48c2c4 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/Make/files @@ -0,0 +1,3 @@ +DPMTurbulenceModels.C + +LIB = $(FOAM_LIBBIN)/libDPMTurbulenceModels diff --git a/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/Make/options b/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/Make/options new file mode 100644 index 0000000000..716929b562 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/DPMTurbulenceModels/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/foam/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude diff --git a/applications/solvers/lagrangian/DPMFoam/MPPICFoam/MPPICFoam.C b/applications/solvers/lagrangian/DPMFoam/MPPICFoam/MPPICFoam.C new file mode 100644 index 0000000000..5a036f8f50 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/MPPICFoam/MPPICFoam.C @@ -0,0 +1,40 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Application + MPPICFoam + +Description + Transient solver for the coupled transport of a single kinematic particle + could including the effect of the volume fraction of particles on the + continuous phase. Multi-Phase Particle In Cell (MPPIC) modeling is used to + represent collisions without resolving particle-particle interactions. + +\*---------------------------------------------------------------------------*/ + +#define MPPIC + +#include "DPMFoam.C" + + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/DPMFoam/MPPICFoam/Make/files b/applications/solvers/lagrangian/DPMFoam/MPPICFoam/Make/files new file mode 100644 index 0000000000..d311f5a33c --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/MPPICFoam/Make/files @@ -0,0 +1,3 @@ +MPPICFoam.C + +EXE = $(FOAM_APPBIN)/MPPICFoam diff --git a/applications/solvers/lagrangian/DPMFoam/MPPICFoam/Make/options b/applications/solvers/lagrangian/DPMFoam/MPPICFoam/Make/options new file mode 100644 index 0000000000..948df09838 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/MPPICFoam/Make/options @@ -0,0 +1,34 @@ +EXE_INC = \ + -I.. \ + -I../DPMTurbulenceModels/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/intermediate/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ + -I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude \ + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -llagrangian \ + -llagrangianIntermediate \ + -lthermophysicalFunctions \ + -lspecie \ + -lradiationModels \ + -lincompressibleTransportModels \ + -lturbulenceModels \ + -lincompressibleTurbulenceModels \ + -lDPMTurbulenceModels \ + -lregionModels \ + -lsurfaceFilmModels \ + -lsampling diff --git a/applications/solvers/lagrangian/DPMFoam/Make/files b/applications/solvers/lagrangian/DPMFoam/Make/files new file mode 100644 index 0000000000..c4d729205d --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/Make/files @@ -0,0 +1,3 @@ +DPMFoam.C + +EXE = $(FOAM_APPBIN)/DPMFoam diff --git a/applications/solvers/lagrangian/DPMFoam/Make/options b/applications/solvers/lagrangian/DPMFoam/Make/options new file mode 100644 index 0000000000..e9524dfc2b --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/Make/options @@ -0,0 +1,33 @@ +EXE_INC = \ + -I./DPMTurbulenceModels/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/lagrangian/basic/lnInclude \ + -I$(LIB_SRC)/lagrangian/intermediate/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/specie/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/reactionThermo/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/radiation/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/phaseIncompressible/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude \ + -I$(LIB_SRC)/regionModels/surfaceFilmModels/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -llagrangian \ + -llagrangianIntermediate \ + -lthermophysicalFunctions \ + -lspecie \ + -lradiationModels \ + -lincompressibleTransportModels \ + -lturbulenceModels \ + -lincompressibleTurbulenceModels \ + -lDPMTurbulenceModels \ + -lregionModels \ + -lsurfaceFilmModels \ + -lsampling diff --git a/applications/solvers/lagrangian/DPMFoam/UcEqn.H b/applications/solvers/lagrangian/DPMFoam/UcEqn.H new file mode 100644 index 0000000000..0bd4a7146d --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/UcEqn.H @@ -0,0 +1,32 @@ +fvVectorMatrix UcEqn +( + fvm::ddt(alphac, Uc) + fvm::div(alphaPhic, Uc) + - fvm::Sp(fvc::ddt(alphac) + fvc::div(alphaPhic), Uc) + + continuousPhaseTurbulence->divDevRhoReff(Uc) + == + (1.0/rhoc)*cloudSU +); + +UcEqn.relax(); + +volScalarField rAUc(1.0/UcEqn.A()); +surfaceScalarField rAUcf("Dp", fvc::interpolate(rAUc)); + +surfaceScalarField phicForces +( + (fvc::interpolate(rAUc*cloudVolSUSu/rhoc) & mesh.Sf()) + + rAUcf*(g & mesh.Sf()) +); + +if (pimple.momentumPredictor()) +{ + solve + ( + UcEqn + == + fvc::reconstruct + ( + phicForces/rAUcf - fvc::snGrad(p)*mesh.magSf() + ) + ); +} diff --git a/applications/solvers/lagrangian/DPMFoam/continuityErrs.H b/applications/solvers/lagrangian/DPMFoam/continuityErrs.H new file mode 100644 index 0000000000..f07d42b39a --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/continuityErrs.H @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Global + continuityErrs + +Description + Calculates and prints the continuity errors. + +\*---------------------------------------------------------------------------*/ + +{ + volScalarField contErr(fvc::ddt(alphac) + fvc::div(alphacf*phic)); + + scalar sumLocalContErr = runTime.deltaTValue()* + mag(contErr)().weightedAverage(mesh.V()).value(); + + scalar globalContErr = runTime.deltaTValue()* + contErr.weightedAverage(mesh.V()).value(); + cumulativeContErr += globalContErr; + + Info<< "time step continuity errors : sum local = " << sumLocalContErr + << ", global = " << globalContErr + << ", cumulative = " << cumulativeContErr + << endl; +} + +// ************************************************************************* // diff --git a/applications/solvers/lagrangian/DPMFoam/createFields.H b/applications/solvers/lagrangian/DPMFoam/createFields.H new file mode 100644 index 0000000000..16ed9fa919 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/createFields.H @@ -0,0 +1,166 @@ + Info<< "\nReading transportProperties\n" << endl; + + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + word contiuousPhaseName(transportProperties.lookup("contiuousPhaseName")); + + dimensionedScalar rhocValue + ( + IOobject::groupName("rho", contiuousPhaseName), + dimDensity, + transportProperties.lookup + ( + IOobject::groupName("rho", contiuousPhaseName) + ) + ); + + volScalarField rhoc + ( + IOobject + ( + rhocValue.name(), + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + rhocValue + ); + + Info<< "Reading field U\n" << endl; + volVectorField Uc + ( + IOobject + ( + IOobject::groupName("U", contiuousPhaseName), + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + Info<< "Reading field p\n" << endl; + volScalarField p + ( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + + Info<< "Reading/calculating continuous-phase face flux field phic\n" + << endl; + + surfaceScalarField phic + ( + IOobject + ( + IOobject::groupName("phi", contiuousPhaseName), + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + linearInterpolate(Uc) & mesh.Sf() + ); + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell(p, mesh.solutionDict().subDict("PIMPLE"), pRefCell, pRefValue); + + Info<< "Creating turbulence model\n" << endl; + + singlePhaseTransportModel continuousPhaseTransport(Uc, phic); + + volScalarField muc + ( + IOobject + ( + IOobject::groupName("mu", contiuousPhaseName), + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + rhoc*continuousPhaseTransport.nu() + ); + + Info << "Creating field alphac\n" << endl; + // alphac must be constructed before the cloud + // so that the drag-models can find it + volScalarField alphac + ( + IOobject + ( + IOobject::groupName("alpha", contiuousPhaseName), + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("0", dimless, 0) + ); + + word kinematicCloudName("kinematicCloud"); + args.optionReadIfPresent("cloudName", kinematicCloudName); + + Info<< "Constructing kinematicCloud " << kinematicCloudName << endl; + basicKinematicTypeCloud kinematicCloud + ( + kinematicCloudName, + rhoc, + Uc, + muc, + g + ); + + // Particle fraction upper limit + scalar alphacMin + ( + 1.0 + - readScalar + ( + kinematicCloud.particleProperties().subDict("constantProperties") + .lookup("alphaMax") + ) + ); + + // Update alphac from the particle locations + alphac = max(1.0 - kinematicCloud.theta(), alphacMin); + alphac.correctBoundaryConditions(); + + surfaceScalarField alphacf("alphacf", fvc::interpolate(alphac)); + surfaceScalarField alphaPhic("alphaPhic", alphacf*phic); + + autoPtr > + continuousPhaseTurbulence + ( + PhaseIncompressibleTurbulenceModel::New + ( + alphac, + Uc, + alphaPhic, + phic, + continuousPhaseTransport + ) + ); diff --git a/applications/solvers/lagrangian/DPMFoam/pEqn.H b/applications/solvers/lagrangian/DPMFoam/pEqn.H new file mode 100644 index 0000000000..34cce4f166 --- /dev/null +++ b/applications/solvers/lagrangian/DPMFoam/pEqn.H @@ -0,0 +1,52 @@ +{ + volVectorField HbyA("HbyA", Uc); + HbyA = rAUc*UcEqn.H(); + + surfaceScalarField phiHbyA + ( + "phiHbyA", + ( + (fvc::interpolate(HbyA) & mesh.Sf()) + + alphacf*rAUcf*fvc::ddtCorr(Uc, phic) + + phicForces + ) + ); + + // Update the fixedFluxPressure BCs to ensure flux consistency + setSnGrad + ( + p.boundaryField(), + ( + phiHbyA.boundaryField() + - (mesh.Sf().boundaryField() & Uc.boundaryField()) + )/(mesh.magSf().boundaryField()*rAUcf.boundaryField()) + ); + + // Non-orthogonal pressure corrector loop + while (pimple.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvm::laplacian(alphacf*rAUcf, p) + == + fvc::ddt(alphac) + fvc::div(alphacf*phiHbyA) + ); + + pEqn.setReference(pRefCell, pRefValue); + + pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter()))); + + if (pimple.finalNonOrthogonalIter()) + { + phic = phiHbyA - pEqn.flux()/alphacf; + + p.relax(); + + Uc = HbyA + + rAUc*fvc::reconstruct((phicForces - pEqn.flux()/alphacf)/rAUcf); + Uc.correctBoundaryConditions(); + } + } +} + +#include "continuityErrs.H" diff --git a/applications/solvers/lagrangian/coalChemistryFoam/Make/options b/applications/solvers/lagrangian/coalChemistryFoam/Make/options index 85cd3a4713..4f85279a69 100644 --- a/applications/solvers/lagrangian/coalChemistryFoam/Make/options +++ b/applications/solvers/lagrangian/coalChemistryFoam/Make/options @@ -35,6 +35,7 @@ EXE_LIBS = \ -lcompressibleLESModels \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lcoalCombustion\ -lspecie \ -lfluidThermophysicalModels \ diff --git a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/Make/options b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/Make/options index cb0f90524a..13f3b20206 100644 --- a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/Make/options +++ b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/Make/options @@ -16,6 +16,7 @@ EXE_INC = \ EXE_LIBS = \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lthermophysicalFunctions \ -lfluidThermophysicalModels \ -lspecie \ diff --git a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/icoUncoupledKinematicParcelDyMFoam/Make/options b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/icoUncoupledKinematicParcelDyMFoam/Make/options index 942c217fa4..2474917002 100644 --- a/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/icoUncoupledKinematicParcelDyMFoam/Make/options +++ b/applications/solvers/lagrangian/icoUncoupledKinematicParcelFoam/icoUncoupledKinematicParcelDyMFoam/Make/options @@ -20,6 +20,7 @@ EXE_INC = \ EXE_LIBS = \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lthermophysicalFunctions \ -lfluidThermophysicalModels \ -lspecie \ diff --git a/applications/solvers/lagrangian/reactingParcelFilmFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFilmFoam/Make/options index e0aac8c5db..1520f13fcb 100644 --- a/applications/solvers/lagrangian/reactingParcelFilmFoam/Make/options +++ b/applications/solvers/lagrangian/reactingParcelFilmFoam/Make/options @@ -43,6 +43,8 @@ EXE_LIBS = \ -lregionModels \ -lradiationModels \ -lsurfaceFilmModels \ + -lsurfaceFilmDerivedFvPatchFields \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lODE \ -lcombustionModels diff --git a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/Make/options index 9aa1847960..2cc7dfa1e7 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/Make/options +++ b/applications/solvers/lagrangian/reactingParcelFoam/LTSReactingParcelFoam/Make/options @@ -34,6 +34,7 @@ EXE_LIBS = \ -lcompressibleLESModels \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lspecie \ -lfluidThermophysicalModels \ -lliquidProperties \ diff --git a/applications/solvers/lagrangian/reactingParcelFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFoam/Make/options index 705cfc9433..ce479be6b6 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/Make/options +++ b/applications/solvers/lagrangian/reactingParcelFoam/Make/options @@ -34,6 +34,7 @@ EXE_LIBS = \ -lcompressibleLESModels \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lspecie \ -lfluidThermophysicalModels \ -lliquidProperties \ diff --git a/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/Make/options b/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/Make/options index 705cfc9433..ce479be6b6 100644 --- a/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/Make/options +++ b/applications/solvers/lagrangian/reactingParcelFoam/simpleReactingParcelFoam/Make/options @@ -34,6 +34,7 @@ EXE_LIBS = \ -lcompressibleLESModels \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lspecie \ -lfluidThermophysicalModels \ -lliquidProperties \ diff --git a/applications/solvers/lagrangian/sprayFoam/Make/options b/applications/solvers/lagrangian/sprayFoam/Make/options index 9dce65d023..bbae7d499b 100644 --- a/applications/solvers/lagrangian/sprayFoam/Make/options +++ b/applications/solvers/lagrangian/sprayFoam/Make/options @@ -35,6 +35,7 @@ EXE_LIBS = \ -lcompressibleLESModels \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -llagrangianSpray \ -lspecie \ -lfluidThermophysicalModels \ diff --git a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/Make/options b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/Make/options index 77034c9ef3..e516ea3f10 100644 --- a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/Make/options +++ b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/Make/options @@ -37,6 +37,7 @@ EXE_LIBS = \ -lcompressibleLESModels \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -llagrangianSpray \ -lspecie \ -lfluidThermophysicalModels \ diff --git a/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/options b/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/options index 12c7c1c551..dd86faf2ab 100644 --- a/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/options +++ b/applications/solvers/lagrangian/uncoupledKinematicParcelFoam/Make/options @@ -14,6 +14,7 @@ EXE_INC = \ EXE_LIBS = \ -llagrangian \ -llagrangianIntermediate \ + -llagrangianTurbulence \ -lthermophysicalFunctions \ -lfluidThermophysicalModels \ -lspecie \ diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/pEqn.H b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/pEqn.H index a014a5ab4e..e7fd7241db 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterDyMFoam/pEqn.H @@ -32,6 +32,9 @@ )/(mesh.magSf().boundaryField()*rAUf.boundaryField()) ); + // Make the fluxes relative to the mesh motion + fvc::makeRelative(phiHbyA, U); + tmp p_rghEqnComp1; tmp p_rghEqnComp2; @@ -114,12 +117,9 @@ { Uf = fvc::interpolate(U); surfaceVectorField n(mesh.Sf()/mesh.magSf()); - Uf += n*(phi/mesh.magSf() - (n & Uf)); + Uf += n*(fvc::absolute(phi, U)/mesh.magSf() - (n & Uf)); } - // Make the fluxes relative to the mesh motion - fvc::makeRelative(phi, U); - // Update densities from change in p_rgh rho1 += psi1*(p_rgh - p_rgh_0); rho2 += psi2*(p_rgh - p_rgh_0); diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H index 53d04d827f..699d789adb 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/correctPhi.H @@ -37,7 +37,8 @@ if (mesh.changing()) pcorrTypes ); - dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0); + // dimensionedScalar rAUf("rAUf", dimTime/rho.dimensions(), 1.0); + surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); while (pimple.correctNonOrthogonal()) { diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C index ba7b4efa9a..83398509e7 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C @@ -57,6 +57,21 @@ int main(int argc, char *argv[]) #include "createFields.H" #include "readTimeControls.H" #include "createPrghCorrTypes.H" + + volScalarField rAU + ( + IOobject + ( + "rAU", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0) + ); + #include "correctPhi.H" #include "createUf.H" #include "CourantNo.H" diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H index 7644120791..ec99a63883 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/pEqn.H @@ -1,5 +1,5 @@ { - volScalarField rAU("rAU", 1.0/UEqn.A()); + rAU = 1.0/UEqn.A(); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C index 810edeff30..8bd1984539 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C +++ b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/interPhaseChangeDyMFoam.C @@ -67,6 +67,21 @@ int main(int argc, char *argv[]) #include "createFields.H" #include "readTimeControls.H" #include "createPcorrTypes.H" + + volScalarField rAU + ( + IOobject + ( + "rAU", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("rAUf", dimTime/rho.dimensions(), 1.0) + ); + #include "../interFoam/interDyMFoam/correctPhi.H" #include "createUf.H" #include "CourantNo.H" diff --git a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/pEqn.H b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/pEqn.H index 6fac1df95c..5915b68035 100644 --- a/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interPhaseChangeFoam/interPhaseChangeDyMFoam/pEqn.H @@ -1,5 +1,5 @@ { - volScalarField rAU("rAU", 1.0/UEqn.A()); + rAU = 1.0/UEqn.A(); surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); volVectorField HbyA("HbyA", U); diff --git a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict index 87922d974d..44cdbaeec6 100644 --- a/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict +++ b/applications/utilities/mesh/generation/snappyHexMesh/snappyHexMeshDict @@ -410,12 +410,17 @@ addLayersControls // Number of smoothing iterations of interior mesh movement direction nSmoothNormals 3; + // Optional: limit the number of steps walking away from the surface. + // Default is unlimited. + //nMedialAxisIter 10; + // Optional: smooth displacement after medial axis determination. // default is 0. - nSmoothDisplacement 90; + //nSmoothDisplacement 90; - // Optional: limit the number of steps walking away from the surface - nMedialAxisIter 10; + // Optional: do not extrude any point where all surrounding faces + // have at least one point not extruded. Default is true. + //detectExtrusionIsland false; // Mesh shrinking diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index e7e1d52255..defbca4c69 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -706,10 +706,17 @@ int main(int argc, char *argv[]) { const fvMesh& procMesh = procMeshes.meshes()[procI]; + // Note: look at sets in current time only or between + // mesh and current time?. For now current time. This will + // miss out on sets in intermediate times that have not + // been reconstructed. IOobjectList objects ( - procMesh, procMesh.facesInstance(), "polyMesh/sets" + procMesh, + databases[0].timeName(), //procMesh.facesInstance() + polyMesh::meshSubDir/"sets" ); + IOobjectList cSets(objects.lookupClass(cellSet::typeName)); forAllConstIter(IOobjectList, cSets, iter) { @@ -754,7 +761,9 @@ int main(int argc, char *argv[]) IOobjectList objects ( - procMesh, procMesh.facesInstance(), "polyMesh/sets" + procMesh, + databases[0].timeName(), //procMesh.facesInstance(), + polyMesh::meshSubDir/"sets" ); // cellSets @@ -856,6 +865,9 @@ int main(int argc, char *argv[]) // the master processor forAll(timeDirs, timeI) { + runTime.setTime(timeDirs[timeI], timeI); + databases[0].setTime(timeDirs[timeI], timeI); + fileName uniformDir0 = databases[0].timePath()/"uniform"; if (isDir(uniformDir0)) { diff --git a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C index c76e466f83..cc1981e1d5 100644 --- a/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C +++ b/applications/utilities/surface/surfaceLambdaMuSmooth/surfaceLambdaMuSmooth.C @@ -33,6 +33,9 @@ Description Provide an edgeMesh file containing points that are not to be moved during smoothing in order to preserve features. + lambda/mu smoothing: G. Taubin, IBM Research report Rc-19923 (02/01/95) + "A signal processing approach to fair surface design" + \*---------------------------------------------------------------------------*/ #include "argList.H" diff --git a/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C b/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C index 3feefdaf40..1a09b7f473 100644 --- a/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C +++ b/src/OpenFOAM/db/IOstreams/Fstreams/OFstream.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,10 +104,10 @@ Foam::OFstream::OFstream { if (debug) { - Info<< "IFstream::IFstream(const fileName&," - "streamFormat format=ASCII," - "versionNumber version=currentVersion) : " - "could not open file for input\n" + Info<< "OFstream::OFstream(const fileName&," + "streamFormat, versionNumber, compressionType) : " + "could not open file " << pathname + << "for input\n" "in stream " << info() << Foam::endl; } diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C index a1db6529f1..dfb60891d6 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.C @@ -145,4 +145,19 @@ void Foam::PstreamBuffers::finishedSends(labelListList& sizes, const bool block) } +void Foam::PstreamBuffers::clear() +{ + forAll(sendBuf_, i) + { + sendBuf_[i].clear(); + } + forAll(recvBuf_, i) + { + recvBuf_[i].clear(); + } + recvBufPos_ = 0; + finishedSendsCalled_ = false; +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H index 52b9960bde..8d5998fe82 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamBuffers.H @@ -112,8 +112,6 @@ class PstreamBuffers bool finishedSendsCalled_; - // Private Member Functions - public: // Static data @@ -155,6 +153,9 @@ public: // non-blocking. void finishedSends(labelListList& sizes, const bool block = true); + //- Clear storage and reset + void clear(); + }; diff --git a/src/OpenFOAM/meshes/MeshObject/MeshObject.C b/src/OpenFOAM/meshes/MeshObject/MeshObject.C index 1a8ebe937a..546c3d1c98 100644 --- a/src/OpenFOAM/meshes/MeshObject/MeshObject.C +++ b/src/OpenFOAM/meshes/MeshObject/MeshObject.C @@ -374,4 +374,32 @@ void Foam::meshObject::clear(objectRegistry& obr) } +template +< + class Mesh, + template class FromType, + template class ToType +> +void Foam::meshObject::clearUpto(objectRegistry& obr) +{ + HashTable*> meshObjects + ( + obr.lookupClass >() + ); + + forAllIter(typename HashTable*>, meshObjects, iter) + { + if (!isA >(*iter())) + { + if (meshObject::debug) + { + Pout<< "meshObject::clearUpto(objectRegistry&) : destroying " + << iter()->name() << endl; + } + obr.checkOut(*iter()); + } + } +} + + // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/MeshObject/MeshObject.H b/src/OpenFOAM/meshes/MeshObject/MeshObject.H index b95c631e52..bc844bd1eb 100644 --- a/src/OpenFOAM/meshes/MeshObject/MeshObject.H +++ b/src/OpenFOAM/meshes/MeshObject/MeshObject.H @@ -182,6 +182,16 @@ public: template class MeshObjectType> static void clear(objectRegistry&); + + //- Clear all meshObject derived from FromType up to (but not including) + // ToType. Used to clear e.g. all non-updateable meshObjects + template + < + class Mesh, + template class FromType, + template class ToType + > + static void clearUpto(objectRegistry&); }; diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C index af15b5edf5..162e895170 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.C @@ -265,7 +265,7 @@ Foam::polyMesh::polyMesh(const IOobject& io) ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -447,7 +447,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -606,7 +606,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -673,8 +673,8 @@ void Foam::polyMesh::resetPrimitives const bool validBoundary ) { - // Clear addressing. Keep geometric props for mapping. - clearAddressing(); + // Clear addressing. Keep geometric props and updateable props for mapping. + clearAddressing(true); // Take over new primitive data. // Optimized to avoid overwriting data at all diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H index 47fe014d60..5d95d9cfb8 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.H @@ -172,8 +172,8 @@ private: //- Is the mesh moving bool moving_; - //- Is the mesh changing (moving and/or topology changing) - bool changing_; + //- Is the mesh topology changing + bool topoChanging_; //- Current time index for mesh motion mutable label curMotionTimeIndex_; @@ -489,22 +489,27 @@ public: { bool m0 = moving_; moving_ = m; - changing_ = changing_ || moving_; return m0; } + //- Is mesh topology changing + bool topoChanging() const + { + return topoChanging_; + } + + //- Set the mesh topology to be changing + bool topoChanging(const bool c) + { + bool c0 = topoChanging_; + topoChanging_ = c; + return c0; + } + //- Is mesh changing (topology changing and/or moving) bool changing() const { - return changing_; - } - - //- Set the mesh to be changing - bool changing(const bool c) - { - bool c0 = changing_; - changing_ = c; - return c0; + return moving()||topoChanging(); } //- Move points, returns volumes swept by faces in motion @@ -580,7 +585,7 @@ public: void clearGeom(); //- Clear addressing - void clearAddressing(); + void clearAddressing(const bool isMeshUpdate = false); //- Clear all geometry and addressing unnecessary for CFD void clearOut(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C b/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C index 7a9558187d..96297ed3e1 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshClear.C @@ -60,6 +60,7 @@ void Foam::polyMesh::clearGeom() << endl; } + // Clear all geometric mesh objects meshObject::clear(*this); primitiveMesh::clearGeom(); @@ -93,16 +94,33 @@ void Foam::polyMesh::clearAdditionalGeom() } -void Foam::polyMesh::clearAddressing() +void Foam::polyMesh::clearAddressing(const bool isMeshUpdate) { if (debug) { Info<< "void polyMesh::clearAddressing() : " - << "clearing topology" + << "clearing topology isMeshUpdate:" << isMeshUpdate << endl; } - meshObject::clear(*this); + if (isMeshUpdate) + { + // Part of a mesh update. Keep meshObjects that have an updateMesh + // callback + meshObject::clearUpto + < + polyMesh, + TopologicalMeshObject, + UpdateableMeshObject + > + ( + *this + ); + } + else + { + meshObject::clear(*this); + } primitiveMesh::clearAddressing(); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C index 43d55876ca..ef5ee9956c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshFromShapeMesh.C @@ -553,7 +553,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { @@ -837,7 +837,7 @@ Foam::polyMesh::polyMesh ), globalMeshDataPtr_(NULL), moving_(false), - changing_(false), + topoChanging_(false), curMotionTimeIndex_(time().timeIndex()), oldPointsPtr_(NULL) { diff --git a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C index 49b48f8df7..5061538f4c 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C +++ b/src/OpenFOAM/meshes/polyMesh/polyPatches/constraint/symmetryPlane/symmetryPlanePolyPatch.C @@ -114,17 +114,26 @@ const Foam::vector& Foam::symmetryPlanePolyPatch::n() const // as the average face-normal if (magSqr(n_) < 0.5) { - const vectorField& nf(faceNormals()); - n_ = gAverage(nf); - - // Check the symmetry plane is planar - forAll(nf, facei) + if (returnReduce(size(), sumOp