From 54f04e6604473d7016d3dfeebdfed6d848715e8a Mon Sep 17 00:00:00 2001 From: Thomas Lichtenegger Date: Mon, 18 Dec 2017 15:31:32 +0100 Subject: [PATCH] Some debugging for rSmoother. --- applications/utilities/rSmoother/Make/options | 12 +-- .../utilities/rSmoother/createFields.H | 17 +++- applications/utilities/rSmoother/rSmoother.C | 13 +-- .../utilities/rSmoother/updateFields.H | 2 +- src/recurrence/recModel/recModel/recModel.H | 4 +- .../standardRecModel/standardRecModel.C | 92 +++++++++---------- .../standardRecModel/standardRecModel.H | 4 +- 7 files changed, 74 insertions(+), 70 deletions(-) diff --git a/applications/utilities/rSmoother/Make/options b/applications/utilities/rSmoother/Make/options index f91d7947..39b05d12 100644 --- a/applications/utilities/rSmoother/Make/options +++ b/applications/utilities/rSmoother/Make/options @@ -4,23 +4,15 @@ EXE_INC = \ -I$(CFDEM_OFVERSION_DIR) \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ - -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ - -I$(LIB_SRC)/transportModels \ - -I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \ - -I$(CFDEM_SRC_DIR)/lagrangian/cfdemParticle/lnInclude \ - -I$(CFDEM_SRC_DIR)/lagrangian/cfdemParticle/cfdTools \ -I$(CFDEM_SRC_DIR)/recurrence/lnInclude \ - -I$(CFDEM_SRC_DIR)/lagrangian/cfdemParticle/derived/cfdemCloudRec \ EXE_LIBS = \ -L$(CFDEM_LIB_DIR)\ -lrecurrence \ - -lturbulenceModels \ - -lincompressibleTurbulenceModels \ - -lincompressibleTransportModels \ -lfiniteVolume \ -lmeshTools \ -l$(CFDEM_LIB_NAME) \ $(CFDEM_ADD_LIB_PATHS) \ + -lsampling \ + -lfvOptions \ $(CFDEM_ADD_LIBS) diff --git a/applications/utilities/rSmoother/createFields.H b/applications/utilities/rSmoother/createFields.H index 3e19a76f..7d1e81cc 100644 --- a/applications/utilities/rSmoother/createFields.H +++ b/applications/utilities/rSmoother/createFields.H @@ -1,4 +1,19 @@ - volVectorField U_smooth +IOdictionary recProperties + ( + IOobject + ( + "recProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ); + +dimensionedScalar dThreshold(recProperties.lookup("threshold")); +scalar threshold = dThreshold.value(); + +volVectorField U_smooth ( IOobject ( diff --git a/applications/utilities/rSmoother/rSmoother.C b/applications/utilities/rSmoother/rSmoother.C index a065e779..337e3cca 100644 --- a/applications/utilities/rSmoother/rSmoother.C +++ b/applications/utilities/rSmoother/rSmoother.C @@ -30,13 +30,11 @@ Description \*---------------------------------------------------------------------------*/ -// #include "fvCFD.H" -// #include "singlePhaseTransportModel.H" -// #include "turbulentTransportModel.H" -// #include "fvOptions.H" + #include "fvCFD.H" + #include "fvOptions.H" #include "recBase.H" - +#include "recModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -47,6 +45,7 @@ int main(int argc, char *argv[]) #include "createTime.H" #include "createMesh.H" #include "createControl.H" + #include "createFields.H" recBase recurrenceBase(mesh); @@ -54,9 +53,8 @@ int main(int argc, char *argv[]) // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // set time step to that of recurrence database - runTime.setDeltaT(recBase.recM().recTimeStep()); + runTime.setDeltaT(recurrenceBase.recM().recTimeStep()); - scalar threshold = 0.5; label index = -1; Info<< "\nSmoothing recurrence statistics\n" << endl; @@ -67,7 +65,6 @@ int main(int argc, char *argv[]) index = runTime.timeIndex(); #include "updateFields.H" runTime++; - recTimeIndex++; } Info<< "End\n" << endl; diff --git a/applications/utilities/rSmoother/updateFields.H b/applications/utilities/rSmoother/updateFields.H index 2f0d84e5..f13bfbee 100644 --- a/applications/utilities/rSmoother/updateFields.H +++ b/applications/utilities/rSmoother/updateFields.H @@ -1,4 +1,4 @@ Info << "averaging fields for time = " << runTime.value() <<", time index = " << index << endl; -U_smooth = recurrenceBase.recM().exportAveragedVolVectorField("U", threshold, index); +U_smooth = recurrenceBase.recM().exportAveragedVolVectorField("UMean", threshold, index)(); U_smooth.write(); diff --git a/src/recurrence/recModel/recModel/recModel.H b/src/recurrence/recModel/recModel/recModel.H index 5bea158a..42ae8efb 100644 --- a/src/recurrence/recModel/recModel/recModel.H +++ b/src/recurrence/recModel/recModel/recModel.H @@ -130,8 +130,8 @@ public: virtual const volVectorField& exportVolVectorField(word, label) const = 0; virtual const surfaceScalarField& exportSurfaceScalarField(word, label) const = 0; - virtual tmp exportAveragedSurfaceScalarField(word, scalar, label index = -1) const = 0; - virtual tmp exportAveragedVolVectorField(word, scalar, label index = -1) const = 0; + // virtual tmp exportAveragedSurfaceScalarField(word, scalar, label index = -1) = 0; + virtual tmp exportAveragedVolVectorField(word, scalar, label index = -1) = 0; virtual SymmetricSquareMatrix& recurrenceMatrix() = 0; diff --git a/src/recurrence/recModel/standardRecModel/standardRecModel.C b/src/recurrence/recModel/standardRecModel/standardRecModel.C index 749b3229..06fbe88d 100644 --- a/src/recurrence/recModel/standardRecModel/standardRecModel.C +++ b/src/recurrence/recModel/standardRecModel/standardRecModel.C @@ -407,7 +407,45 @@ void standardRecModel::writeRecMatrix() const -tmp standardRecModel::exportAveragedSurfaceScalarField(word fieldname, scalar threshold, label index) const +// tmp standardRecModel::exportAveragedSurfaceScalarField(word fieldname, scalar threshold, label index) +// { +// label timeIndex; +// if (index < 0) +// { +// timeIndex = virtualTimeIndex; +// } +// else +// { +// timeIndex = index; +// } +// const label fieldI = getSurfaceScalarFieldIndex(fieldname, timeIndex); +// +// tmp tAveragedSurfaceScalarField(surfaceScalarFieldList_[fieldI][timeIndex]); +// +// label counter = 1; +// scalar recErr; +// label delay = 10; +// label lastMin = -1000; +// +// for(int runningTimeIndex = 1; runningTimeIndex < numRecFields_-1 ; runningTimeIndex++) +// { +// recErr = recurrenceMatrix_[timeIndex][runningTimeIndex]; +// if(recErr > threshold) continue; +// if(recErr > recurrenceMatrix_[timeIndex][runningTimeIndex-1]) continue; +// if(recErr > recurrenceMatrix_[timeIndex][runningTimeIndex+1]) continue; +// if(abs(runningTimeIndex - timeIndex) < delay) continue; +// if(abs(runningTimeIndex - lastMin) < delay) continue; +// +// lastMin = runningTimeIndex; +// counter++; +// tAveragedSurfaceScalarField += surfaceScalarFieldList_[fieldI][runningTimeIndex]; +// } +// +// tAveragedSurfaceScalarField /= counter; +// return tAveragedSurfaceScalarField; +// } + +tmp standardRecModel::exportAveragedVolVectorField(word fieldname, scalar threshold, label index) { label timeIndex; if (index < 0) @@ -418,15 +456,15 @@ tmp standardRecModel::exportAveragedSurfaceScalarField(word { timeIndex = index; } - const label fieldI = getSurfaceScalarFieldIndex(fieldname, timeIndex); - - tmp tAveragedSurfaceScalarField(surfaceScalarFieldList_[fieldI][timeIndex]); + const label fieldI = getVolVectorFieldIndex(fieldname, timeIndex); + tmp tAveragedVolVectorField(volVectorFieldList_[fieldI][timeIndex]); + label counter = 1; scalar recErr; label delay = 10; label lastMin = -1000; - + for(int runningTimeIndex = 1; runningTimeIndex < numRecFields_-1 ; runningTimeIndex++) { recErr = recurrenceMatrix_[timeIndex][runningTimeIndex]; @@ -438,48 +476,10 @@ tmp standardRecModel::exportAveragedSurfaceScalarField(word lastMin = runningTimeIndex; counter++; - tAveragedSurfaceScalarField += surfaceScalarFieldList_[fieldI][runningTimeIndex]; + tAveragedVolVectorField() += volVectorFieldList_[fieldI][runningTimeIndex]; } - - tAveragedSurfaceScalarField /= counter; - return tAveragedSurfaceScalarField; -} - -tmp standardRecModel::exportAveragedVolVectorField(word fieldname, scalar threshold, label index) const -{ - label timeIndex; - if (index < 0) - { - timeIndex = virtualTimeIndex; - } - else - { - timeIndex = index; - } - const label fieldI = getSurfaceScalarFieldIndex(fieldname, timeIndex); - - tmp tAveragedVolVectorField(surfaceScalarFieldList_[fieldI][timeIndex]); - - label counter = 1; - scalar recErr; - label delay = 10; - label lastMin = -1000; - - for(int runningTimeIndex = 1; runningTimeIndex < numRecFields_-1 ; runningTimeIndex++) - { - recErr = recurrenceMatrix_[timeIndex][runningTimeIndex]; - if(recErr > threshold) continue; - if(recErr > recurrenceMatrix_[timeIndex][runningTimeIndex-1]) continue; - if(recErr > recurrenceMatrix_[timeIndex][runningTimeIndex+1]) continue; - if(abs(runningTimeIndex - timeIndex) < delay) continue; - if(abs(runningTimeIndex - lastMin) < delay) continue; - - lastMin = runningTimeIndex; - counter++; - tAveragedVolVectorField += volVectorFieldList_[fieldI][runningTimeIndex]; - } - - tAveragedVolVectorField /= counter; + Info << "time index = " << index << ", counter = " << counter << endl; + tAveragedVolVectorField() /= counter; return tAveragedVolVectorField; } diff --git a/src/recurrence/recModel/standardRecModel/standardRecModel.H b/src/recurrence/recModel/standardRecModel/standardRecModel.H index fbac07e4..5165addb 100644 --- a/src/recurrence/recModel/standardRecModel/standardRecModel.H +++ b/src/recurrence/recModel/standardRecModel/standardRecModel.H @@ -102,8 +102,8 @@ public: const volVectorField& exportVolVectorField(word, label) const; const surfaceScalarField& exportSurfaceScalarField(word, label) const; - tmp exportAveragedSurfaceScalarField(word, scalar, label index = -1) const; - tmp exportAveragedvolVectorField(word, scalar, label index = -1) const; + // tmp exportAveragedSurfaceScalarField(word, scalar, label index = -1); + tmp exportAveragedVolVectorField(word, scalar, label index = -1); SymmetricSquareMatrix& recurrenceMatrix();