mirror of
https://github.com/ParticulateFlow/CFDEMcoupling-PFM.git
synced 2025-12-08 06:37:44 +00:00
Feature for calculation of spatial autocorrelation function.
This commit is contained in:
@ -2,7 +2,6 @@ recBase/recBase.C
|
||||
recModel/recModel/recModel.C
|
||||
recModel/recModel/newRecModel.C
|
||||
recModel/standardRecModel/standardRecModel.C
|
||||
recModel/gerhardsRecModel/gerhardsRecModel.C
|
||||
recNorm/recNorm/recNorm.C
|
||||
recNorm/recNorm/newRecNorm.C
|
||||
recNorm/diffNorm/diffNorm.C
|
||||
@ -23,5 +22,6 @@ recStatAnalysis/recStatAnalysis/recStatAnalysis.C
|
||||
recStatAnalysis/recStatAnalysis/newRecStatAnalysis.C
|
||||
recStatAnalysis/noRecStatAnalysis/noRecStatAnalysis.C
|
||||
recStatAnalysis/standardRecStatAnalysis/standardRecStatAnalysis.C
|
||||
recStatAnalysis/autocorrelation/autocorrelation.C
|
||||
|
||||
LIB = $(CFDEM_LIB_DIR)/librecurrence
|
||||
|
||||
@ -135,11 +135,7 @@ public:
|
||||
|
||||
/*virtual void exportVolScalarField(word, volScalarField&) const = 0;
|
||||
virtual void exportVolVectorField(word, volVectorField&) const = 0;
|
||||
virtual void exportSurfaceScalarField(word, surfaceScalarField&) const = 0;
|
||||
|
||||
virtual const volScalarField& exportVolScalarField(word, label) const = 0;
|
||||
virtual const volVectorField& exportVolVectorField(word, label) const = 0;
|
||||
virtual const surfaceScalarField& exportSurfaceScalarField(word, label) const = 0;*/
|
||||
virtual void exportSurfaceScalarField(word, surfaceScalarField&) const = 0;*/
|
||||
|
||||
virtual void exportVolScalarFieldAve(word, volScalarField&, label = 0)
|
||||
{}
|
||||
@ -148,6 +144,14 @@ public:
|
||||
virtual void exportSurfaceScalarFieldAve(word, surfaceScalarField&, label = 0)
|
||||
{}
|
||||
|
||||
virtual tmp<volScalarField> exportVolScalarFieldAve(word, label = 0)
|
||||
{
|
||||
return volScalarField::null();
|
||||
}
|
||||
virtual tmp<volVectorField> exportVolVectorFieldAve(word, label = 0)
|
||||
{
|
||||
return volVectorField::null();
|
||||
}
|
||||
virtual tmp<surfaceScalarField> exportSurfaceScalarFieldAve(word, label = 0)
|
||||
{
|
||||
return surfaceScalarField::null();
|
||||
@ -161,6 +165,10 @@ public:
|
||||
virtual const volVectorField& exportVolVectorField(word, label) = 0;
|
||||
virtual const surfaceScalarField& exportSurfaceScalarField(word, label) = 0;
|
||||
|
||||
virtual PtrList<volScalarField>& exportVolScalarFieldList(word) = 0;
|
||||
virtual PtrList<volVectorField>& exportVolVectorFieldList(word) = 0;
|
||||
virtual PtrList<surfaceScalarField>& exportSurfaceScalarFieldList(word) = 0;
|
||||
|
||||
// virtual tmp<surfaceScalarField> exportAveragedSurfaceScalarField(word, scalar, label index = -1) = 0;
|
||||
virtual void exportAveragedVolVectorField(volVectorField&, word, scalar, label index = -1) const = 0;
|
||||
|
||||
|
||||
@ -550,6 +550,34 @@ void standardRecModel::exportSurfaceScalarFieldAve(word fieldname, surfaceScalar
|
||||
field = aveSurfaceScalarFieldList_[fieldI][db];
|
||||
}
|
||||
|
||||
tmp<volScalarField> standardRecModel::exportVolScalarFieldAve(word fieldname, label db)
|
||||
{
|
||||
if(!storeAveragedFields_)
|
||||
{
|
||||
FatalError <<"no averaged fields available, need to activate \"storeAveragedFields\"\n" << abort(FatalError);
|
||||
}
|
||||
if (db >= numDataBases_)
|
||||
{
|
||||
FatalError <<"can't find database with number " << db << abort(FatalError);
|
||||
}
|
||||
const label fieldI = getVolScalarFieldIndex(fieldname, 0);
|
||||
return aveVolScalarFieldList_[fieldI][db];
|
||||
}
|
||||
|
||||
tmp<volVectorField> standardRecModel::exportVolVectorFieldAve(word fieldname, label db)
|
||||
{
|
||||
if(!storeAveragedFields_)
|
||||
{
|
||||
FatalError <<"no averaged fields available, need to activate \"storeAveragedFields\"\n" << abort(FatalError);
|
||||
}
|
||||
if (db >= numDataBases_)
|
||||
{
|
||||
FatalError <<"can't find database with number " << db << abort(FatalError);
|
||||
}
|
||||
const label fieldI = getVolVectorFieldIndex(fieldname, 0);
|
||||
return aveVolVectorFieldList_[fieldI][db];
|
||||
}
|
||||
|
||||
tmp<surfaceScalarField> standardRecModel::exportSurfaceScalarFieldAve(word fieldname, label db)
|
||||
{
|
||||
if(!storeAveragedFields_)
|
||||
@ -603,6 +631,27 @@ const surfaceScalarField& standardRecModel::exportSurfaceScalarField(word fieldn
|
||||
return surfaceScalarFieldList_[fieldI][index];
|
||||
}
|
||||
|
||||
PtrList<volScalarField>& standardRecModel::exportVolScalarFieldList(word fieldname)
|
||||
{
|
||||
const label fieldI = getVolScalarFieldIndex(fieldname);
|
||||
|
||||
return volScalarFieldList_[fieldI];
|
||||
}
|
||||
|
||||
PtrList<volVectorField>& standardRecModel::exportVolVectorFieldList(word fieldname)
|
||||
{
|
||||
const label fieldI = getVolVectorFieldIndex(fieldname);
|
||||
|
||||
return volVectorFieldList_[fieldI];
|
||||
}
|
||||
|
||||
PtrList<surfaceScalarField>& standardRecModel::exportSurfaceScalarFieldList(word fieldname)
|
||||
{
|
||||
const label fieldI = getSurfaceScalarFieldIndex(fieldname);
|
||||
|
||||
return surfaceScalarFieldList_[fieldI];
|
||||
}
|
||||
|
||||
|
||||
SymmetricSquareMatrix<scalar>& standardRecModel::recurrenceMatrix()
|
||||
{
|
||||
|
||||
@ -84,9 +84,9 @@ protected:
|
||||
|
||||
scalar checkTimeStep();
|
||||
|
||||
inline label getVolScalarFieldIndex(word, label) const;
|
||||
inline label getVolVectorFieldIndex(word, label) const;
|
||||
inline label getSurfaceScalarFieldIndex(word, label) const;
|
||||
inline label getVolScalarFieldIndex(word, label = 0) const;
|
||||
inline label getVolVectorFieldIndex(word, label = 0) const;
|
||||
inline label getSurfaceScalarFieldIndex(word, label = 0) const;
|
||||
|
||||
void init();
|
||||
|
||||
@ -119,6 +119,8 @@ public:
|
||||
void exportVolVectorFieldAve(word, volVectorField&, label);
|
||||
void exportSurfaceScalarFieldAve(word, surfaceScalarField&, label);
|
||||
|
||||
tmp<volScalarField> exportVolScalarFieldAve(word, label = 0);
|
||||
tmp<volVectorField> exportVolVectorFieldAve(word, label = 0);
|
||||
tmp<surfaceScalarField> exportSurfaceScalarFieldAve(word, label = 0);
|
||||
|
||||
void exportVolScalarField(word, volScalarField&);
|
||||
@ -128,6 +130,10 @@ public:
|
||||
const volScalarField& exportVolScalarField(word, label);
|
||||
const volVectorField& exportVolVectorField(word, label);
|
||||
const surfaceScalarField& exportSurfaceScalarField(word, label);
|
||||
|
||||
PtrList<volScalarField>& exportVolScalarFieldList(word);
|
||||
PtrList<volVectorField>& exportVolVectorFieldList(word);
|
||||
PtrList<surfaceScalarField>& exportSurfaceScalarFieldList(word);
|
||||
|
||||
// tmp<surfaceScalarField> exportAveragedSurfaceScalarField(word, scalar, label index = -1);
|
||||
void exportAveragedVolVectorField(volVectorField&, word, scalar, label index = -1) const;
|
||||
|
||||
179
src/recurrence/recStatAnalysis/autocorrelation/autocorrelation.C
Normal file
179
src/recurrence/recStatAnalysis/autocorrelation/autocorrelation.C
Normal file
@ -0,0 +1,179 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
CFDEMcoupling academic - Open Source CFD-DEM coupling
|
||||
|
||||
Contributing authors:
|
||||
Thomas Lichtenegger, Gerhard Holzinger
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "error.H"
|
||||
#include "Random.H"
|
||||
#include "autocorrelation.H"
|
||||
#include "recModel.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
defineTypeNameAndDebug(autocorrelation, 0);
|
||||
|
||||
addToRunTimeSelectionTable
|
||||
(
|
||||
recStatAnalysis,
|
||||
autocorrelation,
|
||||
dictionary
|
||||
);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
// Construct from components
|
||||
autocorrelation::autocorrelation
|
||||
(
|
||||
const dictionary& dict,
|
||||
recBase& base
|
||||
)
|
||||
:
|
||||
recStatAnalysis(dict,base),
|
||||
propsDict_(dict.subDict(typeName + "Props")),
|
||||
fieldname_(propsDict_.lookup("fieldname")),
|
||||
fieldtype_(propsDict_.lookup("fieldtype")),
|
||||
delaySteps_(propsDict_.lookupOrDefault<label>("delaysteps",0)),
|
||||
refCell_(0),
|
||||
refPoint_(propsDict_.lookup("refPoint")),
|
||||
normalize_(propsDict_.lookupOrDefault<bool>("normalize",true)),
|
||||
autoCorrField_
|
||||
( IOobject
|
||||
(
|
||||
"autoCorrField",
|
||||
base.mesh().time().timeName(),
|
||||
base.mesh(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
base.mesh(),
|
||||
dimensionedScalar("zero", dimensionSet(0,0,0,0,0), 0.0)
|
||||
)
|
||||
{
|
||||
if (fieldtype_ != "scalar" && fieldtype_ != "vector")
|
||||
{
|
||||
FatalError <<"fieldtype needs to be either scalar or vector.\n" << abort(FatalError);
|
||||
}
|
||||
|
||||
scalar delayTime = delaySteps_ * base.recM().recTimeStep();
|
||||
autoCorrField_.rename("autoCorrField"+name(delayTime));
|
||||
|
||||
refCell_ = base.mesh().findCell(refPoint_);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
autocorrelation::~autocorrelation()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
void autocorrelation::init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void autocorrelation::statistics()
|
||||
{
|
||||
autocorr();
|
||||
}
|
||||
|
||||
|
||||
|
||||
void autocorrelation::autocorr()
|
||||
{
|
||||
scalar res = 0.0;
|
||||
PtrList<volScalarField> scalarFieldList;
|
||||
PtrList<volVectorField> vectorFieldList;
|
||||
if (fieldtype_ == "scalar") scalarFieldList.transfer(base_.recM().exportVolScalarFieldList(fieldname_));
|
||||
else vectorFieldList.transfer(base_.recM().exportVolVectorFieldList(fieldname_));
|
||||
|
||||
label tmax = base_.recM().totRecSteps();
|
||||
for (label ti = delaySteps_; ti < tmax; ti++)
|
||||
{
|
||||
forAll(autoCorrField_, cellI)
|
||||
{
|
||||
if (fieldtype_ == "scalar")
|
||||
{
|
||||
res = scalarFieldList[ti-delaySteps_][refCell_] * scalarFieldList[ti][cellI];
|
||||
}
|
||||
else
|
||||
{
|
||||
res = vectorFieldList[ti-delaySteps_][refCell_] & vectorFieldList[ti][cellI];
|
||||
}
|
||||
autoCorrField_[cellI] += res;
|
||||
}
|
||||
}
|
||||
|
||||
autoCorrField_ /= (tmax - delaySteps_);
|
||||
|
||||
if (normalize_)
|
||||
{
|
||||
volScalarField meanProd(autoCorrField_);
|
||||
if (fieldtype_ == "scalar")
|
||||
{
|
||||
volScalarField aveField = base_.recM().exportVolScalarFieldAve(fieldname_);
|
||||
forAll(meanProd, cellI)
|
||||
{
|
||||
meanProd[cellI] = aveField()[cellI] * aveField()[refCell_];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
volVectorField aveField = base_.recM().exportVolVectorFieldAve(fieldname_);
|
||||
forAll(meanProd, cellI)
|
||||
{
|
||||
meanProd[cellI] = aveField()[cellI] & aveField()[refCell_];
|
||||
}
|
||||
}
|
||||
autoCorrField_ /= meanProd;
|
||||
}
|
||||
else
|
||||
{
|
||||
dimensionSet fieldDim(0,0,0,0,0);
|
||||
if (fieldtype_ == "scalar")
|
||||
{
|
||||
fieldDim.reset(scalarFieldList[0].dimensions());
|
||||
}
|
||||
else
|
||||
{
|
||||
fieldDim.reset(vectorFieldList[0].dimensions());
|
||||
}
|
||||
|
||||
fieldDim = fieldDim * fieldDim;
|
||||
|
||||
autoCorrField_.dimensions().reset(fieldDim);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
102
src/recurrence/recStatAnalysis/autocorrelation/autocorrelation.H
Normal file
102
src/recurrence/recStatAnalysis/autocorrelation/autocorrelation.H
Normal file
@ -0,0 +1,102 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
CFDEMcoupling academic - Open Source CFD-DEM coupling
|
||||
|
||||
Contributing authors:
|
||||
Thomas Lichtenegger, Gerhard Holzinger
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef autocorrelation_H
|
||||
#define autocorrelation_H
|
||||
|
||||
#include "recStatAnalysis.H"
|
||||
#include "scalarList.H"
|
||||
#include "fvCFD.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class autocorrelation Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class autocorrelation
|
||||
:
|
||||
public recStatAnalysis
|
||||
{
|
||||
protected:
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("autocorrelation");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
autocorrelation
|
||||
(
|
||||
const dictionary& dict,
|
||||
recBase& base
|
||||
);
|
||||
|
||||
// Destructor
|
||||
|
||||
~autocorrelation();
|
||||
|
||||
void init();
|
||||
|
||||
void statistics();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
dictionary propsDict_;
|
||||
|
||||
word fieldname_;
|
||||
|
||||
word fieldtype_;
|
||||
|
||||
label delaySteps_;
|
||||
|
||||
label refCell_;
|
||||
|
||||
vector refPoint_;
|
||||
|
||||
bool normalize_;
|
||||
|
||||
volScalarField autoCorrField_;
|
||||
|
||||
void autocorr();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user