Hi,
I changed the rolling model a bit, therefor I needed a flag. So I added a bool variable. For a better understanding: I use the original EPSD2 header rolling_model_epsd2.h.
At the moment it is implemented within the privates of the header
private:
double ** coeffRollFrict;
int history_offset;
bool tipreach_flag;
the name is tipreach_flag. At the beginning it should be false but where can I set it? If I set it directly at the declaration it occurs a warning. So I set it in the function
void noCollision()
and at the following:
RollingModel(class LAMMPS * lmp, IContactHistorySetup * hsetup) : Pointers(lmp), coeffRollFrict(NULL)
{
history_offset = hsetup->add_history_value("r_torquex_old", "1");
hsetup->add_history_value("r_torquey_old", "1");
hsetup->add_history_value("r_torquez_old", "1");
tipreach_flag=false;
}
I'm not sure if it is right that way. I would appreciate any help.
Thanks
Joshua
aaigner | Fri, 07/10/2015 - 10:27
It is correct....
Hi Joshua!
It is more or less correct as you did it.
Just one remark:
In your case this would be
RollingModel(class LAMMPS * lmp, IContactHistorySetup * hsetup) : Pointers(lmp), coeffRollFrict(NULL), tipreach_flag(false)
{ ...
JoshuaP | Fri, 07/10/2015 - 10:53
many thanks for your fast
many thanks for your fast help!!!
Best wishes
Joshua
JoshuaP | Mon, 07/20/2015 - 10:15
If I want to use the flag
If I want to use the flag value for more than one particle, but for each particle an own value, I have to save this value in the cdata? How can I do this?
many thanks in advance!!
Joshua
richti83 | Mon, 07/20/2015 - 14:18
If you want to store the
If you want to store the value by PARTICLE I would use the great fix property/atom, because it implements all the MPI stuff to communicate the value to ghost particles when leaving a subdomain
On Scriptlevel
fix fppacc all property/atom fppacc scalar yes yes yes 0
run 0
In your C++-code you can now access this fix by:
updFix = NULL;
for (int ifix = 0; ifix < (lmp->modify->nfix); ifix++){
updFix = static_cast(modify->find_fix_id("fppacc"));
}
and use it later like this:
if (updFix->vector_atom[i]>=something)
do_anything()
Of course you can create the fix on C++ level, see FixCfdCouplingForce::post_create() for an example.
When you need the flag for every PAIR and don't need it after the contact has been lost just add a new history value like the rolling_model_epsd do.
Best,
Christian
JoshuaP | Mon, 07/20/2015 - 14:43
Hi Christian,
Hi Christian,
thanks for your reply. Actually I want to use the flag for every PAIR and dont need it after contact. What I tried so far is:
in contact_interface.h
struct ContactData {
double radi;
double radj;
double radsum;
double rsq;
double delta[3];
double area_ratio;
int * touch;
double * contact_history;
bool tipreach_flag; // <------ new variable
Then I tried to get access to the variable in rolling_model_eps2.h
bool * const treach_flag = &cdata.tipreach_flag;
*treach_flag=true;
But im still getting errors when I try to compile it.
regards
Joshua
richti83 | Mon, 07/20/2015 - 15:08
pointers and values
I think you mixed up pointers and values of variables.
in contact interface bool tipreach is a place in the memory (oposite to * contact_history which only holds a pointer to the memory where contact_history is stored)
so when accessing the VALUE of tipreach you should only need cdata.tipreach_flag=true; to set the value.
with *treach_flag=true you try to set the pointer to true which is not valid and I think you don't need a pointer to cdata.tipreach_flag (I think you has been inspired by contact_history, but c_h is a vector of type double and not a single value ..).
JoshuaP | Mon, 07/20/2015 - 15:17
I thought with bool* treach=
I thought with bool* treach=&cdata.tipreach_flag; I save the address in variable treach and with *treach I can change the value of the variable that is stored in the address. But I will try it like you said, but i think I have no access than.
JoshuaP | Tue, 07/21/2015 - 12:14
I get always segmentation
I get always segmentation fault and/or no access to the variables in cdata. Does it store the variables for each PAIR in cdata? Because there is no index for the different PAIRs.
All variables that are defined as CONST in the calcRollTorque() are constant until they are out of contact?? But why they use it here
const double r_torque_mag = vectorMag3D(r_torque);
?
Regards
Joshua
richti83 | Tue, 07/21/2015 - 14:46
only a guess
I think cdata is only a single struct which is used as input/output parameter in the function which handles contacts (pair gran und wall gran for example). It is filled for every contact detected in pair algorithmus and sent to the normal- und rolling models.
What you need is a history storage place for your flag, as I said you should use the existing contact_history.
something like this might work:
history_offset = hsetup->add_history_value("r_torquex_old", "1");
hsetup->add_history_value("r_torquey_old", "1");
hsetup->add_history_value("the_flag", "1"); //add a 4th contcact-history value
in collision
double * const c_history = &cdata.contact_history[history_offset];
if (c_history[3])
//when condition has been true in LAST contact loop do something interesting
c_history[3]=condition?1:0; //4th value of contact_history is storage for flag
I'm aware that one should not store a bool in a double, but this makes live easier than implementing a boolean contact history storage
JoshuaP | Tue, 07/21/2015 - 15:14
This works even if it is not
This works even if it is not that nice :)
with the bool variable it was always that it points into nowhere.
Thank you Christian for your help!!! If you are interested in an advanced rolling model that is able to reproduce the settlements under compaction of a sandy material I can share it as soon as I implemented and tested it.
Kind regards
Joshua