TensorFieldBase2D

Hello,

I’m trying to modify the cylinder2d example from the basic openLB install. I would like to modify the last ‘for loop’ to getStrainRate rather than getPressure. I see getPressure is related to scalarField2d while getStrainRate is related to TensorField2d but I can not figure out how to implement the additional argument associated with the functions of TensorFieldBase. Any help with this task would be greatly appreciated.

Thanks

Tim

Hello Tim,

what do you want to do exactly?

Orestis

Ultimately I would like to implement a rheology curve in conjunction with multi-component flow around an obstruction. The upper fluid will have an initial velocity, at some critical point, the lower non-Newtonian fluid will begin to flow. I would like to calculate the strain rate of the lower fluid in order to update its viscosity.

These concepts are new to me and I am trying to practice with the examples by implementing single components of the code I will eventually write.

Thanks

OK. But I’m not sure what you want to do from a technical point of view. What is the problem you are really facing?

Here is the function I’ve modified. The calls associated with ScalarFieldBase work but I can’t get the call to getStrainRate (associated with tensorFieldBase to work.

Here is a portion of the code…

void plotStatistics(BlockStructure2D<T, DESCRIPTOR>& latticeTwo,
BlockStructure2D<T, DESCRIPTOR>& latticeOne, int iT)
{
cout << “Writing Gif\n”;
ImageWriter imageCreator(“leeloo.map”);
imageCreator.writeScaledGif(createFileName(“p”, iT, 6), latticeOne.getDataAnalysis().getPressure());
imageCreator.writeScaledGif(createFileName(“v”, iT, 6), latticeOne.getDataAnalysis().getVelocityNorm());
imageCreator.writeScaledGif<T, 3>(createFileName(“s”, iT, 6), latticeOne.getDataAnalysis().getStrainRate());
}

And the associated error…

In function void plotStatistics(olb::BlockStructure2D<T, olb::descriptors::ForcedShanChenD2Q9Descriptor> &, olb::BlockStructure2D<T, olb::descriptors::ForcedShanChenD2Q9Descriptor>&, int)': rayleighTaylor.cpp:165: error: no matching function for call toolb::graphics::ImageWriter::
writeScaledGif(std::string, const olb::TensorFieldBase2D<T, 3>&)’

Thanks

Tim

Hello,
when you try to write a gif file, you have to write a scalarfield (gif images are 2D). Therefore you have to select a component of you tensor in order to write the file. Something like

latticeOne.getDataAnalysis().getStrainRate().getComponent(0);

Thanks Orestis, that worked. I had to use extractComponenet() and remove the <T, 3> from earlier in the line but I have what I was looking for.

Thanks again

Tim

Hi,

A while back a needed some help creating a gif of strain rate. With the above help I was able to get the GIFs I wanted. I now need to capture the value of strain rate at each node. I’m trying to store the value as a double (gammaDot).

I’ve tried many things but the two below I feel are my best attempts.

I’ve tried
gammaDot = latticeOne.getDataAnalysis().getStrainRate().extractComponent(0);
It returns
error: cannot convert ‘const olb::ScalarFieldBase3D’ to ‘T’ in assignment.

I’ve tried
gammaDot = latticeOne.getDataAnalysis().getStrainRate().get().extractComponent(0);
It returns
error: no matching function for call to ‘olb::TensorFieldBase3D<T, 6>::get() const’

Anyone have any ideas I can try?

Thanks

Tim

Hello,

when you extract one component of the tensorfield you get a scalarfield, then in order to get the value on a given lattice node, you need to “get” it.

Example :

gammaDot = latticeOne.getDataAnalysis().getStrainRate().extractComponent(0).get(iX,iY,iZ);

But you also can simplify that a bit. Get hte tensorfield, the get the tensor on the lattice node, and then get the value of the zeroth component of the tensor.

gammaDot = latticeOne.getDataAnalysis().getStrainRate().get(iX,iY,iZ)[0];

Good luck,
Orestis

That worked great. Thanks again.

Tim