diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..592cb24277 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,6 @@ +[submodule "cfmesh"] + path = modules/cfmesh + url = https://develop.openfoam.com/Community/integration-cfmesh.git +[submodule "avalanche"] + path = modules/avalanche + url = https://develop.openfoam.com/Community/avalanche.git diff --git a/Allwmake b/Allwmake index b9cfa95a5e..ed3d03e789 100755 --- a/Allwmake +++ b/Allwmake @@ -43,6 +43,15 @@ echo "Compile OpenFOAM applications" echo applications/Allwmake $targetType $* +# Additional components/modules +if [ -d "$WM_PROJECT_DIR/modules" ] +then + echo "========================================" + echo "Compile OpenFOAM modules" + echo + (cd $WM_PROJECT_DIR/modules 2>/dev/null && wmake -all) +fi + # Some summary information echo date "+%Y-%m-%d %H:%M:%S %z" 2>/dev/null || echo "date is unknown" diff --git a/BuildIssues.txt b/BuildIssues.txt index 011b5dc048..a05b5301c3 100644 --- a/BuildIssues.txt +++ b/BuildIssues.txt @@ -1,8 +1,23 @@ -OpenFOAM-1706 +OpenFOAM-1712 ================== Known Build Issues ================== +--------------------- +Intel MPI (Gcc/Clang) +--------------------- + + Either I_MPI_ROOT or MPI_ROOT can be used to specify the Intel-MPI + installation directory path. + + The ThirdParty build of ptscotch uses `mpiicc` for Intel-MPI + instead of the usual `mpicc`. + When gcc or clang are used, it is highly likely that the + I_MPI_CC environment variable also needs to be set accordingly. + + See `mpiicc -help` for more information about environment variables. + + -------------- Intel Compiler -------------- @@ -60,6 +75,33 @@ If your system compiler is too old to build the minimum required gcc or clang/llvm, it is just simply too old. +--------------------------------- +ThirdParty clang without gmp/mpfr +--------------------------------- + +If using ThirdParty clang without gmp/mpfr, the ThirdParty makeCGAL +script will need to be run manually and specify that there is no +gmp/mpfr. Eg, + + cd $WM_THIRD_PARTY_DIR + ./makeCGAL gmp-none mpfr-none + +Subequent compilation with Allwmake will now run largely without any +problems, except that the components linking against CGAL +(foamyMesh and surfaceBooleanFeatures) will also try to link against +a nonexistent mpfr library. As a workaround, the link-dependency can +be removed in wmake/rules/General/CGAL : + + CGAL_LIBS = \ + -L$(BOOST_ARCH_PATH)/lib \ + -L$(BOOST_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -L$(CGAL_ARCH_PATH)/lib \ + -L$(CGAL_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \ + -lCGAL + +This is a temporary inconvenience until a more robust solution is found. + + ------------------------- Building with spack ------------------------- diff --git a/README.md b/README.md index fed8a6e758..f93560c986 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # About OpenFOAM OpenFOAM is a free, open source CFD software [released and developed primarily by OpenCFD Ltd](http://www.openfoam.com) since 2004. It has a large user base across most areas of engineering and science, from both commercial and academic organisations. OpenFOAM has an extensive range of features to solve anything from complex fluid flows involving chemical reactions, turbulence and heat transfer, to acoustics, solid mechanics and electromagnetics. [More...](http://www.openfoam.com/documentation) -OpenFOAM+ is professionally released every six months to include customer sponsored developments and contributions from the community, including the OpenFOAM Foundation. Releases designated OpenFOAM+ contain several man years of client-sponsored developments of which much has been transferred to, but not released in the OpenFOAM Foundation branch. + +OpenFOAM is professionally released every six months to include customer sponsored developments and contributions from the community - individual and group contributors, fork re-integrations including from FOAM-extend and OpenFOAM Foundation Ltd - in this Official Release sanctioned by the OpenFOAM Worldwide Trademark Owner aiming towards one OpenFOAM. # Copyright @@ -9,7 +10,7 @@ OpenFOAM is free software: you can redistribute it and/or modify it under the te # OpenFOAM Trademark -OpenCFD Ltd grants use of the OpenFOAM trademark by Third Parties on a licence basis. ESI Group and the OpenFOAM Foundation Ltd are currently permitted to use the Name and agreed Domain Name. For information on trademark use, please refer to the [trademark policy guidelines](http://www.openfoam.com/legal/trademark-policy.php). +OpenCFD Ltd grants use of its OpenFOAM trademark by Third Parties on a licence basis. ESI Group and OpenFOAM Foundation Ltd are currently permitted to use the Name and agreed Domain Name. For information on trademark use, please refer to the [trademark policy guidelines](http://www.openfoam.com/legal/trademark-policy.php). Please [contact OpenCFD](http://www.openfoam.com/contact) if you have any questions on the use of the OpenFOAM trademark. diff --git a/applications/solvers/basic/potentialFoam/overPotentialFoam/Make/files b/applications/solvers/basic/potentialFoam/overPotentialFoam/Make/files new file mode 100644 index 0000000000..511066afa5 --- /dev/null +++ b/applications/solvers/basic/potentialFoam/overPotentialFoam/Make/files @@ -0,0 +1,3 @@ +potentialFoam.C + +EXE = $(FOAM_APPBIN)/overPotentialFoam diff --git a/applications/solvers/basic/potentialFoam/overPotentialFoam/Make/options b/applications/solvers/basic/potentialFoam/overPotentialFoam/Make/options new file mode 100644 index 0000000000..155894029a --- /dev/null +++ b/applications/solvers/basic/potentialFoam/overPotentialFoam/Make/options @@ -0,0 +1,12 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/sampling/lnInclude + +EXE_LIBS = \ + -lfiniteVolume \ + -lmeshTools \ + -lsampling \ + -loverset diff --git a/applications/solvers/basic/potentialFoam/overPotentialFoam/createControls.H b/applications/solvers/basic/potentialFoam/overPotentialFoam/createControls.H new file mode 100644 index 0000000000..7015cae02e --- /dev/null +++ b/applications/solvers/basic/potentialFoam/overPotentialFoam/createControls.H @@ -0,0 +1,9 @@ +const dictionary& potentialFlow +( + mesh.solutionDict().subDict("potentialFlow") +); + +const int nNonOrthCorr +( + potentialFlow.lookupOrDefault("nNonOrthogonalCorrectors", 0) +); diff --git a/applications/solvers/basic/potentialFoam/overPotentialFoam/createFields.H b/applications/solvers/basic/potentialFoam/overPotentialFoam/createFields.H new file mode 100644 index 0000000000..b7daa4fe47 --- /dev/null +++ b/applications/solvers/basic/potentialFoam/overPotentialFoam/createFields.H @@ -0,0 +1,146 @@ +Info<< "Reading velocity field U\n" << endl; +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + mesh +); + +// Initialise the velocity internal field to zero +U = dimensionedVector("0", U.dimensions(), Zero); + +surfaceScalarField phi +( + IOobject + ( + "phi", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + fvc::flux(U) +); + +if (args.optionFound("initialiseUBCs")) +{ + U.correctBoundaryConditions(); + phi = fvc::flux(U); +} + + +// Construct a pressure field +// If it is available read it otherwise construct from the velocity BCs +// converting fixed-value BCs to zero-gradient and vice versa. +word pName("p"); + +// Update name of the pressure field from the command-line option +args.optionReadIfPresent("pName", pName); + +// Infer the pressure BCs from the velocity +wordList pBCTypes +( + U.boundaryField().size(), + fixedValueFvPatchScalarField::typeName +); + +forAll(U.boundaryField(), patchi) +{ + if (U.boundaryField()[patchi].fixesValue()) + { + pBCTypes[patchi] = zeroGradientFvPatchScalarField::typeName; + } +} + +// Note that registerObject is false for the pressure field. The pressure +// field in this solver doesn't have a physical value during the solution. +// It shouldn't be looked up and used by sub models or boundary conditions. +Info<< "Constructing pressure field " << pName << nl << endl; +volScalarField p +( + IOobject + ( + pName, + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE, + false + ), + mesh, + dimensionedScalar(pName, sqr(dimVelocity), 0), + pBCTypes +); + +// Infer the velocity potential BCs from the pressure +wordList PhiBCTypes +( + p.boundaryField().size(), + zeroGradientFvPatchScalarField::typeName +); + +forAll(p.boundaryField(), patchi) +{ + if (p.boundaryField()[patchi].fixesValue()) + { + PhiBCTypes[patchi] = fixedValueFvPatchScalarField::typeName; + } +} + +Info<< "Constructing velocity potential field Phi\n" << endl; +volScalarField Phi +( + IOobject + ( + "Phi", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("Phi", dimLength*dimVelocity, 0), + PhiBCTypes +); + +label PhiRefCell = 0; +scalar PhiRefValue = 0; +setRefCell +( + Phi, + potentialFlow.dict(), + PhiRefCell, + PhiRefValue +); +mesh.setFluxRequired(Phi.name()); + +#include "createMRF.H" + +// Add overset specific interpolations +{ + dictionary oversetDict; + oversetDict.add("Phi", true); + oversetDict.add("U", 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" diff --git a/applications/solvers/basic/potentialFoam/overPotentialFoam/potentialFoam.C b/applications/solvers/basic/potentialFoam/overPotentialFoam/potentialFoam.C new file mode 100644 index 0000000000..7d340fbc36 --- /dev/null +++ b/applications/solvers/basic/potentialFoam/overPotentialFoam/potentialFoam.C @@ -0,0 +1,260 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +Application + potentialFoam + +Group + grpBasicSolvers + +Description + Potential flow solver which solves for the velocity potential, to + calculate the flux-field, from which the velocity field is obtained by + reconstructing the flux. + + \heading Solver details + The potential flow solution is typically employed to generate initial fields + for full Navier-Stokes codes. The flow is evolved using the equation: + + \f[ + \laplacian \Phi = \div(\vec{U}) + \f] + + Where: + \vartable + \Phi | Velocity potential [m2/s] + \vec{U} | Velocity [m/s] + \endvartable + + The corresponding pressure field could be calculated from the divergence + of the Euler equation: + + \f[ + \laplacian p + \div(\div(\vec{U}\otimes\vec{U})) = 0 + \f] + + but this generates excessive pressure variation in regions of large + velocity gradient normal to the flow direction. A better option is to + calculate the pressure field corresponding to velocity variation along the + stream-lines: + + \f[ + \laplacian p + \div(\vec{F}\cdot\div(\vec{U}\otimes\vec{U})) = 0 + \f] + where the flow direction tensor \f$\vec{F}\f$ is obtained from + \f[ + \vec{F} = \hat{\vec{U}}\otimes\hat{\vec{U}} + \f] + + \heading Required fields + \plaintable + U | Velocity [m/s] + \endplaintable + + \heading Optional fields + \plaintable + p | Kinematic pressure [m2/s2] + Phi | Velocity potential [m2/s] + | Generated from p (if present) or U if not present + \endplaintable + + \heading Options + \plaintable + -writep | write the Euler pressure + -writePhi | Write the final velocity potential + -initialiseUBCs | Update the velocity boundaries before solving for Phi + \endplaintable + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "pisoControl.H" +#include "dynamicFvMesh.H" +#include "cellCellStencilObject.H" +#include "localMin.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + argList::addOption + ( + "pName", + "pName", + "Name of the pressure field" + ); + + argList::addBoolOption + ( + "initialiseUBCs", + "Initialise U boundary conditions" + ); + + argList::addBoolOption + ( + "writePhi", + "Write the final velocity potential field" + ); + + argList::addBoolOption + ( + "writep", + "Calculate and write the Euler pressure field" + ); + + argList::addBoolOption + ( + "withFunctionObjects", + "execute functionObjects" + ); + + #include "setRootCase.H" + #include "createTime.H" + #include "createNamedDynamicFvMesh.H" + + pisoControl potentialFlow(mesh, "potentialFlow"); + + #include "createFields.H" + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + + Info<< nl << "Calculating potential flow" << endl; + + mesh.update(); + + surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); + + // Since solver contains no time loop it would never execute + // function objects so do it ourselves + runTime.functionObjects().start(); + + MRF.makeRelative(phi); + adjustPhi(phi, U, p); + + // Non-orthogonal velocity potential corrector loop + while (potentialFlow.correct()) + { + phi = fvc::flux(U); + + while (potentialFlow.correctNonOrthogonal()) + { + fvScalarMatrix PhiEqn + ( + fvm::laplacian(faceMask, Phi) + == + fvc::div(phi) + ); + + PhiEqn.setReference(PhiRefCell, PhiRefValue); + PhiEqn.solve(); + + if (potentialFlow.finalNonOrthogonalIter()) + { + phi -= PhiEqn.flux(); + } + } + + MRF.makeAbsolute(phi); + + Info<< "Continuity error = " + << mag(fvc::div(phi))().weightedAverage(mesh.V()).value() + << endl; + + U = fvc::reconstruct(phi); + U.correctBoundaryConditions(); + + Info<< "Interpolated velocity error = " + << (sqrt(sum(sqr(fvc::flux(U) - phi)))/sum(mesh.magSf())).value() + << endl; + } + + // Write U and phi + U.write(); + phi.write(); + + // Optionally write Phi + if (args.optionFound("writePhi")) + { + Phi.write(); + } + + // Calculate the pressure field from the Euler equation + if (args.optionFound("writep")) + { + Info<< nl << "Calculating approximate pressure field" << endl; + + label pRefCell = 0; + scalar pRefValue = 0.0; + setRefCell + ( + p, + potentialFlow.dict(), + pRefCell, + pRefValue + ); + + // Calculate the flow-direction filter tensor + volScalarField magSqrU(magSqr(U)); + volSymmTensorField F(sqr(U)/(magSqrU + SMALL*average(magSqrU))); + + // Calculate the divergence of the flow-direction filtered div(U*U) + // Filtering with the flow-direction generates a more reasonable + // pressure distribution in regions of high velocity gradient in the + // direction of the flow + volScalarField divDivUU + ( + fvc::div + ( + F & fvc::div(phi, U), + "div(div(phi,U))" + ) + ); + + // Solve a Poisson equation for the approximate pressure + while (potentialFlow.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvm::laplacian(p) + divDivUU + ); + + pEqn.setReference(pRefCell, pRefValue); + pEqn.solve(); + } + + p.write(); + } + + runTime.functionObjects().end(); + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C index 6a6581182b..25a4a2098e 100644 --- a/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C +++ b/applications/solvers/combustion/PDRFoam/PDRModels/dragModels/PDRDragModel/PDRDragModelNew.C @@ -40,15 +40,14 @@ Foam::autoPtr Foam::PDRDragModel::New Info<< "Selecting flame-wrinkling model " << modelType << endl; - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(modelType); + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); if (!cstrIter.found()) { FatalErrorInFunction << "Unknown PDRDragModel type " << modelType << nl << nl - << "Valid PDRDragModels are : " << endl + << "Valid PDRDragModel types :" << endl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C index 932080e717..251d429c8f 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiEqModels/XiEqModel/XiEqModelNew.C @@ -39,15 +39,14 @@ Foam::autoPtr Foam::XiEqModel::New Info<< "Selecting flame-wrinkling model " << modelType << endl; - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(modelType); + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); if (!cstrIter.found()) { FatalErrorInFunction << "Unknown XiEqModel type " << modelType << nl << nl - << "Valid XiEqModels are : " << endl + << "Valid XiEqModel types :" << endl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C index 27fe3f5e17..b46192ea38 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiGModels/XiGModel/XiGModelNew.C @@ -39,15 +39,14 @@ Foam::autoPtr Foam::XiGModel::New Info<< "Selecting flame-wrinkling model " << modelType << endl; - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(modelType); + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); if (!cstrIter.found()) { FatalErrorInFunction << "Unknown XiGModel type " << modelType << nl << nl - << "Valid XiGModels are : " << endl + << "Valid XiGModel types :" << endl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } diff --git a/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C b/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C index ed9dfb2fb3..c2dccb0180 100644 --- a/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C +++ b/applications/solvers/combustion/PDRFoam/XiModels/XiModel/XiModelNew.C @@ -42,15 +42,14 @@ Foam::autoPtr Foam::XiModel::New Info<< "Selecting flame-wrinkling model " << modelType << endl; - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(modelType); + auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType); if (!cstrIter.found()) { FatalErrorInFunction << "Unknown XiModel type " << modelType << nl << nl - << "Valid XiModels are : " << endl + << "Valid XiModel types :" << endl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } diff --git a/applications/solvers/combustion/chemFoam/chemFoam.C b/applications/solvers/combustion/chemFoam/chemFoam.C index 8098ae464e..79037aae50 100644 --- a/applications/solvers/combustion/chemFoam/chemFoam.C +++ b/applications/solvers/combustion/chemFoam/chemFoam.C @@ -42,7 +42,7 @@ Description #include "OFstream.H" #include "thermoPhysicsTypes.H" #include "basicMultiComponentMixture.H" -#include "cellModeller.H" +#include "cellModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H index 9b9d0f376b..a43af46326 100644 --- a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H +++ b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H @@ -13,8 +13,7 @@ points[5] = vector(1, 0, 1); points[6] = vector(1, 1, 1); points[7] = vector(0, 1, 1); -const cellModel& hexa = *(cellModeller::lookup("hex")); -faceList faces = hexa.modelFaces(); +faceList faces = cellModel::ref(cellModel::HEX).modelFaces(); fvMesh mesh ( @@ -25,7 +24,7 @@ fvMesh mesh runTime, IOobject::READ_IF_PRESENT ), - xferMove>(points), + xferMove(points), faces.xfer(), owner.xfer(), neighbour.xfer() diff --git a/applications/solvers/combustion/fireFoam/createFieldRefs.H b/applications/solvers/combustion/fireFoam/createFieldRefs.H index 6df6f9df2f..a911c586d9 100644 --- a/applications/solvers/combustion/fireFoam/createFieldRefs.H +++ b/applications/solvers/combustion/fireFoam/createFieldRefs.H @@ -1,4 +1,4 @@ const volScalarField& psi = thermo.psi(); const volScalarField& T = thermo.T(); -filmModelType& surfaceFilm = tsurfaceFilm(); +regionModels::surfaceFilmModel& surfaceFilm = tsurfaceFilm(); const label inertIndex(composition.species()[inertSpecie]); diff --git a/applications/solvers/combustion/fireFoam/createSurfaceFilmModel.H b/applications/solvers/combustion/fireFoam/createSurfaceFilmModel.H index ffdbcbf6a9..81995c09a5 100644 --- a/applications/solvers/combustion/fireFoam/createSurfaceFilmModel.H +++ b/applications/solvers/combustion/fireFoam/createSurfaceFilmModel.H @@ -1,5 +1,6 @@ Info<< "\nConstructing surface film model" << endl; -typedef regionModels::surfaceFilmModels::surfaceFilmModel filmModelType; - -autoPtr tsurfaceFilm(filmModelType::New(mesh, g)); +autoPtr tsurfaceFilm +( + regionModels::surfaceFilmModel::New(mesh, g) +); diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C index d9a4a4e7df..0590e8d098 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.C @@ -209,16 +209,14 @@ void Foam::smoluchowskiJumpTFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent(os, "U", "U", UName_); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); - writeEntryIfDifferent(os, "psi", "thermo:psi", psiName_); - writeEntryIfDifferent(os, "mu", "thermo:mu", muName_); + os.writeEntryIfDifferent("U", "U", UName_); + os.writeEntryIfDifferent("rho", "rho", rhoName_); + os.writeEntryIfDifferent("psi", "thermo:psi", psiName_); + os.writeEntryIfDifferent("mu", "thermo:mu", muName_); - os.writeKeyword("accommodationCoeff") - << accommodationCoeff_ << token::END_STATEMENT << nl; + os.writeEntry("accommodationCoeff", accommodationCoeff_); Twall_.writeEntry("Twall", os); - os.writeKeyword("gamma") - << gamma_ << token::END_STATEMENT << nl; + os.writeEntry("gamma", gamma_); writeEntry("value", os); } diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H index 03625d8968..a854e75458 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/T/smoluchowskiJumpTFvPatchScalarField.H @@ -32,8 +32,8 @@ SourceFiles \*---------------------------------------------------------------------------*/ -#ifndef smoluchowskiJumpTFvPatchScalarFields_H -#define smoluchowskiJumpTFvPatchScalarFields_H +#ifndef smoluchowskiJumpTFvPatchScalarField_H +#define smoluchowskiJumpTFvPatchScalarField_H #include "mixedFvPatchFields.H" @@ -43,7 +43,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class smoluchowskiJumpTFvPatch Declaration + Class smoluchowskiJumpTFvPatchScalarField Declaration \*---------------------------------------------------------------------------*/ class smoluchowskiJumpTFvPatchScalarField @@ -74,6 +74,7 @@ class smoluchowskiJumpTFvPatchScalarField //- Heat capacity ratio (default 1.4) scalar gamma_; + public: //- Runtime type information diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C index 7f19817660..c79f8d5062 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/U/maxwellSlipUFvPatchVectorField.C @@ -200,18 +200,16 @@ void Foam::maxwellSlipUFvPatchVectorField::updateCoeffs() void Foam::maxwellSlipUFvPatchVectorField::write(Ostream& os) const { fvPatchVectorField::write(os); - writeEntryIfDifferent(os, "T", "T", TName_); - writeEntryIfDifferent(os, "rho", "rho", rhoName_); - writeEntryIfDifferent(os, "psi", "thermo:psi", psiName_); - writeEntryIfDifferent(os, "mu", "thermo:mu", muName_); - writeEntryIfDifferent(os, "tauMC", "tauMC", tauMCName_); + os.writeEntryIfDifferent("T", "T", TName_); + os.writeEntryIfDifferent("rho", "rho", rhoName_); + os.writeEntryIfDifferent("psi", "thermo:psi", psiName_); + os.writeEntryIfDifferent("mu", "thermo:mu", muName_); + os.writeEntryIfDifferent("tauMC", "tauMC", tauMCName_); - os.writeKeyword("accommodationCoeff") - << accommodationCoeff_ << token::END_STATEMENT << nl; + os.writeEntry("accommodationCoeff", accommodationCoeff_); Uwall_.writeEntry("Uwall", os); - os.writeKeyword("thermalCreep") - << thermalCreep_ << token::END_STATEMENT << nl; - os.writeKeyword("curvature") << curvature_ << token::END_STATEMENT << nl; + os.writeEntry("thermalCreep", thermalCreep_); + os.writeEntry("curvature", curvature_); refValue().writeEntry("refValue", os); valueFraction().writeEntry("valueFraction", os); diff --git a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C index 5eefe82ff5..d71824052f 100644 --- a/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C +++ b/applications/solvers/compressible/rhoCentralFoam/BCs/rho/fixedRhoFvPatchScalarField.C @@ -117,8 +117,8 @@ void Foam::fixedRhoFvPatchScalarField::write(Ostream& os) const { fvPatchScalarField::write(os); - writeEntryIfDifferent(os, "p", "p", this->pName_); - writeEntryIfDifferent(os, "psi", "thermo:psi", psiName_); + os.writeEntryIfDifferent("p", "p", pName_); + os.writeEntryIfDifferent("psi", "thermo:psi", psiName_); writeEntry("value", os); } diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C index b24f21fe8d..5d76f3deab 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralDyMFoam/rhoCentralDyMFoam.C @@ -113,6 +113,9 @@ int main(int argc, char *argv[]) phiv_pos -= mesh.phi(); phiv_neg -= mesh.phi(); } + // Note: extracted out the orientation so becomes unoriented + phiv_pos.setOriented(false); + phiv_neg.setOriented(false); volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi)); surfaceScalarField cSf_pos @@ -120,14 +123,11 @@ int main(int argc, char *argv[]) "cSf_pos", interpolate(c, pos, T.name())*mesh.magSf() ); - cSf_pos.setOriented(); - surfaceScalarField cSf_neg ( "cSf_neg", interpolate(c, neg, T.name())*mesh.magSf() ); - cSf_neg.setOriented(); surfaceScalarField ap ( @@ -168,11 +168,12 @@ int main(int argc, char *argv[]) phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg; - surfaceVectorField phiUp - ( - (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg) - + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf() - ); + surfaceVectorField phiU(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg); + // Note: reassembled orientation from the pos and neg parts so becomes + // oriented + phiU.setOriented(true); + + surfaceVectorField phiUp(phiU + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf()); surfaceScalarField phiEp ( @@ -185,7 +186,10 @@ int main(int argc, char *argv[]) // Make flux for pressure-work absolute if (mesh.moving()) { - phiEp += mesh.phi()*(a_pos*p_pos + a_neg*p_neg); + surfaceScalarField phia(a_pos*p_pos + a_neg*p_neg); + phia.setOriented(true); + + phiEp += mesh.phi()*phia; } volScalarField muEff("muEff", turbulence->muEff()); @@ -222,7 +226,7 @@ int main(int argc, char *argv[]) fvc::interpolate(muEff)*mesh.magSf()*fvc::snGrad(U) + fvc::dotInterpolate(mesh.Sf(), tauMC) ) - & (a_pos*U_pos + a_neg*U_neg) + & (a_pos*U_pos + a_neg*U_neg) ); solve diff --git a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C index 6550d62b28..a975275925 100644 --- a/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C +++ b/applications/solvers/compressible/rhoCentralFoam/rhoCentralFoam.C @@ -93,7 +93,10 @@ int main(int argc, char *argv[]) surfaceScalarField p_neg("p_neg", rho_neg*rPsi_neg); surfaceScalarField phiv_pos("phiv_pos", U_pos & mesh.Sf()); + // Note: extracted out the orientation so becomes unoriented + phiv_pos.setOriented(false); surfaceScalarField phiv_neg("phiv_neg", U_neg & mesh.Sf()); + phiv_neg.setOriented(false); volScalarField c("c", sqrt(thermo.Cp()/thermo.Cv()*rPsi)); surfaceScalarField cSf_pos @@ -101,20 +104,19 @@ int main(int argc, char *argv[]) "cSf_pos", interpolate(c, pos, T.name())*mesh.magSf() ); - cSf_pos.setOriented(); surfaceScalarField cSf_neg ( "cSf_neg", interpolate(c, neg, T.name())*mesh.magSf() ); - cSf_neg.setOriented(); surfaceScalarField ap ( "ap", max(max(phiv_pos + cSf_pos, phiv_neg + cSf_neg), v_zero) ); + surfaceScalarField am ( "am", @@ -163,11 +165,12 @@ int main(int argc, char *argv[]) phi = aphiv_pos*rho_pos + aphiv_neg*rho_neg; - surfaceVectorField phiUp - ( - (aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg) - + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf() - ); + surfaceVectorField phiU(aphiv_pos*rhoU_pos + aphiv_neg*rhoU_neg); + // Note: reassembled orientation from the pos and neg parts so becomes + // oriented + phiU.setOriented(true); + + surfaceVectorField phiUp(phiU + (a_pos*p_pos + a_neg*p_neg)*mesh.Sf()); surfaceScalarField phiEp ( diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H index 27f568bce7..41c1cd5635 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/createFields.H @@ -61,18 +61,6 @@ dimensionedScalar rhoMin ) ); -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; @@ -115,3 +103,15 @@ volScalarField K("K", 0.5*magSqr(U)); // Mask field for zeroing out contributions on hole cells #include "createCellMask.H" + +Info<< "Creating turbulence model\n" << endl; +autoPtr turbulence +( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) +); diff --git a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H index 5f1fc7451c..ec31872e6d 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/overRhoPimpleDyMFoam/pEqn.H @@ -7,8 +7,8 @@ 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); +volVectorField HbyA("HbyA", U); +HbyA = constrainHbyA(cellMask*rAU*UEqn.H(), U, p); if (pimple.nCorrPISO() <= 1) { diff --git a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/Make/files b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/Make/files new file mode 100644 index 0000000000..0519e8b961 --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/Make/files @@ -0,0 +1,3 @@ +rhoSimpleFoam.C + +EXE = $(FOAM_APPBIN)/overRhoSimpleFoam diff --git a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/Make/options b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/Make/options new file mode 100644 index 0000000000..e027221b0c --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/Make/options @@ -0,0 +1,27 @@ +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)/sampling/lnInclude \ + -I$(LIB_SRC)/dynamicFvMesh/lnInclude \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/overset/lnInclude + +EXE_LIBS = \ + -lcompressibleTransportModels \ + -lfluidThermophysicalModels \ + -lspecie \ + -lturbulenceModels \ + -lcompressibleTurbulenceModels \ + -lfiniteVolume \ + -lsampling \ + -lmeshTools \ + -lfvOptions \ + -loverset \ + -ldynamicFvMesh \ + -ltopoChangerFvMesh diff --git a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/UEqn.H b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/UEqn.H new file mode 100644 index 0000000000..9d4afec58e --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/UEqn.H @@ -0,0 +1,23 @@ + // Solve the Momentum equation + MRF.correctBoundaryVelocity(U); + + tmp tUEqn + ( + fvm::div(phi, U) + + MRF.DDt(rho, U) + + turbulence->divDevRhoReff(U) + == + fvOptions(rho, U) + ); + fvVectorMatrix& UEqn = tUEqn.ref(); + + UEqn.relax(); + + fvOptions.constrain(UEqn); + + if (simple.momentumPredictor()) + { + solve(UEqn == -cellMask*fvc::grad(p)); + } + + fvOptions.correct(U); diff --git a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createFieldRefs.H b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createFieldRefs.H new file mode 100644 index 0000000000..502b3b4230 --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createFieldRefs.H @@ -0,0 +1 @@ +const volScalarField& psi = thermo.psi(); diff --git a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createFields.H b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createFields.H new file mode 100644 index 0000000000..2544f3e559 --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createFields.H @@ -0,0 +1,91 @@ +Info<< "Reading thermophysical properties\n" << endl; + +autoPtr pThermo +( + fluidThermo::New(mesh) +); +fluidThermo& thermo = pThermo(); +thermo.validate(args.executable(), "h", "e"); + +volScalarField& p = thermo.p(); + +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" + +pressureControl pressureControl(p, rho, simple.dict()); + +mesh.setFluxRequired(p.name()); + +Info<< "Creating turbulence model\n" << endl; +autoPtr turbulence +( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) +); + +dimensionedScalar initialMass = fvc::domainIntegrate(rho); + +#include "createMRF.H" + +//- 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); + oversetDict.add("rho", 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) +); diff --git a/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createUpdatedDynamicFvMesh.H b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/createUpdatedDynamicFvMesh.H new file mode 100644 index 0000000000..db58f90828 --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/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/compressible/rhoSimpleFoam/overRhoSimpleFoam/pEqn.H b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/pEqn.H new file mode 100644 index 0000000000..b4e670bee7 --- /dev/null +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/pEqn.H @@ -0,0 +1,123 @@ +{ + surfaceScalarField faceMask(localMin(mesh).interpolate(cellMask)); + + volScalarField rAU(1.0/UEqn.A()); + surfaceScalarField rhorAUf("rhorAUf", faceMask*fvc::interpolate(rho*rAU)); + volVectorField HbyA("HbyA", U); + HbyA = constrainHbyA(cellMask*rAU*UEqn.H(), U, p); + tUEqn.clear(); + + bool closedVolume = false; + + surfaceScalarField phiHbyA("phiHbyA", fvc::interpolate(rho)*fvc::flux(HbyA)); + MRF.makeRelative(fvc::interpolate(rho), phiHbyA); + + // Update the pressure BCs to ensure flux consistency + constrainPressure(p, rho, U, phiHbyA, rhorAUf, MRF); + + if (simple.transonic()) + { + surfaceScalarField phid + ( + "phid", + (fvc::interpolate(psi)/fvc::interpolate(rho))*phiHbyA + ); + + phiHbyA -= fvc::interpolate(psi*p)*phiHbyA/fvc::interpolate(rho); + + while (simple.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvc::div(phiHbyA) + + fvm::div(phid, p) + - fvm::laplacian(rhorAUf, p) + == + fvOptions(psi, p, rho.name()) + ); + + // Relax the pressure equation to ensure diagonal-dominance + pEqn.relax(); + + pEqn.setReference + ( + pressureControl.refCell(), + pressureControl.refValue() + ); + + pEqn.solve(); + + if (simple.finalNonOrthogonalIter()) + { + phi = phiHbyA + pEqn.flux(); + } + } + } + else + { + closedVolume = adjustPhi(phiHbyA, U, p); + + if (adjustFringe) + { + oversetAdjustPhi(phiHbyA, U); + } + + while (simple.correctNonOrthogonal()) + { + fvScalarMatrix pEqn + ( + fvc::div(phiHbyA) + - fvm::laplacian(rhorAUf, p) + == + fvOptions(psi, p, rho.name()) + ); + + pEqn.setReference + ( + pressureControl.refCell(), + pressureControl.refValue() + ); + + pEqn.solve(); + + if (simple.finalNonOrthogonalIter()) + { + phi = phiHbyA + pEqn.flux(); + } + } + } + + #include "incompressible/continuityErrs.H" + + // Explicitly relax pressure for momentum corrector + p.relax(); + + volVectorField gradP(fvc::grad(p)); + + U = HbyA - rAU*cellMask*gradP; + U.correctBoundaryConditions(); + fvOptions.correct(U); + + + bool pLimited = pressureControl.limit(p); + + // For closed-volume cases adjust the pressure and density levels + // to obey overall mass continuity + if (closedVolume) + { + p += (initialMass - fvc::domainIntegrate(psi*p)) + /fvc::domainIntegrate(psi); + } + + if (pLimited || closedVolume) + { + p.correctBoundaryConditions(); + } + + rho = thermo.rho(); + + if (!simple.transonic()) + { + rho.relax(); + } +} diff --git a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/rhoSimpleFoam.C similarity index 59% rename from applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C rename to applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/rhoSimpleFoam.C index 35348ac933..d2aced6375 100644 --- a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C +++ b/applications/solvers/compressible/rhoSimpleFoam/overRhoSimpleFoam/rhoSimpleFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,43 +22,41 @@ License along with OpenFOAM. If not, see . Application - reactingParcelFilmFoam + overRhoSimpleFoam Group - grpLagrangianSolvers + grpCompressibleSolvers Description - Transient solver for compressible, turbulent flow with a reacting, - multiphase particle cloud, and surface film modelling. + Overset steady-state solver for turbulent flow of compressible fluids. \*---------------------------------------------------------------------------*/ #include "fvCFD.H" +#include "dynamicFvMesh.H" +#include "fluidThermo.H" #include "turbulentFluidThermoModel.H" -#include "basicReactingCloud.H" -#include "surfaceFilmModel.H" -#include "psiCombustionModel.H" -#include "radiationModel.H" -#include "SLGThermo.H" +#include "simpleControl.H" +#include "pressureControl.H" #include "fvOptions.H" -#include "pimpleControl.H" +#include "cellCellStencilObject.H" +#include "localMin.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 "createMesh.H" + #include "createUpdatedDynamicFvMesh.H" #include "createControl.H" - #include "createTimeControls.H" #include "createFields.H" #include "createFieldRefs.H" #include "createFvOptions.H" - #include "compressibleCourantNo.H" - #include "setInitialDeltaT.H" #include "initContinuityErrs.H" turbulence->validate(); @@ -67,46 +65,16 @@ int main(int argc, char *argv[]) Info<< "\nStarting time loop\n" << endl; - while (runTime.run()) + while (simple.loop()) { - #include "readTimeControls.H" - #include "compressibleCourantNo.H" - #include "setMultiRegionDeltaT.H" - #include "setDeltaT.H" - - runTime++; - Info<< "Time = " << runTime.timeName() << nl << endl; - parcels.evolve(); + // Pressure-velocity SIMPLE corrector + #include "UEqn.H" + #include "EEqn.H" + #include "pEqn.H" - surfaceFilm.evolve(); - - if (solvePrimaryRegion) - { - #include "rhoEqn.H" - - // --- PIMPLE loop - while (pimple.loop()) - { - #include "UEqn.H" - #include "YEqn.H" - #include "EEqn.H" - - // --- Pressure corrector loop - while (pimple.correct()) - { - #include "pEqn.H" - } - - if (pimple.turbCorr()) - { - turbulence->correct(); - } - } - - rho = thermo.rho(); - } + turbulence->correct(); runTime.write(); @@ -115,7 +83,7 @@ int main(int argc, char *argv[]) << nl << endl; } - Info<< "End" << endl; + Info<< "End\n" << endl; return 0; } diff --git a/applications/solvers/doc/solver.dox b/applications/solvers/doc/solver.dox index 4c829de162..56bc8f1fd7 100644 --- a/applications/solvers/doc/solver.dox +++ b/applications/solvers/doc/solver.dox @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,6 +39,7 @@ The available solvers are grouped into the following categories: - \ref grpLagrangianSolvers - \ref grpMultiphaseSolvers - \ref grpStressAnalysisSolvers + - \ref grpFiniteAreaSolvers \*---------------------------------------------------------------------------*/ diff --git a/applications/solvers/doc/solversDoc.H b/applications/solvers/doc/solversDoc.H index da58bc0ce3..c0a01e5d76 100644 --- a/applications/solvers/doc/solversDoc.H +++ b/applications/solvers/doc/solversDoc.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -34,4 +34,10 @@ License This group contains moving mesh solvers solvers @} +\defgroup grpFiniteAreaSolvers Finite area solvers +@{ + \ingroup grpSolvers + This group contains finite area solvers +@} + \*---------------------------------------------------------------------------*/ diff --git a/applications/solvers/electromagnetics/mhdFoam/createPhiB.H b/applications/solvers/electromagnetics/mhdFoam/createPhiB.H index 21076a51a5..02b48f8d28 100644 --- a/applications/solvers/electromagnetics/mhdFoam/createPhiB.H +++ b/applications/solvers/electromagnetics/mhdFoam/createPhiB.H @@ -9,7 +9,7 @@ IOobject phiBHeader surfaceScalarField* phiBPtr = nullptr; - if (phiBHeader.typeHeaderOk(true)) +if (phiBHeader.typeHeaderOk(true)) { Info<< "Reading face flux "; diff --git a/applications/solvers/finiteArea/liquidFilmFoam/Make/files b/applications/solvers/finiteArea/liquidFilmFoam/Make/files new file mode 100755 index 0000000000..39ee7f75e9 --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/Make/files @@ -0,0 +1,3 @@ +liquidFilmFoam.C + +EXE = $(FOAM_APPBIN)/liquidFilmFoam diff --git a/applications/solvers/finiteArea/liquidFilmFoam/Make/options b/applications/solvers/finiteArea/liquidFilmFoam/Make/options new file mode 100755 index 0000000000..02549914ff --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteArea/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/cfdTools/general/lnInclude + +EXE_LIBS = \ + -lfiniteArea \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/finiteArea/liquidFilmFoam/calcFrictionFactor.H b/applications/solvers/finiteArea/liquidFilmFoam/calcFrictionFactor.H new file mode 100644 index 0000000000..701b4635a1 --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/calcFrictionFactor.H @@ -0,0 +1,7 @@ +{ + // Stabilisation of friction factor calculation + // Friction factor is defined with standard gravity + frictionFactor.primitiveFieldRef() = + mag(2*9.81*sqr(manningField.primitiveField())/ + pow(mag(h.primitiveField()) + 1e-7, 1.0/3.0)); +} diff --git a/applications/solvers/finiteArea/liquidFilmFoam/capillaryCourantNo.H b/applications/solvers/finiteArea/liquidFilmFoam/capillaryCourantNo.H new file mode 100644 index 0000000000..8e66fd171f --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/capillaryCourantNo.H @@ -0,0 +1,13 @@ +{ + scalar CoNumSigma = max + ( + sqrt + ( + 2*M_PI*sigma*sqr(aMesh.edgeInterpolation::deltaCoeffs()) + *aMesh.edgeInterpolation::deltaCoeffs() + /rhol + ) + ).value()*runTime.deltaT().value(); + + Info<< "Max Capillary Courant Number = " << CoNumSigma << '\n' << endl; +} diff --git a/applications/solvers/finiteArea/liquidFilmFoam/createFaFields.H b/applications/solvers/finiteArea/liquidFilmFoam/createFaFields.H new file mode 100644 index 0000000000..5c760788c9 --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/createFaFields.H @@ -0,0 +1,158 @@ + Info<< "Reading field h" << endl; + areaScalarField h + ( + IOobject + ( + "h", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + aMesh + ); + + + Info<< "Reading field Us" << endl; + areaVectorField Us + ( + IOobject + ( + "Us", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + aMesh + ); + + + edgeScalarField phis + ( + IOobject + ( + "phis", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + fac::interpolate(Us) & aMesh.Le() + ); + + + edgeScalarField phi2s + ( + IOobject + ( + "phi2s", + runTime.timeName(), + mesh, + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE + ), + fac::interpolate(h*Us) & aMesh.Le() + ); + + + const areaVectorField& Ns = aMesh.faceAreaNormals(); + areaVectorField Gs(g - Ns*(Ns & g)); + areaScalarField Gn(mag(g - Gs)); + + // Mass source + areaScalarField Sm + ( + IOobject + ( + "Sm", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + aMesh, + dimensionedScalar("Sm", dimLength/dimTime, 0) + ); + + // Mass sink + areaScalarField Sd + ( + IOobject + ( + "Sd", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + aMesh, + dimensionedScalar("Sd", dimLength/dimTime, 0) + ); + + areaVectorField Ug + ( + IOobject + ( + "Sg", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + aMesh, + dimensionedVector("Ug", dimVelocity, vector::zero) + ); + + + // Surface pressure + areaScalarField ps + ( + IOobject + ( + "ps", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + rhol*Gn*h - sigma*fac::laplacian(h) + ); + + // Friction factor + areaScalarField dotProduct + ( + aMesh.faceAreaNormals() & (g/mag(g)) + ); + + Info<< "View factor: min = " << min(dotProduct.internalField()) + << " max = " << max(dotProduct.internalField()) << endl; + + areaScalarField manningField + ( + IOobject + ( + "manningField", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + aMesh + ); + + areaScalarField frictionFactor + ( + IOobject + ( + "frictionFactor", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + aMesh, + dimensionedScalar("one", dimless, 0.01) + ); + + aMesh.setFluxRequired("h"); diff --git a/applications/solvers/finiteArea/liquidFilmFoam/createFvFields.H b/applications/solvers/finiteArea/liquidFilmFoam/createFvFields.H new file mode 100644 index 0000000000..788b155588 --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/createFvFields.H @@ -0,0 +1,31 @@ +volVectorField U +( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedVector("0", dimVelocity, vector::zero) +); + + +volScalarField H +( + IOobject + ( + "H", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("0", dimLength, 0) +); + +// Create volume-to surface mapping object +volSurfaceMapping vsm(aMesh); diff --git a/applications/solvers/finiteArea/liquidFilmFoam/liquidFilmFoam.C b/applications/solvers/finiteArea/liquidFilmFoam/liquidFilmFoam.C new file mode 100644 index 0000000000..1f1f8e389d --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/liquidFilmFoam.C @@ -0,0 +1,160 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2016-2017 Wikki 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 + liquidFilmFoam + +Group + grpFiniteAreaSolvers + +Description + Transient solver for incompressible, laminar flow of Newtonian fluids in + liquid film formulation. + +Author + Zeljko Tukovic, FMENA + Hrvoje Jasak, Wikki Ltd. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "faCFD.H" +#include "loopControl.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createFaMesh.H" + #include "readGravitationalAcceleration.H" + #include "readTransportProperties.H" + #include "createFaFields.H" + #include "createFvFields.H" + #include "createTimeControls.H" + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.run()) + { + #include "readSolutionControls.H" + #include "readTimeControls.H" + #include "surfaceCourantNo.H" + #include "capillaryCourantNo.H" + #include "setDeltaT.H" + + runTime++; + + Info<< "Time = " << runTime.timeName() << nl << endl; + + while (iters.loop()) + { + phi2s = fac::interpolate(h)*phis; + + #include "calcFrictionFactor.H" + + faVectorMatrix UsEqn + ( + fam::ddt(h, Us) + + fam::div(phi2s, Us) + + fam::Sp(0.0125*frictionFactor*mag(Us), Us) + == + Gs*h + - fam::Sp(Sd, Us) + ); + + UsEqn.relax(); + solve(UsEqn == - fac::grad(ps*h)/rhol + ps*fac::grad(h)/rhol); + + areaScalarField UsA(UsEqn.A()); + + Us = UsEqn.H()/UsA; + Us.correctBoundaryConditions(); + + phis = + (fac::interpolate(Us) & aMesh.Le()) + - fac::interpolate(1.0/(rhol*UsA))*fac::lnGrad(ps*h)*aMesh.magLe() + + fac::interpolate(ps/(rhol*UsA))*fac::lnGrad(h)*aMesh.magLe(); + + faScalarMatrix hEqn + ( + fam::ddt(h) + + fam::div(phis, h) + == + Sm + - fam::Sp + ( + Sd/(h + dimensionedScalar("small", dimLength, SMALL)), + h + ) + ); + + hEqn.relax(); + hEqn.solve(); + + phi2s = hEqn.flux(); + + // Bound h + h.primitiveFieldRef() = max + ( + max + ( + h.primitiveField(), + fac::average(max(h, h0))().primitiveField() + *pos(h0.value() - h.primitiveField()) + ), + h0.value() + ); + + ps = rhol*Gn*h - sigma*fac::laplacian(h); + ps.correctBoundaryConditions(); + + Us -= (1.0/(rhol*UsA))*fac::grad(ps*h) + - (ps/(rhol*UsA))*fac::grad(h); + Us.correctBoundaryConditions(); + } + + if (runTime.outputTime()) + { + vsm.mapToVolume(h, H.boundaryFieldRef()); + vsm.mapToVolume(Us, U.boundaryFieldRef()); + + runTime.write(); + } + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/finiteArea/liquidFilmFoam/readSolutionControls.H b/applications/solvers/finiteArea/liquidFilmFoam/readSolutionControls.H new file mode 100644 index 0000000000..3d0c97261c --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/readSolutionControls.H @@ -0,0 +1 @@ +loopControl iters(runTime, aMesh.solutionDict(), "solution"); diff --git a/applications/solvers/finiteArea/liquidFilmFoam/readTransportProperties.H b/applications/solvers/finiteArea/liquidFilmFoam/readTransportProperties.H new file mode 100644 index 0000000000..2f2c99ffda --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/readTransportProperties.H @@ -0,0 +1,41 @@ +IOdictionary transportProperties +( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + +dimensionedScalar mug +( + transportProperties.lookup("mug") +); + +dimensionedScalar mul +( + transportProperties.lookup("mul") +); + +dimensionedScalar sigma +( + transportProperties.lookup("sigma") +); + +dimensionedScalar rhol +( + transportProperties.lookup("rhol") +); + +dimensionedScalar rhog +( + transportProperties.lookup("rhog") +); + +dimensionedScalar h0 +( + transportProperties.lookup("h0") +); diff --git a/applications/solvers/finiteArea/liquidFilmFoam/surfaceCourantNo.H b/applications/solvers/finiteArea/liquidFilmFoam/surfaceCourantNo.H new file mode 100644 index 0000000000..9e58e23282 --- /dev/null +++ b/applications/solvers/finiteArea/liquidFilmFoam/surfaceCourantNo.H @@ -0,0 +1,63 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2016-2017 Wikki 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 + surfaceCourantNo + +Author + Hrvoje Jasak, Wikki Ltd. + +Description + Calculates and outputs the mean and maximum Courant Numbers for the + Finite Area method. + +\*---------------------------------------------------------------------------*/ + +scalar CoNum = 0.0; +scalar meanCoNum = 0.0; +scalar velMag = 0.0; + +if (aMesh.nInternalEdges()) +{ + edgeScalarField SfUfbyDelta + ( + aMesh.edgeInterpolation::deltaCoeffs()*mag(phis) + ); + + CoNum = max(SfUfbyDelta/aMesh.magLe()) + .value()*runTime.deltaT().value(); + + meanCoNum = (sum(SfUfbyDelta)/sum(aMesh.magLe())) + .value()*runTime.deltaT().value(); + + velMag = max(mag(phis)/aMesh.magLe()).value(); +} + +Info<< "Courant Number mean: " << meanCoNum + << " max: " << CoNum + << " velocity magnitude: " << velMag << endl; + + +// ************************************************************************* // diff --git a/applications/solvers/finiteArea/sphereSurfactantFoam/Make/files b/applications/solvers/finiteArea/sphereSurfactantFoam/Make/files new file mode 100644 index 0000000000..574a497031 --- /dev/null +++ b/applications/solvers/finiteArea/sphereSurfactantFoam/Make/files @@ -0,0 +1,3 @@ +surfactantFoam.C + +EXE = $(FOAM_USER_APPBIN)/sphereSurfactantFoam diff --git a/applications/solvers/finiteArea/sphereSurfactantFoam/Make/options b/applications/solvers/finiteArea/sphereSurfactantFoam/Make/options new file mode 100644 index 0000000000..02549914ff --- /dev/null +++ b/applications/solvers/finiteArea/sphereSurfactantFoam/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteArea/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/cfdTools/general/lnInclude + +EXE_LIBS = \ + -lfiniteArea \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/finiteArea/sphereSurfactantFoam/createFaFields.H b/applications/solvers/finiteArea/sphereSurfactantFoam/createFaFields.H new file mode 100644 index 0000000000..4ec416f95b --- /dev/null +++ b/applications/solvers/finiteArea/sphereSurfactantFoam/createFaFields.H @@ -0,0 +1,78 @@ +Info<< "Reading field Cs" << endl; +areaScalarField Cs +( + IOobject + ( + "Cs", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + aMesh +); + +dimensioned Cs0 +( + "Cs0", + dimensionSet(1, -2, 0, 0, 0, 0, 0), + 1.0 +); + +const areaVectorField& R = aMesh.areaCentres(); + +Cs = Cs0*(1.0 + R.component(vector::X)/mag(R)); + + +dimensioned Ds +( + "Ds", + dimensionSet(0, 2, -1, 0, 0, 0, 0), + 1.0 +); + + +areaVectorField Us +( + IOobject + ( + "Us", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + aMesh, + dimensioned("Us", dimVelocity, vector::zero) +); + +dimensioned Uinf("Uinf", dimVelocity, 1.0); + +forAll (Us, faceI) +{ + Us[faceI].x() = + Uinf.value()*(0.25*(3.0 + sqr(R[faceI].x()/mag(R[faceI]))) - 1.0); + + Us[faceI].y() = + Uinf.value()*0.25*R[faceI].x()*R[faceI].y()/sqr(mag(R[faceI])); + + Us[faceI].z() = + Uinf.value()*0.25*R[faceI].x()*R[faceI].z()/sqr(mag(R[faceI])); +} + +Us -= aMesh.faceAreaNormals()*(aMesh.faceAreaNormals() & Us); + + +edgeScalarField phis +( + IOobject + ( + "phis", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + linearEdgeInterpolate(Us) & aMesh.Le() +); + diff --git a/applications/solvers/finiteArea/sphereSurfactantFoam/createFaMesh.H b/applications/solvers/finiteArea/sphereSurfactantFoam/createFaMesh.H new file mode 100644 index 0000000000..905c8e7405 --- /dev/null +++ b/applications/solvers/finiteArea/sphereSurfactantFoam/createFaMesh.H @@ -0,0 +1,2 @@ + // Create Finite Area mesh + faMesh aMesh(mesh); diff --git a/applications/solvers/finiteArea/sphereSurfactantFoam/createVolFields.H b/applications/solvers/finiteArea/sphereSurfactantFoam/createVolFields.H new file mode 100644 index 0000000000..fed56e0409 --- /dev/null +++ b/applications/solvers/finiteArea/sphereSurfactantFoam/createVolFields.H @@ -0,0 +1,36 @@ + // Create volume-to surface mapping object + volSurfaceMapping vsm(aMesh); + + volScalarField Cvf + ( + IOobject + ( + "Cvf", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("0", dimless/dimLength, 0) + ); + + vsm.mapToVolume(Cs, Cvf.boundaryFieldRef()); + Cvf.write(); + + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedVector("zero", dimVelocity, vector::zero) + ); + + vsm.mapToVolume(Us, U.boundaryFieldRef()); + U.write(); diff --git a/applications/solvers/finiteArea/sphereSurfactantFoam/surfactantFoam.C b/applications/solvers/finiteArea/sphereSurfactantFoam/surfactantFoam.C new file mode 100644 index 0000000000..893d46284d --- /dev/null +++ b/applications/solvers/finiteArea/sphereSurfactantFoam/surfactantFoam.C @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2016-2017 Wikki 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 + surfactantFoam for sphere transport + +Group + grpFiniteAreaSolvers + +Description + Passive scalar transport equation solver on a sphere + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "faCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + + #include "createFaMesh.H" + #include "createFaFields.H" + #include "createVolFields.H" + + Info<< "Total mass of surfactant: " + << sum(Cs.internalField()*aMesh.S()) << endl; + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.loop()) + { + Info<< "Time = " << runTime.value() << endl; + + faScalarMatrix CsEqn + ( + fam::ddt(Cs) + + fam::div(phis, Cs) + - fam::laplacian(Ds, Cs) + ); + + CsEqn.solve(); + + if (runTime.writeTime()) + { + vsm.mapToVolume(Cs, Cvf.boundaryFieldRef()); + + runTime.write(); + } + + Info<< "Total mass of surfactant: " + << sum(Cs.internalField()*aMesh.S()) << endl; + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/finiteArea/surfactantFoam/Make/files b/applications/solvers/finiteArea/surfactantFoam/Make/files new file mode 100644 index 0000000000..b4086fd825 --- /dev/null +++ b/applications/solvers/finiteArea/surfactantFoam/Make/files @@ -0,0 +1,3 @@ +surfactantFoam.C + +EXE = $(FOAM_APPBIN)/surfactantFoam diff --git a/applications/solvers/finiteArea/surfactantFoam/Make/options b/applications/solvers/finiteArea/surfactantFoam/Make/options new file mode 100644 index 0000000000..02549914ff --- /dev/null +++ b/applications/solvers/finiteArea/surfactantFoam/Make/options @@ -0,0 +1,10 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteArea/lnInclude \ + -I$(LIB_SRC)/finiteVolume/lnInclude \ + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/cfdTools/general/lnInclude + +EXE_LIBS = \ + -lfiniteArea \ + -lfiniteVolume \ + -lmeshTools diff --git a/applications/solvers/finiteArea/surfactantFoam/createFaFields.H b/applications/solvers/finiteArea/surfactantFoam/createFaFields.H new file mode 100644 index 0000000000..a285b21cee --- /dev/null +++ b/applications/solvers/finiteArea/surfactantFoam/createFaFields.H @@ -0,0 +1,63 @@ +Info<< "Reading field Cs" << endl; +areaScalarField Cs +( + IOobject + ( + "Cs", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::AUTO_WRITE + ), + aMesh +); + +Info<< "Reading transportProperties\n" << endl; + +IOdictionary transportProperties +( + IOobject + ( + "transportProperties", + runTime.constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) +); + + +Info<< "Reading diffusivity D\n" << endl; + +dimensionedScalar Ds +( + transportProperties.lookup("Ds") +); + +areaVectorField Us +( + IOobject + ( + "Us", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ), + aMesh +); + + +edgeScalarField phis +( + IOobject + ( + "phis", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + linearEdgeInterpolate(Us) & aMesh.Le() +); + diff --git a/applications/solvers/finiteArea/surfactantFoam/createFaMesh.H b/applications/solvers/finiteArea/surfactantFoam/createFaMesh.H new file mode 100644 index 0000000000..905c8e7405 --- /dev/null +++ b/applications/solvers/finiteArea/surfactantFoam/createFaMesh.H @@ -0,0 +1,2 @@ + // Create Finite Area mesh + faMesh aMesh(mesh); diff --git a/applications/solvers/finiteArea/surfactantFoam/createVolFields.H b/applications/solvers/finiteArea/surfactantFoam/createVolFields.H new file mode 100644 index 0000000000..fed56e0409 --- /dev/null +++ b/applications/solvers/finiteArea/surfactantFoam/createVolFields.H @@ -0,0 +1,36 @@ + // Create volume-to surface mapping object + volSurfaceMapping vsm(aMesh); + + volScalarField Cvf + ( + IOobject + ( + "Cvf", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedScalar("0", dimless/dimLength, 0) + ); + + vsm.mapToVolume(Cs, Cvf.boundaryFieldRef()); + Cvf.write(); + + volVectorField U + ( + IOobject + ( + "U", + runTime.timeName(), + mesh, + IOobject::NO_READ, + IOobject::AUTO_WRITE + ), + mesh, + dimensionedVector("zero", dimVelocity, vector::zero) + ); + + vsm.mapToVolume(Us, U.boundaryFieldRef()); + U.write(); diff --git a/applications/solvers/finiteArea/surfactantFoam/surfactantFoam.C b/applications/solvers/finiteArea/surfactantFoam/surfactantFoam.C new file mode 100644 index 0000000000..630ca8e668 --- /dev/null +++ b/applications/solvers/finiteArea/surfactantFoam/surfactantFoam.C @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | + \\/ M anipulation | +------------------------------------------------------------------------------- + | Copyright (C) 2016-2017 Wikki 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 + surfactantFoam + +Group + grpFiniteAreaSolvers + +Description + Passive scalar transport equation solver. + + \heading Solver details + The equation is given by: + + \f[ + \ddt{Cs} + \div \left(\vec{U} Cs\right) - \div \left(D_T \grad Cs \right) + = 0 + \f] + + Where: + \vartable + Cs | Passive scalar + Ds | Diffusion coefficient + \endvartable + + \heading Required fields + \plaintable + Cs | Passive scalar + Us | Velocity [m/s] + \endplaintable + +Author + Zeljko Tukovic, FMENA + Hrvoje Jasak, Wikki Ltd. + +\*---------------------------------------------------------------------------*/ + +#include "fvCFD.H" +#include "faCFD.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +int main(int argc, char *argv[]) +{ + #include "setRootCase.H" + #include "createTime.H" + #include "createMesh.H" + #include "createFaMesh.H" + #include "createFaFields.H" + #include "createVolFields.H" + + Info<< "Total mass of surfactant: " + << sum(Cs.internalField()*aMesh.S()) << endl; + + Info<< "\nStarting time loop\n" << endl; + + while (runTime.loop()) + { + Info<< "Time = " << runTime.value() << endl; + + faScalarMatrix CsEqn + ( + fam::ddt(Cs) + + fam::div(phis, Cs) + - fam::laplacian(Ds, Cs) + ); + + CsEqn.solve(); + + if (runTime.writeTime()) + { + vsm.mapToVolume(Cs, Cvf.boundaryFieldRef()); + + runTime.write(); + } + + Info<< "Total mass of surfactant: " + << sum(Cs.internalField()*aMesh.S()) << endl; + + Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" + << " ClockTime = " << runTime.elapsedClockTime() << " s" + << nl << endl; + } + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C index 155b08a0f8..80e7e78fbb 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionFoam.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. @@ -47,6 +47,7 @@ Description #include "radiationModel.H" #include "fvOptions.H" #include "coordinateSystem.H" +#include "loopControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -89,11 +90,10 @@ int main(int argc, char *argv[]) } } - // --- PIMPLE loop - for (int oCorr=0; oCorr 1) + { + loopControl looping(runTime, pimple, "energyCoupling"); + + while (looping.loop()) + { + Info<< nl << looping << nl; + + forAll(fluidRegions, i) + { + Info<< "\nSolving for fluid region " + << fluidRegions[i].name() << endl; + #include "setRegionFluidFields.H" + #include "readFluidMultiRegionPIMPLEControls.H" + frozenFlow = true; + #include "solveFluid.H" + } + + forAll(solidRegions, i) + { + Info<< "\nSolving for solid region " + << solidRegions[i].name() << endl; + #include "setRegionSolidFields.H" + #include "readSolidMultiRegionPIMPLEControls.H" + #include "solveSolid.H" + } + } + } } runTime.write(); diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C index ea89befe12..20aa2d59cd 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.C +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/chtMultiRegionSimpleFoam.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. @@ -42,6 +42,7 @@ Description #include "radiationModel.H" #include "fvOptions.H" #include "coordinateSystem.H" +#include "loopControl.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -57,7 +58,6 @@ int main(int argc, char *argv[]) #include "createFields.H" #include "initContinuityErrs.H" - while (runTime.loop()) { Info<< "Time = " << runTime.timeName() << nl << endl; @@ -80,6 +80,35 @@ int main(int argc, char *argv[]) #include "solveSolid.H" } + // Additional loops for energy solution only + { + loopControl looping(runTime, "SIMPLE", "energyCoupling"); + + while (looping.loop()) + { + Info<< nl << looping << nl; + + forAll(fluidRegions, i) + { + Info<< "\nSolving for fluid region " + << fluidRegions[i].name() << endl; + #include "setRegionFluidFields.H" + #include "readFluidMultiRegionSIMPLEControls.H" + frozenFlow = true; + #include "solveFluid.H" + } + + forAll(solidRegions, i) + { + Info<< "\nSolving for solid region " + << solidRegions[i].name() << endl; + #include "setRegionSolidFields.H" + #include "readSolidMultiRegionSIMPLEControls.H" + #include "solveSolid.H" + } + } + } + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H index 6cde0ec06b..119c2ad7ea 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/fluid/setRegionFluidFields.H @@ -12,6 +12,14 @@ volScalarField& p = thermo.p(); const volScalarField& psi = thermo.psi(); + volScalarField& p_rgh = p_rghFluid[i]; + + const dimensionedVector& g = gFluid[i]; + const volScalarField& gh = ghFluid[i]; + const surfaceScalarField& ghf = ghfFluid[i]; + + radiation::radiationModel& rad = radiation[i]; + IOMRFZoneList& MRF = MRFfluid[i]; fv::options& fvOptions = fluidFvOptions[i]; @@ -22,14 +30,7 @@ initialMassFluid[i] ); - radiation::radiationModel& rad = radiation[i]; + bool frozenFlow = frozenFlowFluid[i]; const label pRefCell = pRefCellFluid[i]; const scalar pRefValue = pRefValueFluid[i]; - const bool frozenFlow = frozenFlowFluid[i]; - - volScalarField& p_rgh = p_rghFluid[i]; - - const dimensionedVector& g = gFluid[i]; - const volScalarField& gh = ghFluid[i]; - const surfaceScalarField& ghf = ghfFluid[i]; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/solveSolid.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/solveSolid.H index 0600a1c650..2b6306e5c2 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/solveSolid.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/chtMultiRegionSimpleFoam/solid/solveSolid.H @@ -1,5 +1,5 @@ { - for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) + for (int nonOrth=0; nonOrth<=nNonOrthCorr; ++nonOrth) { fvScalarMatrix hEqn ( @@ -20,9 +20,9 @@ fvOptions.correct(h); } + + thermo.correct(); + + Info<< "Min/max T:" << min(thermo.T()).value() << ' ' + << max(thermo.T()).value() << endl; } - -thermo.correct(); - -Info<< "Min/max T:" << min(thermo.T()).value() << ' ' - << max(thermo.T()).value() << endl; diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index 87e372fcae..15aba4cb27 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -19,8 +19,8 @@ List frozenFlowFluid(fluidRegions.size(), false); PtrList MRFfluid(fluidRegions.size()); PtrList fluidFvOptions(fluidRegions.size()); -List