Pointer moved to reax lists
This commit is contained in:
@ -108,6 +108,8 @@ PairReaxC::PairReaxC(LAMMPS *lmp) : Pair(lmp)
|
||||
system->bndry_cuts.ghost_cutoff = 0;
|
||||
system->my_atoms = NULL;
|
||||
system->pair_ptr = this;
|
||||
system->error_ptr = this->lmp->error;
|
||||
control->error_ptr = this->lmp->error;
|
||||
|
||||
system->omp_active = 0;
|
||||
|
||||
@ -139,13 +141,13 @@ PairReaxC::~PairReaxC()
|
||||
|
||||
if (control->tabulate ) Deallocate_Lookup_Tables( lmp, system);
|
||||
|
||||
if (control->hbond_cut > 0 ) Delete_List( lmp, lists+HBONDS, world);
|
||||
Delete_List( lmp, lists+BONDS, world );
|
||||
Delete_List( lmp, lists+THREE_BODIES, world );
|
||||
Delete_List( lmp, lists+FAR_NBRS, world );
|
||||
if (control->hbond_cut > 0 ) Delete_List( lists+HBONDS, world);
|
||||
Delete_List( lists+BONDS, world );
|
||||
Delete_List( lists+THREE_BODIES, world );
|
||||
Delete_List( lists+FAR_NBRS, world );
|
||||
|
||||
DeAllocate_Workspace( lmp, control, workspace );
|
||||
DeAllocate_System( lmp, system );
|
||||
DeAllocate_Workspace( control, workspace );
|
||||
DeAllocate_System( system );
|
||||
}
|
||||
|
||||
memory->destroy( system );
|
||||
@ -437,13 +439,14 @@ void PairReaxC::setup( )
|
||||
|
||||
// initialize my data structures
|
||||
|
||||
PreAllocate_Space( lmp, system, control, workspace, world );
|
||||
PreAllocate_Space( system, control, workspace, world );
|
||||
write_reax_atoms();
|
||||
|
||||
int num_nbrs = estimate_reax_lists();
|
||||
if(!Make_List(lmp, system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR,
|
||||
if(!Make_List(system->total_cap, num_nbrs, TYP_FAR_NEIGHBOR,
|
||||
lists+FAR_NBRS, world))
|
||||
error->one(FLERR,"Pair reax/c problem in far neighbor list");
|
||||
(lists+FAR_NBRS)->error_ptr=lmp->error;
|
||||
|
||||
write_reax_lists();
|
||||
Initialize( lmp, system, control, data, workspace, &lists, out_control,
|
||||
@ -466,7 +469,7 @@ void PairReaxC::setup( )
|
||||
|
||||
// check if I need to shrink/extend my data-structs
|
||||
|
||||
ReAllocate( lmp, system, control, data, workspace, &lists, mpi_data );
|
||||
ReAllocate( system, control, data, workspace, &lists, mpi_data );
|
||||
}
|
||||
|
||||
bigint local_ngroup = list->inum;
|
||||
|
||||
@ -43,7 +43,7 @@ using namespace LAMMPS_NS;
|
||||
important: we cannot know the exact number of atoms that will fall into a
|
||||
process's box throughout the whole simulation. therefore
|
||||
we need to make upper bound estimates for various data structures */
|
||||
int PreAllocate_Space( LAMMPS_NS::LAMMPS* lmp, reax_system *system, control_params * /*control*/,
|
||||
int PreAllocate_Space( reax_system *system, control_params * /*control*/,
|
||||
storage * workspace, MPI_Comm comm )
|
||||
{
|
||||
int mincap = system->mincap;
|
||||
@ -55,7 +55,7 @@ int PreAllocate_Space( LAMMPS_NS::LAMMPS* lmp, reax_system *system, control_para
|
||||
system->total_cap = MAX( (int)(system->N * safezone), mincap );
|
||||
|
||||
system->my_atoms = (reax_atom*)
|
||||
scalloc(lmp, system->total_cap, sizeof(reax_atom), "my_atoms", comm );
|
||||
scalloc(system->error_ptr, system->total_cap, sizeof(reax_atom), "my_atoms", comm );
|
||||
|
||||
// Nullify some arrays only used in omp styles
|
||||
// Should be safe to do here since called in pair->setup();
|
||||
@ -84,45 +84,45 @@ int Allocate_System( reax_system *system, int /*local_cap*/, int total_cap,
|
||||
}
|
||||
|
||||
|
||||
void DeAllocate_System( LAMMPS_NS::LAMMPS *lmp, reax_system *system )
|
||||
void DeAllocate_System( reax_system *system )
|
||||
{
|
||||
int i, j, k;
|
||||
int ntypes;
|
||||
reax_interaction *ff_params;
|
||||
|
||||
// dealloocate the atom list
|
||||
sfree(lmp, system->my_atoms, "system->my_atoms" );
|
||||
// deallocate the atom list
|
||||
sfree(system->error_ptr, system->my_atoms, "system->my_atoms" );
|
||||
|
||||
// deallocate the ffield parameters storage
|
||||
ff_params = &(system->reax_param);
|
||||
ntypes = ff_params->num_atom_types;
|
||||
|
||||
sfree(lmp, ff_params->gp.l, "ff:globals" );
|
||||
sfree(system->error_ptr, ff_params->gp.l, "ff:globals" );
|
||||
|
||||
for( i = 0; i < ntypes; ++i ) {
|
||||
for( j = 0; j < ntypes; ++j ) {
|
||||
for( k = 0; k < ntypes; ++k ) {
|
||||
sfree(lmp, ff_params->fbp[i][j][k], "ff:fbp[i,j,k]" );
|
||||
sfree(system->error_ptr, ff_params->fbp[i][j][k], "ff:fbp[i,j,k]" );
|
||||
}
|
||||
sfree(lmp, ff_params->fbp[i][j], "ff:fbp[i,j]" );
|
||||
sfree(lmp, ff_params->thbp[i][j], "ff:thbp[i,j]" );
|
||||
sfree(lmp, ff_params->hbp[i][j], "ff:hbp[i,j]" );
|
||||
sfree(system->error_ptr, ff_params->fbp[i][j], "ff:fbp[i,j]" );
|
||||
sfree(system->error_ptr, ff_params->thbp[i][j], "ff:thbp[i,j]" );
|
||||
sfree(system->error_ptr, ff_params->hbp[i][j], "ff:hbp[i,j]" );
|
||||
}
|
||||
sfree(lmp, ff_params->fbp[i], "ff:fbp[i]" );
|
||||
sfree(lmp, ff_params->thbp[i], "ff:thbp[i]" );
|
||||
sfree(lmp, ff_params->hbp[i], "ff:hbp[i]" );
|
||||
sfree(lmp, ff_params->tbp[i], "ff:tbp[i]" );
|
||||
sfree(system->error_ptr, ff_params->fbp[i], "ff:fbp[i]" );
|
||||
sfree(system->error_ptr, ff_params->thbp[i], "ff:thbp[i]" );
|
||||
sfree(system->error_ptr, ff_params->hbp[i], "ff:hbp[i]" );
|
||||
sfree(system->error_ptr, ff_params->tbp[i], "ff:tbp[i]" );
|
||||
}
|
||||
sfree(lmp, ff_params->fbp, "ff:fbp" );
|
||||
sfree(lmp, ff_params->thbp, "ff:thbp" );
|
||||
sfree(lmp, ff_params->hbp, "ff:hbp" );
|
||||
sfree(lmp, ff_params->tbp, "ff:tbp" );
|
||||
sfree(lmp, ff_params->sbp, "ff:sbp" );
|
||||
sfree(system->error_ptr, ff_params->fbp, "ff:fbp" );
|
||||
sfree(system->error_ptr, ff_params->thbp, "ff:thbp" );
|
||||
sfree(system->error_ptr, ff_params->hbp, "ff:hbp" );
|
||||
sfree(system->error_ptr, ff_params->tbp, "ff:tbp" );
|
||||
sfree(system->error_ptr, ff_params->sbp, "ff:sbp" );
|
||||
}
|
||||
|
||||
|
||||
/************* workspace *************/
|
||||
void DeAllocate_Workspace( LAMMPS_NS::LAMMPS* lmp, control_params * /*control*/, storage *workspace )
|
||||
void DeAllocate_Workspace( control_params * control, storage *workspace )
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -133,84 +133,84 @@ void DeAllocate_Workspace( LAMMPS_NS::LAMMPS* lmp, control_params * /*control*/,
|
||||
|
||||
/* communication storage */
|
||||
for( i = 0; i < MAX_NBRS; ++i ) {
|
||||
sfree(lmp, workspace->tmp_dbl[i], "tmp_dbl[i]" );
|
||||
sfree(lmp, workspace->tmp_rvec[i], "tmp_rvec[i]" );
|
||||
sfree(lmp, workspace->tmp_rvec2[i], "tmp_rvec2[i]" );
|
||||
sfree(control->error_ptr, workspace->tmp_dbl[i], "tmp_dbl[i]" );
|
||||
sfree(control->error_ptr, workspace->tmp_rvec[i], "tmp_rvec[i]" );
|
||||
sfree(control->error_ptr, workspace->tmp_rvec2[i], "tmp_rvec2[i]" );
|
||||
}
|
||||
|
||||
/* bond order storage */
|
||||
sfree(lmp, workspace->within_bond_box, "skin" );
|
||||
sfree(lmp, workspace->total_bond_order, "total_bo" );
|
||||
sfree(lmp, workspace->Deltap, "Deltap" );
|
||||
sfree(lmp, workspace->Deltap_boc, "Deltap_boc" );
|
||||
sfree(lmp, workspace->dDeltap_self, "dDeltap_self" );
|
||||
sfree(lmp, workspace->Delta, "Delta" );
|
||||
sfree(lmp, workspace->Delta_lp, "Delta_lp" );
|
||||
sfree(lmp, workspace->Delta_lp_temp, "Delta_lp_temp" );
|
||||
sfree(lmp, workspace->dDelta_lp, "dDelta_lp" );
|
||||
sfree(lmp, workspace->dDelta_lp_temp, "dDelta_lp_temp" );
|
||||
sfree(lmp, workspace->Delta_e, "Delta_e" );
|
||||
sfree(lmp, workspace->Delta_boc, "Delta_boc" );
|
||||
sfree(lmp, workspace->Delta_val, "Delta_val" );
|
||||
sfree(lmp, workspace->nlp, "nlp" );
|
||||
sfree(lmp, workspace->nlp_temp, "nlp_temp" );
|
||||
sfree(lmp, workspace->Clp, "Clp" );
|
||||
sfree(lmp, workspace->vlpex, "vlpex" );
|
||||
sfree(lmp, workspace->bond_mark, "bond_mark" );
|
||||
sfree(lmp, workspace->done_after, "done_after" );
|
||||
sfree(control->error_ptr, workspace->within_bond_box, "skin" );
|
||||
sfree(control->error_ptr, workspace->total_bond_order, "total_bo" );
|
||||
sfree(control->error_ptr, workspace->Deltap, "Deltap" );
|
||||
sfree(control->error_ptr, workspace->Deltap_boc, "Deltap_boc" );
|
||||
sfree(control->error_ptr, workspace->dDeltap_self, "dDeltap_self" );
|
||||
sfree(control->error_ptr, workspace->Delta, "Delta" );
|
||||
sfree(control->error_ptr, workspace->Delta_lp, "Delta_lp" );
|
||||
sfree(control->error_ptr, workspace->Delta_lp_temp, "Delta_lp_temp" );
|
||||
sfree(control->error_ptr, workspace->dDelta_lp, "dDelta_lp" );
|
||||
sfree(control->error_ptr, workspace->dDelta_lp_temp, "dDelta_lp_temp" );
|
||||
sfree(control->error_ptr, workspace->Delta_e, "Delta_e" );
|
||||
sfree(control->error_ptr, workspace->Delta_boc, "Delta_boc" );
|
||||
sfree(control->error_ptr, workspace->Delta_val, "Delta_val" );
|
||||
sfree(control->error_ptr, workspace->nlp, "nlp" );
|
||||
sfree(control->error_ptr, workspace->nlp_temp, "nlp_temp" );
|
||||
sfree(control->error_ptr, workspace->Clp, "Clp" );
|
||||
sfree(control->error_ptr, workspace->vlpex, "vlpex" );
|
||||
sfree(control->error_ptr, workspace->bond_mark, "bond_mark" );
|
||||
sfree(control->error_ptr, workspace->done_after, "done_after" );
|
||||
|
||||
/* QEq storage */
|
||||
sfree(lmp, workspace->Hdia_inv, "Hdia_inv" );
|
||||
sfree(lmp, workspace->b_s, "b_s" );
|
||||
sfree(lmp, workspace->b_t, "b_t" );
|
||||
sfree(lmp, workspace->b_prc, "b_prc" );
|
||||
sfree(lmp, workspace->b_prm, "b_prm" );
|
||||
sfree(lmp, workspace->s, "s" );
|
||||
sfree(lmp, workspace->t, "t" );
|
||||
sfree(lmp, workspace->droptol, "droptol" );
|
||||
sfree(lmp, workspace->b, "b" );
|
||||
sfree(lmp, workspace->x, "x" );
|
||||
sfree(control->error_ptr, workspace->Hdia_inv, "Hdia_inv" );
|
||||
sfree(control->error_ptr, workspace->b_s, "b_s" );
|
||||
sfree(control->error_ptr, workspace->b_t, "b_t" );
|
||||
sfree(control->error_ptr, workspace->b_prc, "b_prc" );
|
||||
sfree(control->error_ptr, workspace->b_prm, "b_prm" );
|
||||
sfree(control->error_ptr, workspace->s, "s" );
|
||||
sfree(control->error_ptr, workspace->t, "t" );
|
||||
sfree(control->error_ptr, workspace->droptol, "droptol" );
|
||||
sfree(control->error_ptr, workspace->b, "b" );
|
||||
sfree(control->error_ptr, workspace->x, "x" );
|
||||
|
||||
/* GMRES storage */
|
||||
for( i = 0; i < RESTART+1; ++i ) {
|
||||
sfree(lmp, workspace->h[i], "h[i]" );
|
||||
sfree(lmp, workspace->v[i], "v[i]" );
|
||||
sfree(control->error_ptr, workspace->h[i], "h[i]" );
|
||||
sfree(control->error_ptr, workspace->v[i], "v[i]" );
|
||||
}
|
||||
sfree(lmp, workspace->h, "h" );
|
||||
sfree(lmp, workspace->v, "v" );
|
||||
sfree(lmp, workspace->y, "y" );
|
||||
sfree(lmp, workspace->z, "z" );
|
||||
sfree(lmp, workspace->g, "g" );
|
||||
sfree(lmp, workspace->hs, "hs" );
|
||||
sfree(lmp, workspace->hc, "hc" );
|
||||
sfree(control->error_ptr, workspace->h, "h" );
|
||||
sfree(control->error_ptr, workspace->v, "v" );
|
||||
sfree(control->error_ptr, workspace->y, "y" );
|
||||
sfree(control->error_ptr, workspace->z, "z" );
|
||||
sfree(control->error_ptr, workspace->g, "g" );
|
||||
sfree(control->error_ptr, workspace->hs, "hs" );
|
||||
sfree(control->error_ptr, workspace->hc, "hc" );
|
||||
/* CG storage */
|
||||
sfree(lmp, workspace->r, "r" );
|
||||
sfree(lmp, workspace->d, "d" );
|
||||
sfree(lmp, workspace->q, "q" );
|
||||
sfree(lmp, workspace->p, "p" );
|
||||
sfree(lmp, workspace->r2, "r2" );
|
||||
sfree(lmp, workspace->d2, "d2" );
|
||||
sfree(lmp, workspace->q2, "q2" );
|
||||
sfree(lmp, workspace->p2, "p2" );
|
||||
sfree(control->error_ptr, workspace->r, "r" );
|
||||
sfree(control->error_ptr, workspace->d, "d" );
|
||||
sfree(control->error_ptr, workspace->q, "q" );
|
||||
sfree(control->error_ptr, workspace->p, "p" );
|
||||
sfree(control->error_ptr, workspace->r2, "r2" );
|
||||
sfree(control->error_ptr, workspace->d2, "d2" );
|
||||
sfree(control->error_ptr, workspace->q2, "q2" );
|
||||
sfree(control->error_ptr, workspace->p2, "p2" );
|
||||
|
||||
/* integrator storage */
|
||||
sfree(lmp, workspace->v_const, "v_const" );
|
||||
sfree(control->error_ptr, workspace->v_const, "v_const" );
|
||||
|
||||
/* force related storage */
|
||||
sfree(lmp, workspace->f, "f" );
|
||||
sfree(lmp, workspace->CdDelta, "CdDelta" );
|
||||
sfree(control->error_ptr, workspace->f, "f" );
|
||||
sfree(control->error_ptr, workspace->CdDelta, "CdDelta" );
|
||||
|
||||
/* reductions */
|
||||
#ifdef LMP_USER_OMP
|
||||
if (workspace->CdDeltaReduction) sfree(lmp, workspace->CdDeltaReduction, "cddelta_reduce" );
|
||||
if (workspace->forceReduction) sfree(lmp, workspace->forceReduction, "f_reduce" );
|
||||
if (workspace->valence_angle_atom_myoffset) sfree(lmp, workspace->valence_angle_atom_myoffset, "valence_angle_atom_myoffset");
|
||||
if (workspace->my_ext_pressReduction) sfree(lmp, workspace->my_ext_pressReduction, "ext_press_reduce");
|
||||
if (workspace->CdDeltaReduction) sfree(control->error_ptr, workspace->CdDeltaReduction, "cddelta_reduce" );
|
||||
if (workspace->forceReduction) sfree(control->error_ptr, workspace->forceReduction, "f_reduce" );
|
||||
if (workspace->valence_angle_atom_myoffset) sfree(control->error_ptr, workspace->valence_angle_atom_myoffset, "valence_angle_atom_myoffset");
|
||||
if (workspace->my_ext_pressReduction) sfree(control->error_ptr, workspace->my_ext_pressReduction, "ext_press_reduce");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
int Allocate_Workspace( LAMMPS_NS::LAMMPS* lmp, reax_system * /*system*/, control_params * control,
|
||||
int Allocate_Workspace( reax_system * /*system*/, control_params * control,
|
||||
storage *workspace, int local_cap, int total_cap,
|
||||
MPI_Comm comm, char * /*msg*/ )
|
||||
{
|
||||
@ -224,94 +224,94 @@ int Allocate_Workspace( LAMMPS_NS::LAMMPS* lmp, reax_system * /*system*/, contro
|
||||
/* communication storage */
|
||||
for( i = 0; i < MAX_NBRS; ++i ) {
|
||||
workspace->tmp_dbl[i] = (double*)
|
||||
scalloc(lmp, total_cap, sizeof(double), "tmp_dbl", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(double), "tmp_dbl", comm );
|
||||
workspace->tmp_rvec[i] = (rvec*)
|
||||
scalloc(lmp, total_cap, sizeof(rvec), "tmp_rvec", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(rvec), "tmp_rvec", comm );
|
||||
workspace->tmp_rvec2[i] = (rvec2*)
|
||||
scalloc(lmp, total_cap, sizeof(rvec2), "tmp_rvec2", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(rvec2), "tmp_rvec2", comm );
|
||||
}
|
||||
|
||||
/* bond order related storage */
|
||||
workspace->within_bond_box = (int*)
|
||||
scalloc(lmp, total_cap, sizeof(int), "skin", comm );
|
||||
workspace->total_bond_order = (double*) smalloc(lmp, total_real, "total_bo", comm );
|
||||
workspace->Deltap = (double*) smalloc(lmp, total_real, "Deltap", comm );
|
||||
workspace->Deltap_boc = (double*) smalloc(lmp, total_real, "Deltap_boc", comm );
|
||||
workspace->dDeltap_self = (rvec*) smalloc(lmp, total_rvec, "dDeltap_self", comm );
|
||||
workspace->Delta = (double*) smalloc(lmp, total_real, "Delta", comm );
|
||||
workspace->Delta_lp = (double*) smalloc(lmp, total_real, "Delta_lp", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(int), "skin", comm );
|
||||
workspace->total_bond_order = (double*) smalloc(control->error_ptr, total_real, "total_bo", comm );
|
||||
workspace->Deltap = (double*) smalloc(control->error_ptr, total_real, "Deltap", comm );
|
||||
workspace->Deltap_boc = (double*) smalloc(control->error_ptr, total_real, "Deltap_boc", comm );
|
||||
workspace->dDeltap_self = (rvec*) smalloc(control->error_ptr, total_rvec, "dDeltap_self", comm );
|
||||
workspace->Delta = (double*) smalloc(control->error_ptr, total_real, "Delta", comm );
|
||||
workspace->Delta_lp = (double*) smalloc(control->error_ptr, total_real, "Delta_lp", comm );
|
||||
workspace->Delta_lp_temp = (double*)
|
||||
smalloc(lmp, total_real, "Delta_lp_temp", comm );
|
||||
workspace->dDelta_lp = (double*) smalloc(lmp, total_real, "dDelta_lp", comm );
|
||||
smalloc(control->error_ptr, total_real, "Delta_lp_temp", comm );
|
||||
workspace->dDelta_lp = (double*) smalloc(control->error_ptr, total_real, "dDelta_lp", comm );
|
||||
workspace->dDelta_lp_temp = (double*)
|
||||
smalloc(lmp, total_real, "dDelta_lp_temp", comm );
|
||||
workspace->Delta_e = (double*) smalloc(lmp, total_real, "Delta_e", comm );
|
||||
workspace->Delta_boc = (double*) smalloc(lmp, total_real, "Delta_boc", comm );
|
||||
workspace->Delta_val = (double*) smalloc(lmp, total_real, "Delta_val", comm );
|
||||
workspace->nlp = (double*) smalloc(lmp, total_real, "nlp", comm );
|
||||
workspace->nlp_temp = (double*) smalloc(lmp, total_real, "nlp_temp", comm );
|
||||
workspace->Clp = (double*) smalloc(lmp, total_real, "Clp", comm );
|
||||
workspace->vlpex = (double*) smalloc(lmp, total_real, "vlpex", comm );
|
||||
smalloc(control->error_ptr, total_real, "dDelta_lp_temp", comm );
|
||||
workspace->Delta_e = (double*) smalloc(control->error_ptr, total_real, "Delta_e", comm );
|
||||
workspace->Delta_boc = (double*) smalloc(control->error_ptr, total_real, "Delta_boc", comm );
|
||||
workspace->Delta_val = (double*) smalloc(control->error_ptr, total_real, "Delta_val", comm );
|
||||
workspace->nlp = (double*) smalloc(control->error_ptr, total_real, "nlp", comm );
|
||||
workspace->nlp_temp = (double*) smalloc(control->error_ptr, total_real, "nlp_temp", comm );
|
||||
workspace->Clp = (double*) smalloc(control->error_ptr, total_real, "Clp", comm );
|
||||
workspace->vlpex = (double*) smalloc(control->error_ptr, total_real, "vlpex", comm );
|
||||
workspace->bond_mark = (int*)
|
||||
scalloc(lmp, total_cap, sizeof(int), "bond_mark", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(int), "bond_mark", comm );
|
||||
workspace->done_after = (int*)
|
||||
scalloc(lmp, total_cap, sizeof(int), "done_after", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(int), "done_after", comm );
|
||||
|
||||
/* QEq storage */
|
||||
workspace->Hdia_inv = (double*)
|
||||
scalloc(lmp, total_cap, sizeof(double), "Hdia_inv", comm );
|
||||
workspace->b_s = (double*) scalloc(lmp, total_cap, sizeof(double), "b_s", comm );
|
||||
workspace->b_t = (double*) scalloc(lmp, total_cap, sizeof(double), "b_t", comm );
|
||||
workspace->b_prc = (double*) scalloc(lmp, total_cap, sizeof(double), "b_prc", comm );
|
||||
workspace->b_prm = (double*) scalloc(lmp, total_cap, sizeof(double), "b_prm", comm );
|
||||
workspace->s = (double*) scalloc(lmp, total_cap, sizeof(double), "s", comm );
|
||||
workspace->t = (double*) scalloc(lmp, total_cap, sizeof(double), "t", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(double), "Hdia_inv", comm );
|
||||
workspace->b_s = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_s", comm );
|
||||
workspace->b_t = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_t", comm );
|
||||
workspace->b_prc = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_prc", comm );
|
||||
workspace->b_prm = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "b_prm", comm );
|
||||
workspace->s = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "s", comm );
|
||||
workspace->t = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "t", comm );
|
||||
workspace->droptol = (double*)
|
||||
scalloc(lmp, total_cap, sizeof(double), "droptol", comm );
|
||||
workspace->b = (rvec2*) scalloc(lmp, total_cap, sizeof(rvec2), "b", comm );
|
||||
workspace->x = (rvec2*) scalloc(lmp, total_cap, sizeof(rvec2), "x", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(double), "droptol", comm );
|
||||
workspace->b = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "b", comm );
|
||||
workspace->x = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "x", comm );
|
||||
|
||||
/* GMRES storage */
|
||||
workspace->y = (double*) scalloc(lmp, RESTART+1, sizeof(double), "y", comm );
|
||||
workspace->z = (double*) scalloc(lmp, RESTART+1, sizeof(double), "z", comm );
|
||||
workspace->g = (double*) scalloc(lmp, RESTART+1, sizeof(double), "g", comm );
|
||||
workspace->h = (double**) scalloc(lmp, RESTART+1, sizeof(double*), "h", comm );
|
||||
workspace->hs = (double*) scalloc(lmp, RESTART+1, sizeof(double), "hs", comm );
|
||||
workspace->hc = (double*) scalloc(lmp, RESTART+1, sizeof(double), "hc", comm );
|
||||
workspace->v = (double**) scalloc(lmp, RESTART+1, sizeof(double*), "v", comm );
|
||||
workspace->y = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "y", comm );
|
||||
workspace->z = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "z", comm );
|
||||
workspace->g = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "g", comm );
|
||||
workspace->h = (double**) scalloc(control->error_ptr, RESTART+1, sizeof(double*), "h", comm );
|
||||
workspace->hs = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "hs", comm );
|
||||
workspace->hc = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "hc", comm );
|
||||
workspace->v = (double**) scalloc(control->error_ptr, RESTART+1, sizeof(double*), "v", comm );
|
||||
|
||||
for( i = 0; i < RESTART+1; ++i ) {
|
||||
workspace->h[i] = (double*) scalloc(lmp, RESTART+1, sizeof(double), "h[i]", comm );
|
||||
workspace->v[i] = (double*) scalloc(lmp, total_cap, sizeof(double), "v[i]", comm );
|
||||
workspace->h[i] = (double*) scalloc(control->error_ptr, RESTART+1, sizeof(double), "h[i]", comm );
|
||||
workspace->v[i] = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "v[i]", comm );
|
||||
}
|
||||
|
||||
/* CG storage */
|
||||
workspace->r = (double*) scalloc(lmp, total_cap, sizeof(double), "r", comm );
|
||||
workspace->d = (double*) scalloc(lmp, total_cap, sizeof(double), "d", comm );
|
||||
workspace->q = (double*) scalloc(lmp, total_cap, sizeof(double), "q", comm );
|
||||
workspace->p = (double*) scalloc(lmp, total_cap, sizeof(double), "p", comm );
|
||||
workspace->r2 = (rvec2*) scalloc(lmp, total_cap, sizeof(rvec2), "r2", comm );
|
||||
workspace->d2 = (rvec2*) scalloc(lmp, total_cap, sizeof(rvec2), "d2", comm );
|
||||
workspace->q2 = (rvec2*) scalloc(lmp, total_cap, sizeof(rvec2), "q2", comm );
|
||||
workspace->p2 = (rvec2*) scalloc(lmp, total_cap, sizeof(rvec2), "p2", comm );
|
||||
workspace->r = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "r", comm );
|
||||
workspace->d = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "d", comm );
|
||||
workspace->q = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "q", comm );
|
||||
workspace->p = (double*) scalloc(control->error_ptr, total_cap, sizeof(double), "p", comm );
|
||||
workspace->r2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "r2", comm );
|
||||
workspace->d2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "d2", comm );
|
||||
workspace->q2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "q2", comm );
|
||||
workspace->p2 = (rvec2*) scalloc(control->error_ptr, total_cap, sizeof(rvec2), "p2", comm );
|
||||
|
||||
/* integrator storage */
|
||||
workspace->v_const = (rvec*) smalloc(lmp, local_rvec, "v_const", comm );
|
||||
workspace->v_const = (rvec*) smalloc(control->error_ptr, local_rvec, "v_const", comm );
|
||||
|
||||
/* force related storage */
|
||||
workspace->f = (rvec*) scalloc(lmp, total_cap, sizeof(rvec), "f", comm );
|
||||
workspace->f = (rvec*) scalloc(control->error_ptr, total_cap, sizeof(rvec), "f", comm );
|
||||
workspace->CdDelta = (double*)
|
||||
scalloc(lmp, total_cap, sizeof(double), "CdDelta", comm );
|
||||
scalloc(control->error_ptr, total_cap, sizeof(double), "CdDelta", comm );
|
||||
|
||||
// storage for reductions with multiple threads
|
||||
#ifdef LMP_USER_OMP
|
||||
workspace->CdDeltaReduction = (double *) scalloc(lmp, sizeof(double), total_cap*control->nthreads,
|
||||
workspace->CdDeltaReduction = (double *) scalloc(control->error_ptr, sizeof(double), total_cap*control->nthreads,
|
||||
"cddelta_reduce", comm);
|
||||
|
||||
workspace->forceReduction = (rvec *) scalloc(lmp, sizeof(rvec), total_cap*control->nthreads,
|
||||
workspace->forceReduction = (rvec *) scalloc(control->error_ptr, sizeof(rvec), total_cap*control->nthreads,
|
||||
"forceReduction", comm);
|
||||
|
||||
workspace->valence_angle_atom_myoffset = (int *) scalloc(lmp, sizeof(int), total_cap, "valence_angle_atom_myoffset", comm);
|
||||
workspace->valence_angle_atom_myoffset = (int *) scalloc(control->error_ptr, sizeof(int), total_cap, "valence_angle_atom_myoffset", comm);
|
||||
workspace->my_ext_pressReduction = (rvec *) calloc(sizeof(rvec), control->nthreads);
|
||||
#else
|
||||
LMP_UNUSED_PARAM(control);
|
||||
@ -321,17 +321,17 @@ int Allocate_Workspace( LAMMPS_NS::LAMMPS* lmp, reax_system * /*system*/, contro
|
||||
}
|
||||
|
||||
|
||||
static void Reallocate_Neighbor_List( LAMMPS* lmp, reax_list *far_nbrs, int n,
|
||||
static void Reallocate_Neighbor_List( reax_list *far_nbrs, int n,
|
||||
int num_intrs, MPI_Comm comm )
|
||||
{
|
||||
Delete_List( lmp, far_nbrs, comm );
|
||||
if(!Make_List( lmp, n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs, comm )){
|
||||
lmp->error->one(FLERR,"Problem in initializing far neighbors list");
|
||||
Delete_List( far_nbrs, comm );
|
||||
if(!Make_List( n, num_intrs, TYP_FAR_NEIGHBOR, far_nbrs, comm )){
|
||||
far_nbrs->error_ptr->one(FLERR,"Problem in initializing far neighbors list");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static int Reallocate_HBonds_List( LAMMPS *lmp, reax_system *system, reax_list *hbonds,
|
||||
static int Reallocate_HBonds_List( reax_system *system, reax_list *hbonds,
|
||||
MPI_Comm comm )
|
||||
{
|
||||
int i, total_hbonds;
|
||||
@ -346,16 +346,16 @@ static int Reallocate_HBonds_List( LAMMPS *lmp, reax_system *system, reax_list *
|
||||
}
|
||||
total_hbonds = (int)(MAX( total_hbonds*saferzone, mincap*MIN_HBONDS ));
|
||||
|
||||
Delete_List( lmp, hbonds, comm );
|
||||
if (!Make_List( lmp, system->Hcap, total_hbonds, TYP_HBOND, hbonds, comm )) {
|
||||
lmp->error->one(FLERR, "Not enough space for hydrogen bonds list");
|
||||
Delete_List( hbonds, comm );
|
||||
if (!Make_List( system->Hcap, total_hbonds, TYP_HBOND, hbonds, comm )) {
|
||||
hbonds->error_ptr->one(FLERR, "Not enough space for hydrogen bonds list");
|
||||
}
|
||||
|
||||
return total_hbonds;
|
||||
}
|
||||
|
||||
|
||||
static int Reallocate_Bonds_List( LAMMPS *lmp, reax_system *system, reax_list *bonds,
|
||||
static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds,
|
||||
int *total_bonds, int *est_3body,
|
||||
MPI_Comm comm )
|
||||
{
|
||||
@ -375,12 +375,12 @@ static int Reallocate_Bonds_List( LAMMPS *lmp, reax_system *system, reax_list *b
|
||||
#ifdef LMP_USER_OMP
|
||||
if (system->omp_active)
|
||||
for (i = 0; i < bonds->num_intrs; ++i)
|
||||
sfree(lmp, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction");
|
||||
sfree(system->error_ptr, bonds->select.bond_list[i].bo_data.CdboReduction, "CdboReduction");
|
||||
#endif
|
||||
|
||||
Delete_List( lmp, bonds, comm );
|
||||
if(!Make_List(lmp, system->total_cap, *total_bonds, TYP_BOND, bonds, comm)) {
|
||||
lmp->error->one(FLERR, "Not enough space for bonds list");
|
||||
Delete_List( bonds, comm );
|
||||
if(!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds, comm)) {
|
||||
bonds->error_ptr->one(FLERR, "Not enough space for bonds list");
|
||||
}
|
||||
|
||||
#ifdef LMP_USER_OMP
|
||||
@ -393,14 +393,14 @@ static int Reallocate_Bonds_List( LAMMPS *lmp, reax_system *system, reax_list *b
|
||||
if (system->omp_active)
|
||||
for (i = 0; i < bonds->num_intrs; ++i)
|
||||
bonds->select.bond_list[i].bo_data.CdboReduction =
|
||||
(double*) smalloc(lmp, sizeof(double)*nthreads, "CdboReduction", comm);
|
||||
(double*) smalloc(system->error_ptr, sizeof(double)*nthreads, "CdboReduction", comm);
|
||||
#endif
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void ReAllocate( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
void ReAllocate( reax_system *system, control_params *control,
|
||||
simulation_data *data, storage *workspace, reax_list **lists,
|
||||
mpi_datatypes *mpi_data )
|
||||
{
|
||||
@ -436,17 +436,17 @@ void ReAllocate( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
if (ret != SUCCESS) {
|
||||
char errmsg[128];
|
||||
snprintf(errmsg, 128, "Not enough space for atom_list: total_cap=%d", system->total_cap);
|
||||
lmp->error->one(FLERR, errmsg);
|
||||
system->error_ptr->one(FLERR, errmsg);
|
||||
}
|
||||
|
||||
/* workspace */
|
||||
DeAllocate_Workspace( lmp, control, workspace );
|
||||
ret = Allocate_Workspace( lmp, system, control, workspace, system->local_cap,
|
||||
DeAllocate_Workspace( control, workspace );
|
||||
ret = Allocate_Workspace( system, control, workspace, system->local_cap,
|
||||
system->total_cap, comm, msg );
|
||||
if (ret != SUCCESS) {
|
||||
char errmsg[128];
|
||||
snprintf(errmsg, 128, "Not enough space for workspace: local_cap=%d total_cap=%d", system->local_cap, system->total_cap);
|
||||
lmp->error->one(FLERR, errmsg);
|
||||
system->error_ptr->one(FLERR, errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,13 +460,13 @@ void ReAllocate( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
if (realloc->num_far > far_nbrs->num_intrs) {
|
||||
char errmsg[128];
|
||||
snprintf(errmsg, 128, "step%d-ran out of space on far_nbrs: top=%d, max=%d", data->step, realloc->num_far, far_nbrs->num_intrs);
|
||||
lmp->error->one(FLERR, errmsg);
|
||||
system->error_ptr->one(FLERR, errmsg);
|
||||
}
|
||||
|
||||
newsize = static_cast<int>
|
||||
(MAX( realloc->num_far*safezone, mincap*MIN_NBRS ));
|
||||
|
||||
Reallocate_Neighbor_List( lmp, far_nbrs, system->total_cap, newsize, comm );
|
||||
Reallocate_Neighbor_List( far_nbrs, system->total_cap, newsize, comm );
|
||||
realloc->num_far = 0;
|
||||
}
|
||||
}
|
||||
@ -481,7 +481,7 @@ void ReAllocate( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
}
|
||||
|
||||
if (Hflag || realloc->hbonds) {
|
||||
ret = Reallocate_HBonds_List( lmp, system, (*lists)+HBONDS, comm );
|
||||
ret = Reallocate_HBonds_List( system, (*lists)+HBONDS, comm );
|
||||
realloc->hbonds = 0;
|
||||
}
|
||||
}
|
||||
@ -489,7 +489,7 @@ void ReAllocate( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
/* bonds list */
|
||||
num_bonds = est_3body = -1;
|
||||
if (Nflag || realloc->bonds) {
|
||||
Reallocate_Bonds_List( lmp, system, (*lists)+BONDS, &num_bonds,
|
||||
Reallocate_Bonds_List( system, (*lists)+BONDS, &num_bonds,
|
||||
&est_3body, comm );
|
||||
realloc->bonds = 0;
|
||||
realloc->num_3body = MAX( realloc->num_3body, est_3body ) * 2;
|
||||
@ -497,16 +497,16 @@ void ReAllocate( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
|
||||
/* 3-body list */
|
||||
if (realloc->num_3body > 0) {
|
||||
Delete_List( lmp, (*lists)+THREE_BODIES, comm );
|
||||
Delete_List( (*lists)+THREE_BODIES, comm );
|
||||
|
||||
if (num_bonds == -1)
|
||||
num_bonds = ((*lists)+BONDS)->num_intrs;
|
||||
|
||||
realloc->num_3body = (int)(MAX(realloc->num_3body*safezone, MIN_3BODIES));
|
||||
|
||||
if( !Make_List( lmp, num_bonds, realloc->num_3body, TYP_THREE_BODY,
|
||||
if( !Make_List( num_bonds, realloc->num_3body, TYP_THREE_BODY,
|
||||
(*lists)+THREE_BODIES, comm ) ) {
|
||||
lmp->error->one(FLERR, "Problem in initializing angles list");
|
||||
system->error_ptr->one(FLERR, "Problem in initializing angles list");
|
||||
}
|
||||
realloc->num_3body = -1;
|
||||
}
|
||||
|
||||
@ -33,15 +33,15 @@
|
||||
#include "error.h"
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
int PreAllocate_Space( LAMMPS_NS::LAMMPS*, reax_system*, control_params*, storage*, MPI_Comm );
|
||||
int PreAllocate_Space( reax_system*, control_params*, storage*, MPI_Comm );
|
||||
|
||||
int Allocate_System( reax_system*, int, int, char* );
|
||||
void DeAllocate_System( LAMMPS_NS::LAMMPS*, reax_system* );
|
||||
void DeAllocate_System( reax_system* );
|
||||
|
||||
int Allocate_Workspace( LAMMPS_NS::LAMMPS*, reax_system*, control_params*, storage*,
|
||||
int Allocate_Workspace( reax_system*, control_params*, storage*,
|
||||
int, int, MPI_Comm, char* );
|
||||
void DeAllocate_Workspace( LAMMPS_NS::LAMMPS*, control_params*, storage* );
|
||||
void DeAllocate_Workspace( control_params*, storage* );
|
||||
|
||||
void ReAllocate( LAMMPS *lmp, reax_system*, control_params*, simulation_data*, storage*,
|
||||
void ReAllocate( reax_system*, control_params*, simulation_data*, storage*,
|
||||
reax_list**, mpi_datatypes* );
|
||||
#endif
|
||||
|
||||
@ -99,54 +99,54 @@ char Read_Force_Field( LAMMPS_NS::LAMMPS* lmp, FILE *fp, reax_interaction *reax,
|
||||
|
||||
/* Allocating structures in reax_interaction */
|
||||
reax->sbp = (single_body_parameters*)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(single_body_parameters), "sbp",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(single_body_parameters), "sbp",
|
||||
comm );
|
||||
reax->tbp = (two_body_parameters**)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(two_body_parameters*), "tbp", comm );
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(two_body_parameters*), "tbp", comm );
|
||||
reax->thbp= (three_body_header***)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(three_body_header**), "thbp", comm );
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(three_body_header**), "thbp", comm );
|
||||
reax->hbp = (hbond_parameters***)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(hbond_parameters**), "hbp", comm );
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(hbond_parameters**), "hbp", comm );
|
||||
reax->fbp = (four_body_header****)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(four_body_header***), "fbp", comm );
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(four_body_header***), "fbp", comm );
|
||||
tor_flag = (char****)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(char***), "tor_flag", comm );
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(char***), "tor_flag", comm );
|
||||
|
||||
for( i = 0; i < reax->num_atom_types; i++ ) {
|
||||
reax->tbp[i] = (two_body_parameters*)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(two_body_parameters), "tbp[i]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(two_body_parameters), "tbp[i]",
|
||||
comm );
|
||||
reax->thbp[i]= (three_body_header**)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(three_body_header*), "thbp[i]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(three_body_header*), "thbp[i]",
|
||||
comm );
|
||||
reax->hbp[i] = (hbond_parameters**)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(hbond_parameters*), "hbp[i]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(hbond_parameters*), "hbp[i]",
|
||||
comm );
|
||||
reax->fbp[i] = (four_body_header***)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(four_body_header**), "fbp[i]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(four_body_header**), "fbp[i]",
|
||||
comm );
|
||||
tor_flag[i] = (char***)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(char**), "tor_flag[i]", comm );
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(char**), "tor_flag[i]", comm );
|
||||
|
||||
for( j = 0; j < reax->num_atom_types; j++ ) {
|
||||
reax->thbp[i][j]= (three_body_header*)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(three_body_header), "thbp[i,j]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(three_body_header), "thbp[i,j]",
|
||||
comm );
|
||||
reax->hbp[i][j] = (hbond_parameters*)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(hbond_parameters), "hbp[i,j]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(hbond_parameters), "hbp[i,j]",
|
||||
comm );
|
||||
reax->fbp[i][j] = (four_body_header**)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(four_body_header*), "fbp[i,j]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(four_body_header*), "fbp[i,j]",
|
||||
comm );
|
||||
tor_flag[i][j] = (char**)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(char*), "tor_flag[i,j]", comm );
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(char*), "tor_flag[i,j]", comm );
|
||||
|
||||
for (k=0; k < reax->num_atom_types; k++) {
|
||||
reax->fbp[i][j][k] = (four_body_header*)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(four_body_header), "fbp[i,j,k]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(four_body_header), "fbp[i,j,k]",
|
||||
comm );
|
||||
tor_flag[i][j][k] = (char*)
|
||||
scalloc(lmp, reax->num_atom_types, sizeof(char), "tor_flag[i,j,k]",
|
||||
scalloc(lmp->error, reax->num_atom_types, sizeof(char), "tor_flag[i,j,k]",
|
||||
comm );
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +127,7 @@ int Init_Workspace( LAMMPS_NS::LAMMPS* lmp, reax_system *system, control_params
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = Allocate_Workspace( lmp, system, control, workspace,
|
||||
ret = Allocate_Workspace( system, control, workspace,
|
||||
system->local_cap, system->total_cap, comm, msg );
|
||||
if (ret != SUCCESS)
|
||||
return ret;
|
||||
@ -181,10 +181,11 @@ int Init_Lists( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
}
|
||||
total_hbonds = (int)(MAX( total_hbonds*saferzone, mincap*MIN_HBONDS ));
|
||||
|
||||
if( !Make_List( lmp, system->Hcap, total_hbonds, TYP_HBOND,
|
||||
if( !Make_List( system->Hcap, total_hbonds, TYP_HBOND,
|
||||
*lists+HBONDS, comm ) ) {
|
||||
lmp->error->one(FLERR, "Not enough space for hbonds list.");
|
||||
}
|
||||
(*lists+HBONDS)->error_ptr = system->error_ptr;
|
||||
}
|
||||
|
||||
total_bonds = 0;
|
||||
@ -194,17 +195,19 @@ int Init_Lists( LAMMPS *lmp, reax_system *system, control_params *control,
|
||||
}
|
||||
bond_cap = (int)(MAX( total_bonds*safezone, mincap*MIN_BONDS ));
|
||||
|
||||
if( !Make_List( lmp, system->total_cap, bond_cap, TYP_BOND,
|
||||
if( !Make_List( system->total_cap, bond_cap, TYP_BOND,
|
||||
*lists+BONDS, comm ) ) {
|
||||
lmp->error->one(FLERR, "Not enough space for bonds list.");
|
||||
}
|
||||
(*lists+BONDS)->error_ptr = system->error_ptr;
|
||||
|
||||
/* 3bodies list */
|
||||
cap_3body = (int)(MAX( num_3body*safezone, MIN_3BODIES ));
|
||||
if( !Make_List( lmp, bond_cap, cap_3body, TYP_THREE_BODY,
|
||||
if( !Make_List( bond_cap, cap_3body, TYP_THREE_BODY,
|
||||
*lists+THREE_BODIES, comm ) ){
|
||||
lmp->error->one(FLERR,"Problem in initializing angles list.");
|
||||
}
|
||||
(*lists+THREE_BODIES)->error_ptr = system->error_ptr;
|
||||
|
||||
free( hb_top );
|
||||
free( bond_top );
|
||||
|
||||
@ -29,118 +29,118 @@
|
||||
#include "reaxc_tool_box.h"
|
||||
|
||||
/************* allocate list space ******************/
|
||||
int Make_List( LAMMPS_NS::LAMMPS *lmp, int n, int num_intrs, int type, reax_list *l, MPI_Comm comm)
|
||||
int Make_List( int n, int num_intrs, int type, reax_list *l, MPI_Comm comm)
|
||||
{
|
||||
l->allocated = 1;
|
||||
|
||||
l->n = n;
|
||||
l->num_intrs = num_intrs;
|
||||
|
||||
if (l->index) sfree(lmp, l->index, "list:index");
|
||||
if (l->end_index) sfree(lmp, l->end_index, "list:end_index");
|
||||
l->index = (int*) smalloc(lmp, n * sizeof(int), "list:index", comm );
|
||||
l->end_index = (int*) smalloc(lmp, n * sizeof(int), "list:end_index", comm );
|
||||
if (l->index) sfree(l->error_ptr, l->index, "list:index");
|
||||
if (l->end_index) sfree(l->error_ptr, l->end_index, "list:end_index");
|
||||
l->index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:index", comm );
|
||||
l->end_index = (int*) smalloc(l->error_ptr, n * sizeof(int), "list:end_index", comm );
|
||||
|
||||
l->type = type;
|
||||
|
||||
switch(l->type) {
|
||||
case TYP_VOID:
|
||||
if (l->select.v) sfree(lmp, l->select.v, "list:v");
|
||||
l->select.v = (void*) smalloc(lmp, l->num_intrs * sizeof(void*), "list:v", comm);
|
||||
if (l->select.v) sfree(l->error_ptr, l->select.v, "list:v");
|
||||
l->select.v = (void*) smalloc(l->error_ptr, l->num_intrs * sizeof(void*), "list:v", comm);
|
||||
break;
|
||||
|
||||
case TYP_THREE_BODY:
|
||||
if (l->select.three_body_list) sfree(lmp, l->select.three_body_list,"list:three_bodies");
|
||||
if (l->select.three_body_list) sfree(l->error_ptr, l->select.three_body_list,"list:three_bodies");
|
||||
l->select.three_body_list = (three_body_interaction_data*)
|
||||
smalloc(lmp, l->num_intrs * sizeof(three_body_interaction_data),
|
||||
smalloc(l->error_ptr, l->num_intrs * sizeof(three_body_interaction_data),
|
||||
"list:three_bodies", comm );
|
||||
break;
|
||||
|
||||
case TYP_BOND:
|
||||
if (l->select.bond_list) sfree(lmp, l->select.bond_list,"list:bonds");
|
||||
if (l->select.bond_list) sfree(l->error_ptr, l->select.bond_list,"list:bonds");
|
||||
l->select.bond_list = (bond_data*)
|
||||
smalloc(lmp, l->num_intrs * sizeof(bond_data), "list:bonds", comm );
|
||||
smalloc(l->error_ptr, l->num_intrs * sizeof(bond_data), "list:bonds", comm );
|
||||
break;
|
||||
|
||||
case TYP_DBO:
|
||||
if (l->select.dbo_list) sfree(lmp, l->select.dbo_list,"list:dbonds");
|
||||
if (l->select.dbo_list) sfree(l->error_ptr, l->select.dbo_list,"list:dbonds");
|
||||
l->select.dbo_list = (dbond_data*)
|
||||
smalloc(lmp, l->num_intrs * sizeof(dbond_data), "list:dbonds", comm );
|
||||
smalloc(l->error_ptr, l->num_intrs * sizeof(dbond_data), "list:dbonds", comm );
|
||||
break;
|
||||
|
||||
case TYP_DDELTA:
|
||||
if (l->select.dDelta_list) sfree(lmp, l->select.dDelta_list,"list:dDeltas");
|
||||
if (l->select.dDelta_list) sfree(l->error_ptr, l->select.dDelta_list,"list:dDeltas");
|
||||
l->select.dDelta_list = (dDelta_data*)
|
||||
smalloc(lmp, l->num_intrs * sizeof(dDelta_data), "list:dDeltas", comm );
|
||||
smalloc(l->error_ptr, l->num_intrs * sizeof(dDelta_data), "list:dDeltas", comm );
|
||||
break;
|
||||
|
||||
case TYP_FAR_NEIGHBOR:
|
||||
if (l->select.far_nbr_list) sfree(lmp, l->select.far_nbr_list,"list:far_nbrs");
|
||||
if (l->select.far_nbr_list) sfree(l->error_ptr, l->select.far_nbr_list,"list:far_nbrs");
|
||||
l->select.far_nbr_list = (far_neighbor_data*)
|
||||
smalloc(lmp, l->num_intrs * sizeof(far_neighbor_data), "list:far_nbrs", comm);
|
||||
smalloc(l->error_ptr, l->num_intrs * sizeof(far_neighbor_data), "list:far_nbrs", comm);
|
||||
break;
|
||||
|
||||
case TYP_HBOND:
|
||||
if (l->select.hbond_list) sfree(lmp, l->select.hbond_list,"list:hbonds");
|
||||
if (l->select.hbond_list) sfree(l->error_ptr, l->select.hbond_list,"list:hbonds");
|
||||
l->select.hbond_list = (hbond_data*)
|
||||
smalloc(lmp, l->num_intrs * sizeof(hbond_data), "list:hbonds", comm );
|
||||
smalloc(l->error_ptr, l->num_intrs * sizeof(hbond_data), "list:hbonds", comm );
|
||||
break;
|
||||
|
||||
default:
|
||||
char errmsg[128];
|
||||
snprintf(errmsg, 128, "No %d list type defined", l->type);
|
||||
lmp->error->all(FLERR,errmsg);
|
||||
l->error_ptr->all(FLERR,errmsg);
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
void Delete_List( LAMMPS_NS::LAMMPS *lmp, reax_list *l, MPI_Comm comm )
|
||||
void Delete_List( reax_list *l, MPI_Comm comm )
|
||||
{
|
||||
if (l->allocated == 0)
|
||||
return;
|
||||
l->allocated = 0;
|
||||
|
||||
sfree(lmp, l->index, "list:index" );
|
||||
sfree(lmp, l->end_index, "list:end_index" );
|
||||
sfree(l->error_ptr, l->index, "list:index" );
|
||||
sfree(l->error_ptr, l->end_index, "list:end_index" );
|
||||
l->index = NULL;
|
||||
l->end_index = NULL;
|
||||
|
||||
switch(l->type) {
|
||||
case TYP_VOID:
|
||||
sfree(lmp, l->select.v, "list:v" );
|
||||
sfree(l->error_ptr, l->select.v, "list:v" );
|
||||
l->select.v = NULL;
|
||||
break;
|
||||
case TYP_HBOND:
|
||||
sfree(lmp, l->select.hbond_list, "list:hbonds" );
|
||||
sfree(l->error_ptr, l->select.hbond_list, "list:hbonds" );
|
||||
l->select.hbond_list = NULL;
|
||||
break;
|
||||
case TYP_FAR_NEIGHBOR:
|
||||
sfree(lmp, l->select.far_nbr_list, "list:far_nbrs" );
|
||||
sfree(l->error_ptr, l->select.far_nbr_list, "list:far_nbrs" );
|
||||
l->select.far_nbr_list = NULL;
|
||||
break;
|
||||
case TYP_BOND:
|
||||
sfree(lmp, l->select.bond_list, "list:bonds" );
|
||||
sfree(l->error_ptr, l->select.bond_list, "list:bonds" );
|
||||
l->select.bond_list = NULL;
|
||||
break;
|
||||
case TYP_DBO:
|
||||
sfree(lmp, l->select.dbo_list, "list:dbos" );
|
||||
sfree(l->error_ptr, l->select.dbo_list, "list:dbos" );
|
||||
l->select.dbo_list = NULL;
|
||||
break;
|
||||
case TYP_DDELTA:
|
||||
sfree(lmp, l->select.dDelta_list, "list:dDeltas" );
|
||||
sfree(l->error_ptr, l->select.dDelta_list, "list:dDeltas" );
|
||||
l->select.dDelta_list = NULL;
|
||||
break;
|
||||
case TYP_THREE_BODY:
|
||||
sfree(lmp, l->select.three_body_list, "list:three_bodies" );
|
||||
sfree(l->error_ptr, l->select.three_body_list, "list:three_bodies" );
|
||||
l->select.three_body_list = NULL;
|
||||
break;
|
||||
|
||||
default:
|
||||
char errmsg[128];
|
||||
snprintf(errmsg, 128, "No %d list type defined", l->type);
|
||||
lmp->error->all(FLERR,errmsg);
|
||||
l->error_ptr->all(FLERR,errmsg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -29,8 +29,8 @@
|
||||
|
||||
#include "reaxc_types.h"
|
||||
|
||||
int Make_List( LAMMPS_NS::LAMMPS*, int, int, int, reax_list*, MPI_Comm );
|
||||
void Delete_List( LAMMPS_NS::LAMMPS*, reax_list*, MPI_Comm );
|
||||
int Make_List( int, int, int, reax_list*, MPI_Comm );
|
||||
void Delete_List( reax_list*, MPI_Comm );
|
||||
|
||||
inline int Num_Entries(int,reax_list*);
|
||||
inline int Start_Index( int, reax_list* );
|
||||
|
||||
@ -58,11 +58,11 @@ void Natural_Cubic_Spline( LAMMPS_NS::LAMMPS* lmp, const double *h, const double
|
||||
double *a, *b, *c, *d, *v;
|
||||
|
||||
/* allocate space for the linear system */
|
||||
a = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
b = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
c = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
d = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
v = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
a = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
b = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
c = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
d = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
v = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
|
||||
/* build the linear system */
|
||||
a[0] = a[1] = a[n-1] = 0;
|
||||
@ -92,11 +92,11 @@ void Natural_Cubic_Spline( LAMMPS_NS::LAMMPS* lmp, const double *h, const double
|
||||
coef[i-1].a = f[i];
|
||||
}
|
||||
|
||||
sfree(lmp, a, "cubic_spline:a" );
|
||||
sfree(lmp, b, "cubic_spline:b" );
|
||||
sfree(lmp, c, "cubic_spline:c" );
|
||||
sfree(lmp, d, "cubic_spline:d" );
|
||||
sfree(lmp, v, "cubic_spline:v" );
|
||||
sfree(lmp->error, a, "cubic_spline:a" );
|
||||
sfree(lmp->error, b, "cubic_spline:b" );
|
||||
sfree(lmp->error, c, "cubic_spline:c" );
|
||||
sfree(lmp->error, d, "cubic_spline:d" );
|
||||
sfree(lmp->error, v, "cubic_spline:v" );
|
||||
}
|
||||
|
||||
|
||||
@ -109,11 +109,11 @@ void Complete_Cubic_Spline( LAMMPS_NS::LAMMPS* lmp, const double *h, const doubl
|
||||
double *a, *b, *c, *d, *v;
|
||||
|
||||
/* allocate space for the linear system */
|
||||
a = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
b = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
c = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
d = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
v = (double*) smalloc(lmp, n * sizeof(double), "cubic_spline:a", comm );
|
||||
a = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
b = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
c = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
d = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
v = (double*) smalloc(lmp->error, n * sizeof(double), "cubic_spline:a", comm );
|
||||
|
||||
/* build the linear system */
|
||||
a[0] = 0;
|
||||
@ -142,11 +142,11 @@ void Complete_Cubic_Spline( LAMMPS_NS::LAMMPS* lmp, const double *h, const doubl
|
||||
coef[i-1].a = f[i];
|
||||
}
|
||||
|
||||
sfree(lmp, a, "cubic_spline:a" );
|
||||
sfree(lmp, b, "cubic_spline:b" );
|
||||
sfree(lmp, c, "cubic_spline:c" );
|
||||
sfree(lmp, d, "cubic_spline:d" );
|
||||
sfree(lmp, v, "cubic_spline:v" );
|
||||
sfree(lmp->error, a, "cubic_spline:a" );
|
||||
sfree(lmp->error, b, "cubic_spline:b" );
|
||||
sfree(lmp->error, c, "cubic_spline:c" );
|
||||
sfree(lmp->error, d, "cubic_spline:d" );
|
||||
sfree(lmp->error, v, "cubic_spline:v" );
|
||||
}
|
||||
|
||||
|
||||
@ -171,23 +171,23 @@ int Init_Lookup_Tables( LAMMPS_NS::LAMMPS* lmp, reax_system *system, control_par
|
||||
num_atom_types = system->reax_param.num_atom_types;
|
||||
dr = control->nonb_cut / control->tabulate;
|
||||
h = (double*)
|
||||
smalloc(lmp, (control->tabulate+2) * sizeof(double), "lookup:h", comm );
|
||||
smalloc(lmp->error, (control->tabulate+2) * sizeof(double), "lookup:h", comm );
|
||||
fh = (double*)
|
||||
smalloc(lmp, (control->tabulate+2) * sizeof(double), "lookup:fh", comm );
|
||||
smalloc(lmp->error, (control->tabulate+2) * sizeof(double), "lookup:fh", comm );
|
||||
fvdw = (double*)
|
||||
smalloc(lmp, (control->tabulate+2) * sizeof(double), "lookup:fvdw", comm );
|
||||
smalloc(lmp->error, (control->tabulate+2) * sizeof(double), "lookup:fvdw", comm );
|
||||
fCEvd = (double*)
|
||||
smalloc(lmp, (control->tabulate+2) * sizeof(double), "lookup:fCEvd", comm );
|
||||
smalloc(lmp->error, (control->tabulate+2) * sizeof(double), "lookup:fCEvd", comm );
|
||||
fele = (double*)
|
||||
smalloc(lmp, (control->tabulate+2) * sizeof(double), "lookup:fele", comm );
|
||||
smalloc(lmp->error, (control->tabulate+2) * sizeof(double), "lookup:fele", comm );
|
||||
fCEclmb = (double*)
|
||||
smalloc(lmp, (control->tabulate+2) * sizeof(double), "lookup:fCEclmb", comm );
|
||||
smalloc(lmp->error, (control->tabulate+2) * sizeof(double), "lookup:fCEclmb", comm );
|
||||
|
||||
LR = (LR_lookup_table**)
|
||||
scalloc(lmp, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR", comm );
|
||||
scalloc(lmp->error, num_atom_types, sizeof(LR_lookup_table*), "lookup:LR", comm );
|
||||
for( i = 0; i < num_atom_types; ++i )
|
||||
LR[i] = (LR_lookup_table*)
|
||||
scalloc(lmp, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]", comm );
|
||||
scalloc(lmp->error, num_atom_types, sizeof(LR_lookup_table), "lookup:LR[i]", comm );
|
||||
|
||||
for( i = 0; i < MAX_ATOM_TYPES; ++i )
|
||||
existing_types[i] = 0;
|
||||
@ -207,21 +207,21 @@ int Init_Lookup_Tables( LAMMPS_NS::LAMMPS* lmp, reax_system *system, control_par
|
||||
LR[i][j].dx = dr;
|
||||
LR[i][j].inv_dx = control->tabulate / control->nonb_cut;
|
||||
LR[i][j].y = (LR_data*)
|
||||
smalloc(lmp, LR[i][j].n * sizeof(LR_data), "lookup:LR[i,j].y", comm );
|
||||
smalloc(lmp->error, LR[i][j].n * sizeof(LR_data), "lookup:LR[i,j].y", comm );
|
||||
LR[i][j].H = (cubic_spline_coef*)
|
||||
smalloc(lmp, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].H" ,
|
||||
smalloc(lmp->error, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].H" ,
|
||||
comm );
|
||||
LR[i][j].vdW = (cubic_spline_coef*)
|
||||
smalloc(lmp, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].vdW",
|
||||
smalloc(lmp->error, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].vdW",
|
||||
comm);
|
||||
LR[i][j].CEvd = (cubic_spline_coef*)
|
||||
smalloc(lmp, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].CEvd",
|
||||
smalloc(lmp->error, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].CEvd",
|
||||
comm);
|
||||
LR[i][j].ele = (cubic_spline_coef*)
|
||||
smalloc(lmp, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].ele",
|
||||
smalloc(lmp->error, LR[i][j].n*sizeof(cubic_spline_coef),"lookup:LR[i,j].ele",
|
||||
comm );
|
||||
LR[i][j].CEclmb = (cubic_spline_coef*)
|
||||
smalloc(lmp, LR[i][j].n*sizeof(cubic_spline_coef),
|
||||
smalloc(lmp->error, LR[i][j].n*sizeof(cubic_spline_coef),
|
||||
"lookup:LR[i,j].CEclmb", comm );
|
||||
|
||||
for( r = 1; r <= control->tabulate; ++r ) {
|
||||
@ -291,14 +291,14 @@ void Deallocate_Lookup_Tables( LAMMPS_NS::LAMMPS* lmp, reax_system *system )
|
||||
for( i = 0; i < ntypes; ++i ) {
|
||||
for( j = i; j < ntypes; ++j )
|
||||
if (LR[i][j].n) {
|
||||
sfree(lmp, LR[i][j].y, "LR[i,j].y" );
|
||||
sfree(lmp, LR[i][j].H, "LR[i,j].H" );
|
||||
sfree(lmp, LR[i][j].vdW, "LR[i,j].vdW" );
|
||||
sfree(lmp, LR[i][j].CEvd, "LR[i,j].CEvd" );
|
||||
sfree(lmp, LR[i][j].ele, "LR[i,j].ele" );
|
||||
sfree(lmp, LR[i][j].CEclmb, "LR[i,j].CEclmb" );
|
||||
sfree(lmp->error, LR[i][j].y, "LR[i,j].y" );
|
||||
sfree(lmp->error, LR[i][j].H, "LR[i,j].H" );
|
||||
sfree(lmp->error, LR[i][j].vdW, "LR[i,j].vdW" );
|
||||
sfree(lmp->error, LR[i][j].CEvd, "LR[i,j].CEvd" );
|
||||
sfree(lmp->error, LR[i][j].ele, "LR[i,j].ele" );
|
||||
sfree(lmp->error, LR[i][j].CEclmb, "LR[i,j].CEclmb" );
|
||||
}
|
||||
sfree(lmp, LR[i], "LR[i]" );
|
||||
sfree(lmp->error, LR[i], "LR[i]" );
|
||||
}
|
||||
sfree(lmp, LR, "LR" );
|
||||
sfree(lmp->error, LR, "LR" );
|
||||
}
|
||||
|
||||
@ -56,7 +56,7 @@ int Tokenize( char* s, char*** tok )
|
||||
|
||||
|
||||
/* safe malloc */
|
||||
void *smalloc( LAMMPS_NS::LAMMPS *lmp, rc_bigint n, const char *name, MPI_Comm comm )
|
||||
void *smalloc( LAMMPS_NS::Error *error_ptr, rc_bigint n, const char *name, MPI_Comm comm )
|
||||
{
|
||||
void *ptr;
|
||||
char errmsg[256];
|
||||
@ -64,14 +64,14 @@ void *smalloc( LAMMPS_NS::LAMMPS *lmp, rc_bigint n, const char *name, MPI_Comm c
|
||||
if (n <= 0) {
|
||||
snprintf(errmsg, 256, "Trying to allocate %ld bytes for array %s. "
|
||||
"returning NULL.", n, name);
|
||||
lmp->error->warning(FLERR,errmsg);
|
||||
error_ptr->warning(FLERR,errmsg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ptr = malloc( n );
|
||||
if (ptr == NULL) {
|
||||
snprintf(errmsg, 256, "Failed to allocate %ld bytes for array %s", n, name);
|
||||
lmp->error->one(FLERR,errmsg);
|
||||
error_ptr->one(FLERR,errmsg);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
@ -79,7 +79,7 @@ void *smalloc( LAMMPS_NS::LAMMPS *lmp, rc_bigint n, const char *name, MPI_Comm c
|
||||
|
||||
|
||||
/* safe calloc */
|
||||
void *scalloc( LAMMPS_NS::LAMMPS *lmp, rc_bigint n, rc_bigint size, const char *name, MPI_Comm comm )
|
||||
void *scalloc( LAMMPS_NS::Error *error_ptr, rc_bigint n, rc_bigint size, const char *name, MPI_Comm comm )
|
||||
{
|
||||
void *ptr;
|
||||
char errmsg[256];
|
||||
@ -87,14 +87,14 @@ void *scalloc( LAMMPS_NS::LAMMPS *lmp, rc_bigint n, rc_bigint size, const char *
|
||||
if (n <= 0) {
|
||||
snprintf(errmsg, 256, "Trying to allocate %ld elements for array %s. "
|
||||
"returning NULL.\n", n, name );
|
||||
lmp->error->warning(FLERR,errmsg);
|
||||
error_ptr->warning(FLERR,errmsg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (size <= 0) {
|
||||
snprintf(errmsg, 256, "Elements size for array %s is %ld. "
|
||||
"returning NULL", name, size );
|
||||
lmp->error->warning(FLERR,errmsg);
|
||||
error_ptr->warning(FLERR,errmsg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -102,7 +102,7 @@ void *scalloc( LAMMPS_NS::LAMMPS *lmp, rc_bigint n, rc_bigint size, const char *
|
||||
if (ptr == NULL) {
|
||||
char errmsg[256];
|
||||
snprintf(errmsg, 256, "Failed to allocate %ld bytes for array %s", n*size, name);
|
||||
lmp->error->one(FLERR,errmsg);
|
||||
error_ptr->one(FLERR,errmsg);
|
||||
}
|
||||
|
||||
return ptr;
|
||||
@ -110,12 +110,12 @@ void *scalloc( LAMMPS_NS::LAMMPS *lmp, rc_bigint n, rc_bigint size, const char *
|
||||
|
||||
|
||||
/* safe free */
|
||||
void sfree( LAMMPS_NS::LAMMPS* lmp, void *ptr, const char *name )
|
||||
void sfree( LAMMPS_NS::Error* error_ptr, void *ptr, const char *name )
|
||||
{
|
||||
if (ptr == NULL) {
|
||||
char errmsg[256];
|
||||
snprintf(errmsg, 256, "Trying to free the already NULL pointer %s", name );
|
||||
lmp->error->one(FLERR,errmsg);
|
||||
error_ptr->one(FLERR,errmsg);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@ -37,7 +37,7 @@ double Get_Time( );
|
||||
int Tokenize( char*, char*** );
|
||||
|
||||
/* from lammps */
|
||||
void *smalloc( LAMMPS_NS::LAMMPS*, rc_bigint, const char*, MPI_Comm );
|
||||
void *scalloc( LAMMPS_NS::LAMMPS*, rc_bigint, rc_bigint, const char*, MPI_Comm );
|
||||
void sfree( LAMMPS_NS::LAMMPS*, void*, const char* );
|
||||
void *smalloc( LAMMPS_NS::Error*, rc_bigint, const char*, MPI_Comm );
|
||||
void *scalloc( LAMMPS_NS::Error*, rc_bigint, rc_bigint, const char*, MPI_Comm );
|
||||
void sfree( LAMMPS_NS::Error*, void*, const char* );
|
||||
#endif
|
||||
|
||||
@ -41,6 +41,7 @@
|
||||
|
||||
#include "lammps.h"
|
||||
#include "error.h"
|
||||
using LAMMPS_NS::Error;
|
||||
|
||||
#if defined LMP_USER_OMP
|
||||
#define OMP_TIMING 0
|
||||
@ -414,6 +415,7 @@ struct _reax_system
|
||||
boundary_cutoff bndry_cuts;
|
||||
reax_atom *my_atoms;
|
||||
|
||||
class Error *error_ptr;
|
||||
class Pair *pair_ptr;
|
||||
int my_bonds;
|
||||
int mincap;
|
||||
@ -491,6 +493,7 @@ typedef struct
|
||||
|
||||
int lgflag;
|
||||
int enobondsflag;
|
||||
class Error *error_ptr;
|
||||
|
||||
} control_params;
|
||||
|
||||
@ -777,6 +780,7 @@ struct _reax_list
|
||||
|
||||
int type;
|
||||
list_type select;
|
||||
class Error *error_ptr;
|
||||
};
|
||||
typedef _reax_list reax_list;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user