Hello Team, greetings. I'm trying to find that point in the CFDEMCoupling source code where the LIGGGHTS data is transferred to OpenFOAM solver. End goal is to output particle positions to terminal and later on, subtract a constant value from all the x - coordinates of particles for a simulation.
I think, data_liggghts_to_of( ) in library_cfd_coupling.cpp inside LIGGGHTS-PUBLIC/src is the function, which is called by getData( ) in twoWayMPI.C, is the point where LIGGGHTS data is transferred to OpenFOAM. Function is as given below.
void data_liggghts_to_of(const char *name,const char *type,void *ptr,void *&data,const char* datatype)
{
std::cout << "\nONS::data_li_to_of: " << name << "\n";
//LAMMPS *lmp = (LAMMPS *) ptr;
FixCfdCoupling* fcfd = (FixCfdCoupling*)locate_coupling_fix(ptr);
fcfd->get_dc()->push(name,type,data,datatype);
}
The variables "name" , "type" are (radius, scalar-atom), (x, vector-atom), (v, vector-atom) which are self-explanatory but I'm unable to output particle positions. How to do that?
What is the datatype of "data" argument in this function? I tried with "<< *&data <<" OR "<< &data <<", but all I see is addresses.
Thank you,
Jagan Mohan.
mschramm | Thu, 11/12/2020 - 18:46
void data type
Hello,
data is of type void as the function does not know what type it should be int, double, int*, double*, int**, ... .
This is why you also pass the string of what the data should be.
So looking at positions, You can obviously get position inside a force function from
particleCloud_.position(index)
for a specific value or
particleCloud_.position
for the entire array.
If you want to read it from the data_liggghts_to_of function, then you must cast it to the correct data type.
What value will you be altering the positions by? Will it change per atom? Will it be a different value per dimension?
Lets say you have a force function that needs the atom position and a special value per dimension.
You will need to add a property per atom in your liggghts script or add it to the calls when using the fix CFD command.
The positions will be updated for you but to get the updated special values (if they change) you would perform the following before you begin your loop
particleCloud_.dataExchangeM().getData("specialVals", "vector-atom", specialVals_);
Then in the loop you would use the value as
position = position_[index]
specialVal = specialVals_[index]
newVal = position - specialVal