From 700e17bdb484d60cd8e01ac6fd1e131819ddfefc Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Fri, 8 Dec 2017 15:54:34 +0000 Subject: [PATCH 01/29] INT: Initial check-in of IH Cantabria streamFunction wave generation model and test case Code supplied by Gabriel BARAJAS OJEDA --- src/waveModels/Make/files | 1 + .../streamFunction/streamFunctionWaveModel.C | 253 ++++++++++++++++++ .../streamFunction/streamFunctionWaveModel.H | 162 +++++++++++ .../waveExampleStreamFunction/0.orig/U | 54 ++++ .../0.orig/alpha.water | 52 ++++ .../waveExampleStreamFunction/0.orig/p_rgh | 54 ++++ .../waveExampleStreamFunction/Allclean | 10 + .../laminar/waveExampleStreamFunction/Allrun | 15 ++ .../waveExampleStreamFunction/constant/g | 22 ++ .../constant/transportProperties | 37 +++ .../constant/turbulenceProperties | 20 ++ .../constant/waveProperties | 84 ++++++ .../system/blockMeshDict | 91 +++++++ .../system/controlDict | 162 +++++++++++ .../system/decomposeParDict | 29 ++ .../system/fvSchemes | 54 ++++ .../system/fvSolution | 78 ++++++ .../system/setFieldsDict | 36 +++ 18 files changed, 1214 insertions(+) create mode 100644 src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.C create mode 100644 src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.H create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/U create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/alpha.water create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/p_rgh create mode 100755 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allclean create mode 100755 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allrun create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/g create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/transportProperties create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/turbulenceProperties create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/waveProperties create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/blockMeshDict create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/controlDict create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/decomposeParDict create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSchemes create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSolution create mode 100644 tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/setFieldsDict diff --git a/src/waveModels/Make/files b/src/waveModels/Make/files index 44b6ad45c1..d50a062cf3 100644 --- a/src/waveModels/Make/files +++ b/src/waveModels/Make/files @@ -8,6 +8,7 @@ waveGenerationModels/derived/Boussinesq/BoussinesqWaveModel.C waveGenerationModels/derived/cnoidal/cnoidalWaveModel.C waveGenerationModels/derived/Grimshaw/GrimshawWaveModel.C waveGenerationModels/derived/McCowan/McCowanWaveModel.C +waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.C waveGenerationModels/derived/StokesII/StokesIIWaveModel.C waveGenerationModels/derived/StokesI/StokesIWaveModel.C waveGenerationModels/derived/StokesV/StokesVWaveModel.C diff --git a/src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.C b/src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.C new file mode 100644 index 0000000000..30a2e037ec --- /dev/null +++ b/src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.C @@ -0,0 +1,253 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015 IH-Cantabria +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "streamFunctionWaveModel.H" +#include "mathematicalConstants.H" +#include "addToRunTimeSelectionTable.H" + +using namespace Foam::constant; + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ +namespace waveModels +{ + defineTypeNameAndDebug(streamFunction, 0); + addToRunTimeSelectionTable + ( + waveModel, + streamFunction, + patch + ); +} +} + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * // + +Foam::scalar Foam::waveModels::streamFunction::eta +( + const scalar h, + const scalar kx, + const scalar ky, + const scalar T, + const scalar x, + const scalar y, + const scalar omega, + const scalar t, + const scalar phase +) const +{ + + const scalar k = sqrt(kx*kx + ky*ky); + scalar strfnAux = 0.0; + forAll(Ejs_, iterSF) + { + strfnAux += Ejs_[iterSF]*cos((iterSF + 1) + *(kx*x + ky*y - omega*t + phase)); + } + + return (1/k)*strfnAux; +} + +Foam::vector Foam::waveModels::streamFunction::Uf +( + const scalar h, + const scalar kx, + const scalar ky, + const scalar T, + const scalar x, + const scalar y, + const scalar omega, + const scalar t, + const scalar phase, + const scalar z +) const +{ + const scalar k = sqrt(kx*kx + ky*ky); + const scalar phaseTot = kx*x + ky*y - omega*t + phase; + + scalar u = 0.0; + scalar w = 0.0; + + forAll(Bjs_, iterSF2) + { + u += (iterSF2 + 1)*Bjs_[iterSF2] *cosh((iterSF2 + 1)*k*z) + /cosh((iterSF2 + 1)*k*h)*cos((iterSF2 + 1)*phaseTot); + + w += (iterSF2 + 1)*Bjs_[iterSF2]*sinh((iterSF2 + 1)*k*z) + /cosh((iterSF2 + 1)*k*h)*sin((iterSF2 + 1)*phaseTot); + } + + u = waveLengthSF_/T - uMean_ + sqrt(mag(g_)/k)*u; + w = sqrt(mag(g_)/k)*w; + + scalar v = u*sin(waveAngle_); + u *= cos(waveAngle_); + + return vector(u, v, w); +} + + +// * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * * // + +void Foam::waveModels::streamFunction::setLevel +( + const scalar t, + const scalar tCoeff, + scalarField& level +) const +{ + const scalar waveOmega = mathematical::twoPi/wavePeriod_; + const scalar waveK = mathematical::twoPi/waveLengthSF_; + const scalar waveKx = waveK*cos(waveAngle_); + const scalar waveKy = waveK*sin(waveAngle_); + + forAll(level, paddlei) + { + const scalar eta = + this->eta + ( + waterDepthRef_, + waveKx, + waveKy, + wavePeriod_, + xPaddle_[paddlei], + yPaddle_[paddlei], + waveOmega, + t, + wavePhase_ + ); + + level[paddlei] = waterDepthRef_ + tCoeff*eta; + } +} + + +void Foam::waveModels::streamFunction::setVelocity +( + const scalar t, + const scalar tCoeff, + const scalarField& level +) +{ + const scalar waveOmega = mathematical::twoPi/wavePeriod_; + const scalar waveK = mathematical::twoPi/waveLengthSF_; + const scalar waveKx = waveK*cos(waveAngle_); + const scalar waveKy = waveK*sin(waveAngle_); + + forAll(U_, facei) + { + // Fraction of geometry represented by paddle - to be set + scalar fraction = 1; + + // Height - to be set + scalar z = 0; + + setPaddlePropeties(level, facei, fraction, z); + + if (fraction > 0) + { + const label paddlei = faceToPaddle_[facei]; + + const vector Uf = this->Uf + ( + waterDepthRef_, + waveKx, + waveKy, + wavePeriod_, + xPaddle_[paddlei], + yPaddle_[paddlei], + waveOmega, + t, + wavePhase_, + z + ); + + U_[facei] = fraction*Uf*tCoeff; + } + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::waveModels::streamFunction::streamFunction +( + const dictionary& dict, + const fvMesh& mesh, + const polyPatch& patch, + const bool readFields +) +: + regularWaveModel(dict, mesh, patch, false), + uMean_(0), + waveLengthSF_(0), + Bjs_( List (1, -1.0) ), + Ejs_( List (1, -1.0) ) +{ + if (readFields) + { + readDict(dict); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::waveModels::streamFunction::~streamFunction() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::waveModels::streamFunction::readDict(const dictionary& overrideDict) +{ + if (regularWaveModel::readDict(overrideDict)) + { + lookup("uMean") >> uMean_; + lookup("waveLengthSF") >> waveLengthSF_; + lookup("Bjs") >> Bjs_; + lookup("Ejs") >> Ejs_; + + return true; + } + + return false; +} + + +void Foam::waveModels::streamFunction::info(Ostream& os) const +{ + regularWaveModel::info(os); + + os << " uMean : " << uMean_ << nl + << " wave Length streamFunction : " << waveLengthSF_ << nl + << " Bj coefficients : " << Bjs_ << nl + << " Ej coefficients : " << Ejs_ << nl; +} + + diff --git a/src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.H b/src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.H new file mode 100644 index 0000000000..4728c9c1e1 --- /dev/null +++ b/src/waveModels/waveGenerationModels/derived/streamFunction/streamFunctionWaveModel.H @@ -0,0 +1,162 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2016-2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015 IH-Cantabria +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::waveModels::streamFunction + +Description + streamFunction wave model + +\*---------------------------------------------------------------------------*/ + +#ifndef waveModels_streamFunction_H +#define waveModels_streamFunction_H + +#include "regularWaveModel.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ +namespace waveModels +{ + +/*---------------------------------------------------------------------------*\ + Class streamFunction Declaration +\*---------------------------------------------------------------------------*/ + +class streamFunction +: + public regularWaveModel +{ +private: + + + + // Private Member Functions + + //- Wave height + virtual scalar eta + ( + const scalar h, + const scalar kx, + const scalar ky, + const scalar T, + const scalar x, + const scalar y, + const scalar omega, + const scalar t, + const scalar phase + ) const; + + //- Wave velocity + virtual vector Uf + ( + const scalar d, + const scalar kx, + const scalar ky, + const scalar T, + const scalar x, + const scalar y, + const scalar omega, + const scalar t, + const scalar phase, + const scalar z + ) const; + + +protected: + + // Protected data + + //- Mean fluid speed in frame of reference (stream function) + scalar uMean_; + + //-Stream waveLength + scalar waveLengthSF_; + + //- Stream Function Bj coefficients + scalarList Bjs_; + + //- Stream Function Ej coefficients + scalarList Ejs_; + + + // Protected Member Functions + + + //- Set the water level + virtual void setLevel + ( + const scalar t, + const scalar tCoeff, + scalarField& level + ) const; + + //- Calculate the wave model velocity + virtual void setVelocity + ( + const scalar t, + const scalar tCoeff, + const scalarField& level + ); + + +public: + + //- Runtime type information + TypeName("streamFunction"); + + //- Constructor + streamFunction + ( + const dictionary& dict, + const fvMesh& mesh, + const polyPatch& patch, + const bool readFields = true + ); + + //- Destructor + virtual ~streamFunction(); + + + // Public Member Functions + + //- Read from dictionary + virtual bool readDict(const dictionary& overrideDict); + + //- Info + virtual void info(Ostream& os) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace waveModels +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/U b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/U new file mode 100644 index 0000000000..95453554e5 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/U @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform (0 0 0); + +boundaryField +{ + inlet + { + type waveVelocity; + value uniform (0 0 0); + } + + outlet + { + type waveVelocity; + value uniform (0 0 0); + } + + sides + { + type empty; + } + + ground + { + type fixedValue; + value uniform (0 0 0); + } + + top + { + type pressureInletOutletVelocity; + value uniform (0 0 0); + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/alpha.water b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/alpha.water new file mode 100644 index 0000000000..aca611d915 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/alpha.water @@ -0,0 +1,52 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object alpha.water; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type waveAlpha; + value uniform 0; + } + + outlet + { + type zeroGradient; + } + + ground + { + type zeroGradient; + } + + sides + { + type empty; + } + + top + { + type inletOutlet; + inletValue uniform 0; + value uniform 0; + } +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/p_rgh b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/p_rgh new file mode 100644 index 0000000000..f43a02558a --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/0.orig/p_rgh @@ -0,0 +1,54 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + object p_rgh; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + inlet + { + type fixedFluxPressure; + value uniform 0; + } + + outlet + { + type fixedFluxPressure; + value uniform 0; + } + + ground + { + type fixedFluxPressure; + value uniform 0; + } + + sides + { + type empty; + } + + top + { + type totalPressure; + p0 uniform 0; + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allclean b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allclean new file mode 100755 index 0000000000..705f91474c --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allclean @@ -0,0 +1,10 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/CleanFunctions + +rm -rf 0 + +cleanCase + diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allrun b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allrun new file mode 100755 index 0000000000..9f0c668029 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/Allrun @@ -0,0 +1,15 @@ +#!/bin/sh +cd ${0%/*} || exit 1 # run from this directory + +# Source tutorial run functions +. $WM_PROJECT_DIR/bin/tools/RunFunctions + +restore0Dir + +runApplication blockMesh + +runApplication decomposePar + +runParallel setFields + +runParallel $(getApplication) diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/g b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/g new file mode 100644 index 0000000000..3ec2141e5c --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/g @@ -0,0 +1,22 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value ( 0 0 -9.81 ); + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/transportProperties b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/transportProperties new file mode 100644 index 0000000000..43a98e9c59 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/transportProperties @@ -0,0 +1,37 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object transportProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +phases (water air); + +water +{ + transportModel Newtonian; + nu 1e-06; + rho 1000; +} + +air +{ + transportModel Newtonian; + nu 1.48e-05; + rho 1; +} + +sigma 0.07; + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/turbulenceProperties b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/turbulenceProperties new file mode 100644 index 0000000000..115a9830c1 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/turbulenceProperties @@ -0,0 +1,20 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType laminar; + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/waveProperties b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/waveProperties new file mode 100644 index 0000000000..762db81aa5 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/constant/waveProperties @@ -0,0 +1,84 @@ +/*---------------------------------------------------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object wavesProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +inlet +{ + alpha alpha.water; + + waveModel streamFunction; + + nPaddle 1; + + waveHeight 0.1517; + + waveAngle 0.0; + + rampTime 6.034; + + activeAbsorption yes; + + wavePeriod 3.017; + + uMean 2.0825; + + waveLengthSF 6.2832; + + Bjs + 10 + ( + 8.6669014e-002 + 2.4849799e-002 + 7.7446850e-003 + 2.3355420e-003 + 6.4497731e-004 + 1.5205114e-004 + 2.5433769e-005 + -2.2045436e-007 + -2.8711504e-006 + -1.2287334e-006 + ); + + Ejs + 10 + ( + 5.6009609e-002 + 3.1638171e-002 + 1.5375952e-002 + 7.1743178e-003 + 3.3737077e-003 + 1.6324880e-003 + 8.2331980e-004 + 4.4403497e-004 + 2.7580059e-004 + 2.2810557e-004 + ); + +} + +outlet +{ + alpha alpha.water; + + waveModel shallowWaterAbsorption; + + nPaddle 1; +} + + +// ************************************************************************* // + + diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/blockMeshDict b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/blockMeshDict new file mode 100644 index 0000000000..cf37101f40 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/blockMeshDict @@ -0,0 +1,91 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + ( 0.0 0.0 0.0) + ( 40.0 0.0 0.0) + ( 40.0 0.01 0.0) + ( 0.0 0.01 0.0) + ( 0.0 0.0 0.8) + ( 40.0 0.0 0.8) + ( 40.0 0.01 0.8) + ( 0.0 0.01 0.8) +); + +blocks +( + hex (0 1 2 3 4 5 6 7) (2000 1 80) simpleGrading (1 1 1) +); + +edges +( +); + +boundary +( + inlet + { + type patch; + faces + ( + (0 4 7 3) + ); + } + outlet + { + type patch; + faces + ( + (1 5 6 2) + ); + } + ground + { + type wall; + faces + ( + (0 1 2 3) + ); + } + top + { + type patch; + faces + ( + (4 5 6 7) + ); + } + sides + { + type empty; + faces + ( + (0 1 5 4) + (3 2 6 7) + ); + } +); + +mergePatchPairs +( +); + +// ************************************************************************* // + + diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/controlDict b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/controlDict new file mode 100644 index 0000000000..5539a0a0b2 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/controlDict @@ -0,0 +1,162 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application interFoam; + +startFrom latestTime; + +startTime 0; + +stopAt endTime; + +endTime 30.0; + +deltaT 0.01; + +writeControl adjustableRunTime; + +writeInterval 0.033; + +purgeWrite 0; + +writeFormat ascii; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 6; + +runTimeModifiable yes; + +adjustTimeStep yes; + +maxCo 0.65; +maxAlphaCo 0.65; + +maxDeltaT 0.05; + + +functions +{ + line + { + type sets; + libs ("libsampling.so"); + enabled true; + writeControl writeTime; + writeInterval 1; + + interpolationScheme cellPoint; + setFormat raw; + sets + ( + line1 + { + type uniform; + axis distance; + start ( 1.0 0.005 0.0 ); + end ( 1.0 0.005 1.0 ); + nPoints 1001; + } + line2 + { + type uniform; + axis distance; + start ( 2.0 0.005 0.0 ); + end ( 2.0 0.005 1.0 ); + nPoints 1001; + } + line3 + { + type uniform; + axis distance; + start ( 3.0 0.005 0.0 ); + end ( 3.0 0.005 1.0 ); + nPoints 1001; + } + line4 + { + type uniform; + axis distance; + start ( 5.0 0.005 0.0 ); + end ( 5.0 0.005 1.0 ); + nPoints 1001; + } + line5 + { + type uniform; + axis distance; + start ( 7.5 0.005 0.0 ); + end ( 7.5 0.005 1.0 ); + nPoints 1001; + } + + line6 + { + type uniform; + axis distance; + start ( 10.0 0.005 0.0 ); + end ( 10.0 0.005 1.0 ); + nPoints 1001; + } + line7 + { + type uniform; + axis distance; + start ( 12.0 0.005 0.0 ); + end ( 12.0 0.005 1.0 ); + nPoints 1001; + } + line8 + { + type uniform; + axis distance; + start ( 15.0 0.005 0.0 ); + end ( 15.0 0.005 1.0 ); + nPoints 1001; + } + line9 + { + type uniform; + axis distance; + start ( 20.0 0.005 0.0 ); + end ( 20.0 0.005 1.0 ); + nPoints 1001; + } + line10 + { + type uniform; + axis distance; + start ( 28.0 0.005 0.0 ); + end ( 28.0 0.005 1.0 ); + nPoints 1001; + } + ); + + fixedLocations false; + fields + ( + U alpha.water + ); + } +} + + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/decomposeParDict b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/decomposeParDict new file mode 100644 index 0000000000..301d97027b --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/decomposeParDict @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object decomposeParDict; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +numberOfSubdomains 2; + +method hierarchical; + +hierarchicalCoeffs +{ + n (2 1 1); + delta 0.001; + order xyz; +} + +// ************************************************************************* // diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSchemes b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSchemes new file mode 100644 index 0000000000..eeff89271f --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSchemes @@ -0,0 +1,54 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSchemes; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +ddtSchemes +{ + default Euler; +} + +gradSchemes +{ + default Gauss linear; +} + +divSchemes +{ + div(rhoPhi,U) Gauss linearUpwind grad(U); + div(phi,alpha) Gauss vanLeer; + div(phirb,alpha) Gauss linear; + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear orthogonal; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default orthogonal; +} + + +// ************************************************************************* // + diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSolution b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSolution new file mode 100644 index 0000000000..dee334f852 --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/fvSolution @@ -0,0 +1,78 @@ + +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "alpha.water.*" + { + nAlphaCorr 1; + nAlphaSubCycles 3; + cAlpha 1; + } + + "pcorr.*" + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0; + } + + p_rgh + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0.1; + } + + p_rghFinal + { + solver GAMG; + smoother DIC; + tolerance 1e-7; + relTol 0; + } + + U + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0.1; + } + + UFinal + { + solver PBiCG; + preconditioner DILU; + tolerance 1e-6; + relTol 0; + } +} + +PIMPLE +{ + momentumPredictor no; + nCorrectors 2; + nNonOrthogonalCorrectors 0; +} + + +// ************************************************************************* // + diff --git a/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/setFieldsDict b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/setFieldsDict new file mode 100644 index 0000000000..b51d428a4d --- /dev/null +++ b/tutorials/multiphase/interFoam/laminar/waveExampleStreamFunction/system/setFieldsDict @@ -0,0 +1,36 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: plus | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object setFieldsDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +defaultFieldValues +( + volScalarFieldValue alpha.water 0 +); + +regions +( + boxToCell + { + box (0 0 0) (40.0 1.0 0.4046); + fieldValues + ( + volScalarFieldValue alpha.water 1 + ); + } +); + + +// ************************************************************************* // From 995c55b60e49b7db0815d241d1c2ce9558b2fc2a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 19 Dec 2017 16:07:15 +0100 Subject: [PATCH 02/29] CONFIG: add clang third-party lib to LD_LIBRARY_PATH - required if there is no system openmp and libomp or libgomp are only found in the clang hierarchy STYLE: add some notes in the openmp rules. - the _OPENMP macro is now used in low-level testing files --- applications/test/openmp/Make/options | 2 +- applications/test/openmp/Test-openmp.C | 16 ++++++++++++---- etc/config.csh/settings | 1 + etc/config.sh/settings | 1 + wmake/rules/linux64Clang/openmp | 4 ++++ wmake/rules/linux64Cray/openmp | 1 + wmake/rules/linux64Gcc/openmp | 1 + wmake/rules/linux64GccKNL/openmp | 1 + wmake/rules/linux64Icc/openmp | 1 + wmake/rules/linux64IccKNL/openmp | 1 + wmake/rules/linuxARM64Clang/openmp | 4 ++++ wmake/rules/linuxARM64Gcc/openmp | 1 + wmake/rules/linuxARM7Gcc/openmp | 1 + wmake/rules/linuxClang/openmp | 4 ++++ wmake/rules/linuxGcc/openmp | 1 + wmake/rules/linuxIA64Gcc/openmp | 1 + wmake/rules/linuxIA64Icc/openmp | 1 + wmake/rules/linuxPPC64Gcc/openmp | 1 + wmake/rules/linuxPPC64leGcc/openmp | 1 + 19 files changed, 39 insertions(+), 5 deletions(-) diff --git a/applications/test/openmp/Make/options b/applications/test/openmp/Make/options index 54eed51fb9..9c1cb59980 100644 --- a/applications/test/openmp/Make/options +++ b/applications/test/openmp/Make/options @@ -1,4 +1,4 @@ -EXE_INC = ${COMP_OPENMP} +EXE_INC = ${COMP_OPENMP} /* -UUSE_OMP */ /* Mostly do not need to explicitly link openmp libraries */ /* EXE_LIBS = ${LINK_OPENMP} */ diff --git a/applications/test/openmp/Test-openmp.C b/applications/test/openmp/Test-openmp.C index acb68e9ed8..1ac9762c76 100644 --- a/applications/test/openmp/Test-openmp.C +++ b/applications/test/openmp/Test-openmp.C @@ -30,7 +30,7 @@ Description #include #include -#ifdef USE_OMP +#if _OPENMP #include #endif @@ -39,11 +39,19 @@ Description int main(int argc, char *argv[]) { +#if USE_OMP + std::cout << "USE_OMP defined (" << USE_OMP << ")\n"; +#else + std::cout << "USE_OMP undefined\n"; +#endif + +#if _OPENMP + std::cout << "_OPENMP = " << _OPENMP << "\n\n"; + + // Fork threads with their own copies of variables int nThreads, threadId; -// Fork threads with their own copies of variables -#ifdef USE_OMP -#pragma omp parallel private(nThreads, threadId) + #pragma omp parallel private(nThreads, threadId) { threadId = omp_get_thread_num(); nThreads = omp_get_num_threads(); diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 4c88b294b8..37c49f4e91 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -302,6 +302,7 @@ CLANG_NOT_FOUND _foamAddMan $clangDir/man _foamAddPath $clangDir/bin + _foamAddLib $clangDir/lib # For things like libomp (openmp) etc if ($?FOAM_VERBOSE && $?prompt) then echo "Using ThirdParty compiler" diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 286339aa53..33aa7fa893 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -287,6 +287,7 @@ CLANG_NOT_FOUND _foamAddMan $clangDir/share/man _foamAddPath $clangDir/bin + _foamAddLib $clangDir/lib # For things like libomp (openmp) etc if [ "$FOAM_VERBOSE" -a "$PS1" ] then diff --git a/wmake/rules/linux64Clang/openmp b/wmake/rules/linux64Clang/openmp index bcb805f57c..070a2c5d3a 100644 --- a/wmake/rules/linux64Clang/openmp +++ b/wmake/rules/linux64Clang/openmp @@ -1,4 +1,8 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) +# - +# Clang provides 'omp' and a link for 'gomp'. +# With 'gomp' we can use system libs. COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Cray/openmp b/wmake/rules/linux64Cray/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linux64Cray/openmp +++ b/wmake/rules/linux64Cray/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Gcc/openmp b/wmake/rules/linux64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linux64Gcc/openmp +++ b/wmake/rules/linux64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64GccKNL/openmp b/wmake/rules/linux64GccKNL/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linux64GccKNL/openmp +++ b/wmake/rules/linux64GccKNL/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linux64Icc/openmp b/wmake/rules/linux64Icc/openmp index 154c9e5743..738673ca91 100644 --- a/wmake/rules/linux64Icc/openmp +++ b/wmake/rules/linux64Icc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -qopenmp LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linux64IccKNL/openmp b/wmake/rules/linux64IccKNL/openmp index 154c9e5743..738673ca91 100644 --- a/wmake/rules/linux64IccKNL/openmp +++ b/wmake/rules/linux64IccKNL/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -qopenmp LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxARM64Clang/openmp b/wmake/rules/linuxARM64Clang/openmp index bcb805f57c..070a2c5d3a 100644 --- a/wmake/rules/linuxARM64Clang/openmp +++ b/wmake/rules/linuxARM64Clang/openmp @@ -1,4 +1,8 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) +# - +# Clang provides 'omp' and a link for 'gomp'. +# With 'gomp' we can use system libs. COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxARM64Gcc/openmp b/wmake/rules/linuxARM64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxARM64Gcc/openmp +++ b/wmake/rules/linuxARM64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxARM7Gcc/openmp b/wmake/rules/linuxARM7Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxARM7Gcc/openmp +++ b/wmake/rules/linuxARM7Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxClang/openmp b/wmake/rules/linuxClang/openmp index bcb805f57c..070a2c5d3a 100644 --- a/wmake/rules/linuxClang/openmp +++ b/wmake/rules/linuxClang/openmp @@ -1,4 +1,8 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) +# - +# Clang provides 'omp' and a link for 'gomp'. +# With 'gomp' we can use system libs. COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxGcc/openmp b/wmake/rules/linuxGcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxGcc/openmp +++ b/wmake/rules/linuxGcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Gcc/openmp b/wmake/rules/linuxIA64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxIA64Gcc/openmp +++ b/wmake/rules/linuxIA64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxIA64Icc/openmp b/wmake/rules/linuxIA64Icc/openmp index 154c9e5743..738673ca91 100644 --- a/wmake/rules/linuxIA64Icc/openmp +++ b/wmake/rules/linuxIA64Icc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -qopenmp LINK_OPENMP = -liomp5 diff --git a/wmake/rules/linuxPPC64Gcc/openmp b/wmake/rules/linuxPPC64Gcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxPPC64Gcc/openmp +++ b/wmake/rules/linuxPPC64Gcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp diff --git a/wmake/rules/linuxPPC64leGcc/openmp b/wmake/rules/linuxPPC64leGcc/openmp index bcb805f57c..cd007d1529 100644 --- a/wmake/rules/linuxPPC64leGcc/openmp +++ b/wmake/rules/linuxPPC64leGcc/openmp @@ -1,4 +1,5 @@ # Flags for compiling/linking openmp +# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP) COMP_OPENMP = -DUSE_OMP -fopenmp LINK_OPENMP = -lgomp From 774dcadb65f79e638bc83d1acf28909d4554ad99 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 21 Dec 2017 13:00:44 +0000 Subject: [PATCH 03/29] BUG: cellCuts: incorrect correspondence. Fixes #670. --- src/dynamicMesh/meshCut/cellCuts/cellCuts.C | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C index 32e36d279c..2358feb5e2 100644 --- a/src/dynamicMesh/meshCut/cellCuts/cellCuts.C +++ b/src/dynamicMesh/meshCut/cellCuts/cellCuts.C @@ -242,7 +242,12 @@ void Foam::cellCuts::syncProc() else { label oppFp = relCut[i]-1; - label fp = f.size()-1-oppFp; + label fp = + ( + oppFp == 0 + ? 0 + : f.size()-oppFp + ); absoluteCut[i] = vertToEVert(f[fp]); } } From d259402e40fcd292a4b1200670d7492f85811909 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 21 Dec 2017 13:03:52 +0000 Subject: [PATCH 04/29] GIT: .foam: left over --- .../overInterDyMFoam/floatingBody/background/background.foam | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tutorials/multiphase/overInterDyMFoam/floatingBody/background/background.foam diff --git a/tutorials/multiphase/overInterDyMFoam/floatingBody/background/background.foam b/tutorials/multiphase/overInterDyMFoam/floatingBody/background/background.foam deleted file mode 100644 index e69de29bb2..0000000000 From 2967be7d4df501e7d6a89f7766805f7c06a00ebb Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 21 Dec 2017 14:25:13 +0000 Subject: [PATCH 05/29] ENH: fileHandler support. Fixes channel395DFSEM in #675. --- .../turbulentDFSEMInletFvPatchVectorField.C | 27 ++++++++++++----- ...entDFSEMInletFvPatchVectorFieldTemplates.C | 29 ++++++++++++++----- 2 files changed, 41 insertions(+), 15 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C index 5dda836639..22cd511d18 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorField.C @@ -108,16 +108,29 @@ void Foam::turbulentDFSEMInletFvPatchVectorField::writeLumleyCoeffs() const { fileName valsFile ( - this->db().time().caseConstant() - /"boundaryData" - /this->patch().name() - /"0" - /"R" + fileHandler().filePath + ( + fileName + ( + db().time().path() + /db().time().caseConstant() + /"boundaryData" + /this->patch().name() + /"0" + /"R" + ) + ) ); - IFstream is(valsFile); + autoPtr isPtr + ( + fileHandler().NewIFstream + ( + valsFile + ) + ); - Field Rexp(is); + Field Rexp(isPtr()); OFstream os(db().time().path()/"lumley_input.out"); diff --git a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorFieldTemplates.C b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorFieldTemplates.C index 2a17b6f76a..96896e24b6 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorFieldTemplates.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/turbulentDFSEMInlet/turbulentDFSEMInletFvPatchVectorFieldTemplates.C @@ -72,16 +72,29 @@ Foam::turbulentDFSEMInletFvPatchVectorField::interpolateBoundaryData fileName valsFile ( - this->db().time().path() - /this->db().time().caseConstant() - /"boundaryData" - /patchName - /"0" - /fieldName + fileHandler().filePath + ( + fileName + ( + this->db().time().path() + /this->db().time().caseConstant() + /"boundaryData" + /patchName + /"0" + /fieldName + ) + ) ); - IFstream is(valsFile); - Field vals(is); + autoPtr isPtr + ( + fileHandler().NewIFstream + ( + valsFile + ) + ); + + Field vals(isPtr()); Info<< "Turbulent DFSEM patch " << patchName << ": interpolating field " << fieldName From 8931e443d8dd34c11e51277ca67f587a1b97e1b7 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 21 Dec 2017 14:53:16 +0000 Subject: [PATCH 06/29] ENH: collated support. Fixes lumpedPointMotion in #675. --- .../manipulation/renumberMesh/renumberMesh.C | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C index 21796ed9d6..7193d08ed6 100644 --- a/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C +++ b/applications/utilities/mesh/manipulation/renumberMesh/renumberMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -1094,7 +1094,9 @@ int main(int argc, char *argv[]) // Update proc maps if (cellProcAddressing.headerOk()) { - if (cellProcAddressing.size() == mesh.nCells()) + bool localOk = (cellProcAddressing.size() == mesh.nCells()); + + if (returnReduce(localOk, andOp())) { Info<< "Renumbering processor cell decomposition map " << cellProcAddressing.name() << endl; @@ -1118,7 +1120,9 @@ int main(int argc, char *argv[]) if (faceProcAddressing.headerOk()) { - if (faceProcAddressing.size() == mesh.nFaces()) + bool localOk = (faceProcAddressing.size() == mesh.nFaces()); + + if (returnReduce(localOk, andOp())) { Info<< "Renumbering processor face decomposition map " << faceProcAddressing.name() << endl; @@ -1158,7 +1162,9 @@ int main(int argc, char *argv[]) if (pointProcAddressing.headerOk()) { - if (pointProcAddressing.size() == mesh.nPoints()) + bool localOk = (pointProcAddressing.size() == mesh.nPoints()); + + if (returnReduce(localOk, andOp())) { Info<< "Renumbering processor point decomposition map " << pointProcAddressing.name() << endl; @@ -1182,7 +1188,16 @@ int main(int argc, char *argv[]) if (boundaryProcAddressing.headerOk()) { - if (boundaryProcAddressing.size() != mesh.boundaryMesh().size()) + bool localOk = + ( + boundaryProcAddressing.size() + == mesh.boundaryMesh().size() + ); + if (returnReduce(localOk, andOp())) + { + // No renumbering needed + } + else { Info<< "Not writing inconsistent processor patch decomposition" << " map " << boundaryProcAddressing.filePath() << endl; From e97275cf12923e97ad4680ecb3c3fd2e2f3e8dba Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 21 Dec 2017 15:05:10 +0000 Subject: [PATCH 07/29] ENH: collated support. Fixes createZeroDirectory in #675. --- .../createZeroDirectory/createZeroDirectory.C | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C b/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C index 0e9b0fbd04..533ced2cff 100644 --- a/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C +++ b/applications/utilities/preProcessing/createZeroDirectory/createZeroDirectory.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2015 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -133,7 +133,6 @@ void createFieldFiles Info<< " Generating field files" << nl << endl; // Create files - mkDir(runTime.path()/runTime.timeName()/regionName); forAll(fieldNames, i) { const_cast(IOdictionary::typeName) = @@ -181,8 +180,8 @@ void createFieldFiles field2.remove("initialConditions"); field2.remove("boundaryConditions"); - // Construct and write field dictionary - IOdictionary fieldOut + // Construct and write field dictionary. Note use of localIOdictionary + localIOdictionary fieldOut ( IOobject ( From bd181f9a6cbf930a20aefc6476f2e976c37a6818 Mon Sep 17 00:00:00 2001 From: Andrew Heather Date: Tue, 19 Dec 2017 21:25:12 +0000 Subject: [PATCH 08/29] BUG: lagrangian - corrected references to position() --- .../dataConversion/foamToEnsight/ensightOutputCloud.C | 6 +++--- .../dataConversion/foamToVTK/foamVtkLagrangianWriter.C | 2 +- .../steadyParticleTracks/steadyParticleTracks.C | 2 +- src/lagrangian/basic/particle/particle.C | 6 +++--- .../CollisionModel/PairCollision/PairCollision.C | 2 +- .../InflationInjection/InflationInjection.C | 2 +- .../submodels/Kinematic/ParticleForces/SRF/SRFForce.C | 2 +- .../spray/parcels/Templates/SprayParcel/SprayParcel.C | 2 +- .../TrajectoryCollision/TrajectoryCollision.C | 8 ++++---- 9 files changed, 16 insertions(+), 16 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloud.C b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloud.C index bb190f9eef..ed76498ad0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloud.C +++ b/applications/utilities/postProcessing/dataConversion/foamToEnsight/ensightOutputCloud.C @@ -74,7 +74,7 @@ void Foam::ensightCloud::writePositions // Master forAllConstIter(Cloud, cloudPtr(), elmnt) { - const point& p = elmnt().position(); + const point p(elmnt().position()); os.write(p.x()); os.write(p.y()); @@ -104,7 +104,7 @@ void Foam::ensightCloud::writePositions label parcelId = 0; forAllConstIter(Cloud, cloudPtr(), elmnt) { - const point& p = elmnt().position(); + const point p(elmnt().position()); os.write(++parcelId, 8); // unusual width os.write(p.x()); @@ -140,7 +140,7 @@ void Foam::ensightCloud::writePositions label pti = 0; forAllConstIter(Cloud, cloudPtr(), elmnt) { - const point& p = elmnt().position(); + const point p(elmnt().position()); points[pti++] = p; } diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamVtkLagrangianWriter.C b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamVtkLagrangianWriter.C index b3c254c6f0..23e7621e7f 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/foamVtkLagrangianWriter.C +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/foamVtkLagrangianWriter.C @@ -76,7 +76,7 @@ void Foam::vtk::lagrangianWriter::writePoints() forAllConstIters(parcels, iter) { - const point& pt = iter().position(); + const point pt(iter().position()); vtk::write(format(), pt); } diff --git a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C index a36a86b0b0..11078c91fb 100644 --- a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C +++ b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C @@ -283,7 +283,7 @@ int main(int argc, char *argv[]) forAll(ids, j) { const label localId = particleIds[j]; - const vector& pos = particles[localId].position(); + const vector pos(particles[localId].position()); os << pos.x() << ' ' << pos.y() << ' ' << pos.z() << nl; } diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index 9725ba4358..e81c521991 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -388,7 +388,7 @@ void Foam::particle::changeFace(const label tetTriI) tetFacei_ = newFaceI; tetPti_ = edgeI; - // Exit the loop now that the the tet point has been found + // Exit the loop now that the tet point has been found break; } @@ -890,11 +890,11 @@ Foam::scalar Foam::particle::trackToMovingTri // Calculate the hit fraction label iH = -1; scalar muH = std::isnormal(detA[0]) && detA[0] <= 0 ? VGREAT : 1/detA[0]; - for (label i = 0; i < 4; ++ i) + for (label i = 0; i < 4; ++i) { const Roots<3> mu = hitEqn[i].roots(); - for (label j = 0; j < 3; ++ j) + for (label j = 0; j < 3; ++j) { if (mu.type(j) == roots::real && hitEqn[i].derivative(mu[j]) < 0) { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C index c1dd0fea6b..05402b4893 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/CollisionModel/PairCollision/PairCollision.C @@ -220,7 +220,7 @@ void Foam::PairCollision::wallInteraction() typename CloudType::parcelType& p = *cellOccupancy[realCelli][cellParticleI]; - const point& pos = p.position(); + const point pos(p.position()); scalar r = wallModel_->pREff(p); diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C index 5078830ad9..98bd08e71d 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InflationInjection/InflationInjection.C @@ -292,7 +292,7 @@ Foam::label Foam::InflationInjection::parcelsToInject continue; } - const point& pP = pPtr->position(); + const point pP(pPtr->position()); const vector& pU = pPtr->U(); // Generate a tetrahedron of new positions with the diff --git a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.C b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.C index 83443fda39..6ffa34dd69 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/ParticleForces/SRF/SRFForce.C @@ -93,7 +93,7 @@ Foam::forceSuSp Foam::SRFForce::calcNonCoupled const vector& omega = srf.omega().value(); - const vector& r = p.position(); + const vector r(p.position()); // Coriolis and centrifugal acceleration terms value.Su() = diff --git a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.C b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.C index 87ca3fbff1..846f100257 100644 --- a/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.C +++ b/src/lagrangian/spray/parcels/Templates/SprayParcel/SprayParcel.C @@ -172,7 +172,7 @@ void Foam::SprayParcel::calcAtomization scalar soi = cloud.injectors().timeStart(); scalar currentTime = cloud.db().time().value(); - const vector& pos = this->position(); + const vector pos(this->position()); const vector& injectionPos = this->position0(); // Disregard the continous phase when calculating the relative velocity diff --git a/src/lagrangian/spray/submodels/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C b/src/lagrangian/spray/submodels/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C index 2d60894141..dc5d7b6d13 100644 --- a/src/lagrangian/spray/submodels/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C +++ b/src/lagrangian/spray/submodels/StochasticCollision/TrajectoryCollision/TrajectoryCollision.C @@ -50,15 +50,15 @@ bool Foam::TrajectoryCollision::collideParcels { bool coalescence = false; - const vector& pos1 = p1.position(); - const vector& pos2 = p2.position(); + const vector pos1(p1.position()); + const vector pos2(p2.position()); const vector& U1 = p1.U(); const vector& U2 = p2.U(); - vector URel = U1 - U2; + vector URel(U1 - U2); - vector d = pos2 - pos1; + vector d(pos2 - pos1); scalar magd = mag(d); scalar vAlign = URel & (d/(magd + ROOTVSMALL)); From 2fe7d0c00bf7689ba8092c51799a75c2c718a73d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 21 Dec 2017 10:38:57 +0100 Subject: [PATCH 09/29] STYLE: update BuildIssues with CGAL mpfr-none problem (issue #674) - add some notes about 'git submodule' in modules/README.md --- BuildIssues.txt | 29 +++++++++++++++++++- etc/bashrc | 57 +++++++++++++++------------------------ etc/config.csh/settings | 9 +++---- etc/config.sh/settings | 9 +++---- etc/cshrc | 54 +++++++++++++++++-------------------- modules/README.md | 59 +++++++++++++++++++++++++++++++++++++---- 6 files changed, 137 insertions(+), 80 deletions(-) diff --git a/BuildIssues.txt b/BuildIssues.txt index fbb6b6dcb5..a05b5301c3 100644 --- a/BuildIssues.txt +++ b/BuildIssues.txt @@ -1,4 +1,4 @@ -OpenFOAM-1706 +OpenFOAM-1712 ================== Known Build Issues ================== @@ -75,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/etc/bashrc b/etc/bashrc index 2ad6b3512d..b1a39aaed3 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -36,7 +36,7 @@ export WM_PROJECT=OpenFOAM export WM_PROJECT_VERSION=plus # [FOAM_INST_DIR] - parent directory containing the OpenFOAM installation. -# * When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines +# \- When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines # should work when sourced by BASH or ZSH shells. If this however fails, # set one of the fallback values to an appropriate path. # -- @@ -104,23 +104,18 @@ export WM_MPLIB=SYSTEMOPENMPI ################################################################################ -# The old dirs to be cleaned from the environment variables +# Old directories to be cleaned from PATH, LD_LIBRARY_PATH foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \ $HOME/$WM_PROJECT/$USER $FOAM_USER_APPBIN $FOAM_USER_LIBBIN \ $WM_PROJECT_SITE $FOAM_SITE_APPBIN $FOAM_SITE_LIBBIN" -# Location of installation -# ~~~~~~~~~~~~~~~~~~~~~~~~ +# Location of installation and third-party software export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION - -# Location of third-party software -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION -# Location of site-specific templates etc -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# unset is equivalent to $WM_PROJECT_INST_DIR/site +# [WM_PROJECT_SITE] - Location of site-specific (group) files +# default (unset) implies WM_PROJECT_INST_DIR/site if [ -d "$WM_PROJECT_SITE" ] then export WM_PROJECT_SITE @@ -128,12 +123,10 @@ else unset WM_PROJECT_SITE fi -# Location of user files -# ~~~~~~~~~~~~~~~~~~~~~~ +# [WM_PROJECT_USER_DIR] - Location of user files export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Load shell functions -# ~~~~~~~~~~~~~~~~~~~~ . $WM_PROJECT_DIR/etc/config.sh/functions # Override definitions via prefs, with 'other' first so the sys-admin @@ -163,35 +156,29 @@ cleaned=$($foamClean "$MANPATH" "$foamOldDirs") && MANPATH="$cleaned" export PATH LD_LIBRARY_PATH MANPATH -# Source project setup files -# ~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for OpenFOAM compilation etc +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.sh/settings -if /usr/bin/tty -s 2>/dev/null # Interactive shell -then - _foamEtc config.sh/aliases - - # Bash completions - if [ "${BASH_VERSINFO:-0}" -ge 4 ] - then - _foamEtc config.sh/bash_completion - fi -fi - - -# Source user setup files for optional packages -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for third-party packages +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.sh/mpi _foamEtc config.sh/paraview _foamEtc config.sh/vtk _foamEtc config.sh/ensight _foamEtc config.sh/gperftools - -#_foamEtc config.sh/ADIOS +## _foamEtc config.csh/ADIOS _foamEtc config.sh/CGAL _foamEtc config.sh/scotch _foamEtc config.sh/FFTW +# Interactive shell +if /usr/bin/tty -s 2>/dev/null +then + _foamEtc config.sh/aliases + [ "${BASH_VERSINFO:-0}" -ge 4 ] && _foamEtc config.sh/bash_completion +fi + # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -214,13 +201,13 @@ then fi -# Cleanup environment -# ~~~~~~~~~~~~~~~~~~~ +# Cleanup temporary information +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# Functions +# Unload shell functions . $WM_PROJECT_DIR/etc/config.sh/functions -# Variables (do as last for a clean exit code) +# Variables (done as the last statement for a clean exit code) unset cleaned foamClean foamOldDirs #------------------------------------------------------------------------------ diff --git a/etc/config.csh/settings b/etc/config.csh/settings index 37c49f4e91..8b7d27e2a3 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -149,15 +149,14 @@ setenv FOAM_LIBBIN $WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # External (ThirdParty) libraries setenv FOAM_EXT_LIBBIN $WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib -# Site-specific directory +# Site-specific (group) files if ( $?WM_PROJECT_SITE ) then set siteDir=$WM_PROJECT_SITE else set siteDir=$WM_PROJECT_INST_DIR/site endif -# Shared site executables/libraries -# Similar naming convention as ~OpenFOAM expansion +# Shared site (group) executables/libraries setenv FOAM_SITE_APPBIN $siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin setenv FOAM_SITE_LIBBIN $siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib @@ -165,8 +164,8 @@ setenv FOAM_SITE_LIBBIN $siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib setenv FOAM_USER_APPBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin setenv FOAM_USER_LIBBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib -# DynamicCode templates -# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion +# [FOAM_CODE_TEMPLATES] - dynamicCode templates +# * fallback == "foamEtcFile -list codeTemplates/dynamicCode" # setenv FOAM_CODE_TEMPLATES $WM_PROJECT_DIR/etc/codeTemplates/dynamicCode # Convenience diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 33aa7fa893..330f197af1 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -133,7 +133,7 @@ export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # External (ThirdParty) libraries export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER$WM_PRECISION_OPTION$WM_LABEL_OPTION/lib -# Site-specific directory +# Site-specific (group) files if [ -n "$WM_PROJECT_SITE" ] then siteDir=$WM_PROJECT_SITE @@ -141,8 +141,7 @@ else siteDir=$WM_PROJECT_INST_DIR/site fi -# Shared site executables/libraries -# Similar naming convention as ~OpenFOAM expansion +# Shared site (group) executables/libraries export FOAM_SITE_APPBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin export FOAM_SITE_LIBBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib @@ -150,8 +149,8 @@ export FOAM_SITE_LIBBIN=$siteDir/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib -# DynamicCode templates -# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion +# [FOAM_CODE_TEMPLATES] - dynamicCode templates +# * fallback == "foamEtcFile -list codeTemplates/dynamicCode" # export FOAM_CODE_TEMPLATES=$WM_PROJECT_DIR/etc/codeTemplates/dynamicCode # Convenience diff --git a/etc/cshrc b/etc/cshrc index 9a1e81d3ee..4dc34be99e 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -36,7 +36,7 @@ setenv WM_PROJECT OpenFOAM setenv WM_PROJECT_VERSION plus # [FOAM_INST_DIR] - parent directory containing the OpenFOAM installation. -# * When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines +# \- When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines # should work when sourced by CSH or TCSH shells. If this however fails, # set one of the fallback values to an appropriate path. # -- @@ -101,7 +101,7 @@ setenv WM_MPLIB SYSTEMOPENMPI ################################################################################ -# The old dirs to be cleaned from the environment variables +# Old directories to be cleaned from PATH, LD_LIBRARY_PATH set foamOldDirs= if ( $?WM_PROJECT_DIR ) then set foamOldDirs="$foamOldDirs $WM_PROJECT_DIR" @@ -119,18 +119,13 @@ if ( $?FOAM_SITE_LIBBIN ) then set foamOldDirs="$foamOldDirs $FOAM_SITE_LIBBIN" endif -# Location of installation -# ~~~~~~~~~~~~~~~~~~~~~~~~ +# Location of installation and third-party software setenv WM_PROJECT_INST_DIR $FOAM_INST_DIR -setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION +setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION -# Location of third-party software -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION - -# Location of site-specific templates etc -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -# unset is equivalent to $WM_PROJECT_INST_DIR/site +# [WM_PROJECT_SITE] - Location of site-specific (group) files +# default (unset) implies WM_PROJECT_INST_DIR/site if ( $?WM_PROJECT_SITE ) then set foamOldDirs="$WM_PROJECT_SITE $foamOldDirs" if ( ! -d "$WM_PROJECT_SITE" ) unsetenv WM_PROJECT_SITE @@ -138,8 +133,7 @@ else unsetenv WM_PROJECT_SITE endif -# Location of user files -# ~~~~~~~~~~~~~~~~~~~~~~ +# [WM_PROJECT_USER_DIR] - Location of user files setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION # Source an etc file, possibly with some verbosity @@ -210,27 +204,26 @@ set cleaned=`$foamClean "$MANPATH" "$foamOldDirs"` if ( $status == 0 ) setenv MANPATH $cleaned -# Source project setup files -# ~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for OpenFOAM compilation etc +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.csh/settings -if ($?prompt) then # Interactive shell - _foamEtc config.csh/aliases - _foamEtc config.csh/tcsh_completion -endif - - -# Source user setup files for optional packages -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Setup for third-party packages +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ _foamEtc config.csh/mpi _foamEtc config.csh/paraview _foamEtc config.csh/vtk _foamEtc config.csh/ensight - -#_foamEtc config.csh/ADIOS +## _foamEtc config.csh/ADIOS _foamEtc config.csh/CGAL _foamEtc config.csh/FFTW +# Interactive shell +if ($?prompt) then + _foamEtc config.csh/aliases + _foamEtc config.csh/tcsh_completion +endif + # Clean environment paths again. Only remove duplicates # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -253,12 +246,15 @@ if ( $?LD_PRELOAD ) then endif -# Cleanup environment -# ~~~~~~~~~~~~~~~~~~~ -unset cleaned foamClean foamOldDirs +# Cleanup temporary information +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Unload shell "functions" unalias _foamEtc unalias _foamAddPath unalias _foamAddLib unalias _foamAddMan +unset cleaned foamClean foamOldDirs + #------------------------------------------------------------------------------ diff --git a/modules/README.md b/modules/README.md index 246fac8696..8bc84322da 100644 --- a/modules/README.md +++ b/modules/README.md @@ -1,15 +1,64 @@ OpenFOAM Modules ================ -This directory is a location to place additional OpenFOAM components -or tools and have them built as part of the normal OpenFOAM build +This directory is a location for additional OpenFOAM components or tools +to placed and have them built as part of the normal OpenFOAM build process. It is assumed that each subdirectory contain an appropriate -Allwmake file, and that they should in all likelihood also build into +Allwmake file, and that they in all likelihood also build into `$FOAM_APPBIN` and `$FOAM_LIBBIN` instead of `$FOAM_USER_APPBIN` and `$FOAM_USER_LIBBIN`. -These additional components may be added as git submodules, by script -or by hand. +These additional components may be added as [git submodules][man git-submodule], +by script or by hand. + + +### git + +On the first use, it will be necessary to register the submodules: + + git submodule init + + +This will clone the relevant submodules from their respective +repositories. + + +The following will indicate the current state: + + git submodule status + + +On the first use, or after merging upstream changes in the OpenFOAM +repository, it will be necessary to update the submodules: + + git submodule update + + +A quick overview of `git submodule` can be in this +[*blog*][blog git-submodule] with full details in the +[*manpage*][man git-submodule]. + + +An easy way to see which submodules are actually in use: + + `cat .gitmodules` + +Which will reveal content resembling the following: + + [submodule "cfmesh"] + path = modules/cfmesh + url = https://develop.openfoam.com/Community/integration-cfmesh.git + + +### doxygen To build the doxygen information for the components, it is also necessary to link the directories to the doc/ subdirectory. +This is a purely manual operation. + + + +[man git-submodule]: https://git-scm.com/docs/git-submodule +[blog git-submodule]: http://blog.joncairns.com/2011/10/how-to-use-git-submodules/ + +--- From 9c38ad6ae49a69e1d3cdb65a9e8a35cfb06652c3 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 21 Dec 2017 14:17:20 +0100 Subject: [PATCH 10/29] TUT: relocate tutorial log analysis as functions for reuse in modules - removed some unneeded tutorial files --- bin/tools/CleanFunctions | 17 +- bin/tools/LogFunctions | 120 ++ bin/tools/RunFunctions | 17 +- tutorials/Allclean | 15 +- tutorials/Allrun | 113 +- .../planeTransport/constant/faMesh/faBoundary | 212 --- .../planeTransport/constant/faMesh/faceLabels | 1224 ----------------- 7 files changed, 143 insertions(+), 1575 deletions(-) create mode 100644 bin/tools/LogFunctions delete mode 100644 tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary delete mode 100644 tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faceLabels diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 431c52f383..2f546b4f84 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -6,20 +6,8 @@ # \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # Script # CleanFunctions @@ -158,6 +146,7 @@ cleanFaMesh () ) } + cleanApplication() { echo "Cleaning application $PWD" diff --git a/bin/tools/LogFunctions b/bin/tools/LogFunctions new file mode 100644 index 0000000000..820ab4a27f --- /dev/null +++ b/bin/tools/LogFunctions @@ -0,0 +1,120 @@ +#!/bin/sh +#------------------------------------------------------------------------------ +# ========= | +# \\ / 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, licensed under GNU General Public License +# . +# +# Script +# LogFunctions +# +# Description +# Miscellaneous functions for running tutorials in a loop and for +# analyzing the output. +# +# Output is normally summarized as 'testLoopReport' +# +#------------------------------------------------------------------------------ + +# logReport +# Extracts useful info from log file. +logReport() +{ + local logfile=$1 + + # logfile is path/to/case/log.application + caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g') + app=$(echo $logfile | sed -e 's/\(.*\)log\.//g') + appAndCase="Application $app - case $caseName" + + if grep -q "FOAM FATAL" $logfile + then + echo "$appAndCase: ** FOAM FATAL ERROR **" + return 1 + fi + + # Check for solution singularity on U equation + for eqn in Ux Uy Uz + do + if grep -q -E "${eqn}[:| ]*solution singularity" $logfile + then + if [ "$eqn" = Uz ] + then + # Can only get here if Ux,Uy,Uz all failed + echo "$appAndCase: ** Solution singularity **" + return 1 + fi + else + break + fi + done + + if grep -q -E "^[\t ]*[Ee]nd" $logfile + then + # Extract time from this type of content + ## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s" + completionTime=$(tail -10 $logfile | \ + sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}') + + echo "$appAndCase: completed${completionTime:+ in }$completionTime" + else + echo "$appAndCase: unconfirmed completion" + fi +} + + +# Collect and analyse all log files +collectLogs() +{ + echo "Collecting log files..." 1>&2 + rm -f logs testLoopReport > /dev/null 2>&1 + touch logs testLoopReport + + local appDir log logFiles + + for appDir in * + do + [ -d $appDir ] || continue + echo -n " $appDir..." 1>&2 + + logFiles=$(find -L $appDir -name 'log.*' -type f) + if [ -n "$logFiles" ] + then + echo 1>&2 + else + echo " (no logs)" 1>&2 + continue + fi + + # Sort logs by time-stamp + for log in $(echo $logFiles | xargs ls -rt) + do + # Concatenate and summarize logs + cat "$log" >> logs 2>/dev/null + logReport $log + done + echo + done > testLoopReport +} + + +removeLogs() +{ + echo "Removing backup files" + + find . \( \ + -name '*~' -o -name '*.bak' \ + -name core -o -name 'core.[1-9]*' \ + -name '*.pvs' -o -name '*.foam' -o -name '*.OpenFOAM' \ + \) -type f -delete + + rm -f logs testLoopReport > /dev/null 2>&1 +} + + +#------------------------------------------------------------------------------ diff --git a/bin/tools/RunFunctions b/bin/tools/RunFunctions index 55ab42d175..d9712dea2c 100644 --- a/bin/tools/RunFunctions +++ b/bin/tools/RunFunctions @@ -6,26 +6,15 @@ # \\/ M anipulation | Copyright (C) 2015-2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # Script # RunFunctions # # Description # Miscellaneous functions for running tutorial cases +# #------------------------------------------------------------------------------ # The normal locations diff --git a/tutorials/Allclean b/tutorials/Allclean index 0eea9fb549..bbaca026e2 100755 --- a/tutorials/Allclean +++ b/tutorials/Allclean @@ -1,18 +1,11 @@ #!/bin/sh -cd ${0%/*} || exit 1 # Run from this directory +cd ${0%/*} || exit 1 # Run from this directory +. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions echo "--------" +removeLogs + echo "Cleaning tutorials ..." -echo "Removing backup files" - -find . \( \ - -name '*~' -o -name '*.bak' \ - -name core -o -name 'core.[1-9]*' \ - -name '*.pvs' -o -name '*.OpenFOAM' \ - \) -type f -delete - -rm -f logs testLoopReport > /dev/null 2>&1 - foamCleanTutorials cases echo "--------" diff --git a/tutorials/Allrun b/tutorials/Allrun index 0a731b3fc9..77d185e928 100755 --- a/tutorials/Allrun +++ b/tutorials/Allrun @@ -7,26 +7,14 @@ # \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM. -# -# OpenFOAM is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# for more details. -# -# You should have received a copy of the GNU General Public License -# along with OpenFOAM. If not, see . +# This file is part of OpenFOAM, licensed under GNU General Public License +# . # # Script # Allrun # # Description -# Runs tutorial cases and summarizes the outcome as 'testLoopReport' +# Run tutorial cases and summarize the outcome as 'testLoopReport' # #------------------------------------------------------------------------------ cd ${0%/*} || exit 1 # Run from this directory @@ -43,27 +31,26 @@ options: -collect Collect logs only. Can be useful for aborted runs. -help print the usage -* Runs tutorial cases and summarizes the outcome as 'testLoopReport' +Run tutorial cases and summarize the outcome as 'testLoopReport' USAGE exit 1 } #------------------------------------------------------------------------------ +unset optCollect -unset optCollectOnly - -# parse options +# Parse options while [ "$#" -gt 0 ] do case "$1" in - -h | -help) + -h | -help*) usage ;; -collect) - optCollectOnly=true + optCollect=true ;; - -test) # Known options that should be passed through + -test) # Known options to pass through break ;; -*) @@ -77,87 +64,13 @@ do done #------------------------------------------------------------------------------ +. $WM_PROJECT_DIR/bin/tools/LogFunctions # Tutorial log-file functions -# logReport -# Extracts useful info from log file. -logReport() -{ - local logfile=$1 - - # logfile is path/to/case/log.application - caseName=$(dirname $logfile | sed -e 's/\(.*\)\.\///g') - app=$(echo $logfile | sed -e 's/\(.*\)log\.//g') - appAndCase="Application $app - case $caseName" - - if grep -q "FOAM FATAL" $logfile - then - echo "$appAndCase: ** FOAM FATAL ERROR **" - return 1 - fi - - # Check for solution singularity on U equation - for eqn in Ux Uy Uz - do - if grep -q -E "${eqn}[:| ]*solution singularity" $logfile - then - if [ "$eqn" = Uz ] - then - # Can only get here if Ux,Uy,Uz all failed - echo "$appAndCase: ** Solution singularity **" - return 1 - fi - else - break - fi - done - - if grep -q -E "^[\t ]*[Ee]nd" $logfile - then - # Extract time from this type of content - ## ExecutionTime = 60.2 s ClockTime = 63 s --> "60.2 s" - completionTime=$(tail -10 $logfile | \ - sed -n -e '/Execution/{s/^[^=]*=[ \t]*//; s/\( s\) .*$/\1/; p}') - - echo "$appAndCase: completed${completionTime:+ in }$completionTime" - else - echo "$appAndCase: unconfirmed completion" - fi -} - -if [ -z "$optCollectOnly" ] +if [ -z "$optCollect" ] then - # Recursively run all tutorials - foamRunTutorials -skipFirst $* + foamRunTutorials -skipFirst $* # Run tutorials recursively fi - -# Analyse all log files -echo "Collecting log files..." 1>&2 -rm -f logs testLoopReport > /dev/null 2>&1 -touch logs testLoopReport - -for appDir in * -do - [ -d $appDir ] || continue - echo -n " $appDir..." 1>&2 - - logs=$(find -L $appDir -name 'log.*' -type f) - if [ -n "$logs" ] - then - echo 1>&2 - else - echo " (no logs)" 1>&2 - continue - fi - - # Sort logs by time-stamp - for log in $(echo $logs | xargs ls -rt) - do - # Concatenate and summarize logs - cat "$log" >> logs 2>/dev/null - logReport $log - done - echo -done > testLoopReport +collectLogs #------------------------------------------------------------------------------ diff --git a/tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary b/tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary deleted file mode 100644 index ed1236d475..0000000000 --- a/tutorials/finiteArea/surfactantFoam/planeTransport/constant/faMesh/faBoundary +++ /dev/null @@ -1,212 +0,0 @@ -/*--------------------------------*- C++ -*----------------------------------*\ -| ========= | | -| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | -| \\ / O peration | Version: plus | -| \\ / A nd | Web: www.OpenFOAM.com | -| \\/ M anipulation | | -\*---------------------------------------------------------------------------*/ -FoamFile -{ - version 2.0; - format ascii; - class faBoundaryMesh; - location "constant/faMesh"; - object faBoundary; -} -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -3 -( - inlet - { - type patch; - edgeLabels List