Operate the whole vector field
OpenLB – Open Source Lattice Boltzmann Code › Forums › on OpenLB › General Topics › Operate the whole vector field
- This topic has 14 replies, 3 voices, and was last updated 7 years, 4 months ago by mathias.
-
AuthorPosts
-
May 15, 2017 at 5:09 am #1915steed188Participant
Hi,
I’d like to operate the whole vector field after every collision step. I wish to know:
1. How should I get the whole vector field such as velocity after collision step?
2. How are linear operations defined in OpenLB? For example this time’s velocity plus last time’s velocity.best wishes,
May 15, 2017 at 4:57 pm #2626albert.minkModeratorDear steed188,
please have a look to our examples and user guide.We provide easy generation of velocity field, linear functions and many more.
Best regards,
AlbertMay 19, 2017 at 8:44 am #2628steed188ParticipantDear Albert,
After I used SuperLatticePhysVelocity3D to get the whole field vectors, I wanted to do some operation to it. For exampleSuperLatticePhysVelocity3D<T, DESCRIPTOR> velocity( sLattice, converter );
velocity = velocity / 2;and it went wrong. I thought that the velocity is the data structure that created by SuperLatticePhysVelocity3D to store whole field vectors. Am I wrong?
So how should I define a structure to store data after using SuperLatticePhysVelocity3D to get it?Thank you so much.
yours sincerely
steed188June 1, 2017 at 9:48 am #2631albert.minkModeratorHi steed188,
there are several ways to get your velocity data modified.
Fist, velocity as you put it in your post has x,z,y component. Perhaps you prefer to compute the magnitude (l^2 norm, see SuperEuklidNorm3D<T,DESCRIPTOR> http://optilb.com/DoxyGen/html/d6/d91/classolb_1_1SuperEuklidNorm3D.html ) first and then divide it by two.These is one way how OpenLB may help you, more details can be found in your documentation, Chapter Functors.
Operations such as multiplication (pointwise) with a constant, or linear function, … are usually done via Analytical Functors. Now, in order to manipulate a lattice Functor, you have to transform it first to an analytical functor and then apply the algebraic operations. Afterwards transform the functor back to a lattice functor, see interpolationF.h
Regards,
AlbertJune 5, 2017 at 12:20 pm #2632steed188ParticipantDear Albert,
Thank you a lot for keeping going my problems.I’ve tried the AnalticalF functors. I do not use the L2 norm velocities. Adversely, I tried to operate with the x,y,z components. I tried like below:
//
SuperLatticePhysVelocity3D<T, DESCRIPTOR> Velocity1( sLattice1, converter );
SuperLatticePhysVelocity3D<T, DESCRIPTOR> Velocity2( sLattice2, converter );AnalyticalFfromSuperF3D<T> AnalVel1( Velocity1, true, 1 );
AnalyticalFfromSuperF3D<T> AnalVel2( Velocity2, true, 1 );
AnalyticalConst3D<T,T> Number1( T( 1.- 1./5. ) );
AnalyticalConst3D<T,T> Number2( T( 1. / 5.) );AnalyticalIdentity3D<T,T> Calc_Temp1( AnalVel1 * Number1);
AnalyticalIdentity3D<T,T> Calc_Temp2( AnalVel2 * Number1);
AnalyticPlus3D<T,T> NewVel( Calc_Temp1 , Calc_Temp2);SuperLatticeFfromAnalyticalF3D< T, DESCRIPTOR> NewVelToLattice(NewVel, lattice3);
SuperLatticePhysVelocity3D<T, DESCRIPTOR> velocity( lattice3, converter );
//
I hope I can create a new velocity field by doing some algebraic calulation with two velocities from two lattice by x,y,z components separately and store it to new lattice3 . But AnalyticalF didn’t works. There are no velocity values in lattice3.
In addition, as you mentioned that “transform it first to an analytical functor and then apply the algebraic operations. Afterwards transform the functor back to a lattice functor” so that I can write it with VTK. Do I have to translate a analytical functor into lattice before I write it to VTK? Because I may have some field results calcuated by analytical functors and then write to VTK files. If that , I need a lattice for every analytical result? That will be a lot of lattices. lol
Thank you again for your patience.
yours sincerely
steed188June 6, 2017 at 1:37 pm #2633albert.minkModeratorHi steed188,
respect for digging in OpenLB. So far you got realy deep 😉
I would like to see much more people doing so.First, pay attention to the dimensions.
SuperLatticePhysVelocity3D maps from R^3 -> R^3
AnalyticalConst3D maps from R^3 -> R^1However, to get a three dimensional Image, OpenLB overloads the constructor by:
—-
AnalyticalConst3D<T,T> Number2( T( 1. ),T( 1. ),T( 1. ) ); // will map from R^3 -> R^3
—-Second, I think OpenLB does not offer a functor to only manipulate a single component of a vector. We are not aware of any application for this operation. Fortunately, it is more of less easy to implement such a functor.
Third, OpenLB requires a lattice functor for writing simulation data to VTK format. You definitely can not store analytical functors. Usually, those mulitplication or other arithmetic operations of velocity fields are done by post processing tools, see ParaView filter CALCULATOR. However, if the result is needed at simulation time, there is perhaps no need to write the data to file system.
Third, I do not get the point of several lattices. I am used to have a lattice for a flow field. So as long as you stay with single phase flows, there is no need to deal with several lattices. What is your point?
Best regards,
AlbertJune 6, 2017 at 2:49 pm #2634steed188ParticipantDear albert.min-k,
Thank you for your focus.
I apologized for my poor English. 🙁First, do you mean that I should modify the code like below as you mentioned the “dimension”
AnalyticalFfromSuperF3D<T> AnalVel1( Velocity1, true, 1 );
AnalyticalConst3D<T,T> Number1( T( 1.- 1./5. ), T ( 1.- 1./5. ), T ( 1.- 1./5. ));
AnalyticalIdentity3D<T,T> Calc_Temp1( AnalVel1 * Number1);
Secondly, I mean that after I get a new velocity named NewVel by
AnalyticalIdentity3D<T,T> Calc_Temp1( AnalVel1 * Number1);
AnalyticalIdentity3D<T,T> Calc_Temp2( AnalVel2 * Number2);
AnalyticPlus3D<T, T> NewVel( Calc_Temp1 , Calc_Temp2);
Did I do get a new kind of velocity named “NewVel” of the whole field?
Then how should I do to put back it to the lattice so that I can write it to VTK? It seems that I can not write “NewVel” to VTK files just by doing as belows
SuperLatticeFfromAnalyticalF3D< T, DESCRIPTOR> NewVelToLattice(NewVel, lattice3);
SuperLatticePhysVelocity3D<T, DESCRIPTOR> New_Velocity( lattice3, converter );
vtmWriter.addFunctor( New_Velocity );
……
Would you mind giving an example or some codes that can teach me put it back to lattice and write it to VTK? As I could not find a similar example from the official tutorial.
Thirdly, what I mean by several lattices is like this:
I’m working on turbulence, in this field, I need to calculate several kinds of velocity indexes to continue my research, for example time average velocity, Reynolds stress velocity and so on. They are different kinds of velocities that calculated based on instantaneous velocity. After I calculated them by AnalyticalF I need to store them every time step and write to VTK. Do I need to store them in different lattice so that they won’t be covered by each other?
If I calculate them during post processing, I have to store every time steps‘ data, that would be a huge data to process. So I want to calculate them during every collisionAndStream period and just store the very time step that I need.Again, thank you for your patience.
Yours steed188
June 6, 2017 at 3:47 pm #2635albert.minkModeratorI implemented some basic application to cylinder2d from OpenLBv1.1
—
if ( iT == 0 ) {
// Writes the geometry, cuboid no. and rank no. as vti file for visualization
SuperLatticeGeometry2D<T, DESCRIPTOR> geometry( sLattice, superGeometry );
SuperLatticeCuboid2D<T, DESCRIPTOR> cuboid( sLattice );
SuperLatticeRank2D<T, DESCRIPTOR> rank( sLattice );
vtmWriter.write( geometry );
vtmWriter.write( cuboid );
vtmWriter.write( rank );vtmWriter.createMasterFile();
// steed188
AnalyticalConst2D<double,double> constTwo( 2.0 );
AnalyticalConst2D<double,double> constOne( 1);
AnalyticalIdentity2D<double,double> TwoMinusOne(constTwo-constOne);SuperLatticeFfromAnalyticalF2D<double,DESCRIPTOR> TwoMinusOne_lattice( TwoMinusOne,sLattice,superGeometry );
vtmWriter.write( TwoMinusOne_lattice );
}// Writes the vtk files
if ( iT%vtkIter == 0 && iT > 0 ) {
vtmWriter.write( iT );SuperEuklidNorm2D<T, DESCRIPTOR> normVel( velocity );
BlockLatticeReduction2D<T, DESCRIPTOR> planeReduction( normVel );
BlockGifWriter<T> gifWriter;
//gifWriter.write(planeReduction, 0, 0.7, iT, “vel”); //static scale
gifWriter.write( planeReduction, iT, “vel” ); // scaled// steed188
SuperLatticePhysVelocity2D<T, DESCRIPTOR> velocity_lattice( sLattice, converter );
AnalyticalConst2D<double,double> constThree( 3.0 );
SuperLatticeFfromAnalyticalF2D<double,DESCRIPTOR> constThree_lattice( constThree,sLattice,superGeometry );
SuperIdentity2D<double,double> velocityTimesConstThree(velocity_lattice*constThree_lattice);
vtmWriter.write( velocityTimesConstThree, iT );}
—-
June 7, 2017 at 8:10 am #2636steed188ParticipantDear albert.mink,
Thank you for your example that I learned much from it. But I have still some problems.1. how can I assign a AnalyticalF with another? I did like below, but it went wrong.
Code:AnalyticalIdentity3D<T,T> * aMeanVelocity; //define an empty AnalyticalF
AnalyticalIdentity3D<T,T> Calc_Temp1( ……);
AnalyticalIdentity3D<T,T> Calc_Temp2( ……);
aMeanVelocity = new AnalyticPlus3D<T,T>( Calc_Temp1 , Calc_Temp2); //assign the AnalyticalFIt seems that I could not simply assign it using AnalyticalF_A=AnalyticalF_B
2. As I calculated a new kind of velocity, how can I write it to the same VTK file that the normal velocity is also written. Because they have the same variation name in VTK files causing error.
I did like below.Code:SuperLatticePhysVelocity3D<T, DESCRIPTOR> velocity( sLattice, converter ); //ordinary velocity like other cases
SuperLatticeFfromAnalyticalF3D<T,DESCRIPTOR> MeanVel( aMeanVelocity,sLattice,superGeometry ); //new kind of mean velocity calculated from AnalyticalF
vtmWriter.addFunctor( velocity ); //write this time’s instantaneous velocity to VTK
vtmWriter.addFunctor( MeanVel ); //write mean velocity to VTK
vtmWriter.write( iT );It Seems wrong? how can I write two velocity into one VTK file ? Because they own the same name when written to VTK.
Thank you
steed188
June 7, 2017 at 10:26 am #2637mathiasKeymasterDear steed188,
You could come to the next spring school in March 2018 and discuss with us about your problems or we start a common project. Please, contact me!
Best
MathiasJune 7, 2017 at 4:20 pm #2639steed188ParticipantDear mathias,
Yeah, I’m discussing with my professor to attend next years’s spring school these days for I have a lot of things to learn and discuss.But before that , would you mind helping me that how to assign one AnalyticalF or SuperLatticeF with another?
for example,SuperIdentity3D<T,T> * sFunctor1 ;
SuperIdentity3D<T,T> sFunctor2(……) ;How should I operate that can meke sFunctor1=sFunctor2?
Thank you.
with best wishes,
August 5, 2017 at 2:12 pm #2684steed188ParticipantI maybe found the problem.
It seems that the SuperData3d can store data correctly. And I could catch cell data after I convert it into SuperDataF3D. But if I used vtmWriter.addFunctor to write the SuperDataF3D it went wrong.Is wright to write SuperDataF3D to vtk files? Or should I convert it to other functors?
with best wishes,
steed188August 6, 2017 at 11:07 am #2687mathiasKeymasterIt should work, if you find where it comes from, please, let us know!
August 7, 2017 at 12:28 pm #2688steed188ParticipantI got the problem.
I mistakenly put the indicator Functor to create the whole simulation field “IndicatorCuboid3D<T> extendedDomain” before the main function. It means the IndicatorCuboid3D did not included in any functions but seemed as a global definition.
The mistake made simulation processed no fault and the results are correct but led to the fault in dealing with superdata3d.
But in my vtk files written from SuperDataF, the data of borders of Cuboids are missing. Does SuperData will deal with overlap data by itself? Or should I do some operation to catch overlap data myself?
August 7, 2017 at 12:37 pm #2689mathiasKeymasterYou need to check yourself. This is too detailed know. If you need further support, please contact me by e-mail.
Best
Mathias -
AuthorPosts
- You must be logged in to reply to this topic.