Merge pull request #432 from Pakketeretet2/user_manifold_fix

Fixed a bug with equal-style variables as manifold params.
This commit is contained in:
sjplimp 2017-03-28 12:33:45 -06:00 committed by GitHub
commit 1dfd61f532
3 changed files with 13 additions and 11 deletions

View File

@ -84,8 +84,8 @@ FixManifoldForce::FixManifoldForce(LAMMPS *lmp, int narg, char **arg) :
error->all(FLERR,msg);
}
*(ptr_m->get_params()) = new double[nvars];
if( ptr_m->get_params() == NULL ){
ptr_m->params = new double[nvars];
if( ptr_m->params == NULL ){
error->all(FLERR,"Parameter pointer was NULL!");
}
@ -94,7 +94,7 @@ FixManifoldForce::FixManifoldForce(LAMMPS *lmp, int narg, char **arg) :
// and sets the values of those arguments that were _not_
// equal style vars (so that they are not overwritten each time step).
double *params = *(ptr_m->get_params());
double *params = ptr_m->params;
for( int i = 0; i < nvars; ++i ){
if( was_var( arg[i+4] ) )
error->all(FLERR,"Equal-style variables not allowed with fix manifoldforce");

View File

@ -131,11 +131,11 @@ FixNVEManifoldRattle::FixNVEManifoldRattle( LAMMPS *lmp, int &narg, char **arg,
strcpy( tstrs[i], arg[i+6] + offset );
}
*ptr_m->get_params() = new double[nvars];
if( !(*ptr_m->get_params()) ) error->all(FLERR,"Failed to allocate params!");
ptr_m->params = new double[nvars];
if( !ptr_m->params ) error->all(FLERR,"Failed to allocate params!");
for( int i = 0; i < nvars; ++i ){
// If param i was variable type, it will be set later...
(*ptr_m->get_params())[i] = is_var[i] ? 0.0 : force->numeric( FLERR, arg[i+6] );
ptr_m->params[i] = is_var[i] ? 0.0 : force->numeric( FLERR, arg[i+6] );
}
ptr_m->post_param_init();
@ -262,6 +262,7 @@ void FixNVEManifoldRattle::init()
void FixNVEManifoldRattle::update_var_params()
{
if( nevery > 0 ){
stats.x_iters = 0;
stats.v_iters = 0;
@ -270,7 +271,8 @@ void FixNVEManifoldRattle::update_var_params()
stats.v_iters_per_atom = 0.0;
}
double **ptr_params = ptr_m->get_params();
double *ptr_params = ptr_m->params;
for( int i = 0; i < nvars; ++i ){
if( is_var[i] ){
tvars[i] = input->variable->find(tstrs[i]);
@ -281,8 +283,8 @@ void FixNVEManifoldRattle::update_var_params()
if( input->variable->equalstyle(tvars[i]) ){
tstyle[i] = EQUAL;
double new_val = input->variable->compute_equal(tvars[i]);
// fprintf( stdout, "New value of var %d is now %f\n", i+1, new_val );
*(ptr_params[i]) = new_val;
ptr_params[i] = new_val;
}else{
error->all(FLERR,
"Variable for fix nve/manifold/rattle is invalid style");

View File

@ -63,12 +63,12 @@ namespace user_manifold {
virtual void set_atom_id( tagint a_id ){}
virtual int nparams() = 0;
double **get_params(){ return &params; };
// double *get_params(){ return params; };
// Overload if any initialization depends on params:
virtual void post_param_init(){}
virtual void checkup(){} // Some diagnostics...
protected:
double *params;
};