From a129d6a146cd57980225d80740c86914909b0f9e Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Fri, 8 Sep 2017 17:22:49 +0100 Subject: [PATCH 1/4] ENH: isoCutCell - improved robustness. Patch provided by Johan Roenby - see #582 --- .../isoAdvection/isoCutCell/isoCutCell.C | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C index 33563d728d..30aaa5f72b 100644 --- a/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C +++ b/src/finiteVolume/fvMatrices/solvers/isoAdvection/isoCutCell/isoCutCell.C @@ -361,6 +361,23 @@ Foam::label Foam::isoCutCell::calcSubCell // Cell cut at least at one face cellStatus_ = 0; calcIsoFaceCentreAndArea(); + + // In the rare but occuring cases where a cell is only touched at a + // point or a line the isoFaceArea_ will have zero length and here the + // cell should be treated as either completely empty or full. + if (mag(isoFaceArea_) < 10*SMALL) + { + if (fullySubFaces_.empty()) + { + // Cell fully above isosurface + cellStatus_ = 1; + } + else + { + // Cell fully below isosurface + cellStatus_ = -1; + } + } } else if (fullySubFaces_.empty()) { From cfeb2c9233dc813296114aa76ce1a647670f74d2 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 8 Sep 2017 15:35:27 -0700 Subject: [PATCH 2/4] ENH: adding oversetAdjustPhi to overInterFoam plus reconstructing U from phi in pEq. --- .../interFoam/overInterDyMFoam/createDyMControls.H | 5 +++++ .../interFoam/overInterDyMFoam/interDyMFoam.C | 3 ++- .../multiphase/interFoam/overInterDyMFoam/pEqn.H | 10 +++++++++- .../interFoam/overInterDyMFoam/readControls.H | 5 +++-- .../floatingBody/background/system/fvSolution | 2 ++ 5 files changed, 21 insertions(+), 4 deletions(-) diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/createDyMControls.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/createDyMControls.H index cb2dfd5ddd..5ddaf3477a 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/createDyMControls.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/createDyMControls.H @@ -23,3 +23,8 @@ bool ddtCorr ( pimple.dict().lookupOrDefault("ddtCorr", true) ); + +bool adjustFringe +( + pimple.dict().lookupOrDefault("oversetAdjustPhi", false) +); diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C index 7bb7f8af6b..4a986ef175 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/interDyMFoam.C @@ -53,6 +53,7 @@ Description #include "interpolationCellPoint.H" #include "transform.H" #include "fvMeshSubset.H" +#include "oversetAdjustPhi.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -64,7 +65,7 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createDynamicFvMesh.H" #include "initContinuityErrs.H" - #include "createControl.H" + pimpleControl pimple(mesh); #include "createTimeControls.H" #include "createDyMControls.H" #include "createFields.H" diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H index 0a5b0296b8..e332a353f6 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/pEqn.H @@ -38,6 +38,13 @@ phiHbyA += phig; + if (adjustFringe) + { + fvc::makeRelative(phiHbyA, U); + oversetAdjustPhi(phiHbyA, U); + fvc::makeAbsolute(phiHbyA, U); + } + // Update the pressure BCs to ensure flux consistency constrainPressure(p_rgh, U, phiHbyA, rAUf, MRF); @@ -64,7 +71,8 @@ "minGradP", fvc::reconstruct((phig - p_rghEqn.flux())/rAUf) ); - U = HbyA + rAU*cellMask*minGradP; + //U = HbyA + rAU*cellMask*minGradP; + U = fvc::reconstruct(phi); U.correctBoundaryConditions(); fvOptions.correct(U); } diff --git a/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H b/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H index 0df2a74f30..d8481c8870 100644 --- a/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H +++ b/applications/solvers/multiphase/interFoam/overInterDyMFoam/readControls.H @@ -11,5 +11,6 @@ moveMeshOuterCorrectors = massFluxInterpolation = pimple.dict().lookupOrDefault("massFluxInterpolation", false); -ddtCorr = - pimple.dict().lookupOrDefault("ddtCorr", true); \ No newline at end of file +ddtCorr = pimple.dict().lookupOrDefault("ddtCorr", true); + +adjustFringe = pimple.dict().lookupOrDefault("oversetAdjustPhi", false); diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSolution b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSolution index f7341ee5c0..04bfe4172a 100644 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSolution +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSolution @@ -85,6 +85,8 @@ PIMPLE ddtCorr yes; correctPhi no; + oversetAdjustPhi no; + moveMeshOuterCorrectors no; turbOnFinalIterOnly no; } From 0eeffc318b15097be874263071f27c93062cdb88 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 8 Sep 2017 15:40:22 -0700 Subject: [PATCH 3/4] ENH: Adding required interpolation for alpha.water in fvSchemes for overInterDyMFoam floatingBody tutorial --- .../floatingBody/background/system/fvSchemes | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSchemes b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSchemes index a7cd9fea3a..9c0e331c99 100644 --- a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSchemes +++ b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/system/fvSchemes @@ -57,6 +57,11 @@ oversetInterpolation method inverseDistance; } +oversetInterpolationRequired +{ + alpha.water; +} + fluxRequired { default no; From 071dfb36fd658096e43742a1a257c7fc67f89512 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 15 Sep 2017 10:40:55 +0200 Subject: [PATCH 4/4] BUG: parse issues for nastran long format (closes #589) --- src/fileFormats/nas/NASCore.C | 25 +++++++++++-------- src/fileFormats/nas/NASCore.H | 4 +-- .../triSurface/interfaces/NAS/readNAS.C | 25 ++++--------------- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/fileFormats/nas/NASCore.C b/src/fileFormats/nas/NASCore.C index 45edbd9691..176953cc67 100644 --- a/src/fileFormats/nas/NASCore.C +++ b/src/fileFormats/nas/NASCore.C @@ -34,28 +34,33 @@ Foam::fileFormats::NASCore::NASCore() // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // -Foam::scalar Foam::fileFormats::NASCore::parseNASCoord -( - const string& s -) +Foam::scalar Foam::fileFormats::NASCore::parseNASCoord(const string& s) { - size_t expSign = s.find_last_of("+-"); + scalar value = 0; - if (expSign != string::npos && expSign > 0 && !isspace(s[expSign-1])) + const size_t expSign = s.find_last_of("+-"); + + if (expSign != std::string::npos && expSign > 0 && !isspace(s[expSign-1])) { - scalar mantissa = readScalar(IStringStream(s.substr(0, expSign))()); - scalar exponent = readScalar(IStringStream(s.substr(expSign+1))()); + scalar exponent = 0; + + // Parse as per strtod/strtof - allowing trailing space or [Ee] + readScalar(s.substr(0, expSign).c_str(), value); // mantissa + readScalar(s.substr(expSign+1).c_str(), exponent); if (s[expSign] == '-') { exponent = -exponent; } - return mantissa * pow(10, exponent); + + value *= ::pow(10, exponent); } else { - return readScalar(IStringStream(s)()); + readScalar(s.c_str(), value); } + + return value; } diff --git a/src/fileFormats/nas/NASCore.H b/src/fileFormats/nas/NASCore.H index e19a040569..ebe3dabb97 100644 --- a/src/fileFormats/nas/NASCore.H +++ b/src/fileFormats/nas/NASCore.H @@ -55,8 +55,8 @@ public: // Public Member Functions - //- Do weird things to extract number - static scalar parseNASCoord(const string&); + //- Extract numbers from things like "-2.358-8" (same as "-2.358e-8") + static scalar parseNASCoord(const string& s); // Constructors diff --git a/src/surfMesh/triSurface/interfaces/NAS/readNAS.C b/src/surfMesh/triSurface/interfaces/NAS/readNAS.C index ae55c60ca3..90aee2238c 100644 --- a/src/surfMesh/triSurface/interfaces/NAS/readNAS.C +++ b/src/surfMesh/triSurface/interfaces/NAS/readNAS.C @@ -36,6 +36,7 @@ Description \*---------------------------------------------------------------------------*/ #include "triSurface.H" +#include "NASCore.H" #include "IFstream.H" #include "IStringStream.H" @@ -47,25 +48,9 @@ namespace Foam // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // Do weird things to extract number -static scalar parseNASCoord(const string& s) +static inline scalar parseNASCoord(const string& s) { - size_t expSign = s.find_last_of("+-"); - - if (expSign != string::npos && expSign > 0 && !isspace(s[expSign-1])) - { - scalar mantissa = readScalar(IStringStream(s.substr(0, expSign))()); - scalar exponent = readScalar(IStringStream(s.substr(expSign+1))()); - - if (s[expSign] == '-') - { - exponent = -exponent; - } - return mantissa*pow(10, exponent); - } - else - { - return readScalar(IStringStream(s)()); - } + return fileFormats::NASCore::parseNASCoord(s); } @@ -311,8 +296,8 @@ bool triSurface::readNAS(const fileName& fName) // GRID* 126 0 -5.55999875E+02 -5.68730474E+02 // * 2.14897901E+02 label index = - readLabel(IStringStream(readNASToken(line, 8, linei))()); - readNASToken(line, 8, linei); + readLabel(IStringStream(readNASToken(line, 16, linei))()); + readNASToken(line, 16, linei); scalar x = parseNASCoord(readNASToken(line, 16, linei)); scalar y = parseNASCoord(readNASToken(line, 16, linei));