diff --git a/README.md b/README.md index aec529e09f..fed8a6e758 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ OpenCFD Ltd grants use of the OpenFOAM trademark by Third Parties on a licence b Please [contact OpenCFD](http://www.openfoam.com/contact) if you have any questions on the use of the OpenFOAM trademark. -Violations of the Trademark are continuously monitored, and will be duly prosecuted. +Violations of the Trademark are continuously monitored, and will be duly prosecuted. # Useful Links diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/files b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/files new file mode 100644 index 0000000000..0c6257a79d --- /dev/null +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/files @@ -0,0 +1,3 @@ +laplacianDyMFoam.C + +EXE = $(FOAM_APPBIN)/overLaplacianDyMFoam diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/options b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/options new file mode 100644 index 0000000000..149f9694b6 --- /dev/null +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/Make/options @@ -0,0 +1,8 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -loverset diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H new file mode 100644 index 0000000000..d14935caab --- /dev/null +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/createFields.H @@ -0,0 +1,53 @@ + Info<< "Reading field T\n" << endl; + + volScalarField T + ( + IOobject + ( + "T", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + // Add overset specific interpolations + { + dictionary oversetDict; + oversetDict.add("T", true); + + const_cast + ( + mesh.schemesDict() + ).add + ( + "oversetInterpolationRequired", + oversetDict, + true + ); + } + + + Info<< "Reading transportProperties\n" << endl; + + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + + Info<< "Reading diffusivity DT\n" << endl; + + dimensionedScalar DT + ( + transportProperties.lookup("DT") + ); diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/laplacianDyMFoam.C b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/laplacianDyMFoam.C new file mode 100644 index 0000000000..7bcd6b6cb6 --- /dev/null +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/laplacianDyMFoam.C @@ -0,0 +1,110 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 + laplacianFoam + +Group + grpBasicSolvers + +Description + Laplace equation solver for a scalar quantity. + + \heading Solver details + The solver is applicable to, e.g. for thermal diffusion in a solid. The + equation is given by: + + \f[ + \ddt{T} = \div \left( D_T \grad T \right) + \f] + + Where: + \vartable + T | Scalar field which is solved for, e.g. temperature + D_T | Diffusion coefficient + \endvartable + + \heading Required fields + \plaintable + T | Scalar field which is solved for, e.g. temperature + \endplaintable + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "fvOptions.H" +#include "simpleControl.H" +#include "dynamicFvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createNamedDynamicFvMesh.H" + + simpleControl simple(mesh); + + #include "createFields.H" + #include "createFvOptions.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nCalculating temperature distribution\n" << endl; + + while (simple.loop()) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + + mesh.update(); + + while (simple.correctNonOrthogonal()) + { + fvScalarMatrix TEqn + ( + fvm::ddt(T) - fvm::laplacian(DT, T) + == + fvOptions(T) + ); + + fvOptions.constrain(TEqn); + TEqn.solve(); + fvOptions.correct(T); + } + + #include "write.H" + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/write.H b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/write.H new file mode 100644 index 0000000000..47aa182c0a --- /dev/null +++ b/applications/solvers/basic/laplacianFoam/overLaplacianDyMFoam/write.H @@ -0,0 +1,46 @@ + if (runTime.outputTime()) + { + volVectorField gradT(fvc::grad(T)); + + volScalarField gradTx + ( + IOobject + ( + "gradTx", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + gradT.component(vector::X) + ); + + volScalarField gradTy + ( + IOobject + ( + "gradTy", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + gradT.component(vector::Y) + ); + + volScalarField gradTz + ( + IOobject + ( + "gradTz", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + gradT.component(vector::Z) + ); + + + runTime.write(); + } diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/Make/files b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/Make/files new file mode 100644 index 0000000000..3d96a548d0 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/Make/files @@ -0,0 +1,3 @@ +rhoPimpleDyMFoam.C + +EXE = $(FOAM_APPBIN)/overRhoPimpleDyMFoam diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/Make/options b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/Make/options new file mode 100644 index 0000000000..ca5b141675 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/Make/options @@ -0,0 +1,25 @@ +EXE_INC = \ + -I.. \ + -I$(LIB_SRC)/transportModels/compressible/lnInclude \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ + -I$(LIB_SRC)/finiteVolume/cfdTools \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + +EXE_LIBS = \ + -lcompressibleTransportModels \ + -lfluidThermophysicalModels \ + -lspecie \ + -lturbulenceModels \ + -lcompressibleTurbulenceModels \ + -loverset \ + -lfvOptions \ + -ldynamicFvMesh \ + -ltopoChangerFvMesh diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/correctPhi.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/correctPhi.H new file mode 100644 index 0000000000..37072312ff --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/correctPhi.H @@ -0,0 +1,11 @@ +CorrectPhi +( + U, + phi, + p, + rho, + psi, + dimensionedScalar("rAUf", dimTime, 1), + divrhoU, + pimple +); diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createControls.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createControls.H new file mode 100644 index 0000000000..aed0e76956 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createControls.H @@ -0,0 +1,11 @@ +#include "createTimeControls.H" + +bool correctPhi +( + pimple.dict().lookupOrDefault("correctPhi", true) +); + +bool checkMeshCourantNo +( + pimple.dict().lookupOrDefault("checkMeshCourantNo", false) +); diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H new file mode 100644 index 0000000000..27f568bce7 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H @@ -0,0 +1,117 @@ +Info<< "Reading thermophysical properties\n" << endl; + +autoPtr pThermo +( + psiThermo::New(mesh) +); +psiThermo& thermo = pThermo(); +thermo.validate(args.executable(), "h", "e"); + +volScalarField& p = thermo.p(); +const volScalarField& psi = thermo.psi(); + +volScalarField rho +( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + thermo.rho() +); + +Info<< "Reading field U\n" << endl; +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +#include "compressibleCreatePhi.H" + +dimensionedScalar rhoMax +( + dimensionedScalar::lookupOrDefault + ( + "rhoMax", + pimple.dict(), + dimDensity, + GREAT + ) +); + +dimensionedScalar rhoMin +( + dimensionedScalar::lookupOrDefault + ( + "rhoMin", + pimple.dict(), + dimDensity, + 0 + ) +); + +Info<< "Creating turbulence model\n" << endl; +autoPtr turbulence +( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) +); + +mesh.setFluxRequired(p.name()); + +Info<< "Creating field dpdt\n" << endl; +volScalarField dpdt +( + IOobject + ( + "dpdt", + runTime.timeName(), + mesh + ), + mesh, + dimensionedScalar("dpdt", p.dimensions()/dimTime, 0) +); + +Info<< "Creating field kinetic energy K\n" << endl; +volScalarField K("K", 0.5*magSqr(U)); + + +//- Overset specific + +// Add solver-specific interpolations +{ + dictionary oversetDict; + oversetDict.add("U", true); + oversetDict.add("p", true); + oversetDict.add("HbyA", true); + oversetDict.add("grad(p)", true); + + const_cast + ( + mesh.schemesDict() + ).add + ( + "oversetInterpolationRequired", + oversetDict, + true + ); +} + +// Mask field for zeroing out contributions on hole cells +#include "createCellMask.H" diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H new file mode 100644 index 0000000000..5f1fc7451c --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H @@ -0,0 +1,123 @@ +rho = thermo.rho(); +rho = max(rho, rhoMin); +rho = min(rho, rhoMax); +rho.relax(); + +surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); + +volScalarField rAU(1.0/UEqn.A()); +surfaceScalarField rhorAUf("rhorAUf", faceMask*fvc::interpolate(rho*rAU)); +volVectorField HbyA("HbyA", constrainHbyA(rAU*UEqn.H(), U, p)); +//mesh.interpolate(HbyA); + +if (pimple.nCorrPISO() <= 1) +{ + tUEqn.clear(); +} + +if (pimple.transonic()) +{ + surfaceScalarField phid + ( + "phid", + fvc::interpolate(psi) + *( + fvc::flux(HbyA) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf)/fvc::interpolate(rho) + ) + ); + + fvc::makeRelative(phid, psi, U); + MRF.makeRelative(fvc::interpolate(psi), phid); + + while (pimple.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvm::div(phid, p) + - fvm::laplacian(rhorAUf, p) + == + fvOptions(psi, p, rho.name()) + ); + + pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter()))); + + if (pimple.finalNonOrthogonalIter()) + { + phi == pEqn.flux(); + } + } +} +else +{ + surfaceScalarField phiHbyA + ( + "phiHbyA", + fvc::flux(rho*HbyA) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) + ); + + fvc::makeRelative(phiHbyA, rho, U); + MRF.makeRelative(fvc::interpolate(rho), phiHbyA); + + // Update the pressure BCs to ensure flux consistency + constrainPressure(p, rho, U, phiHbyA, rhorAUf, MRF); + + while (pimple.correctNonOrthogonal()) + { + // Pressure corrector + fvScalarMatrix pEqn + ( + fvm::ddt(psi, p) + + fvc::div(phiHbyA) + - fvm::laplacian(rhorAUf, p) + == + fvOptions(psi, p, rho.name()) + ); + + pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter()))); + + if (pimple.finalNonOrthogonalIter()) + { + phi = phiHbyA + pEqn.flux(); + } + } +} + +#include "rhoEqn.H" +#include "compressibleContinuityErrs.H" + +// Explicitly relax pressure for momentum corrector +p.relax(); + +// Recalculate density from the relaxed pressure +rho = thermo.rho(); +rho = max(rho, rhoMin); +rho = min(rho, rhoMax); +rho.relax(); +Info<< "rho max/min : " << max(rho).value() + << " " << min(rho).value() << endl; + +volVectorField gradP(fvc::grad(p)); +//mesh.interpolate(gradP); +U = HbyA - rAU*cellMask*gradP; +U.correctBoundaryConditions(); +fvOptions.correct(U); +K = 0.5*magSqr(U); + +{ + rhoUf = fvc::interpolate(rho*U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + rhoUf += n*(fvc::absolute(phi, rho, U)/mesh.magSf() - (n & rhoUf)); +} + +if (thermo.dpdt()) +{ + dpdt = fvc::ddt(p); + + if (mesh.moving()) + { + dpdt -= fvc::div(fvc::meshPhi(rho, U), p); + } +} diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/readControls.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/readControls.H new file mode 100644 index 0000000000..ed2db49fb4 --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/readControls.H @@ -0,0 +1,6 @@ +#include "readTimeControls.H" + +correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); + +checkMeshCourantNo = + pimple.dict().lookupOrDefault("checkMeshCourantNo", false); diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/rhoPimpleDyMFoam.C b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/rhoPimpleDyMFoam.C new file mode 100644 index 0000000000..0bbcefa14b --- /dev/null +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/rhoPimpleDyMFoam.C @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 + rhoPimpleFoam + +Group + grpCompressibleSolvers grpMovingMeshSolvers + +Description + Transient solver for laminar or turbulent flow of compressible fluids + for HVAC and similar applications. + + Uses the flexible PIMPLE (PISO-SIMPLE) solution for time-resolved and + pseudo-transient simulations. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dynamicFvMesh.H" +#include "psiThermo.H" +#include "turbulentFluidThermoModel.H" +#include "bound.H" +#include "pimpleControl.H" +#include "CorrectPhi.H" +#include "fvOptions.H" +#include "localEulerDdtScheme.H" +#include "fvcSmooth.H" +#include "cellCellStencilObject.H" +#include "localMin.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createDynamicFvMesh.H" + + pimpleControl pimple(mesh); + + #include "createRDeltaT.H" + #include "initContinuityErrs.H" + #include "createFields.H" + #include "createMRF.H" + #include "createFvOptions.H" + #include "createRhoUf.H" + #include "createControls.H" + + turbulence->validate(); + + if (!LTS) + { + #include "compressibleCourantNo.H" + #include "setInitialDeltaT.H" + } + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readControls.H" + + { + // Store divrhoU from the previous mesh so that it can be mapped + // and used in correctPhi to ensure the corrected phi has the + // same divergence + volScalarField divrhoU + ( + "divrhoU", + fvc::div(fvc::absolute(phi, rho, U)) + ); + + if (LTS) + { + #include "setRDeltaT.H" + } + else + { + #include "compressibleCourantNo.H" + #include "setDeltaT.H" + } + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + // Store momentum to set rhoUf for introduced faces. + volVectorField rhoU("rhoU", rho*U); + + // Do any mesh changes + mesh.update(); + + if (mesh.changing()) + { + #include "setCellMask.H" + } + + if (mesh.changing() && correctPhi) + { + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & rhoUf; + + #include "correctPhi.H" + + // Make the fluxes relative to the mesh-motion + fvc::makeRelative(phi, rho, U); + } + } + + if (mesh.changing() && checkMeshCourantNo) + { + #include "meshCourantNo.H" + } + + #include "rhoEqn.H" + Info<< "rhoEqn max/min : " << max(rho).value() + << " " << min(rho).value() << endl; + + // --- Pressure-velocity PIMPLE corrector loop + while (pimple.loop()) + { + #include "UEqn.H" + #include "EEqn.H" + + // --- Pressure corrector loop + while (pimple.correct()) + { + #include "pEqn.H" + } + + if (pimple.turbCorr()) + { + turbulence->correct(); + } + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/CourantNo.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/CourantNo.H new file mode 100644 index 0000000000..6353e7908f --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/CourantNo.H @@ -0,0 +1,50 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +------------------------------------------------------------------------------- +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()) +{ + surfaceScalarField phiMask(localMin(mesh).interpolate(cellMask)); + + scalarField sumPhi(fvc::surfaceSum(mag(phiMask*phi))().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/incompressible/pimpleFoam/overPimpleDyMFoam/Make/files b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/Make/files new file mode 100644 index 0000000000..7c557aba24 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/Make/files @@ -0,0 +1,3 @@ +pimpleDyMFoam.C + +EXE = $(FOAM_APPBIN)/overPimpleDyMFoam diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/Make/options b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/Make/options new file mode 100644 index 0000000000..c538a99b57 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/Make/options @@ -0,0 +1,24 @@ +EXE_INC = \ + -I.. \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + +EXE_LIBS = \ + -lturbulenceModels \ + -lincompressibleTurbulenceModels \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lfvOptions \ + -lsampling \ + -ldynamicFvMesh \ + -ltopoChangerFvMesh \ + -ldynamicMesh \ + -loverset diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/UEqn.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/UEqn.H new file mode 100644 index 0000000000..aef0116f7b --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/UEqn.H @@ -0,0 +1,24 @@ +// Solve the Momentum equation + +MRF.correctBoundaryVelocity(U); + +tmp tUEqn +( + fvm::ddt(U) + fvm::div(phi, U) + + MRF.DDt(U) + + turbulence->divDevReff(U) + == + fvOptions(U) +); +fvVectorMatrix& UEqn = tUEqn.ref(); + +UEqn.relax(); + +fvOptions.constrain(UEqn); + +if (pimple.momentumPredictor()) +{ + solve(UEqn == -cellMask*fvc::grad(p)); + + fvOptions.correct(U); +} diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/continuityErrs.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/continuityErrs.H new file mode 100644 index 0000000000..c787055623 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/continuityErrs.H @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +------------------------------------------------------------------------------- +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(interpolatedCells*cellMask*fvc::div(phi)); + + 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/incompressible/pimpleFoam/overPimpleDyMFoam/correctPhi.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/correctPhi.H new file mode 100644 index 0000000000..1951316f46 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/correctPhi.H @@ -0,0 +1,113 @@ +if (mesh.changing()) +{ + volVectorField::Boundary& bfld = U.boundaryFieldRef(); + forAll(bfld, patchi) + { + if (bfld[patchi].fixesValue()) + { + bfld[patchi].initEvaluate(); + } + } + + surfaceScalarField::Boundary& phiBfld = phi.boundaryFieldRef(); + forAll(bfld, patchi) + { + if (bfld[patchi].fixesValue()) + { + bfld[patchi].evaluate(); + + phiBfld[patchi] = bfld[patchi] & mesh.Sf().boundaryField()[patchi]; + } + } +} + // Initialize BCs list for pcorr to zero-gradient + wordList pcorrTypes + ( + p.boundaryField().size(), + zeroGradientFvPatchScalarField::typeName + ); + + // Set BCs of pcorr to fixed-value for patches at which p is fixed + forAll(p.boundaryField(), patchi) + { + if (p.boundaryField()[patchi].fixesValue()) + { + pcorrTypes[patchi] = fixedValueFvPatchScalarField::typeName; + } + } + + volScalarField pcorr + ( + IOobject + ( + "pcorr", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("pcorr", p.dimensions(), 0.0), + pcorrTypes + ); + +{ + dimensionedScalar rAUf("rAUf", dimTime, 1.0); + + const cellCellStencilObject& overlap = Stencil::New(mesh); + const labelList& cellTypes = overlap.cellTypes(); + const labelIOList& zoneIDs = overlap.zoneID(); + + while (pimple.correctNonOrthogonal()) + { + label nZones = gMax(zoneIDs)+1; + + //label refCellI2 = -1; + labelList refCells(nZones, -1); + labelList refZones(nZones, -1); + + forAll(zoneIDs, cellI) + { + label zoneId = zoneIDs[cellI]; + if + ( + refCells[zoneId] == -1 + && cellTypes[cellI] == cellCellStencil::CALCULATED + && refZones[zoneId] == -1 + ) + { + refCells[zoneId] = cellI; + refZones[zoneId] = zoneId; + } + } + + fvScalarMatrix pcorrEqn + ( + fvm::laplacian(rAUf, pcorr) == fvc::div(phi) + ); + + //pcorrEqn.setReference(refCellI2, 0.0, true); + scalarList values(nZones, 0.0); + pcorrEqn.setReferences(refCells, values, true); + + const dictionary& d = mesh.solver + ( + pcorr.select + ( + pimple.finalInnerIter() + ) + ); + mesh.fvMesh::solve(pcorrEqn, d); + + if (pimple.finalNonOrthogonalIter()) + { + phi -= pcorrEqn.flux(); + } + } + + if (runTime.outputTime()) + { + volScalarField("contPhiPcorr", fvc::div(phi)).write(); + pcorr.write(); + } +} diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createControls.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createControls.H new file mode 100644 index 0000000000..53ed2009c7 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createControls.H @@ -0,0 +1,26 @@ +#include "createTimeControls.H" + +bool correctPhi +( + pimple.dict().lookupOrDefault("correctPhi", false) +); + +bool checkMeshCourantNo +( + pimple.dict().lookupOrDefault("checkMeshCourantNo", false) +); + +bool massFluxInterpolation +( + pimple.dict().lookupOrDefault("massFluxInterpolation", false) +); + +bool adjustFringe +( + pimple.dict().lookupOrDefault("oversetAdjustPhi", false) +); + +bool ddtCorr +( + pimple.dict().lookupOrDefault("ddtCorr", true) +); diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createFields.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createFields.H new file mode 100644 index 0000000000..ba991bfd48 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/createFields.H @@ -0,0 +1,70 @@ +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, pimple.dict(), pRefCell, pRefValue); +mesh.setFluxRequired(p.name()); + + +//- Overset specific + +// Add solver-specific interpolations +{ + dictionary oversetDict; + oversetDict.add("U", true); + oversetDict.add("p", true); + oversetDict.add("HbyA", true); + oversetDict.add("grad(p)", true); + + const_cast + ( + mesh.schemesDict() + ).add + ( + "oversetInterpolationRequired", + oversetDict, + true + ); +} + +// Mask field for zeroing out contributions on hole cells +#include "createCellMask.H" + +// Create bool field with interpolated cells +#include "createInterpolatedCells.H" + +singlePhaseTransportModel laminarTransport(U, phi); + +autoPtr turbulence +( + incompressible::turbulenceModel::New(U, phi, laminarTransport) +); diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H new file mode 100644 index 0000000000..e13a2cc0a7 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/interpolatedFaces.H @@ -0,0 +1,269 @@ +// Interpolation used +interpolationCellPoint UInterpolator(HbyA); + +// Determine faces on outside of interpolated cells +PackedBoolList isOwnerInterpolatedFace(mesh.nInternalFaces()); +PackedBoolList isNeiInterpolatedFace(mesh.nInternalFaces()); + +// Determine donor cells +labelListList donorCell(mesh.nInternalFaces()); + +scalarListList weightCellCells(mesh.nInternalFaces()); + +// Interpolated HbyA faces +vectorField UIntFaces(mesh.nInternalFaces(), vector::zero); + +// Determine receptor neighbourd cells +labelList receptorNeigCell(mesh.nInternalFaces(), -1); + +{ + const cellCellStencilObject& overlap = Stencil::New(mesh); + const labelList& cellTypes = overlap.cellTypes(); + const labelIOList& zoneID = overlap.zoneID(); + + label nZones = gMax(zoneID)+1; + PtrList meshParts(nZones); + labelList nCellsPerZone(nZones, 0); + + forAll(nCellsPerZone, zoneI) + { + meshParts.set(zoneI, new fvMeshSubset(mesh)); + meshParts[zoneI].setLargeCellSubset(zoneID, zoneI); + } + + for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) + { + label ownType = cellTypes[mesh.faceOwner()[faceI]]; + label neiType = cellTypes[mesh.faceNeighbour()[faceI]]; + if + ( + ownType == cellCellStencil::INTERPOLATED + && neiType == cellCellStencil::CALCULATED + ) + { + isOwnerInterpolatedFace[faceI] = true; + + const vector& fc = mesh.faceCentres()[faceI]; + + for (label zoneI = 0; zoneI < nZones; zoneI++) + { + if (zoneI != zoneID[mesh.faceOwner()[faceI]]) + { + const fvMesh& partMesh = meshParts[zoneI].subMesh(); + const labelList& cellMap = meshParts[zoneI].cellMap(); + label cellI = partMesh.findCell(fc); + + if (cellI != -1) + { + // Determine weights + labelList stencil(partMesh.cellCells()[cellI]); + + stencil.append(cellI); + + label st = stencil.size(); + + donorCell[faceI].setSize(st); + + weightCellCells[faceI].setSize(st); + + scalarField weights(st); + + forAll(stencil, i) + { + scalar d = mag + ( + partMesh.cellCentres()[stencil[i]] + - fc + ); + weights[i] = 1.0/d; + donorCell[faceI][i] = cellMap[stencil[i]]; + } + weights /= sum(weights); + + weightCellCells[faceI] = weights; + + forAll(stencil, i) + { + UIntFaces[faceI] += + weightCellCells[faceI][i] + *UInterpolator.interpolate + ( + fc, + donorCell[faceI][i] + ); + } + + break; + } + } + } + + receptorNeigCell[faceI] = mesh.faceNeighbour()[faceI]; + } + else if + ( + ownType == cellCellStencil::CALCULATED + && neiType == cellCellStencil::INTERPOLATED + ) + { + isNeiInterpolatedFace[faceI] = true; + + const vector& fc = mesh.faceCentres()[faceI]; + for (label zoneI = 0; zoneI < nZones; zoneI++) + { + if (zoneI != zoneID[mesh.faceNeighbour()[faceI]]) + { + const fvMesh& partMesh = meshParts[zoneI].subMesh(); + const labelList& cellMap = meshParts[zoneI].cellMap(); + label cellI = partMesh.findCell(fc); + + if (cellI != -1) + { + // Determine weights + labelList stencil(partMesh.cellCells()[cellI]); + + stencil.append(cellI); + + label st = stencil.size(); + + donorCell[faceI].setSize(st); + + weightCellCells[faceI].setSize(st); + + scalarField weights(st); + + forAll(stencil, i) + { + scalar d = mag + ( + partMesh.cellCentres()[stencil[i]] + - fc + ); + weights[i] = 1.0/d; + donorCell[faceI][i] = cellMap[stencil[i]]; + } + weights /= sum(weights); + + weightCellCells[faceI] = weights; + + forAll(stencil, i) + { + UIntFaces[faceI] += + weightCellCells[faceI][i] + *UInterpolator.interpolate + ( + fc, + donorCell[faceI][i] + ); + } + + break; + } + } + } + + receptorNeigCell[faceI] = mesh.faceOwner()[faceI]; + } + } +} + +// contravariant U +vectorField U1Contrav(mesh.nInternalFaces(), vector::zero); + +surfaceVectorField faceNormals(mesh.Sf()/mesh.magSf()); + +forAll(isNeiInterpolatedFace, faceI) +{ + label cellId = -1; + if (isNeiInterpolatedFace[faceI]) + { + cellId = mesh.faceNeighbour()[faceI]; + } + else if (isOwnerInterpolatedFace[faceI]) + { + cellId = mesh.faceOwner()[faceI]; + } + + if (cellId != -1) + { + const vector& n = faceNormals[faceI]; + vector n1 = vector::zero; + // 2-D cases + if (mesh.nSolutionD() == 2) + { + for (direction cmpt=0; cmpt mag(n.y()) && mag(n.x()) > mag(n.z())) + { + n1 = vector(n.y(), -n.x(), 0); + } + else if (mag(n.y()) > mag(n.z())) + { + n1 = vector(0, n.z(), -n.y()); + } + else + { + n1 = vector(-n.z(), 0, n.x()); + } + } + + n1 /= mag(n1); + + vector n2 = n ^ n1; + n2 /= mag(n2); + + tensor rot = + tensor + ( + n.x() ,n.y(), n.z(), + n1.x() ,n1.y(), n1.z(), + n2.x() ,n2.y(), n2.z() + ); + +// tensor rot = +// tensor +// ( +// n & x ,n & y, n & z, +// n1 & x ,n1 & y, n1 & z, +// n2 & x ,n2 & y, n2 & z +// ); + + U1Contrav[faceI].x() = + 2*transform(rot, UIntFaces[faceI]).x() + - transform(rot, HbyA[receptorNeigCell[faceI]]).x(); + + U1Contrav[faceI].y() = transform(rot, HbyA[cellId]).y(); + + U1Contrav[faceI].z() = transform(rot, HbyA[cellId]).z(); + + HbyA[cellId] = transform(inv(rot), U1Contrav[faceI]); + } +} diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pEqn.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pEqn.H new file mode 100644 index 0000000000..028dfe4306 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pEqn.H @@ -0,0 +1,109 @@ +volScalarField rAU(1.0/UEqn.A()); + +// Option 1: interpolate rAU, do not block out rAU on blocked cells +//mesh.interpolate(rAU, false); +//surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); + +// Option 2: do not interpolate rAU but block out rAU +//surfaceScalarField rAUf("rAUf", fvc::interpolate(blockedCells*rAU)); + + +// Option 3: do not interpolate rAU but zero out rAUf on faces on holes +// But what about: +// +// H +// H I C C C C +// H +// + +surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); +surfaceScalarField rAUf("rAUf", faceMask*fvc::interpolate(rAU)); + +volVectorField HbyA("HbyA", U); +HbyA = constrainHbyA(rAU*UEqn.H(), U, p); + +//mesh.interpolate(HbyA); +if (massFluxInterpolation) +{ + #include "interpolatedFaces.H" +} + +if (pimple.nCorrPISO() <= 1) +{ + tUEqn.clear(); +} + +surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA)); + +if (ddtCorr) +{ + phiHbyA += rAUf*fvc::ddtCorr(U, Uf); +} + +MRF.makeRelative(phiHbyA); + +if (p.needReference()) +{ + fvc::makeRelative(phiHbyA, U); + adjustPhi(phiHbyA, U, p); + fvc::makeAbsolute(phiHbyA, U); +} + +if (adjustFringe) +{ + fvc::makeRelative(phiHbyA, U); + oversetAdjustPhi(phiHbyA, U); + fvc::makeAbsolute(phiHbyA, U); +} + +if (runTime.outputTime()) +{ + volScalarField + ( + "div(phiHbyA)", + fvc::div(phiHbyA) + //interpolatedCells*cellMask*fvc::div(phiHbyA) + ).write(); +} + +while (pimple.correctNonOrthogonal()) +{ + fvScalarMatrix pEqn + ( + fvm::laplacian(rAUf, p) == fvc::div(phiHbyA) + ); + + pEqn.setReference(pRefCell, pRefValue); + + pEqn.solve(mesh.solver(p.select(pimple.finalInnerIter()))); + + if (pimple.finalNonOrthogonalIter()) + { + phi = phiHbyA - pEqn.flux(); + } +} + +#include "continuityErrs.H" + +// Explicitly relax pressure for momentum corrector +p.relax(); +volVectorField gradP(fvc::grad(p)); +//mesh.interpolate(gradP); + +// Option 1: leave velocity intact on blocked out cells +//U = HbyA - rAU*gradP; + +// Option 2: zero out velocity on blocked out cells +U = (HbyA - rAU*cellMask*gradP); +U.correctBoundaryConditions(); + +fvOptions.correct(U); + +{ + Uf = fvc::interpolate(U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + Uf += n*(phi/mesh.magSf() - (n & Uf)); +} + +// Make the fluxes relative to the mesh motion +fvc::makeRelative(phi, U); diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pimpleDyMFoam.C b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pimpleDyMFoam.C new file mode 100644 index 0000000000..f3dbd6a989 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/pimpleDyMFoam.C @@ -0,0 +1,157 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 + pimpleDyMFoam.C + +Group + grpIncompressibleSolvers grpMovingMeshSolvers + +Description + Transient solver for incompressible, flow of Newtonian fluids + on a moving mesh using the PIMPLE (merged PISO-SIMPLE) algorithm. + + Turbulence modelling is generic, i.e. laminar, RAS or LES may be selected. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dynamicFvMesh.H" +#include "singlePhaseTransportModel.H" +#include "turbulentTransportModel.H" +#include "pimpleControl.H" +#include "fvOptions.H" + +#include "cellCellStencilObject.H" +#include "zeroGradientFvPatchFields.H" +#include "localMin.H" +#include "interpolationCellPoint.H" +#include "transform.H" +#include "fvMeshSubset.H" +#include "oversetAdjustPhi.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addNote + ( + "Experimental version of pimpleDyMFoam with support for overset meshes" + ); + #include "setRootCase.H" + #include "createTime.H" + #include "createDynamicFvMesh.H" + #include "initContinuityErrs.H" + + pimpleControl pimple(mesh); + + #include "createFields.H" + #include "createUf.H" + #include "createMRF.H" + #include "createFvOptions.H" + #include "createControls.H" + #include "CourantNo.H" + #include "setInitialDeltaT.H" + + turbulence->validate(); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readControls.H" + #include "CourantNo.H" + + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + bool changed = mesh.update(); + + if (changed) + { + #include "setCellMask.H" + #include "setInterpolatedCells.H" + } + + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & Uf; + + if (runTime.outputTime()) + { + volScalarField + ( + "contPhi", + interpolatedCells*cellMask*fvc::div(phi) + ).write(); + } + + if (mesh.changing() && correctPhi) + { + #include "correctPhi.H" + } + + // Make the flux relative to the mesh motion + fvc::makeRelative(phi, U); + + if (mesh.changing() && checkMeshCourantNo) + { + #include "meshCourantNo.H" + } + + // --- Pressure-velocity PIMPLE corrector loop + while (pimple.loop()) + { + #include "UEqn.H" + + // --- Pressure corrector loop + while (pimple.correct()) + { + #include "pEqn.H" + } + + if (pimple.turbCorr()) + { + laminarTransport.correct(); + turbulence->correct(); + } + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/readControls.H b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/readControls.H new file mode 100644 index 0000000000..0141c85225 --- /dev/null +++ b/applications/solvers/incompressible/pimpleFoam/overPimpleDyMFoam/readControls.H @@ -0,0 +1,10 @@ +#include "readTimeControls.H" + +correctPhi = pimple.dict().lookupOrDefault("correctPhi", false); + +checkMeshCourantNo = pimple.dict().lookupOrDefault("checkMeshCourantNo", false); + +massFluxInterpolation = + pimple.dict().lookupOrDefault("massFluxInterpolation", false); + +ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true); diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/Make/files b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/Make/files new file mode 100644 index 0000000000..3294949edd --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/Make/files @@ -0,0 +1,3 @@ +simpleFoam.C + +EXE = $(FOAM_APPBIN)/overSimpleFoam diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/Make/options b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/Make/options new file mode 100644 index 0000000000..639b94132a --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/Make/options @@ -0,0 +1,25 @@ +EXE_INC = \ + -I. \ + -I$(FOAM_SOLVERS)/incompressible/pimpleFoam/overPimpleDyMFoam \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + +EXE_LIBS = \ + -lturbulenceModels \ + -lincompressibleTurbulenceModels \ + -lincompressibleTransportModels \ + -lfiniteVolume \ + -lfvOptions \ + -lsampling \ + -ldynamicFvMesh \ + -ltopoChangerFvMesh \ + -ldynamicMesh \ + -loverset diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/UEqn.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/UEqn.H new file mode 100644 index 0000000000..5e9861ccc3 --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/UEqn.H @@ -0,0 +1,21 @@ + // Momentum predictor + + MRF.correctBoundaryVelocity(U); + + tmp tUEqn + ( + fvm::div(phi, U) + + MRF.DDt(U) + + turbulence->divDevReff(U) + == + fvOptions(U) + ); + fvVectorMatrix& UEqn = tUEqn.ref(); + + UEqn.relax(); + + fvOptions.constrain(UEqn); + + solve(UEqn == -cellMask*fvc::grad(p)); + + fvOptions.correct(U); diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/continuityErrs.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/continuityErrs.H new file mode 100644 index 0000000000..c787055623 --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/continuityErrs.H @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +------------------------------------------------------------------------------- +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(interpolatedCells*cellMask*fvc::div(phi)); + + 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/incompressible/simpleFoam/overSimpleFoam/createFields.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createFields.H new file mode 100644 index 0000000000..b3d40776f4 --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createFields.H @@ -0,0 +1,47 @@ +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, simple.dict(), pRefCell, pRefValue); +mesh.setFluxRequired(p.name()); + + +singlePhaseTransportModel laminarTransport(U, phi); + +autoPtr turbulence +( + incompressible::turbulenceModel::New(U, phi, laminarTransport) +); + +#include "createMRF.H" + +#include "createOversetFields.H" diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createOversetFields.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createOversetFields.H new file mode 100644 index 0000000000..7eda905f50 --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createOversetFields.H @@ -0,0 +1,34 @@ +//- Overset specific + +// Add solver-specific interpolations +{ + dictionary oversetDict; + oversetDict.add("U", true); + oversetDict.add("p", true); + oversetDict.add("HbyA", true); + oversetDict.add("grad(p)", true); + + const_cast + ( + mesh.schemesDict() + ).add + ( + "oversetInterpolationRequired", + oversetDict, + true + ); +} + +// Mask field for zeroing out contributions on hole cells +#include "createCellMask.H" + +#include "createInterpolatedCells.H" + +bool adjustFringe +( + simple.dict().lookupOrDefault("oversetAdjustPhi", false) +); +bool massFluxInterpolation +( + simple.dict().lookupOrDefault("massFluxInterpolation", false) +); diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createUpdatedDynamicFvMesh.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createUpdatedDynamicFvMesh.H new file mode 100644 index 0000000000..db58f90828 --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/createUpdatedDynamicFvMesh.H @@ -0,0 +1,22 @@ + Info<< "Create dynamic mesh for time = " + << runTime.timeName() << nl << endl; + + autoPtr meshPtr + ( + dynamicFvMesh::New + ( + IOobject + ( + dynamicFvMesh::defaultRegion, + runTime.timeName(), + runTime, + IOobject::MUST_READ + ) + ) + ); + + dynamicFvMesh& mesh = meshPtr(); + + // Calculate initial mesh-to-mesh mapping. Note that this should be + // done under the hood, e.g. as a MeshObject + mesh.update(); diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/pEqn.H b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/pEqn.H new file mode 100644 index 0000000000..c64f92e33f --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/pEqn.H @@ -0,0 +1,57 @@ +{ + surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); + + volScalarField rAU(1.0/UEqn.A()); + surfaceScalarField rAUf("rAUf", faceMask*fvc::interpolate(rAU)); + + volVectorField HbyA("HbyA", U); + HbyA = constrainHbyA(rAU*UEqn.H(), U, p); + + //mesh.interpolate(HbyA); + if (massFluxInterpolation) + { + #include "interpolatedFaces.H" + } + + tUEqn.clear(); + + surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA)); + + adjustPhi(phiHbyA, U, p); + + if (adjustFringe) + { + oversetAdjustPhi(phiHbyA, U); + } + + // Non-orthogonal pressure corrector loop + while (simple.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvm::laplacian(rAUf, p) == fvc::div(phiHbyA) + ); + + pEqn.setReference(pRefCell, pRefValue); + + pEqn.solve(); + + if (simple.finalNonOrthogonalIter()) + { + phi = phiHbyA - pEqn.flux(); + } + } + + #include "continuityErrs.H" + + // Explicitly relax pressure for momentum corrector + p.relax(); + + // Momentum corrector + volVectorField gradP(fvc::grad(p)); + //mesh.interpolate(gradP); + + U = HbyA - rAU*cellMask*gradP; + U.correctBoundaryConditions(); + fvOptions.correct(U); +} diff --git a/applications/solvers/incompressible/simpleFoam/overSimpleFoam/simpleFoam.C b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/simpleFoam.C new file mode 100644 index 0000000000..4a7cf1315b --- /dev/null +++ b/applications/solvers/incompressible/simpleFoam/overSimpleFoam/simpleFoam.C @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 + simpleFoam + +Group + grpIncompressibleSolvers + +Description + Steady-state solver for incompressible flows with turbulence modelling. + + \heading Solver details + The solver uses the SIMPLE algorithm to solve the continuity equation: + + \f[ + \div \vec{U} = 0 + \f] + + and momentum equation: + + \f[ + \div \left( \vec{U} \vec{U} \right) - \div \gvec{R} + = - \grad p + \vec{S}_U + \f] + + Where: + \vartable + \vec{U} | Velocity + p | Pressure + \vec{R} | Stress tensor + \vec{S}_U | Momentum source + \endvartable + + \heading Required fields + \plaintable + U | Velocity [m/s] + p | Kinematic pressure, p/rho [m2/s2] + \ | As required by user selection + \endplaintable + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "singlePhaseTransportModel.H" +#include "turbulentTransportModel.H" +#include "simpleControl.H" +#include "fvOptions.H" + +#include "dynamicFvMesh.H" +#include "cellCellStencilObject.H" +#include "localMin.H" +#include "interpolationCellPoint.H" +#include "fvMeshSubset.H" +#include "transform.H" +#include "oversetAdjustPhi.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #define CREATE_MESH createUpdatedDynamicFvMesh.H + #include "postProcess.H" + + #include "setRootCase.H" + #include "createTime.H" + #include "createUpdatedDynamicFvMesh.H" + #include "createControl.H" + #include "createFields.H" + #include "createFvOptions.H" + #include "initContinuityErrs.H" + + turbulence->validate(); + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nStarting time loop\n" << endl; + + while (simple.loop()) + { + Info<< "Time = " << runTime.timeName() << nl << endl; + + // --- Pressure-velocity SIMPLE corrector + { + #include "UEqn.H" + #include "pEqn.H" + } + + laminarTransport.correct(); + turbulence->correct(); + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/CourantNo.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/CourantNo.H new file mode 100644 index 0000000000..4182f4e209 --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/CourantNo.H @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Global + CourantNo + +Description + Calculates and outputs the mean and maximum Courant Numbers. + +\*---------------------------------------------------------------------------*/ + +scalar CoNum = 0.0; +scalar meanCoNum = 0.0; + +if (mesh.nInternalFaces()) +{ + surfaceScalarField phiMask(localMin(mesh).interpolate(cellMask)); + + scalarField sumPhi + ( + fvc::surfaceSum(mag(phiMask*phi))().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/multiphase/interFoam/overInterDyMFoam/Make/files b/applications/solvers/multiphase/interFoam/overInterDyMFoam/Make/files new file mode 100644 index 0000000000..e229fbaed0 --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/Make/files @@ -0,0 +1,3 @@ +interDyMFoam.C + +EXE = $(FOAM_APPBIN)/overInterDyMFoam diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/Make/options b/applications/solvers/multiphase/interFoam/overInterDyMFoam/Make/options new file mode 100644 index 0000000000..3b8ac67af5 --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/Make/options @@ -0,0 +1,31 @@ +EXE_INC = \ + -I. \ + -I.. \ + -I../../VoF \ + -I$(LIB_SRC)/transportModels/twoPhaseMixture/lnInclude \ + -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/transportModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/interfaceProperties/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ + -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + -I$(LIB_SRC)/transportModels/immiscibleIncompressibleTwoPhaseMixture/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(FOAM_SOLVERS)/incompressible/pimpleFoam/overPimpleDyMFoam \ + -I$(LIB_SRC)/overset/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +EXE_LIBS = \ + -limmiscibleIncompressibleTwoPhaseMixture \ + -lturbulenceModels \ + -lincompressibleTurbulenceModels \ + -lfiniteVolume \ + -ldynamicMesh \ + -ldynamicFvMesh \ + -ltopoChangerFvMesh \ + -loverset \ + -lfvOptions \ + -lsampling \ + -lwaveModels diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/UEqn.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/UEqn.H new file mode 100644 index 0000000000..600c94829c --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/UEqn.H @@ -0,0 +1,33 @@ + MRF.correctBoundaryVelocity(U); + + fvVectorMatrix UEqn + ( + fvm::ddt(rho, U) + fvm::div(rhoPhi, U) + + MRF.DDt(rho, U) + + turbulence->divDevRhoReff(rho, U) + == + fvOptions(rho, U) + ); + + UEqn.relax(); + + fvOptions.constrain(UEqn); + + if (pimple.momentumPredictor()) + { + solve + ( + UEqn + == + cellMask*fvc::reconstruct + ( + ( + mixture.surfaceTensionForce() + - ghf*fvc::snGrad(rho) + - fvc::snGrad(p_rgh) + ) * mesh.magSf() + ) + ); + + fvOptions.correct(U); + } diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/continuityErrs.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/continuityErrs.H new file mode 100644 index 0000000000..c787055623 --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/continuityErrs.H @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. +------------------------------------------------------------------------------- +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(interpolatedCells*cellMask*fvc::div(phi)); + + 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/multiphase/interFoam/overInterDyMFoam/correctPhi.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/correctPhi.H new file mode 100644 index 0000000000..81948b54da --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/correctPhi.H @@ -0,0 +1,125 @@ +{ + if (mesh.changing()) + { + volVectorField::Boundary& bfld = U.boundaryFieldRef(); + forAll(bfld, patchi) + { + if (bfld[patchi].fixesValue()) + { + bfld[patchi].initEvaluate(); + } + } + + surfaceScalarField::Boundary& phiBfld = phi.boundaryFieldRef(); + forAll(bfld, patchi) + { + if (bfld[patchi].fixesValue()) + { + bfld[patchi].evaluate(); + + phiBfld[patchi] = + bfld[patchi] + & mesh.Sf().boundaryField()[patchi]; + } + } + } + + wordList pcorrTypes + ( + p_rgh.boundaryField().size(), + zeroGradientFvPatchScalarField::typeName + ); + + for (label i=0; i("correctPhi", true) +); + +bool checkMeshCourantNo +( + pimple.dict().lookupOrDefault("checkMeshCourantNo", false) +); + +bool moveMeshOuterCorrectors +( + pimple.dict().lookupOrDefault("moveMeshOuterCorrectors", false) +); + + +bool massFluxInterpolation +( + pimple.dict().lookupOrDefault("massFluxInterpolation", false) +); + +bool ddtCorr +( + pimple.dict().lookupOrDefault("ddtCorr", true) +); diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/createFields.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/createFields.H new file mode 100644 index 0000000000..4a83ab5850 --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/createFields.H @@ -0,0 +1,171 @@ +#include "createRDeltaT.H" + +Info<< "Reading field p_rgh\n" << endl; +volScalarField p_rgh +( + IOobject + ( + "p_rgh", + 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" + + + + //- Overset specific + + // Add solver-specific interpolations + { + dictionary oversetDict; + oversetDict.add("U", true); + oversetDict.add("p", true); + oversetDict.add("HbyA", true); + oversetDict.add("p_rgh", true); + oversetDict.add("alpha1", true); + oversetDict.add("minGradP", true); + + const_cast + ( + mesh.schemesDict() + ).add + ( + "oversetInterpolationRequired", + oversetDict, + true + ); + } + + // Mask field for zeroing out contributions on hole cells + #include "createCellMask.H" + + // Create bool field with interpolated cells + #include "createInterpolatedCells.H" + + + +Info<< "Reading transportProperties\n" << endl; +immiscibleIncompressibleTwoPhaseMixture mixture(U, phi); + +volScalarField& alpha1(mixture.alpha1()); +volScalarField& alpha2(mixture.alpha2()); + +const dimensionedScalar& rho1 = mixture.rho1(); +const dimensionedScalar& rho2 = mixture.rho2(); + + +// Need to store rho for ddt(rho, U) +volScalarField rho +( + IOobject + ( + "rho", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT + ), + alpha1*rho1 + alpha2*rho2 +); +rho.oldTime(); + + +// Mass flux +surfaceScalarField rhoPhi +( + IOobject + ( + "rhoPhi", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + fvc::interpolate(rho)*phi +); + + +// Construct incompressible turbulence model +autoPtr turbulence +( + incompressible::turbulenceModel::New(U, phi, mixture) +); + + +#include "readGravitationalAcceleration.H" +#include "readhRef.H" +#include "gh.H" + + +volScalarField p +( + IOobject + ( + "p", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + p_rgh + rho*gh +); + +label pRefCell = 0; +scalar pRefValue = 0.0; +setRefCell +( + p, + p_rgh, + pimple.dict(), + pRefCell, + pRefValue +); + +if (p_rgh.needReference()) +{ + p += dimensionedScalar + ( + "p", + p.dimensions(), + pRefValue - getRefCellValue(p, pRefCell) + ); + p_rgh = p - rho*gh; +} + +mesh.setFluxRequired(p_rgh.name()); +mesh.setFluxRequired(alpha1.name()); + +// MULES compressed flux is registered in case scalarTransport FO needs it. +surfaceScalarField alphaPhiUn +( + IOobject + ( + "alphaPhiUn", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", phi.dimensions(), 0.0) +); + +#include "createMRF.H" diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C new file mode 100644 index 0000000000..7bb7f8af6b --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C @@ -0,0 +1,209 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 + overInterDyMFoam + +Group + grpMultiphaseSolvers grpMovingMeshSolvers + +Description + Solver for 2 incompressible, isothermal immiscible fluids using a VOF + (volume of fluid) phase-fraction based interface capturing approach, + with optional mesh motion and mesh topology changes including adaptive + re-meshing. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "dynamicFvMesh.H" +#include "CMULES.H" +#include "EulerDdtScheme.H" +#include "localEulerDdtScheme.H" +#include "CrankNicolsonDdtScheme.H" +#include "subCycle.H" +#include "immiscibleIncompressibleTwoPhaseMixture.H" +#include "turbulentTransportModel.H" +#include "pimpleControl.H" +#include "fvOptions.H" +#include "CorrectPhi.H" +#include "fvcSmooth.H" +#include "cellCellStencilObject.H" +#include "localMin.H" +#include "interpolationCellPoint.H" +#include "transform.H" +#include "fvMeshSubset.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "postProcess.H" + + #include "setRootCase.H" + #include "createTime.H" + #include "createDynamicFvMesh.H" + #include "initContinuityErrs.H" + #include "createControl.H" + #include "createTimeControls.H" + #include "createDyMControls.H" + #include "createFields.H" + #include "createAlphaFluxes.H" + #include "createFvOptions.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" + + turbulence->validate(); + + if (!LTS) + { + #include "CourantNo.H" + #include "setInitialDeltaT.H" + } + + #include "setCellMask.H" + #include "setInterpolatedCells.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readControls.H" + + if (LTS) + { + #include "setRDeltaT.H" + } + else + { + #include "CourantNo.H" + #include "alphaCourantNo.H" + #include "setDeltaT.H" + } + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + // --- Pressure-velocity PIMPLE corrector loop + while (pimple.loop()) + { + if (pimple.firstIter() || moveMeshOuterCorrectors) + { + scalar timeBeforeMeshUpdate = runTime.elapsedCpuTime(); + + mesh.update(); + + if (mesh.changing()) + { + Info<< "Execution time for mesh.update() = " + << runTime.elapsedCpuTime() - timeBeforeMeshUpdate + << " s" << endl; + + // Do not apply previous time-step mesh compression flux + // if the mesh topology changed + if (mesh.topoChanging()) + { + talphaPhiCorr0.clear(); + } + + gh = (g & mesh.C()) - ghRef; + ghf = (g & mesh.Cf()) - ghRef; + + // Update cellMask field for blocking out hole cells + #include "setCellMask.H" + #include "setInterpolatedCells.H" + } + + if ((mesh.changing() && correctPhi) || mesh.topoChanging()) + { + // Calculate absolute flux from the mapped surface velocity + // Note: temporary fix until mapped Uf is assessed + Uf = fvc::interpolate(U); + + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & Uf; + + #include "correctPhi.H" + + // Make the flux relative to the mesh motion + fvc::makeRelative(phi, U); + + mixture.correct(); + } + + if (mesh.changing() && checkMeshCourantNo) + { + #include "meshCourantNo.H" + } + } + + #include "alphaControls.H" + #include "alphaEqnSubCycle.H" + + mixture.correct(); + + #include "UEqn.H" + + // --- Pressure corrector loop + while (pimple.correct()) + { + #include "pEqn.H" + } + + if (pimple.turbCorr()) + { + turbulence->correct(); + } + } + + runTime.write(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H new file mode 100644 index 0000000000..0a5b0296b8 --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H @@ -0,0 +1,96 @@ +{ + rAU = 1.0/UEqn.A(); + surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); + + surfaceScalarField rAUf("rAUf", fvc::interpolate(rAU)); + + volVectorField HbyA("HbyA", U); + //HbyA = rAU*UEqn.H(); + HbyA = constrainHbyA(rAU*UEqn.H(), U, p_rgh); + + if (massFluxInterpolation) + { + #include "interpolatedFaces.H" + } + + surfaceScalarField phiHbyA("phiHbyA", fvc::flux(HbyA)); + + if (ddtCorr) + { + phiHbyA += fvc::interpolate(rho*rAU)*fvc::ddtCorr(U, Uf); + } + MRF.makeRelative(phiHbyA); + + if (p_rgh.needReference()) + { + fvc::makeRelative(phiHbyA, U); + adjustPhi(phiHbyA, U, p_rgh); + fvc::makeAbsolute(phiHbyA, U); + } + + surfaceScalarField phig + ( + ( + mixture.surfaceTensionForce() + - ghf*fvc::snGrad(rho) + )*faceMask*rAUf*mesh.magSf() + ); + + phiHbyA += phig; + + // Update the pressure BCs to ensure flux consistency + constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF); + + while (pimple.correctNonOrthogonal()) + { + fvScalarMatrix p_rghEqn + ( + fvm::laplacian(faceMask*rAUf, p_rgh) == fvc::div(phiHbyA) + ); + + p_rghEqn.setReference(pRefCell, getRefCellValue(p_rgh, pRefCell)); + + p_rghEqn.solve(mesh.solver(p_rgh.select(pimple.finalInnerIter()))); + + if (pimple.finalNonOrthogonalIter()) + { + phi = phiHbyA - p_rghEqn.flux(); + + p_rgh.relax(); + + // Reconstruct body forces (-grad(p) and gh etc) + volVectorField minGradP + ( + "minGradP", + fvc::reconstruct((phig - p_rghEqn.flux())/rAUf) + ); + U = HbyA + rAU*cellMask*minGradP; + U.correctBoundaryConditions(); + fvOptions.correct(U); + } + } + + #include "continuityErrs.H" + + { + Uf = fvc::interpolate(U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + Uf += n*(phi/mesh.magSf() - (n & Uf)); + } + + // Make the fluxes relative to the mesh motion + fvc::makeRelative(phi, U); + + p == p_rgh + rho*gh; + + if (p_rgh.needReference()) + { + p += dimensionedScalar + ( + "p", + p.dimensions(), + pRefValue - getRefCellValue(p, pRefCell) + ); + p_rgh = p - rho*gh; + } +} diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H new file mode 100644 index 0000000000..0df2a74f30 --- /dev/null +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H @@ -0,0 +1,15 @@ +#include "readTimeControls.H" + +correctPhi = pimple.dict().lookupOrDefault("correctPhi", true); + +checkMeshCourantNo = + pimple.dict().lookupOrDefault("checkMeshCourantNo", false); + +moveMeshOuterCorrectors = + pimple.dict().lookupOrDefault("moveMeshOuterCorrectors", false); + +massFluxInterpolation = + pimple.dict().lookupOrDefault("massFluxInterpolation", false); + +ddtCorr = + pimple.dict().lookupOrDefault("ddtCorr", true); \ No newline at end of file diff --git a/applications/test/parallelOverset/Make/files b/applications/test/parallelOverset/Make/files new file mode 100644 index 0000000000..1a6be79787 --- /dev/null +++ b/applications/test/parallelOverset/Make/files @@ -0,0 +1,3 @@ +laplacianDyMFoam.C + +EXE = $(FOAM_USER_APPBIN)/correctBoundaryConditions diff --git a/applications/test/parallelOverset/Make/options b/applications/test/parallelOverset/Make/options new file mode 100644 index 0000000000..0dd7b75e80 --- /dev/null +++ b/applications/test/parallelOverset/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -DFULLDEBUG -g -O0 \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lsampling \ + -loverset diff --git a/applications/test/parallelOverset/createFields.H b/applications/test/parallelOverset/createFields.H new file mode 100644 index 0000000000..d14935caab --- /dev/null +++ b/applications/test/parallelOverset/createFields.H @@ -0,0 +1,53 @@ + Info<< "Reading field T\n" << endl; + + volScalarField T + ( + IOobject + ( + "T", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh + ); + + // Add overset specific interpolations + { + dictionary oversetDict; + oversetDict.add("T", true); + + const_cast + ( + mesh.schemesDict() + ).add + ( + "oversetInterpolationRequired", + oversetDict, + true + ); + } + + + Info<< "Reading transportProperties\n" << endl; + + IOdictionary transportProperties + ( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE + ) + ); + + + Info<< "Reading diffusivity DT\n" << endl; + + dimensionedScalar DT + ( + transportProperties.lookup("DT") + ); diff --git a/applications/test/parallelOverset/heatTransfer/0.org/T b/applications/test/parallelOverset/heatTransfer/0.org/T new file mode 100644 index 0000000000..a60edc4bb6 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/0.org/T @@ -0,0 +1,49 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform 273; + +boundaryField +{ + //- Set patchGroups for constraint patches + #include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes" + + "(walls|hole)" + { + type zeroGradient; + } + + left1 + { + type fixedValue; + value uniform 300; + } + + right1 + { + type fixedValue; + value uniform 273; + } + + overset + { + type overset; + } +} + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/0.org/pointDisplacement b/applications/test/parallelOverset/heatTransfer/0.org/pointDisplacement new file mode 100644 index 0000000000..a1dda3a417 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/0.org/pointDisplacement @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class pointVectorField; + object pointDisplacement; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 0 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + ".*" + { + type uniformFixedValue; + uniformValue (0 0 0); + } + + "(free|hole)" + { + patchType overset; + type uniformFixedValue; + uniformValue (0 0 0); +// uniformValue table +// ( +// (0.0 (0 0 0)) +// (1.0 (0.31 0 0)) +// (2.0 (0 0 0)) +// ); + } +} + + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/0.org/zoneID b/applications/test/parallelOverset/heatTransfer/0.org/zoneID new file mode 100644 index 0000000000..1a49886c28 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/0.org/zoneID @@ -0,0 +1,39 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev-OpenCFD.overlap | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object zoneID; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + //- Set patchGroups for constraint patches + #include "${WM_PROJECT_DIR}/etc/caseDicts/setConstraintTypes" + + overset + { + type overset; + } + + ".*" + { + type zeroGradient; + } +} + + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/Allclean b/applications/test/parallelOverset/heatTransfer/Allclean new file mode 100755 index 0000000000..323e09af05 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/Allclean @@ -0,0 +1,13 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial clean functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +cleanCase +rm -f constant/polyMesh/boundary +rm -f constant/polyMesh/zoneID + +rm -rf 0 + +# ----------------------------------------------------------------- end-of-file diff --git a/applications/test/parallelOverset/heatTransfer/Allrun.pre b/applications/test/parallelOverset/heatTransfer/Allrun.pre new file mode 100755 index 0000000000..19e4417a55 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/Allrun.pre @@ -0,0 +1,17 @@ +#!/bin/sh +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +runApplication blockMesh + +# Select cellSets +runApplication topoSet + +runApplication subsetMesh box -patch hole -overwrite + +# Select cellSets +runApplication -s zoneID topoSet + +rm -rf 0 && cp -r 0.org 0 + +# Use cellSets to write zoneID +runApplication setFields diff --git a/applications/test/parallelOverset/heatTransfer/constant/dynamicMeshDict b/applications/test/parallelOverset/heatTransfer/constant/dynamicMeshDict new file mode 100644 index 0000000000..69054196e6 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/constant/dynamicMeshDict @@ -0,0 +1,33 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object dynamicMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +motionSolverLibs ( "libfvMotionSolvers.so" ); + +solver displacementLaplacian; + +displacementLaplacianCoeffs +{ + diffusivity uniform 1; +} + +dynamicFvMesh dynamicOversetFvMesh; + +dynamicOversetFvMeshCoeffs +{ +// layerRelax 0.3; +} + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/constant/transportProperties b/applications/test/parallelOverset/heatTransfer/constant/transportProperties new file mode 100644 index 0000000000..2c17a95828 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/constant/transportProperties @@ -0,0 +1,41 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +DT DT [ 0 2 -1 0 0 0 0 ] 1; + +transportModel Newtonian; + +nu nu [ 0 2 -1 0 0 0 0 ] 1e-05; + +CrossPowerLawCoeffs +{ + nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06; + nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06; + m m [ 0 0 1 0 0 0 0 ] 1; + n n [ 0 0 0 0 0 0 0 ] 1; +} + +BirdCarreauCoeffs +{ + nu0 nu0 [ 0 2 -1 0 0 0 0 ] 1e-06; + nuInf nuInf [ 0 2 -1 0 0 0 0 ] 1e-06; + k k [ 0 0 1 0 0 0 0 ] 0; + n n [ 0 0 0 0 0 0 0 ] 1; +} + + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/blockMeshDict b/applications/test/parallelOverset/heatTransfer/system/blockMeshDict new file mode 100644 index 0000000000..c3dd3573eb --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/blockMeshDict @@ -0,0 +1,126 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: 1.5 | +| \\ / A nd | Web: http://www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + ( 0.00 0.0 0) + ( 1.00 0.0 0) + ( 1.00 1.0 0) + ( 0.00 1.0 0) + ( 0.00 0.0 1) + ( 1.00 0.0 1) + ( 1.00 1.0 1) + ( 0.00 1.0 1) + +//- 0 degrees + ( 0.25 0.25 0) + ( 0.75 0.25 0) + ( 0.75 0.75 0) + ( 0.25 0.75 0) + ( 0.25 0.25 1) + ( 0.75 0.25 1) + ( 0.75 0.75 1) + ( 0.25 0.75 1) + + +//- 45 degrees rotated +// ( 0.25 0.5 0) +// ( 0.5 0.25 0) +// ( 0.75 0.5 0) +// ( 0.5 0.75 0) +// ( 0.25 0.5 1) +// ( 0.5 0.25 1) +// ( 0.75 0.5 1) +// ( 0.5 0.75 1) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (18 18 1) simpleGrading (1 1 1) + + hex (8 9 10 11 12 13 14 15) movingZone (30 30 1) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + free + { + type overset; + faces + ( + (8 12 15 11) + (10 14 13 9) + (11 15 14 10) + ( 9 13 12 8) + ); + } + + walls + { + type patch; + faces + ( + (3 7 6 2) + (1 5 4 0) + ); + } + + // Populated by subsetMesh + hole + { + type patch; + faces (); + } + + frontAndBack + { + type empty; + faces + ( + (0 3 2 1) + (4 5 6 7) + ( 8 11 10 9) + (12 13 14 15) + ); + } + + left1 + { + type patch; + faces + ( + (0 4 7 3) + ); + } + right1 + { + type patch; + faces + ( + (2 6 5 1) + ); + } +); + + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/controlDict b/applications/test/parallelOverset/heatTransfer/system/controlDict new file mode 100644 index 0000000000..535f677519 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/controlDict @@ -0,0 +1,57 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// Make sure all preprocessing tools know about the 'overset' bc +libs ("liboverset.so"); + +DebugSwitches +{ + overset 1; + inverseDistance 1; +} + +application correctBoundaryConditions; //overLaplacianDyMFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 1; + +deltaT 0.1; + +writeControl timeStep; + +writeInterval 1; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 16; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable true; + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/decomposeParDict b/applications/test/parallelOverset/heatTransfer/system/decomposeParDict new file mode 100644 index 0000000000..b1fa24963f --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/decomposeParDict @@ -0,0 +1,44 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + note "mesh decomposition control dictionary"; + object decomposeParDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + + +//constraints +//{ +// localOverset +// { +// //- Keep donor and acceptor on same processor +// type localOverset; +// } +//} + +method hierarchical; + +hierarchicalCoeffs +{ + n (1 2 1); + delta 0.001; + order xyz; +} + +manualCoeffs +{ + dataFile "decompositionData"; +} + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/fvSchemes b/applications/test/parallelOverset/heatTransfer/system/fvSchemes new file mode 100644 index 0000000000..43c631a1f2 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/fvSchemes @@ -0,0 +1,85 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default steadyState; +} + +gradSchemes +{ + default Gauss linear; + grad(T) Gauss linear; +} + +divSchemes +{ + default none; + div(phi,U) bounded Gauss limitedLinearV 1; + div(phi,k) bounded Gauss limitedLinear 1; + div(phi,epsilon) bounded Gauss limitedLinear 1; + div(phi,R) bounded Gauss limitedLinear 1; + div(R) Gauss linear; + div(phi,nuTilda) bounded Gauss limitedLinear 1; + div((nuEff*dev(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; + laplacian(diffusivity,cellDisplacement) Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + pcorr ; + p ; +} + +oversetInterpolation +{ + // Interpolation scheme to use for overset calculation + method inverseDistance; + + // The inverseDistance method uses a 'voxel' like search structure. + // Optionally specify the extent and number of divisions n. + // Note that it will allocate an array of nx*ny*nz. If not specified: + // - searchBox : local mesh bounding box + // - searchBoxDivisions : root (2D) or cube-root(3D) of number of cells + searchBox (0 0 0)(1 1 1); + searchBoxDivisions (100 100 1); +} + + +oversetInterpolationRequired +{ + // Any additional fields that require overset interpolation +} + + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/fvSolution b/applications/test/parallelOverset/heatTransfer/system/fvSolution new file mode 100644 index 0000000000..66c7f94747 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/fvSolution @@ -0,0 +1,77 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + T + { + solver PBiCGStab; + preconditioner DILU; + + //solver GAMG; + //smoother DILUGaussSeidel; + //agglomerator algebraicPair; + //processorAgglomerator none; + + tolerance 1e-10; + relTol 0; + } + + cellDisplacement + { + solver PCG; + preconditioner DIC; + + tolerance 1e-06; + relTol 0; + maxIter 100; + } + + +} + +SIMPLE +{ + nNonOrthogonalCorrectors 0; //2; +} + + +PIMPLE +{ + correctPhi yes; + nOuterCorrectors 2; + nCorrectors 1; + nNonOrthogonalCorrectors 0; +} + + +relaxationFactors +{ + fields + { + p 0.3; + } + equations + { + U 0.7; + k 0.7; + omega 0.7; + } +} + + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/postProcessingDict b/applications/test/parallelOverset/heatTransfer/system/postProcessingDict new file mode 100644 index 0000000000..8fe6333aa0 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/postProcessingDict @@ -0,0 +1,35 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object postProcessingDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +functions +{ + processorField1 + { + // Type of functionObject + type processorField; + + // Where to load it from (if not already in solver) + libs ("libfieldFunctionObjects.so"); + + // Function object enabled flag + enabled true; + + // When to output the average fields + writeControl writeTime; + } +} + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/processorField b/applications/test/parallelOverset/heatTransfer/system/processorField new file mode 100644 index 0000000000..6b41df60e4 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/processorField @@ -0,0 +1,32 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object postProcessingDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +processorField +{ + // Type of functionObject + type processorField; + + // Where to load it from (if not already in solver) + libs ("libfieldFunctionObjects.so"); + + // Function object enabled flag + enabled true; + + // When to output the average fields + writeControl timeStep; +} + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/setFieldsDict b/applications/test/parallelOverset/heatTransfer/system/setFieldsDict new file mode 100644 index 0000000000..2ebc58f23a --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/setFieldsDict @@ -0,0 +1,48 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue zoneID 123 +); + +regions +( + // Set cell values + // (does zerogradient on boundaries) + cellToCell + { + set c0; + + fieldValues + ( + volScalarFieldValue zoneID 0 + ); + } + + cellToCell + { + set c1; + + fieldValues + ( + volScalarFieldValue zoneID 1 + ); + } + +); + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/heatTransfer/system/topoSetDict b/applications/test/parallelOverset/heatTransfer/system/topoSetDict new file mode 100644 index 0000000000..06a8182d40 --- /dev/null +++ b/applications/test/parallelOverset/heatTransfer/system/topoSetDict @@ -0,0 +1,80 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object topoSetDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +actions +( + { + name c0; + type cellSet; + action new; + source regionToCell; + sourceInfo + { + insidePoints ((0.001 0.001 0.001)); + } + } + + { + name c1; + type cellSet; + action new; + source cellToCell; + sourceInfo + { + set c0; + } + } + + { + name c1; + type cellSet; + action invert; + } + + + // Select box to remove from region 1 + + { + name box; + type cellSet; + action new; + source cellToCell; + sourceInfo + { + set c1; + } + } + + + { + name box; + type cellSet; + action subset; + source boxToCell; + sourceInfo + { + box (0.4 0.4 -100)(0.6 0.6 100); + } + } + + { + name box; + type cellSet; + action invert; + } +); + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/laplacianDyMFoam.C b/applications/test/parallelOverset/laplacianDyMFoam.C new file mode 100644 index 0000000000..ea06cd7d3a --- /dev/null +++ b/applications/test/parallelOverset/laplacianDyMFoam.C @@ -0,0 +1,125 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 + laplacianFoam + +Group + grpBasicSolvers + +Description + Laplace equation solver for a scalar quantity. + + \heading Solver details + The solver is applicable to, e.g. for thermal diffusion in a solid. The + equation is given by: + + \f[ + \ddt{T} = \div \left( D_T \grad T \right) + \f] + + Where: + \vartable + T | Scalar field which is solved for, e.g. temperature + D_T | Diffusion coefficient + \endvartable + + \heading Required fields + \plaintable + T | Scalar field which is solved for, e.g. temperature + \endplaintable + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "simpleControl.H" +#include "dynamicFvMesh.H" +#include "dynamicOversetFvMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + + #include "createTime.H" + #include "createNamedDynamicFvMesh.H" + + simpleControl simple(mesh); + + #include "createFields.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< "\nCorrecting boundary conditions on " << T.name() << nl << endl; + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + Info<< "Reading : ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + + mesh.update(); + + Info<< "Overset calculation : ExecutionTime = " + << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + + + if (false) + { + // Test correctBoundaryConditions + + // Change the internalField + component(T.ref(), mesh.C(), 0); + component(T.ref(), mesh.C(), 1); + // Interpolate + halo swap + T.correctBoundaryConditions(); + // Check halo swap + dynamicOversetFvMesh::checkCoupledBC(T); + } + if (true) + { + // Test solving + fvScalarMatrix TEqn(fvm::laplacian(DT, T)); + TEqn.solve(); + } + + runTime.write(); + + + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/test/parallelOverset/write.H b/applications/test/parallelOverset/write.H new file mode 100644 index 0000000000..47aa182c0a --- /dev/null +++ b/applications/test/parallelOverset/write.H @@ -0,0 +1,46 @@ + if (runTime.outputTime()) + { + volVectorField gradT(fvc::grad(T)); + + volScalarField gradTx + ( + IOobject + ( + "gradTx", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + gradT.component(vector::X) + ); + + volScalarField gradTy + ( + IOobject + ( + "gradTy", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + gradT.component(vector::Y) + ); + + volScalarField gradTz + ( + IOobject + ( + "gradTz", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + gradT.component(vector::Z) + ); + + + runTime.write(); + } diff --git a/applications/test/wallDistDyM/Make/files b/applications/test/wallDistDyM/Make/files new file mode 100644 index 0000000000..c84f5e72f5 --- /dev/null +++ b/applications/test/wallDistDyM/Make/files @@ -0,0 +1,3 @@ +Test-wallDistDyM.C + +EXE = $(FOAM_USER_APPBIN)/Test-wallDistDyM diff --git a/applications/test/wallDistDyM/Make/options b/applications/test/wallDistDyM/Make/options new file mode 100644 index 0000000000..8a9d17bf25 --- /dev/null +++ b/applications/test/wallDistDyM/Make/options @@ -0,0 +1,9 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -ldynamicFvMesh diff --git a/applications/test/wallDistDyM/Test-wallDistDyM.C b/applications/test/wallDistDyM/Test-wallDistDyM.C new file mode 100644 index 0000000000..cfa1bbb8be --- /dev/null +++ b/applications/test/wallDistDyM/Test-wallDistDyM.C @@ -0,0 +1,69 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. +------------------------------------------------------------------------------- +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 . + +Description + Calculate and write the distance-to-wall field for a moving mesh. + +\*---------------------------------------------------------------------------*/ + +#include "argList.H" +#include "Time.H" +#include "dynamicFvMesh.H" +#include "wallDist.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +// Main program: + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createDynamicFvMesh.H" + + Info<< "Mesh read in = " + << runTime.cpuTimeIncrement() + << " s\n" << endl << endl; + + // Calculate initial mesh-to-mesh mapping. Note that this should be + // done under the hood, e.g. as a MeshObject + mesh.update(); + + Info<< "Time now = " << runTime.timeName() << endl; + + // Wall-reflection vectors + const volVectorField& n = wallDist::New(mesh).n(); + n.write(); + + // Wall distance + const volScalarField& y = wallDist::New(mesh).y(); + y.write(); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C index 2739ecedd7..ec10dbb003 100644 --- a/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C +++ b/applications/utilities/mesh/manipulation/mergeOrSplitBaffles/mergeOrSplitBaffles.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -177,7 +177,7 @@ void insertDuplicateMerge label patchSize(const polyMesh& mesh, const labelList& patchIDs) { const polyBoundaryMesh& patches = mesh.boundaryMesh(); - + label sz = 0; forAll(patchIDs, i) { @@ -191,7 +191,7 @@ label patchSize(const polyMesh& mesh, const labelList& patchIDs) labelList patchFaces(const polyMesh& mesh, const labelList& patchIDs) { const polyBoundaryMesh& patches = mesh.boundaryMesh(); - + labelList faceIDs(patchSize(mesh, patchIDs)); label sz = 0; forAll(patchIDs, i) diff --git a/etc/caseDicts/setConstraintTypes b/etc/caseDicts/setConstraintTypes index 4fc38fabf0..2098261a27 100644 --- a/etc/caseDicts/setConstraintTypes +++ b/etc/caseDicts/setConstraintTypes @@ -64,5 +64,10 @@ wedge type wedge; } +overset +{ + type overset; +} + // ************************************************************************* // diff --git a/src/Allwmake b/src/Allwmake index 1e71c42e0c..abe861514e 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -54,6 +54,8 @@ wmake $targetType topoChangerFvMesh parallel/Allwmake $targetType $* randomProcesses/Allwmake $targetType $* +wmake $targetType overset + wmake $targetType ODE wmake $targetType fvMotionSolver diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H index 289649f2a9..e1fd26b6c1 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduInterfaceField/LduInterfaceField.H @@ -97,6 +97,7 @@ public: virtual void initInterfaceMatrixUpdate ( Field&, + const bool add, const Field&, const scalarField&, const Pstream::commsTypes commsType @@ -110,6 +111,7 @@ public: virtual void updateInterfaceMatrix ( Field&, + const bool add, const Field&, const scalarField&, const Pstream::commsTypes commsType diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H index f96d583b1f..bcc35cc0ed 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrix.H @@ -617,6 +617,7 @@ public: // for matrix operations void initMatrixInterfaces ( + const bool add, const FieldField& interfaceCoeffs, const Field& psiif, Field& result @@ -625,6 +626,7 @@ public: //- Update interfaced interfaces for matrix operations void updateMatrixInterfaces ( + const bool add, const FieldField& interfaceCoeffs, const Field& psiif, Field& result diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C index 0aa6d26063..84c61a3c67 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixATmul.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -82,6 +82,7 @@ void Foam::LduMatrix::Amul // Initialise the update of interfaced interfaces initMatrixInterfaces ( + true, interfacesUpper_, psi, Apsi @@ -104,6 +105,7 @@ void Foam::LduMatrix::Amul // Update interface interfaces updateMatrixInterfaces ( + true, interfacesUpper_, psi, Apsi @@ -136,6 +138,7 @@ void Foam::LduMatrix::Tmul // Initialise the update of interfaced interfaces initMatrixInterfaces ( + true, interfacesLower_, psi, Tpsi @@ -157,6 +160,7 @@ void Foam::LduMatrix::Tmul // Update interface interfaces updateMatrixInterfaces ( + true, interfacesLower_, psi, Tpsi @@ -237,20 +241,11 @@ void Foam::LduMatrix::residual // Note: there is a change of sign in the coupled // interface update to add the contibution to the r.h.s. - FieldField mBouCoeffs(interfacesUpper_.size()); - - forAll(mBouCoeffs, patchi) - { - if (interfaces_.set(patchi)) - { - mBouCoeffs.set(patchi, -interfacesUpper_[patchi]); - } - } - // Initialise the update of interfaced interfaces initMatrixInterfaces ( - mBouCoeffs, + false, // negate interface contributions + interfacesUpper_, psi, rA ); @@ -272,7 +267,8 @@ void Foam::LduMatrix::residual // Update interface interfaces updateMatrixInterfaces ( - mBouCoeffs, + false, + interfacesUpper_, psi, rA ); diff --git a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C index 465c097bf0..123cc71a10 100644 --- a/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C +++ b/src/OpenFOAM/matrices/LduMatrix/LduMatrix/LduMatrixUpdateMatrixInterfaces.C @@ -31,6 +31,7 @@ License template void Foam::LduMatrix::initMatrixInterfaces ( + const bool add, const FieldField& interfaceCoeffs, const Field& psiif, Field& result @@ -49,6 +50,7 @@ void Foam::LduMatrix::initMatrixInterfaces interfaces_[interfacei].initInterfaceMatrixUpdate ( result, + add, psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), @@ -75,6 +77,7 @@ void Foam::LduMatrix::initMatrixInterfaces interfaces_[interfacei].initInterfaceMatrixUpdate ( result, + add, psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), @@ -96,6 +99,7 @@ void Foam::LduMatrix::initMatrixInterfaces template void Foam::LduMatrix::updateMatrixInterfaces ( + const bool add, const FieldField& interfaceCoeffs, const Field& psiif, Field& result @@ -121,6 +125,7 @@ void Foam::LduMatrix::updateMatrixInterfaces interfaces_[interfacei].updateInterfaceMatrix ( result, + add, psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), @@ -145,6 +150,7 @@ void Foam::LduMatrix::updateMatrixInterfaces interfaces_[interfacei].initInterfaceMatrixUpdate ( result, + add, psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), @@ -156,6 +162,7 @@ void Foam::LduMatrix::updateMatrixInterfaces interfaces_[interfacei].updateInterfaceMatrix ( result, + add, psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), @@ -179,6 +186,7 @@ void Foam::LduMatrix::updateMatrixInterfaces interfaces_[interfacei].updateInterfaceMatrix ( result, + add, psiif, interfaceCoeffs[interfacei], //Amultiplier(interfaceCoeffs[interfacei]), diff --git a/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.C b/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.C index b37ceaa5ba..29cad04bb8 100644 --- a/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.C +++ b/src/OpenFOAM/matrices/LduMatrix/Smoothers/GaussSeidel/TGaussSeidelSmoother.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -91,30 +91,22 @@ void Foam::TGaussSeidelSmoother::smooth // Note: there is a change of sign in the coupled // interface update to add the contibution to the r.h.s. - FieldField mBouCoeffs(matrix_.interfacesUpper().size()); - - forAll(mBouCoeffs, patchi) - { - if (matrix_.interfaces().set(patchi)) - { - mBouCoeffs.set(patchi, -matrix_.interfacesUpper()[patchi]); - } - } - for (label sweep=0; sweep + void addToInternalField + ( + Field& result, + const bool add, + const scalarField& coeffs, + const Field& vals + ) const; }; @@ -160,6 +175,12 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +#ifdef NoRepository + #include "lduInterfaceFieldTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + #endif // ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceFieldTemplates.C b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceFieldTemplates.C new file mode 100644 index 0000000000..12af278846 --- /dev/null +++ b/src/OpenFOAM/matrices/lduMatrix/lduAddressing/lduInterfaceFields/lduInterfaceField/lduInterfaceFieldTemplates.C @@ -0,0 +1,56 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 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 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 . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::lduInterfaceField::addToInternalField +( + Field& result, + const bool add, + const scalarField& coeffs, + const Field& vals +) const +{ + const labelUList& faceCells = this->interface().faceCells(); + + if (add) + { + forAll(faceCells, elemI) + { + result[faceCells[elemI]] += coeffs[elemI]*vals[elemI]; + } + } + else + { + forAll(faceCells, elemI) + { + result[faceCells[elemI]] -= coeffs[elemI]*vals[elemI]; + } + } +} + + +// ************************************************************************* // diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H index 4ef5055cfb..38301514e9 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrix.H @@ -672,6 +672,7 @@ public: // for matrix operations void initMatrixInterfaces ( + const bool add, const FieldField& interfaceCoeffs, const lduInterfaceFieldPtrsList& interfaces, const scalarField& psiif, @@ -682,6 +683,7 @@ public: //- Update interfaced interfaces for matrix operations void updateMatrixInterfaces ( + const bool add, const FieldField& interfaceCoeffs, const lduInterfaceFieldPtrsList& interfaces, const scalarField& psiif, diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C index 715fb420ba..ac34041851 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixATmul.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,6 +56,7 @@ void Foam::lduMatrix::Amul // Initialise the update of interfaced interfaces initMatrixInterfaces ( + true, interfaceBouCoeffs, interfaces, psi, @@ -81,6 +82,7 @@ void Foam::lduMatrix::Amul // Update interface interfaces updateMatrixInterfaces ( + true, interfaceBouCoeffs, interfaces, psi, @@ -117,6 +119,7 @@ void Foam::lduMatrix::Tmul // Initialise the update of interfaced interfaces initMatrixInterfaces ( + true, interfaceIntCoeffs, interfaces, psi, @@ -140,6 +143,7 @@ void Foam::lduMatrix::Tmul // Update interface interfaces updateMatrixInterfaces ( + true, interfaceIntCoeffs, interfaces, psi, @@ -233,20 +237,11 @@ void Foam::lduMatrix::residual // To compensate for this, it is necessary to turn the // sign of the contribution. - FieldField mBouCoeffs(interfaceBouCoeffs.size()); - - forAll(mBouCoeffs, patchi) - { - if (interfaces.set(patchi)) - { - mBouCoeffs.set(patchi, -interfaceBouCoeffs[patchi]); - } - } - // Initialise the update of interfaced interfaces initMatrixInterfaces ( - mBouCoeffs, + false, + interfaceBouCoeffs, interfaces, psi, rA, @@ -271,7 +266,8 @@ void Foam::lduMatrix::residual // Update interface interfaces updateMatrixInterfaces ( - mBouCoeffs, + false, + interfaceBouCoeffs, interfaces, psi, rA, diff --git a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C index af65e1bc68..28dc38f75c 100644 --- a/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C +++ b/src/OpenFOAM/matrices/lduMatrix/lduMatrix/lduMatrixUpdateMatrixInterfaces.C @@ -29,6 +29,7 @@ License void Foam::lduMatrix::initMatrixInterfaces ( + const bool add, const FieldField& coupleCoeffs, const lduInterfaceFieldPtrsList& interfaces, const scalarField& psiif, @@ -49,6 +50,7 @@ void Foam::lduMatrix::initMatrixInterfaces interfaces[interfacei].initInterfaceMatrixUpdate ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, @@ -75,6 +77,7 @@ void Foam::lduMatrix::initMatrixInterfaces interfaces[interfacei].initInterfaceMatrixUpdate ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, @@ -95,6 +98,7 @@ void Foam::lduMatrix::initMatrixInterfaces void Foam::lduMatrix::updateMatrixInterfaces ( + const bool add, const FieldField& coupleCoeffs, const lduInterfaceFieldPtrsList& interfaces, const scalarField& psiif, @@ -111,6 +115,7 @@ void Foam::lduMatrix::updateMatrixInterfaces interfaces[interfacei].updateInterfaceMatrix ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, @@ -139,6 +144,7 @@ void Foam::lduMatrix::updateMatrixInterfaces interfaces[interfacei].updateInterfaceMatrix ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, @@ -190,6 +196,7 @@ void Foam::lduMatrix::updateMatrixInterfaces interfaces[interfacei].updateInterfaceMatrix ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, @@ -214,6 +221,7 @@ void Foam::lduMatrix::updateMatrixInterfaces interfaces[interfacei].initInterfaceMatrixUpdate ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, @@ -225,6 +233,7 @@ void Foam::lduMatrix::updateMatrixInterfaces interfaces[interfacei].updateInterfaceMatrix ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, @@ -248,6 +257,7 @@ void Foam::lduMatrix::updateMatrixInterfaces interfaces[interfacei].updateInterfaceMatrix ( result, + add, psiif, coupleCoeffs[interfacei], cmpt, diff --git a/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C b/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C index b233813d31..40c5892a69 100644 --- a/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C +++ b/src/OpenFOAM/matrices/lduMatrix/smoothers/GaussSeidel/GaussSeidelSmoother.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -107,28 +107,14 @@ void Foam::GaussSeidelSmoother::smooth // To compensate for this, it is necessary to turn the // sign of the contribution. - FieldField& mBouCoeffs = - const_cast&> - ( - interfaceBouCoeffs_ - ); - - forAll(mBouCoeffs, patchi) - { - if (interfaces_.set(patchi)) - { - mBouCoeffs[patchi].negate(); - } - } - - for (label sweep=0; sweep& mBouCoeffs = - const_cast&> - ( - interfaceBouCoeffs_ - ); - forAll(mBouCoeffs, patchi) - { - if (interfaces_.set(patchi)) - { - mBouCoeffs[patchi].negate(); - } - } for (label sweep=0; sweep& mBouCoeffs = - const_cast&> - ( - interfaceBouCoeffs_ - ); - - forAll(mBouCoeffs, patchi) - { - if (interfaces_.set(patchi)) - { - mBouCoeffs[patchi].negate(); - } - } - - for (label sweep=0; sweepaddToInternalField(result, !add, coeffs, pnf); } diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H index f9068707ca..6402e5efd1 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/cyclicGAMGInterfaceField/cyclicGAMGInterfaceField.H @@ -146,6 +146,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C index 852caef35f..3f77067f06 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.C @@ -93,6 +93,7 @@ Foam::processorGAMGInterfaceField::~processorGAMGInterfaceField() void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate ( scalarField&, + const bool, const scalarField& psiInternal, const scalarField&, const direction, @@ -148,6 +149,7 @@ void Foam::processorGAMGInterfaceField::initInterfaceMatrixUpdate void Foam::processorGAMGInterfaceField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField&, const scalarField& coeffs, const direction cmpt, @@ -162,8 +164,6 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix label oldWarn = UPstream::warnComm; UPstream::warnComm = comm(); - const labelUList& faceCells = procInterface_.faceCells(); - if ( commsType == Pstream::commsTypes::nonBlocking @@ -189,10 +189,7 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix transformCoupleField(scalarReceiveBuf_, cmpt); // Multiply the field by coefficients and add into the result - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*scalarReceiveBuf_[elemI]; - } + addToInternalField(result, !add, coeffs, scalarReceiveBuf_); } else { @@ -202,10 +199,7 @@ void Foam::processorGAMGInterfaceField::updateInterfaceMatrix ); transformCoupleField(pnf, cmpt); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + addToInternalField(result, !add, coeffs, pnf); } const_cast(*this).updatedMatrix() = true; diff --git a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H index be57260c44..acf48e7e15 100644 --- a/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H +++ b/src/OpenFOAM/matrices/lduMatrix/solvers/GAMG/interfaceFields/processorGAMGInterfaceField/processorGAMGInterfaceField.H @@ -135,6 +135,7 @@ public: virtual void initInterfaceMatrixUpdate ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -145,6 +146,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, diff --git a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.H b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.H index 7561554b64..3c62577e4a 100644 --- a/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.H +++ b/src/OpenFOAM/meshes/lduMesh/lduPrimitiveMesh.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,21 +78,6 @@ class lduPrimitiveMesh //- Get size of all meshes static label totalSize(const PtrList&); - static labelList upperTriOrder - ( - const label nCells, - const labelUList& lower, - const labelUList& upper - ); - - //- Check if in upper-triangular ordering - static void checkUpperTriangular - ( - const label size, - const labelUList& l, - const labelUList& u - ); - //- Disallow default bitwise copy construct lduPrimitiveMesh(const lduPrimitiveMesh&); @@ -261,6 +246,21 @@ public: template static lduSchedule nonBlockingSchedule(const lduInterfacePtrsList&); + //- Calculate upper-triangular order + static labelList upperTriOrder + ( + const label nCells, + const labelUList& lower, + const labelUList& upper + ); + + //- Check if in upper-triangular ordering + static void checkUpperTriangular + ( + const label size, + const labelUList& l, + const labelUList& u + ); }; diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C index 04d7e7fbdc..4f1edca365 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshTetDecomposition/polyMeshTetDecomposition.C @@ -311,7 +311,7 @@ Foam::labelList Foam::polyMeshTetDecomposition::findFaceBasePts { FatalErrorInFunction << "Coupled face base point exchange failure for face " - << fI + << fI << " at " << mesh.faceCentres()[fI] << abort(FatalError); } @@ -552,6 +552,7 @@ Foam::List Foam::polyMeshTetDecomposition::faceTetIndices { WarningInFunction << "No base point for face " << fI << ", " << f + << ", vertices " << UIndirectList(mesh.points(), f) << ", produces a valid tet decomposition." << endl; nWarnings++; @@ -616,6 +617,7 @@ Foam::tetIndices Foam::polyMeshTetDecomposition::triangleTetIndices { WarningInFunction << "No base point for face " << fI << ", " << f + << ", vertices " << UIndirectList(mesh.points(), f) << ", produces a valid tet decomposition." << endl; nWarnings++; diff --git a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H.orig b/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H.orig deleted file mode 100644 index 9b725409dc..0000000000 --- a/src/TurbulenceModels/compressible/turbulentFluidThermoModels/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.H.orig +++ /dev/null @@ -1,219 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | -<<<<<<< HEAD - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd -======= - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | ->>>>>>> d2a62df7c -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::compressible:: - turbulentTemperatureRadCoupledMixedFvPatchScalarField - -Description - Mixed boundary condition for temperature and radiation heat transfer - to be used for in multiregion cases. Optional thin thermal layer - resistances can be specified through thicknessLayers and kappaLayers - entries. - - The thermal conductivity \c kappa can either be retrieved from various - possible sources, as detailed in the class temperatureCoupledBase. - -Usage - \table - Property | Description | Required | Default value - Tnbr | name of the field | no | T - qrNbr | name of the radiative flux in the nbr region | no | none - qr | name of the radiative flux in this region | no | none - thicknessLayers | list of thicknesses per layer [m] | no | - kappaLayers | list of thermal conductivites per layer [W/m/K] | no | - kappaMethod | inherited from temperatureCoupledBase | inherited | - kappa | inherited from temperatureCoupledBase | inherited | - thermalInertia | Add thermal inertia to wall node | no | false - \endtable - - Example of the boundary condition specification: - \verbatim - - { - type compressible::turbulentTemperatureRadCoupledMixed; - Tnbr T; - qrNbr qr; // or none. Name of qr field on neighbour region - qr qr; // or none. Name of qr field on local region - thicknessLayers (0.1 0.2 0.3 0.4); - kappaLayers (1 2 3 4); - thermalInertia false/true; - kappaMethod lookup; - kappa kappa; - value uniform 300; - } - \endverbatim - - Needs to be on underlying mapped(Wall)FvPatch. - -See also - Foam::temperatureCoupledBase - -SourceFiles - turbulentTemperatureRadCoupledMixedFvPatchScalarField.C - -\*---------------------------------------------------------------------------*/ - -#ifndef turbulentTemperatureRadCoupledMixedFvPatchScalarField_H -#define turbulentTemperatureRadCoupledMixedFvPatchScalarField_H - -#include "mixedFvPatchFields.H" -#include "temperatureCoupledBase.H" -#include "scalarList.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -namespace compressible -{ - -/*---------------------------------------------------------------------------*\ - Class turbulentTemperatureRadCoupledMixedFvPatchScalarField Declaration -\*---------------------------------------------------------------------------*/ - -class turbulentTemperatureRadCoupledMixedFvPatchScalarField -: - public mixedFvPatchScalarField, - public temperatureCoupledBase -{ - // Private data - - //- Name of field on the neighbour region - const word TnbrName_; - - //- Name of the radiative heat flux in the neighbout region - const word qrNbrName_; - - //- Name of the radiative heat flux in local region - const word qrName_; - - //- Thickness of layers - scalarList thicknessLayers_; - - //- Conductivity of layers - scalarList kappaLayers_; - - //- Total contact resistance - scalar contactRes_; - - //- Thermal inertia term - Switch thermalInertia_; - - -public: - - //- Runtime type information - TypeName("compressible::turbulentTemperatureRadCoupledMixed"); - - - // Constructors - - //- Construct from patch and internal field - turbulentTemperatureRadCoupledMixedFvPatchScalarField - ( - const fvPatch&, - const DimensionedField& - ); - - //- Construct from patch, internal field and dictionary - turbulentTemperatureRadCoupledMixedFvPatchScalarField - ( - const fvPatch&, - const DimensionedField&, - const dictionary& - ); - - //- Construct by mapping given - // turbulentTemperatureCoupledBaffleMixedFvPatchScalarField onto a - // new patch - turbulentTemperatureRadCoupledMixedFvPatchScalarField - ( - const - turbulentTemperatureRadCoupledMixedFvPatchScalarField&, - const fvPatch&, - const DimensionedField&, - const fvPatchFieldMapper& - ); - - //- Construct and return a clone - virtual tmp clone() const - { - return tmp - ( - new turbulentTemperatureRadCoupledMixedFvPatchScalarField - ( - *this - ) - ); - } - - //- Construct as copy setting internal field reference - turbulentTemperatureRadCoupledMixedFvPatchScalarField - ( - const turbulentTemperatureRadCoupledMixedFvPatchScalarField&, - const DimensionedField& - ); - - //- Construct and return a clone setting internal field reference - virtual tmp clone - ( - const DimensionedField& iF - ) const - { - return tmp - ( - new turbulentTemperatureRadCoupledMixedFvPatchScalarField - ( - *this, - iF - ) - ); - } - - - // Member functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); - - //- Write - virtual void write(Ostream&) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace compressible -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.H index 2458d1d400..785aa25cca 100644 --- a/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.H +++ b/src/dynamicMesh/motionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.H @@ -25,7 +25,7 @@ Class Foam::displacementInterpolationMotionSolver Group - grpMeshMotionSolvers + grpMeshMotionSolvers Description Mesh motion solver for an fvMesh. diff --git a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.H b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.H index 07444532f4..4975d8c875 100644 --- a/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.H +++ b/src/dynamicMesh/motionSolvers/displacement/layeredSolver/displacementLayeredMotionMotionSolver.H @@ -25,7 +25,7 @@ Class Foam::displacementLayeredMotionMotionSolver Group - grpMeshMotionSolvers + grpMeshMotionSolvers Description Mesh motion solver for an (multi-block) extruded fvMesh. Gets given the diff --git a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H index 20d87b8e86..5523ef2eac 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/basic/coupled/coupledFvPatchField.H @@ -207,6 +207,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction, @@ -217,6 +218,7 @@ public: virtual void updateInterfaceMatrix ( Field&, + const bool add, const Field&, const scalarField&, const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C index db36178e73..9a6dc99faa 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.C @@ -173,6 +173,7 @@ template void Foam::cyclicFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -188,12 +189,7 @@ void Foam::cyclicFvPatchField::updateInterfaceMatrix transformCoupleField(pnf, cmpt); // Multiply the field by coefficients and add into the result - const labelUList& faceCells = cyclicPatch_.faceCells(); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } @@ -201,6 +197,7 @@ template void Foam::cyclicFvPatchField::updateInterfaceMatrix ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes @@ -215,12 +212,7 @@ void Foam::cyclicFvPatchField::updateInterfaceMatrix transformCoupleField(pnf); // Multiply the field by coefficients and add into the result - const labelUList& faceCells = cyclicPatch_.faceCells(); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H index 8122c21139..cd2d5695a4 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclic/cyclicFvPatchField.H @@ -178,6 +178,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -188,6 +189,7 @@ public: virtual void updateInterfaceMatrix ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C index 124c42fb87..912c44173d 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.C @@ -195,6 +195,7 @@ template void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -213,14 +214,9 @@ void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix // Transform according to the transformation tensors transformCoupleField(pnf, cmpt); - const labelUList& faceCells = cyclicACMIPatch_.faceCells(); - pnf = cyclicACMIPatch_.interpolate(pnf); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } @@ -228,6 +224,7 @@ template void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes @@ -244,14 +241,9 @@ void Foam::cyclicACMIFvPatchField::updateInterfaceMatrix // Transform according to the transformation tensors transformCoupleField(pnf); - const labelUList& faceCells = cyclicACMIPatch_.faceCells(); - pnf = cyclicACMIPatch_.interpolate(pnf); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H index ebb2fb8cbd..0ae3c6b014 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicACMI/cyclicACMIFvPatchField.H @@ -202,6 +202,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -212,6 +213,7 @@ public: virtual void updateInterfaceMatrix ( Field&, + const bool add, const Field&, const scalarField&, const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C index 50f0b55938..5bbce362be 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.C @@ -179,6 +179,7 @@ template void Foam::cyclicAMIFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -204,12 +205,7 @@ void Foam::cyclicAMIFvPatchField::updateInterfaceMatrix } // Multiply the field by coefficients and add into the result - const labelUList& faceCells = cyclicAMIPatch_.faceCells(); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } @@ -217,6 +213,7 @@ template void Foam::cyclicAMIFvPatchField::updateInterfaceMatrix ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes @@ -241,12 +238,7 @@ void Foam::cyclicAMIFvPatchField::updateInterfaceMatrix } // Multiply the field by coefficients and add into the result - const labelUList& faceCells = cyclicAMIPatch_.faceCells(); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H index 7ad7bddbb4..d25f2812b2 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/cyclicAMI/cyclicAMIFvPatchField.H @@ -183,6 +183,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -193,6 +194,7 @@ public: virtual void updateInterfaceMatrix ( Field&, + const bool add, const Field&, const scalarField&, const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C index 36705e2111..577f42ee22 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.C @@ -132,6 +132,7 @@ template void Foam::jumpCyclicFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -146,6 +147,7 @@ template void Foam::jumpCyclicFvPatchField::updateInterfaceMatrix ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes @@ -183,11 +185,7 @@ void Foam::jumpCyclicFvPatchField::updateInterfaceMatrix this->transformCoupleField(pnf); // Multiply the field by coefficients and add into the result - const labelUList& faceCells = this->cyclicPatch().faceCells(); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H index 2456df9bba..36ebce0768 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchField.H @@ -128,6 +128,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -138,6 +139,7 @@ public: virtual void updateInterfaceMatrix ( Field&, + const bool add, const Field&, const scalarField&, const Pstream::commsTypes commsType @@ -149,6 +151,7 @@ template<> void jumpCyclicFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C index fc620604db..f4d7d53342 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclic/jumpCyclicFvPatchFields.C @@ -40,6 +40,7 @@ template<> void Foam::jumpCyclicFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -78,11 +79,7 @@ void Foam::jumpCyclicFvPatchField::updateInterfaceMatrix this->transformCoupleField(pnf, cmpt); // Multiply the field by coefficients and add into the result - const labelUList& faceCells = this->cyclicPatch().faceCells(); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C index e22390f84a..d4facb129b 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.C @@ -134,6 +134,7 @@ template void Foam::jumpCyclicAMIFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -148,6 +149,7 @@ template void Foam::jumpCyclicAMIFvPatchField::updateInterfaceMatrix ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes @@ -189,11 +191,7 @@ void Foam::jumpCyclicAMIFvPatchField::updateInterfaceMatrix this->transformCoupleField(pnf); // Multiply the field by coefficients and add into the result - const labelUList& faceCells = this->cyclicAMIPatch().faceCells(); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H index 0815af948f..7ea5016bf3 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchField.H @@ -131,6 +131,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -141,6 +142,7 @@ public: virtual void updateInterfaceMatrix ( Field&, + const bool add, const Field&, const scalarField&, const Pstream::commsTypes commsType @@ -153,6 +155,7 @@ template<> void jumpCyclicAMIFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C index c567c40062..f1d54c7488 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/jumpCyclicAMI/jumpCyclicAMIFvPatchFields.C @@ -42,6 +42,7 @@ template<> void Foam::jumpCyclicAMIFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -72,11 +73,7 @@ void Foam::jumpCyclicAMIFvPatchField::updateInterfaceMatrix this->transformCoupleField(pnf, cmpt); // Multiply the field by coefficients and add into the result - const labelUList& faceCells = this->cyclicAMIPatch().faceCells(); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C index 39b92ea77c..fee3226ea8 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.C @@ -318,6 +318,7 @@ template void Foam::processorFvPatchField::initInterfaceMatrixUpdate ( scalarField&, + const bool add, const scalarField& psiInternal, const scalarField&, const direction, @@ -378,6 +379,7 @@ template void Foam::processorFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField&, const scalarField& coeffs, const direction cmpt, @@ -389,8 +391,6 @@ void Foam::processorFvPatchField::updateInterfaceMatrix return; } - const labelUList& faceCells = this->patch().faceCells(); - if ( commsType == Pstream::commsTypes::nonBlocking @@ -416,10 +416,7 @@ void Foam::processorFvPatchField::updateInterfaceMatrix transformCoupleField(scalarReceiveBuf_, cmpt); // Multiply the field by coefficients and add into the result - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*scalarReceiveBuf_[elemI]; - } + this->addToInternalField(result, !add, coeffs, scalarReceiveBuf_); } else { @@ -432,10 +429,7 @@ void Foam::processorFvPatchField::updateInterfaceMatrix transformCoupleField(pnf, cmpt); // Multiply the field by coefficients and add into the result - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } const_cast&>(*this).updatedMatrix() = true; @@ -446,6 +440,7 @@ template void Foam::processorFvPatchField::initInterfaceMatrixUpdate ( Field&, + const bool add, const Field& psiInternal, const scalarField&, const Pstream::commsTypes commsType @@ -505,6 +500,7 @@ template void Foam::processorFvPatchField::updateInterfaceMatrix ( Field& result, + const bool add, const Field&, const scalarField& coeffs, const Pstream::commsTypes commsType @@ -515,8 +511,6 @@ void Foam::processorFvPatchField::updateInterfaceMatrix return; } - const labelUList& faceCells = this->patch().faceCells(); - if ( commsType == Pstream::commsTypes::nonBlocking @@ -542,10 +536,7 @@ void Foam::processorFvPatchField::updateInterfaceMatrix transformCoupleField(receiveBuf_); // Multiply the field by coefficients and add into the result - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*receiveBuf_[elemI]; - } + this->addToInternalField(result, !add, coeffs, receiveBuf_); } else { @@ -558,10 +549,7 @@ void Foam::processorFvPatchField::updateInterfaceMatrix transformCoupleField(pnf); // Multiply the field by coefficients and add into the result - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } const_cast&>(*this).updatedMatrix() = true; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H index bfe1b75708..11013c8824 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchField.H @@ -209,6 +209,7 @@ public: virtual void initInterfaceMatrixUpdate ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -219,6 +220,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -229,6 +231,7 @@ public: virtual void initInterfaceMatrixUpdate ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes commsType @@ -238,6 +241,7 @@ public: virtual void updateInterfaceMatrix ( Field& result, + const bool add, const Field& psiInternal, const scalarField& coeffs, const Pstream::commsTypes commsType diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C index 53ebbb18e2..85507d0080 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.C @@ -36,6 +36,7 @@ template<> void processorFvPatchField::initInterfaceMatrixUpdate ( scalarField&, + const bool add, const scalarField& psiInternal, const scalarField&, const direction, @@ -96,6 +97,7 @@ template<> void processorFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField&, const scalarField& coeffs, const direction, @@ -107,8 +109,6 @@ void processorFvPatchField::updateInterfaceMatrix return; } - const labelUList& faceCells = this->patch().faceCells(); - if ( commsType == Pstream::commsTypes::nonBlocking @@ -130,10 +130,7 @@ void processorFvPatchField::updateInterfaceMatrix // Consume straight from scalarReceiveBuf_ - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*scalarReceiveBuf_[elemI]; - } + this->addToInternalField(result, !add, coeffs, scalarReceiveBuf_); } else { @@ -142,10 +139,7 @@ void processorFvPatchField::updateInterfaceMatrix procPatch_.compressedReceive(commsType, this->size())() ); - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } const_cast&>(*this).updatedMatrix() = true; diff --git a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H index a8bbb24dcb..0328ef2797 100644 --- a/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/constraint/processor/processorFvPatchScalarField.H @@ -39,6 +39,7 @@ template<> void processorFvPatchField::initInterfaceMatrixUpdate ( scalarField&, + const bool add, const scalarField&, const scalarField&, const direction, @@ -50,6 +51,7 @@ template<> void processorFvPatchField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField&, const scalarField& coeffs, const direction, diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C index db21f33d45..81ff46caa2 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -507,6 +507,32 @@ void Foam::fvMatrix::setReference } +template +void Foam::fvMatrix::setReferences +( + const labelList& cellLabels, + const UList& values, + const bool forceReference +) +{ + bool needRef = (forceReference || psi_.needReference()); + + if (needRef) + { + forAll(cellLabels, celli) + { + label cellId = cellLabels[celli]; + if (celli >= 0) + { + source()[cellId] += diag()[cellId]*values[celli]; + diag()[cellId] += diag()[cellId]; + } + } + } +} + + + template void Foam::fvMatrix::relax(const scalar alpha) { @@ -947,6 +973,20 @@ flux() const } +template +const Foam::dictionary& Foam::fvMatrix::solverDict() const +{ + return psi_.mesh().solverDict + ( + psi_.select + ( + psi_.mesh().data::template lookupOrDefault + ("finalIteration", false) + ) + ); +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H index 590c3e324e..cb843f24fd 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrix.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -299,6 +299,13 @@ public: return source_; } + //- fvBoundary scalar field containing pseudo-matrix coeffs + // for internal cells + const FieldField& internalCoeffs() const + { + return internalCoeffs_; + } + //- fvBoundary scalar field containing pseudo-matrix coeffs // for internal cells FieldField& internalCoeffs() @@ -306,6 +313,13 @@ public: return internalCoeffs_; } + //- fvBoundary scalar field containing pseudo-matrix coeffs + // for boundary cells + const FieldField& boundaryCoeffs() const + { + return boundaryCoeffs_; + } + //- fvBoundary scalar field containing pseudo-matrix coeffs // for boundary cells FieldField& boundaryCoeffs() @@ -351,6 +365,14 @@ public: const bool forceReference = false ); + //- Set references level for solution + void setReferences + ( + const labelList& cells, + const UList& values, + const bool forceReference = false + ); + //- Set reference level for a component of the solution // on a given patch face void setComponentReference @@ -389,7 +411,7 @@ public: //- Solve segregated or coupled returning the solution statistics. // Use the given solver controls - SolverPerformance solve(const dictionary&); + SolverPerformance solveSegregatedOrCoupled(const dictionary&); //- Solve segregated returning the solution statistics. // Use the given solver controls @@ -399,6 +421,10 @@ public: // Use the given solver controls SolverPerformance solveCoupled(const dictionary&); + //- Solve returning the solution statistics. + // Use the given solver controls + SolverPerformance solve(const dictionary&); + //- Solve returning the solution statistics. // Solver controls read from fvSolution SolverPerformance solve(); @@ -425,6 +451,9 @@ public: tmp> flux() const; + //- Return the solver dictionary taking into account finalIteration + const dictionary& solverDict() const; + // Member operators diff --git a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C index 253d344a96..5eb6ead449 100644 --- a/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C +++ b/src/finiteVolume/fvMatrices/fvMatrix/fvMatrixSolve.C @@ -54,7 +54,7 @@ void Foam::fvMatrix::setComponentReference template -Foam::SolverPerformance Foam::fvMatrix::solve +Foam::SolverPerformance Foam::fvMatrix::solveSegregatedOrCoupled ( const dictionary& solverControls ) @@ -69,7 +69,8 @@ Foam::SolverPerformance Foam::fvMatrix::solve if (debug) { Info.masterStream(this->mesh().comm()) - << "fvMatrix::solve(const dictionary& solverControls) : " + << "fvMatrix::solveSegregatedOrCoupled" + "(const dictionary& solverControls) : " "solving fvMatrix" << endl; } @@ -174,6 +175,7 @@ Foam::SolverPerformance Foam::fvMatrix::solveSegregated // conditions initMatrixInterfaces ( + true, bouCoeffsCmpt, interfaces, psiCmpt, @@ -183,6 +185,7 @@ Foam::SolverPerformance Foam::fvMatrix::solveSegregated updateMatrixInterfaces ( + true, bouCoeffsCmpt, interfaces, psiCmpt, @@ -283,55 +286,35 @@ Foam::SolverPerformance Foam::fvMatrix::solveCoupled } +template +Foam::SolverPerformance Foam::fvMatrix::solve +( + const dictionary& solverControls +) +{ + return psi_.mesh().solve(*this, solverControls); +} + + template Foam::autoPtr::fvSolver> Foam::fvMatrix::solver() { - return solver - ( - psi_.mesh().solverDict - ( - psi_.select - ( - psi_.mesh().data::template lookupOrDefault - ("finalIteration", false) - ) - ) - ); + return solver(solverDict()); } template Foam::SolverPerformance Foam::fvMatrix::fvSolver::solve() { - return solve - ( - fvMat_.psi_.mesh().solverDict - ( - fvMat_.psi_.select - ( - fvMat_.psi_.mesh().data::template lookupOrDefault - ("finalIteration", false) - ) - ) - ); + return solve(fvMat_.solverDict()); } template Foam::SolverPerformance Foam::fvMatrix::solve() { - return solve - ( - psi_.mesh().solverDict - ( - psi_.select - ( - psi_.mesh().data::template lookupOrDefault - ("finalIteration", false) - ) - ) - ); + return this->solve(solverDict()); } diff --git a/src/finiteVolume/fvMesh/fvMesh.C b/src/finiteVolume/fvMesh/fvMesh.C index 6b071d9131..2c667ac619 100644 --- a/src/finiteVolume/fvMesh/fvMesh.C +++ b/src/finiteVolume/fvMesh/fvMesh.C @@ -3,6 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -36,6 +37,7 @@ License #include "fvMeshMapper.H" #include "mapClouds.H" #include "MeshObject.H" +#include "fvMatrix.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -408,6 +410,50 @@ Foam::fvMesh::~fvMesh() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::SolverPerformance Foam::fvMesh::solve +( + fvMatrix& m, + const dictionary& dict +) const +{ + // Redirect to fvMatrix solver + return m.solveSegregatedOrCoupled(dict); +} + + +Foam::SolverPerformance Foam::fvMesh::solve +( + fvMatrix& m, + const dictionary& dict +) const +{ + // Redirect to fvMatrix solver + return m.solveSegregatedOrCoupled(dict); +} + + +Foam::SolverPerformance Foam::fvMesh::solve +( + fvMatrix& m, + const dictionary& dict +) const +{ + // Redirect to fvMatrix solver + return m.solveSegregatedOrCoupled(dict); +} + + +Foam::SolverPerformance Foam::fvMesh::solve +( + fvMatrix& m, + const dictionary& dict +) const +{ + // Redirect to fvMatrix solver + return m.solveSegregatedOrCoupled(dict); +} + + void Foam::fvMesh::addFvPatches ( const List & p, diff --git a/src/finiteVolume/fvMesh/fvMesh.H b/src/finiteVolume/fvMesh/fvMesh.H index 94a6f68f21..6132523c6c 100644 --- a/src/finiteVolume/fvMesh/fvMesh.H +++ b/src/finiteVolume/fvMesh/fvMesh.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -62,6 +62,7 @@ SourceFiles #include "slicedVolFieldsFwd.H" #include "slicedSurfaceFieldsFwd.H" #include "className.H" +#include "SolverPerformance.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,6 +71,8 @@ namespace Foam class fvMeshLduAddressing; class volMesh; +template +class fvMatrix; /*---------------------------------------------------------------------------*\ @@ -265,16 +268,93 @@ public: return polyMesh::comm(); } - //- Internal face owner + + // Overlap + + //- Interpolate interpolationCells only + virtual void interpolate(volScalarField&) const + {} + + //- Interpolate interpolationCells only + virtual void interpolate(volVectorField&) const + {} + + //- Interpolate interpolationCells only + virtual void interpolate(volSphericalTensorField&) const + {} + + //- Interpolate interpolationCells only + virtual void interpolate(volSymmTensorField&) const + {} + + //- Interpolate interpolationCells only + virtual void interpolate(volTensorField&) const + {} + + //- Interpolate interpolationCells only. No bcs. + virtual void interpolate(scalarField&) const + {} + + //- Interpolate interpolationCells only. No bcs. + virtual void interpolate(vectorField&) const + {} + + //- Interpolate interpolationCells only. No bcs. + virtual void interpolate(sphericalTensorField&) const + {} + + //- Interpolate interpolationCells only. No bcs. + virtual void interpolate(symmTensorField&) const + {} + + //- Interpolate interpolationCells only. No bcs. + virtual void interpolate(tensorField&) const + {} + + //- Solve returning the solution statistics given convergence + // tolerance. Use the given solver controls + virtual SolverPerformance solve + ( + fvMatrix&, + const dictionary& + ) const; + + //- Solve returning the solution statistics given convergence + // tolerance. Use the given solver controls + virtual SolverPerformance solve + ( + fvMatrix&, + const dictionary& + ) const; + + //- Solve returning the solution statistics given convergence + // tolerance. Use the given solver controls + virtual SolverPerformance solve + ( + fvMatrix&, + const dictionary& + ) const; + + //- Solve returning the solution statistics given convergence + // tolerance. Use the given solver controls + virtual SolverPerformance solve + ( + fvMatrix&, + const dictionary& + ) const; + + + //- Internal face owner. Note bypassing virtual mechanism so + // e.g. relaxation always gets done using original addressing const labelUList& owner() const { - return lduAddr().lowerAddr(); + return fvMesh::lduAddr().lowerAddr(); } //- Internal face neighbour const labelUList& neighbour() const { - return lduAddr().upperAddr(); + return fvMesh::lduAddr().upperAddr(); } //- Return cell volumes diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C index fa3d382d66..7dd34b9343 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/Poisson/PoissonPatchDistMethod.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -103,6 +103,15 @@ bool Foam::patchDistMethods::Poisson::correct y = sqrt(magSqr(gradyPsi) + 2*yPsi) - magGradyPsi; + // Need to stabilise the y for overset meshes since the holed cells + // keep the initial value (0.0) so the gradient of that will be + // zero as well. Turbulence models do not like zero wall distance. + y.max(SMALL); + + // For overset: enforce smooth y field (yPsi is smooth, magGradyPsi is + // not) + mesh_.interpolate(y); + // Cache yPsi if the mesh is moving otherwise delete if (!mesh_.changing()) { @@ -118,7 +127,11 @@ bool Foam::patchDistMethods::Poisson::correct ( magGradyPsi, dimensionedScalar("smallMagGradyPsi", dimLength, SMALL) + ); + + // For overset: enforce smooth field + mesh_.interpolate(n); } return true; diff --git a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C index 9e0826340a..99820db026 100644 --- a/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C +++ b/src/finiteVolume/fvMesh/wallDist/patchDistMethods/advectionDiffusion/advectionDiffusionPatchDistMethod.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -145,6 +145,11 @@ bool Foam::patchDistMethods::advectionDiffusion::correct } while (initialResidual > tolerance_ && ++iter < maxIter_); + // Need to stabilise the y for overset meshes since the holed cells + // keep the initial value (0.0) so the gradient of that will be + // zero as well. Turbulence models do not like zero wall distance. + y.max(SMALL); + // Only calculate n if the field is defined if (notNull(n)) { diff --git a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C index a8c37d2c30..0ac6e22f1a 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentDisplacement/componentLaplacian/displacementComponentLaplacianFvMotionSolver.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -231,7 +231,9 @@ void Foam::displacementComponentLaplacianFvMotionSolver::solve() diffusivityPtr_->correct(); pointDisplacement_.boundaryFieldRef().updateCoeffs(); - Foam::solve + // We explicitly do NOT want to interpolate the motion inbetween + // different regions so bypass all the matrix manipulation. + fvScalarMatrix TEqn ( fvm::laplacian ( @@ -240,6 +242,8 @@ void Foam::displacementComponentLaplacianFvMotionSolver::solve() "laplacian(diffusivity,cellDisplacement)" ) ); + + TEqn.solveSegregatedOrCoupled(TEqn.solverDict()); } diff --git a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C index 6facb08138..3f16a8eb87 100644 --- a/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/componentVelocity/componentLaplacian/velocityComponentLaplacianFvMotionSolver.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -129,7 +129,9 @@ void Foam::velocityComponentLaplacianFvMotionSolver::solve() diffusivityPtr_->correct(); pointMotionU_.boundaryFieldRef().updateCoeffs(); - Foam::solve + // We explicitly do NOT want to interpolate the motion inbetween + // different regions so bypass all the matrix manipulation. + fvScalarMatrix TEqn ( fvm::laplacian ( @@ -138,6 +140,8 @@ void Foam::velocityComponentLaplacianFvMotionSolver::solve() "laplacian(diffusivity,cellMotionU)" ) ); + + TEqn.solveSegregatedOrCoupled(TEqn.solverDict()); } diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C index 2bed22c26c..8a131674e9 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/SBRStress/displacementSBRStressFvMotionSolver.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -186,7 +186,7 @@ void Foam::displacementSBRStressFvMotionSolver::solve() volTensorField gradCd("gradCd", fvc::grad(cellDisplacement_)); - Foam::solve + fvVectorMatrix TEqn ( fvm::laplacian ( @@ -234,6 +234,8 @@ void Foam::displacementSBRStressFvMotionSolver::solve() ) */ ); + + TEqn.solveSegregatedOrCoupled(TEqn.solverDict()); } diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C index 85c1201364..fc35fa6166 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/laplacian/displacementLaplacianFvMotionSolver.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -332,7 +332,9 @@ void Foam::displacementLaplacianFvMotionSolver::solve() diffusivity().correct(); pointDisplacement_.boundaryFieldRef().updateCoeffs(); - Foam::solve + // We explicitly do NOT want to interpolate the motion inbetween + // different regions so bypass all the matrix manipulation. + fvVectorMatrix TEqn ( fvm::laplacian ( @@ -341,6 +343,8 @@ void Foam::displacementLaplacianFvMotionSolver::solve() "laplacian(diffusivity,cellDisplacement)" ) ); + + TEqn.solveSegregatedOrCoupled(TEqn.solverDict()); } diff --git a/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C index 6294da02a1..3c39edb7b5 100644 --- a/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/displacement/surfaceAlignedSBRStress/surfaceAlignedSBRStressFvMotionSolver.C @@ -409,7 +409,8 @@ void Foam::surfaceAlignedSBRStressFvMotionSolver::solve() fvc::div(sigmaD_) ); - DEqn.solve(); + // Note: solve uncoupled + DEqn.solveSegregatedOrCoupled(DEqn.solverDict()); } } diff --git a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C index 46e7f34e2d..2a5bd14fcd 100644 --- a/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C +++ b/src/fvMotionSolver/fvMotionSolvers/velocity/laplacian/velocityLaplacianFvMotionSolver.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -124,7 +124,7 @@ void Foam::velocityLaplacianFvMotionSolver::solve() diffusivityPtr_->correct(); pointMotionU_.boundaryFieldRef().updateCoeffs(); - Foam::solve + fvVectorMatrix UEqn ( fvm::laplacian ( @@ -133,6 +133,8 @@ void Foam::velocityLaplacianFvMotionSolver::solve() "laplacian(diffusivity,cellMotionU)" ) ); + + UEqn.solveSegregatedOrCoupled(UEqn.solverDict()); } diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C index 4963d926cd..772799af49 100644 --- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.C @@ -93,6 +93,7 @@ Foam::cyclicACMIGAMGInterfaceField::~cyclicACMIGAMGInterfaceField() void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -117,12 +118,7 @@ void Foam::cyclicACMIGAMGInterfaceField::updateInterfaceMatrix pnf = cyclicACMIInterface_.neighbPatch().AMI().interpolateToTarget(pnf); } - const labelUList& faceCells = cyclicACMIInterface_.faceCells(); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.H b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.H index e06d76328d..a2f4dc8aec 100644 --- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.H +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicACMIGAMGInterfaceField/cyclicACMIGAMGInterfaceField.H @@ -120,6 +120,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C index 1cb34ad792..7f6034a226 100644 --- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.C @@ -93,6 +93,7 @@ Foam::cyclicAMIGAMGInterfaceField::~cyclicAMIGAMGInterfaceField() void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, @@ -117,12 +118,7 @@ void Foam::cyclicAMIGAMGInterfaceField::updateInterfaceMatrix pnf = cyclicAMIInterface_.neighbPatch().AMI().interpolateToTarget(pnf); } - const labelUList& faceCells = cyclicAMIInterface_.faceCells(); - - forAll(faceCells, elemI) - { - result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI]; - } + this->addToInternalField(result, !add, coeffs, pnf); } diff --git a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H index 868e2cc47b..7f1aa72acd 100644 --- a/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H +++ b/src/meshTools/AMIInterpolation/GAMG/interfaceFields/cyclicAMIGAMGInterfaceField/cyclicAMIGAMGInterfaceField.H @@ -119,6 +119,7 @@ public: virtual void updateInterfaceMatrix ( scalarField& result, + const bool add, const scalarField& psiInternal, const scalarField& coeffs, const direction cmpt, diff --git a/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledGAMGInterfaceField.H b/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledGAMGInterfaceField.H index 5b26ddc2a7..6701e2b7bc 100644 --- a/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledGAMGInterfaceField.H +++ b/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledGAMGInterfaceField.H @@ -112,6 +112,7 @@ public: virtual void updateInterfaceMatrix ( scalarField&, + const bool add, const scalarField&, const scalarField&, const direction, diff --git a/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledWallGAMGInterfaceField.H b/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledWallGAMGInterfaceField.H index 8bcdd2e114..ca8c0b9b68 100644 --- a/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledWallGAMGInterfaceField.H +++ b/src/meshTools/regionCoupled/GAMG/interfaceFields/regionCoupledGAMGInterfaceField/regionCoupledWallGAMGInterfaceField.H @@ -113,6 +113,7 @@ public: virtual void updateInterfaceMatrix ( scalarField&, + const bool add, const scalarField&, const scalarField&, const direction, diff --git a/src/overset/Make/files b/src/overset/Make/files new file mode 100644 index 0000000000..a285c4979c --- /dev/null +++ b/src/overset/Make/files @@ -0,0 +1,31 @@ +cellCellStencil/cellCellStencil/cellCellStencil.C +cellCellStencil/cellVolumeWeight/cellVolumeWeightCellCellStencil.C +cellCellStencil/cellCellStencil/cellCellStencilObject.C +cellCellStencil/inverseDistance/inverseDistanceCellCellStencil.C +cellCellStencil/inverseDistance/waveMethod.C +cellCellStencil/inverseDistance/meshToMeshData.C +cellCellStencil/trackingInverseDistance/voxelMeshSearch.C +cellCellStencil/trackingInverseDistance/trackingInverseDistanceCellCellStencil.C + +dynamicOversetFvMesh/dynamicOversetFvMesh.C + +fvMeshPrimitiveLduAddressing/fvMeshPrimitiveLduAddressing.C + +oversetPolyPatch/oversetPolyPatch.C +oversetPolyPatch/oversetLduInterface.C +oversetPolyPatch/oversetFvPatch.C +oversetPolyPatch/oversetFvPatchFields.C +oversetPolyPatch/oversetFvsPatchFields.C +oversetPolyPatch/oversetGAMGInterface.C +oversetPolyPatch/oversetGAMGInterfaceField.C +oversetPolyPatch/oversetPointPatch.C +oversetPolyPatch/oversetPointPatchFields.C + +oversetAdjustPhi/oversetAdjustPhi.C + +regionsToCell/regionsToCell.C + +lduPrimitiveProcessorInterface/lduPrimitiveProcessorInterface.C + + +LIB = $(FOAM_LIBBIN)/liboverset diff --git a/src/overset/Make/options b/src/overset/Make/options new file mode 100644 index 0000000000..ae7529a227 --- /dev/null +++ b/src/overset/Make/options @@ -0,0 +1,15 @@ +EXE_INC = \ + /* -DFULLDEBUG -O0 -g */ \ + -I$(LIB_SRC)/fileFormats/lnInclude \ + -I$(LIB_SRC)/surfMesh/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude + +LIB_LIBS = \ + -ldynamicFvMesh \ + -lsampling \ + -ldecompositionMethods diff --git a/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C new file mode 100644 index 0000000000..9ef72576fa --- /dev/null +++ b/src/overset/cellCellStencil/cellCellStencil/cellCellStencil.C @@ -0,0 +1,276 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify i + 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 "cellCellStencil.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" +#include "syncTools.H" +#include "globalIndex.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(cellCellStencil, 0); + defineRunTimeSelectionTable(cellCellStencil, mesh); + + template<> + const char* NamedEnum + < + cellCellStencil::cellType, + 3 + >::names[] = + { + "calculated", + "interpolated", + "hole" + }; +} + +const Foam::NamedEnum +Foam::cellCellStencil::cellTypeNames_; + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::cellCellStencil::cellCellStencil(const fvMesh& mesh) +: + mesh_(mesh) +{} + + +Foam::autoPtr Foam::cellCellStencil::New +( + const fvMesh& mesh, + const dictionary& dict +) +{ + if (debug) + { + InfoInFunction << "Constructing cellCellStencil" << endl; + } + + word type(dict.lookup("method")); + + + meshConstructorTable::iterator cstrIter = + meshConstructorTablePtr_->find(type); + + if (cstrIter == meshConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown cellCellStencil type " + << type << nl << nl + << "Valid cellCellStencil types are" << endl + << meshConstructorTablePtr_->sortedToc() + << abort(FatalError); + } + + return autoPtr(cstrIter()(mesh, dict, true)); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::cellCellStencil::~cellCellStencil() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +const Foam::labelIOList& Foam::cellCellStencil::zoneID() const +{ + if (!mesh_.foundObject("zoneID")) + { + labelIOList* zoneIDPtr = new labelIOList + ( + IOobject + ( + "zoneID", + mesh_.facesInstance(), + polyMesh::meshSubDir, + mesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh_.nCells() + ); + labelIOList& zoneID = *zoneIDPtr; + + volScalarField volZoneID + ( + IOobject + ( + "zoneID", + mesh_.time().findInstance(mesh_.dbDir(), "zoneID"), + mesh_, + IOobject::MUST_READ, + IOobject::NO_WRITE, + false + ), + mesh_ + ); + forAll(volZoneID, cellI) + { + zoneID[cellI] = label(volZoneID[cellI]); + } + + zoneIDPtr->store(); + } + return mesh_.lookupObject("zoneID"); +} + + +Foam::labelList Foam::cellCellStencil::count +( + const label size, + const labelUList& lst +) +{ + labelList count(size, 0); + forAll(lst, i) + { + count[lst[i]]++; + } + Pstream::listCombineGather(count, plusEqOp