time average function

Hi,
I’m new in LBM working on turbulence. I wonder whether there is a function to calculate time average values for vector fields like time average velocity?
with best wishes

your sincerely
steed188

Hello steed188,

I’m also new to LB and Palabos.
On my quest of understanding how things work i found a ‘processingFunctional’ that looks like it is capable of calculating a time average of e.g. the velocity field which I then wanted to export as vti file.

It is named ‘updateAveTensorTransientStatistics’ and can be found in “src/dataProcessors/dataAnalysisFunctional3D.h” and “dataAnalysisFunctional3D.hh”

It is implemented in the showcase example “showCases/gridRefinement3d/offLatticeExternalFlow.cpp” alongside with fancy other things like gridRefinement.

I find it quite hard to understand what’s going on and how to implement it in my own simulation.
Even though I managed to compile my code, it does not produce the expected results.

What approach have you taken? If you used the ‘updateAveTensorTransientStatistics’, please let me know how.

Cheers,
david

Hello cyberspeck,
I solved the problem myself with a stupid method.
I created a global MultiTensorField3d to store the Sum velocity and do the mean operation myself.
Like
[code=“cpp”]
for (plint iT=iniT/parameters.getDeltaT(); iT*parameters.getDeltaT()<maxT; ++iT)
{SumVelTensor = SumVelTensor + CurrentVelTensor;
}

         MeanVelTensor = SumVelTensor / TotalIter;


     I haven't tried the updateAveTensorTransientStatistics you said, because besides the mean velocity, I have also to calculate other mean variables and their  standard deviation, so I did the mean operation myself.

    Hope this will help you.

besh wishes,
steed188

Dear steed188,
I managed to use the functions provided by palabos and put everything in a little functional:

[code=“cpp”]

/// A functional, used for averaging
template
class Averaging3D {
public:
Averaging3D(MultiBlockLattice3D<T, DESCRIPTOR> &lattice_, IncomprFlowParam &parameters_,
BoxProcessingFunctional3D_LT<T,DESCRIPTOR, T,DESCRIPTOR::d>* functional_,
const plint avgStartT_, const plint avgSaveT_, const string &name_)
: plattice(&lattice_),
parameters(parameters_),
functional(functional_),
nowField( generateMultiTensorField<T,3>(lattice_.getBoundingBox()) ),
avgField( generateMultiTensorField<T,3>(lattice_.getBoundingBox()) ),
avgStartT(avgStartT_),
avgSaveT(avgSaveT_),
iter(0),
name(name_)
{ }
void operator() (plb::plint iT) {
if ( iT>=avgStartT && iter==0 ) {
pcout << “Start of " << name << " averaging!!!” << endl;
integrateProcessingFunctional(
functional, plattice->getBoundingBox(), *plattice, *nowField);
// the following 2 lines did not work for me:
// integrateProcessingFunctional(
// new UpdateAveTensorTransientStatistics3D<T,3>(iter), plattice->getBoundingBox(), *nowField, *avgField, 0);
iter = 1;
}

    if ( iT>=avgStartT && iter ) {

// so instead I used ‘applyProcessingFunctional’
applyProcessingFunctional(
// UpdateAveTensorTransientStatistics3D is derived from: BoxProcessingFunctional3D_TT
// and can be found in: dataAnalysisFunctional3D.h
new UpdateAveTensorTransientStatistics3D<T,3>(iter), plattice->getBoundingBox(), *nowField, *avgField);
iter++;
}

    if ( iter && iT>avgStartT && (iT-avgStartT)%avgSaveT==0 ) {
        pcout << "Saving VTK average " << name << " file ..." << endl;
        writeVTK(*plattice, parameters, iT, *avgField, name);
    }
    return;
}

private:
MultiBlockLattice3D<T, DESCRIPTOR>* plattice;
IncomprFlowParam const& parameters;
BoxProcessingFunctional3D_LT<T,DESCRIPTOR, T,DESCRIPTOR::d>* functional;
std::auto_ptr<MultiTensorField3D<T,3> > nowField; // for storing velocity field at current time
std::auto_ptr<MultiTensorField3D<T,3> > avgField; // for storing averaged velocity
plb::plint avgStartT;
plb::plint avgSaveT;
plint iter;
const string name;
};

// in main()
const plint avgStartT = 5000; // example for step at which to start averaging
const plint avgSaveT = 200; // period after which to save current average

Averaging3D vel(lattice, parameters, new BoxVelocityFunctional3D<T,DESCRIPTOR>(), avgStartT, avgSaveT, “avgVelocity”);

// Main loop over time iterations.
for (plint iT=iniT; iT<=endT; ++iT) {

    lattice.collideAndStream();
    vel(iT);


Hope you find it interesting and maybe even helpful!

Cheers,
david