From 3132d9bf4e1e198c6498c83020a8eb15eb1598fa Mon Sep 17 00:00:00 2001 From: Paul Kieckhefen Date: Wed, 23 May 2018 14:21:30 +0200 Subject: [PATCH] * readNorm: refactor recurrence matrix reading into its own recNorm -> less duplication * predefinedPath: backport ability to follow prescribed recurrence path --- src/recurrence/Make/files | 3 + .../recNorm/absDiffNorm/absDiffNorm.C | 11 +-- src/recurrence/recNorm/maxNorm/maxNorm.C | 11 +-- src/recurrence/recNorm/noRecNorm/noRecNorm.C | 75 ++++++++++++++++ src/recurrence/recNorm/noRecNorm/noRecNorm.H | 81 +++++++++++++++++ src/recurrence/recNorm/readNorm/readNorm.C | 82 ++++++++++++++++++ src/recurrence/recNorm/readNorm/readNorm.H | 86 +++++++++++++++++++ src/recurrence/recNorm/recNorm/recNorm.C | 17 +--- src/recurrence/recNorm/recNorm/recNorm.H | 6 -- .../recNorm/sqrDiffNorm/sqrDiffNorm.C | 13 +-- .../recPath/predefinedPath/predefinedPath.C | 81 +++++++++++++++++ .../recPath/predefinedPath/predefinedPath.H | 86 +++++++++++++++++++ 12 files changed, 499 insertions(+), 53 deletions(-) create mode 100644 src/recurrence/recNorm/noRecNorm/noRecNorm.C create mode 100644 src/recurrence/recNorm/noRecNorm/noRecNorm.H create mode 100644 src/recurrence/recNorm/readNorm/readNorm.C create mode 100644 src/recurrence/recNorm/readNorm/readNorm.H create mode 100644 src/recurrence/recPath/predefinedPath/predefinedPath.C create mode 100644 src/recurrence/recPath/predefinedPath/predefinedPath.H diff --git a/src/recurrence/Make/files b/src/recurrence/Make/files index 35075389..12150c15 100644 --- a/src/recurrence/Make/files +++ b/src/recurrence/Make/files @@ -7,13 +7,16 @@ recNorm/recNorm/recNorm.C recNorm/recNorm/newRecNorm.C recNorm/absDiffNorm/absDiffNorm.C recNorm/maxNorm/maxNorm.C +recNorm/readNorm/readNorm.C recNorm/sqrDiffNorm/sqrDiffNorm.C +recNorm/noRecNorm/noRecNorm.C recPath/recPath/recPath.C recPath/recPath/newRecPath.C recPath/simpleRandomPath/simpleRandomPath.C recPath/noPath/noPath.C recPath/MarkovPath/MarkovPath.C recPath/multiIntervalPath/multiIntervalPath.C +recPath/predefinedPath/predefinedPath.C recStatAnalysis/recStatAnalysis/recStatAnalysis.C recStatAnalysis/recStatAnalysis/newRecStatAnalysis.C recStatAnalysis/noRecStatAnalysis/noRecStatAnalysis.C diff --git a/src/recurrence/recNorm/absDiffNorm/absDiffNorm.C b/src/recurrence/recNorm/absDiffNorm/absDiffNorm.C index 63c2b550..706df36f 100644 --- a/src/recurrence/recNorm/absDiffNorm/absDiffNorm.C +++ b/src/recurrence/recNorm/absDiffNorm/absDiffNorm.C @@ -59,16 +59,7 @@ absDiffNorm::absDiffNorm normConstant_(propsDict_.lookupOrDefault("normConstant",-1.0)), fieldType_(propsDict_.lookup("fieldType")), fieldName_(propsDict_.lookup("fieldName")) -{ - if (propsDict_.found("readRecMat")) - { - readRecMat_ = bool(readBool(propsDict_.lookup("readRecMat"))); - if (readRecMat_ && propsDict_.found("recMatName")) - { - recMatName_ = word(propsDict_.lookup("recMatName")); - } - } -} +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/src/recurrence/recNorm/maxNorm/maxNorm.C b/src/recurrence/recNorm/maxNorm/maxNorm.C index 1bf4b2f4..876d71b5 100644 --- a/src/recurrence/recNorm/maxNorm/maxNorm.C +++ b/src/recurrence/recNorm/maxNorm/maxNorm.C @@ -58,16 +58,7 @@ maxNorm::maxNorm normConstant_(propsDict_.lookupOrDefault("normConstant",-1.0)), fieldType_(propsDict_.lookup("fieldType")), fieldName_(propsDict_.lookup("fieldName")) -{ - if (propsDict_.found("readRecMat")) - { - readRecMat_ = bool(readBool(propsDict_.lookup("readRecMat"))); - if (readRecMat_ && propsDict_.found("recMatName")) - { - recMatName_ = word(propsDict_.lookup("recMatName")); - } - } -} +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // diff --git a/src/recurrence/recNorm/noRecNorm/noRecNorm.C b/src/recurrence/recNorm/noRecNorm/noRecNorm.C new file mode 100644 index 00000000..a9f73df0 --- /dev/null +++ b/src/recurrence/recNorm/noRecNorm/noRecNorm.C @@ -0,0 +1,75 @@ +/*---------------------------------------------------------------------------*\ + CFDEMcoupling academic - Open Source CFD-DEM coupling + + Contributing authors: + Thomas Lichtenegger + Copyright (C) 2015- Johannes Kepler University, Linz +------------------------------------------------------------------------------- +License + This file is part of CFDEMcoupling academic. + + CFDEMcoupling academic 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. + + CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see . +\*---------------------------------------------------------------------------*/ + +#include "error.H" +#include "noRecNorm.H" +#include "recModel.H" +#include "addToRunTimeSelectionTable.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(noRecNorm, 0); + +addToRunTimeSelectionTable +( + recNorm, + noRecNorm, + dictionary +); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +noRecNorm::noRecNorm +( + const dictionary& dict, + recBase& base +) +: + recNorm(dict, base) + {} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +noRecNorm::~noRecNorm() +{} + +// * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * * * // + +void noRecNorm::computeRecMatrix() +{ + return; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/recurrence/recNorm/noRecNorm/noRecNorm.H b/src/recurrence/recNorm/noRecNorm/noRecNorm.H new file mode 100644 index 00000000..ca8b8c49 --- /dev/null +++ b/src/recurrence/recNorm/noRecNorm/noRecNorm.H @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + CFDEMcoupling academic - Open Source CFD-DEM coupling + + Contributing authors: + Thomas Lichtenegger + Copyright (C) 2015- Johannes Kepler University, Linz +------------------------------------------------------------------------------- +License + This file is part of CFDEMcoupling academic. + + CFDEMcoupling academic 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. + + CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see . +\*---------------------------------------------------------------------------*/ + +#ifndef noRecNorm_H +#define noRecNorm_H + +#include "recNorm.H" + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class noRecNorm Declaration +\*---------------------------------------------------------------------------*/ + +class noRecNorm +: + public recNorm +{ +protected: + + // Protected data + void computeRecMatrix(); + + +public: + + //- Runtime type information + TypeName("none"); + + // Constructors + + //- Construct from components + noRecNorm + ( + const dictionary& dict, + recBase& base + ); + + + // Destructor + + virtual ~noRecNorm(); + + + // Member Functions + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/recurrence/recNorm/readNorm/readNorm.C b/src/recurrence/recNorm/readNorm/readNorm.C new file mode 100644 index 00000000..2e90230a --- /dev/null +++ b/src/recurrence/recNorm/readNorm/readNorm.C @@ -0,0 +1,82 @@ +/*---------------------------------------------------------------------------*\ + CFDEMcoupling academic - Open Source CFD-DEM coupling + + Contributing authors: + Thomas Lichtenegger + Copyright (C) 2015- Johannes Kepler University, Linz + + Paul Kieckhefen, TUHH +------------------------------------------------------------------------------- +License + This file is part of CFDEMcoupling academic. + + CFDEMcoupling academic 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. + + CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see . +\*---------------------------------------------------------------------------*/ + +#include "error.H" +#include "readNorm.H" +#include "recModel.H" +#include "addToRunTimeSelectionTable.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(readNorm, 0); + +addToRunTimeSelectionTable +( + recNorm, + readNorm, + dictionary +); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +readNorm::readNorm +( + const dictionary& dict, + recBase& base +) +: + recNorm(dict, base), + propsDict_(dict.subDict(typeName + "Props")), + recMatName_(propsDict_.lookupOrDefault("recMatName", "recurrenceMatrix")) +{} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +readNorm::~readNorm() +{} + +// * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * * * // + +void readNorm::computeRecMatrix() +{ + Info << nl << type() << ": reading recurrence matrix " << recMatName_ << nl << endl; + SymmetricSquareMatrix& recurrenceMatrix( base_.recM().recurrenceMatrix() ); + IFstream matrixFile(recMatName_); + matrixFile >> recurrenceMatrix; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/recurrence/recNorm/readNorm/readNorm.H b/src/recurrence/recNorm/readNorm/readNorm.H new file mode 100644 index 00000000..b7753188 --- /dev/null +++ b/src/recurrence/recNorm/readNorm/readNorm.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + CFDEMcoupling academic - Open Source CFD-DEM coupling + + Contributing authors: + Thomas Lichtenegger + Copyright (C) 2015- Johannes Kepler University, Linz +------------------------------------------------------------------------------- +License + This file is part of CFDEMcoupling academic. + + CFDEMcoupling academic 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. + + CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see . +\*---------------------------------------------------------------------------*/ + +#ifndef readNorm_H +#define readNorm_H + +#include "recNorm.H" + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class readNorm Declaration +\*---------------------------------------------------------------------------*/ + +class readNorm +: + public recNorm +{ +protected: + + // Protected data + + dictionary propsDict_; + + const word recMatName_; + + void computeRecMatrix(); + + +public: + + //- Runtime type information + TypeName("readNorm"); + + // Constructors + + //- Construct from components + readNorm + ( + const dictionary& dict, + recBase& base + ); + + + // Destructor + + virtual ~readNorm(); + + + // Member Functions + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/recurrence/recNorm/recNorm/recNorm.C b/src/recurrence/recNorm/recNorm/recNorm.C index 2d25dfae..4852b36e 100644 --- a/src/recurrence/recNorm/recNorm/recNorm.C +++ b/src/recurrence/recNorm/recNorm/recNorm.C @@ -52,9 +52,7 @@ recNorm::recNorm : base_(base), recProperties_(dict), - verbose_(dict.lookupOrDefault("verbose", false)), - readRecMat_(false), - recMatName_("recurrenceMatrix") + verbose_(dict.lookupOrDefault("verbose", false)) { } @@ -67,18 +65,7 @@ recNorm::~recNorm() // * * * * * * * * * * * * * private Member Functions * * * * * * * * * * * * // -bool recNorm::readRecMatrix() -{ - if (readRecMat_) - { - Info << nl << type() << ": reading recurrence matrix " << recMatName_ <<"\n" << endl; - SymmetricSquareMatrix& recurrenceMatrix( base_.recM().recurrenceMatrix() ); - IFstream matrixFile(recMatName_); - matrixFile >> recurrenceMatrix; - return true; - } - return false; -} + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/recurrence/recNorm/recNorm/recNorm.H b/src/recurrence/recNorm/recNorm/recNorm.H index b99b0af0..308303e6 100644 --- a/src/recurrence/recNorm/recNorm/recNorm.H +++ b/src/recurrence/recNorm/recNorm/recNorm.H @@ -49,14 +49,8 @@ protected: bool verbose_; - bool readRecMat_; - - word recMatName_; - virtual void computeRecMatrix() = 0; - bool readRecMatrix(); - public: diff --git a/src/recurrence/recNorm/sqrDiffNorm/sqrDiffNorm.C b/src/recurrence/recNorm/sqrDiffNorm/sqrDiffNorm.C index 091a4b58..cbbd5766 100644 --- a/src/recurrence/recNorm/sqrDiffNorm/sqrDiffNorm.C +++ b/src/recurrence/recNorm/sqrDiffNorm/sqrDiffNorm.C @@ -58,16 +58,7 @@ sqrDiffNorm::sqrDiffNorm normConstant_(propsDict_.lookupOrDefault("normConstant",-1.0)), fieldType_(propsDict_.lookup("fieldType")), fieldName_(propsDict_.lookup("fieldName")) -{ - if (propsDict_.found("readRecMat")) - { - readRecMat_ = bool(readBool(propsDict_.lookup("readRecMat"))); - if (readRecMat_ && propsDict_.found("recMatName")) - { - recMatName_ = word(propsDict_.lookup("recMatName")); - } - } -} +{} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // @@ -78,8 +69,6 @@ sqrDiffNorm::~sqrDiffNorm() void sqrDiffNorm::computeRecMatrix() { - if (readRecMatrix()) return; - Info << nl << type() << ": computing recurrence matrix\n" << endl; label totNumRecSteps = base_.recM().numRecFields(); diff --git a/src/recurrence/recPath/predefinedPath/predefinedPath.C b/src/recurrence/recPath/predefinedPath/predefinedPath.C new file mode 100644 index 00000000..09565e6d --- /dev/null +++ b/src/recurrence/recPath/predefinedPath/predefinedPath.C @@ -0,0 +1,81 @@ +/*---------------------------------------------------------------------------*\ + CFDEMcoupling academic - Open Source CFD-DEM coupling + + Contributing authors: + Thomas Lichtenegger + Copyright (C) 2015- Johannes Kepler University, Linz +------------------------------------------------------------------------------- +License + This file is part of CFDEMcoupling academic. + + CFDEMcoupling academic 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. + + CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see . +\*---------------------------------------------------------------------------*/ + +#include "error.H" +#include "predefinedPath.H" +#include "Random.H" +#include "recModel.H" +#include "addToRunTimeSelectionTable.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(predefinedPath, 0); + +addToRunTimeSelectionTable +( + recPath, + predefinedPath, + dictionary +); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +predefinedPath::predefinedPath +( + const dictionary& dict, + recBase& base +) +: + recPath(dict, base), + propsDict_(dict.subDict(typeName + "Props")), + fileName_(propsDict_.lookupOrDefault("recPathName", "recurrencePath")) +{} + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +predefinedPath::~predefinedPath() +{} + +// * * * * * * * * * * * * * protected Member Functions * * * * * * * * * * * * // + +void predefinedPath::computeRecPath() +{ + IFstream f(fileName_); + f >> virtualTimeIndexList_; + + Info << "Read recurrence path from file " << fileName_ << endl; +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/recurrence/recPath/predefinedPath/predefinedPath.H b/src/recurrence/recPath/predefinedPath/predefinedPath.H new file mode 100644 index 00000000..c030aec5 --- /dev/null +++ b/src/recurrence/recPath/predefinedPath/predefinedPath.H @@ -0,0 +1,86 @@ +/*---------------------------------------------------------------------------*\ + CFDEMcoupling academic - Open Source CFD-DEM coupling + + Contributing authors: + Thomas Lichtenegger + Copyright (C) 2015- Johannes Kepler University, Linz +------------------------------------------------------------------------------- +License + This file is part of CFDEMcoupling academic. + + CFDEMcoupling academic 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. + + CFDEMcoupling academic 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 CFDEMcoupling academic. If not, see . +\*---------------------------------------------------------------------------*/ + +#ifndef predefinedPath_H +#define predefinedPath_H + +#include "recPath.H" + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class predefinedPath Declaration +\*---------------------------------------------------------------------------*/ + +class predefinedPath +: + public recPath +{ +protected: + + // Protected data + + dictionary propsDict_; + + word fileName_; + + void computeRecPath(); + + +public: + + //- Runtime type information + TypeName("predefinedPath"); + + // Constructors + + //- Construct from components + predefinedPath + ( + const dictionary& dict, + recBase& base + ); + + + // Destructor + + virtual ~predefinedPath(); + + + // Member Functions + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* //