From 61c87b555270e0e9545daba33a1700f857045daa Mon Sep 17 00:00:00 2001 From: Johan Roenby Date: Tue, 30 Apr 2019 16:07:48 +0200 Subject: [PATCH 01/16] Introduced changes required to make isoAdvector and interIsoFoam work with morphing meshes: 1) In the alphaEqn.H U is made relative to mesh motion before the interface advection step, 2) in isoAdvection::advect() alpha must be multiplied by Vsc0()/Vsc(). Implementation tested and verified with 1) a spherical interface in a cubic domain with no flow, where the domain walls are squeezed together and 2) a spherical interfacee inside the sloshingCylinder, again with no flow, so the sphere should stay spherical, which it does. --- .../solvers/multiphase/interIsoFoam/alphaEqn.H | 13 +++++++++++++ .../isoAdvection/isoAdvection/isoAdvection.C | 8 +++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/applications/solvers/multiphase/interIsoFoam/alphaEqn.H b/applications/solvers/multiphase/interIsoFoam/alphaEqn.H index fda7a30c9b..8de0ac0161 100644 --- a/applications/solvers/multiphase/interIsoFoam/alphaEqn.H +++ b/applications/solvers/multiphase/interIsoFoam/alphaEqn.H @@ -1,6 +1,19 @@ { + // Temporarily making U relative to mesh motion + if (mesh.moving()) + { + U -= fvc::reconstruct(mesh.phi()); + } + // Updating alpha1 advector.advect(); + + // Making U absolute again after advection step + if (mesh.moving()) + { + U += fvc::reconstruct(mesh.phi()); + } + #include "rhofs.H" rhoPhi = advector.getRhoPhi(rho1f, rho2f); diff --git a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C index ac7667e663..edb2d75f1c 100644 --- a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C +++ b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoAdvection/isoAdvection.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- isoAdvector | Copyright (C) 2016-2017 DHI - Modified work | Copyright (C) 2018 Johan Roenby + Modified work | Copyright (C) 2019 Johan Roenby ------------------------------------------------------------------------------- License @@ -852,6 +852,12 @@ void Foam::isoAdvection::advect() // Do the isoAdvection on surface cells timeIntegratedFlux(); + // Adjust alpha for mesh motion + if (mesh_.moving()) + { + alpha1In_ *= (mesh_.Vsc0()/mesh_.Vsc()); + } + // Adjust dVf for unbounded cells limitFluxes(); From c83f3eda026fc89e717c2c81cabfb8753f54c162 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Fri, 14 Jun 2019 09:53:49 +0100 Subject: [PATCH 02/16] ENH: hydrostaticPressure FO - updated handling of pRef --- .../hydrostaticPressure/hydrostaticPressure.C | 8 +++++++- .../hydrostaticPressure/hydrostaticPressure.H | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C index 1b7e2505c7..2ea4db38c7 100644 --- a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C +++ b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.C @@ -57,6 +57,10 @@ Foam::dimensionedScalar Foam::functionObjects::hydrostaticPressure::pRef() const { if (pRefName_ == "none") + { + return dimensionedScalar(dimPressure, Zero); + } + else if (pRefName_ == "pInf") { return dimensionedScalar("pRef", dimPressure, pRefValue_); } @@ -217,10 +221,12 @@ bool Foam::functionObjects::hydrostaticPressure::read(const dictionary& dict) dict.readIfPresent("ghf", ghfName_); dict.readIfPresent("nCorrectors", nCorrectors_); - if (pRefName_ == "none") + pRefValue_ = 0; + if (pRefName_ == "pInf") { pRefValue_ = dict.get("pRefValue"); } + return true; } diff --git a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.H b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.H index d14228fe1e..ce280223e7 100644 --- a/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.H +++ b/src/functionObjects/initialisation/hydrostaticPressure/hydrostaticPressure.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2018 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -48,6 +48,7 @@ Usage p_rgh | Name of p_rgh field | no | p_rgh ph_rgh | Name of ph_rgh field | no | ph_rgh pRef | Name of pressure ref field | no | pRef + pRefValue | Value of pressure ref when pRef set to pInf | no | 0 rho | Name of density field | no | rho U | Name of velocity field | no | U gh | Name of gravity*height volume field | no | gh @@ -97,10 +98,10 @@ protected: word ph_rghName_; //- Name of uniform pressure reference field, default is "pRef" - // Set to "none" to set to zero + // Set to "none" to set to zero or pInf to set according to pRefValue word pRefName_; - //- Reference pressure if pRef is set to "none" + //- Reference pressure if pRefName is set to "pInf" scalar pRefValue_; //- Name of density field, default is "rho" From 17260280a4d606fe5a15f81133ab9b2e151e2d3a Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Wed, 20 Feb 2019 12:36:37 +0000 Subject: [PATCH 03/16] ENH: Forces function object - user can now select bin limits --- src/functionObjects/forces/forces/forces.C | 61 +++++++++++++++------- src/functionObjects/forces/forces/forces.H | 3 ++ 2 files changed, 46 insertions(+), 18 deletions(-) diff --git a/src/functionObjects/forces/forces/forces.C b/src/functionObjects/forces/forces/forces.C index 06a6e3ba5d..68c48405fe 100644 --- a/src/functionObjects/forces/forces/forces.C +++ b/src/functionObjects/forces/forces/forces.C @@ -107,6 +107,7 @@ void Foam::functionObjects::forces::writeBinHeader writeHeader(os, header + " bins"); writeHeaderValue(os, "bins", nBin_); writeHeaderValue(os, "start", binMin_); + writeHeaderValue(os, "end", binMax_); writeHeaderValue(os, "delta", binDx_); writeHeaderValue(os, "direction", binDir_); @@ -249,14 +250,14 @@ void Foam::functionObjects::forces::initialiseBins() const polyBoundaryMesh& pbm = mesh_.boundaryMesh(); // Determine extents of patches - binMin_ = GREAT; - scalar binMax = -GREAT; + scalar geomMin = GREAT; + scalar geomMax = -GREAT; for (const label patchi : patchSet_) { const polyPatch& pp = pbm[patchi]; scalarField d(pp.faceCentres() & binDir_); - binMin_ = min(min(d), binMin_); - binMax = max(max(d), binMax); + geomMin = min(min(d), geomMin); + geomMax = max(max(d), geomMax); } // Include porosity @@ -276,22 +277,31 @@ void Foam::functionObjects::forces::initialiseBins() { const cellZone& cZone = mesh_.cellZones()[zonei]; const scalarField d(dd, cZone); - binMin_ = min(min(d), binMin_); - binMax = max(max(d), binMax); + geomMin = min(min(d), geomMin); + geomMax = max(max(d), geomMax); } } } - reduce(binMin_, minOp()); - reduce(binMax, maxOp()); + reduce(geomMin, minOp()); + reduce(geomMax, maxOp()); - // Slightly boost binMax so that region of interest is fully - // within bounds - binMax = 1.0001*(binMax - binMin_) + binMin_; + // Slightly boost max so that region of interest is fully within bounds + geomMax = 1.0001*(geomMax - geomMin) + geomMin; - binDx_ = (binMax - binMin_)/scalar(nBin_); + // Use geometry limits if not specified by the user + if (binMin_ == GREAT) + { + binMin_ = geomMin; + } + if (binMax_ == GREAT) + { + binMax_ = geomMax; + } - // Create the bin points used for writing + binDx_ = (binMax_ - binMin_)/scalar(nBin_); + + // Create the bin mid-points used for writing binPoints_.setSize(nBin_); forAll(binPoints_, i) { @@ -723,8 +733,9 @@ Foam::functionObjects::forces::forces porosity_(false), nBin_(1), binDir_(Zero), - binDx_(0.0), + binDx_(0), binMin_(GREAT), + binMax_(GREAT), binPoints_(), binCumulative_(true), writeFields_(false), @@ -767,8 +778,9 @@ Foam::functionObjects::forces::forces porosity_(false), nBin_(1), binDir_(Zero), - binDx_(0.0), + binDx_(0), binMin_(GREAT), + binMax_(GREAT), binPoints_(), binCumulative_(true), writeFields_(false), @@ -848,8 +860,9 @@ bool Foam::functionObjects::forces::read(const dictionary& dict) if (dict.found("binData")) { + Info<< " Activated data bins" << endl; const dictionary& binDict(dict.subDict("binData")); - binDict.readEntry("nBin", nBin_); + nBin_ = binDict.get