Commit 146e2f28 authored by mkanski's avatar mkanski
Browse files

Better error handling in reaxc_forces

parent d8845b68
Loading
Loading
Loading
Loading
+6 −5
Original line number Diff line number Diff line
@@ -394,6 +394,7 @@ void PairReaxC::init_style( )
                   "increased neighbor list skin.");

  for( int i = 0; i < LIST_N; ++i )
    if (lists[i].allacated != 1)
      lists[i].allocated = 0;

  if (fix_reax == NULL) {
@@ -445,7 +446,7 @@ void PairReaxC::setup( )
      error->all(FLERR,"Pair reax/c problem in far neighbor list");

    write_reax_lists();
    Initialize( system, control, data, workspace, &lists, out_control,
    Initialize( lmp, system, control, data, workspace, &lists, out_control,
                mpi_data, world );
    for( int k = 0; k < system->N; ++k ) {
      num_bonds[k] = system->my_atoms[k].num_bonds;
@@ -465,7 +466,7 @@ void PairReaxC::setup( )

    // check if I need to shrink/extend my data-structs

    ReAllocate( system, control, data, workspace, &lists, mpi_data );
    ReAllocate( lmp, system, control, data, workspace, &lists, mpi_data );
  }

  bigint local_ngroup = list->inum;
@@ -517,7 +518,7 @@ void PairReaxC::compute(int eflag, int vflag)

  setup();

  Reset( system, control, data, workspace, &lists, world );
  Reset( lmp, system, control, data, workspace, &lists, world );
  workspace->realloc.num_far = write_reax_lists();
  // timing for filling in the reax lists
  if (comm->me == 0) {
@@ -527,7 +528,7 @@ void PairReaxC::compute(int eflag, int vflag)

  // forces

  Compute_Forces(system,control,data,workspace,&lists,out_control,mpi_data);
  Compute_Forces(lmp, system,control,data,workspace,&lists,out_control,mpi_data);
  read_reax_forces(vflag);

  for(int k = 0; k < system->N; ++k) {
+8 −4
Original line number Diff line number Diff line
@@ -35,6 +35,10 @@
#include <omp.h>
#endif

#include "lammps.h"
#include "error.h"
using namespace LAMMPS_NS;

/* allocate space for my_atoms
   important: we cannot know the exact number of atoms that will fall into a
   process's box throughout the whole simulation. therefore
@@ -353,7 +357,7 @@ static int Reallocate_HBonds_List( reax_system *system, reax_list *hbonds,
}


static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds,
static int Reallocate_Bonds_List( LAMMPS *lmp, reax_system *system, reax_list *bonds,
                                  int *total_bonds, int *est_3body,
                                  MPI_Comm comm )
{
@@ -379,7 +383,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds,
  Delete_List( bonds, comm );
  if(!Make_List(system->total_cap, *total_bonds, TYP_BOND, bonds, comm)) {
    fprintf( stderr, "not enough space for bonds list. terminating!\n" );
    MPI_Abort( comm, INSUFFICIENT_MEMORY );
    lmp->error->all(FLERR, "Can't allocate space for hbonds.");
  }

#ifdef LMP_USER_OMP
@@ -399,7 +403,7 @@ static int Reallocate_Bonds_List( reax_system *system, reax_list *bonds,
}


void ReAllocate( reax_system *system, control_params *control,
void ReAllocate( LAMMPS *lmp, reax_system *system, control_params *control,
                 simulation_data *data, storage *workspace, reax_list **lists,
                 mpi_datatypes *mpi_data )
{
@@ -490,7 +494,7 @@ void ReAllocate( reax_system *system, control_params *control,
  /* bonds list */
  num_bonds = est_3body = -1;
  if (Nflag || realloc->bonds) {
    Reallocate_Bonds_List( system, (*lists)+BONDS, &num_bonds,
    Reallocate_Bonds_List( lmp, system, (*lists)+BONDS, &num_bonds,
                           &est_3body, comm );
    realloc->bonds = 0;
    realloc->num_3body = MAX( realloc->num_3body, est_3body ) * 2;
+6 −1
Original line number Diff line number Diff line
@@ -28,6 +28,11 @@
#define __ALLOCATE_H_

#include "reaxc_types.h"

#include "lammps.h"
#include "error.h"
using namespace LAMMPS_NS;

int  PreAllocate_Space( reax_system*, control_params*, storage*, MPI_Comm );

int  Allocate_System( reax_system*, int, int, char* );
@@ -37,6 +42,6 @@ int Allocate_Workspace( reax_system*, control_params*, storage*,
                         int, int, MPI_Comm, char* );
void DeAllocate_Workspace( control_params*, storage* );

void ReAllocate( reax_system*, control_params*, simulation_data*, storage*,
void ReAllocate( LAMMPS *lmp, reax_system*, control_params*, simulation_data*, storage*,
                 reax_list**, mpi_datatypes* );
#endif
+11 −7
Original line number Diff line number Diff line
@@ -39,7 +39,11 @@
#include "reaxc_valence_angles.h"
#include "reaxc_vector.h"

#include "lammps.h"
#include "error.h"

interaction_function Interaction_Functions[NUM_INTRS];
using namespace LAMMPS_NS;

void Dummy_Interaction( reax_system * /*system*/, control_params * /*control*/,
                        simulation_data * /*data*/, storage * /*workspace*/,
@@ -114,7 +118,7 @@ void Compute_Total_Force( reax_system *system, control_params *control,

}

void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **lists,
void Validate_Lists( LAMMPS *lmp, reax_system *system, storage * /*workspace*/, reax_list **lists,
                     int step, int /*n*/, int N, int numH, MPI_Comm comm )
{
  int i, comp, Hindex;
@@ -136,7 +140,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l
      if (End_Index(i, bonds) > comp) {
        fprintf( stderr, "step%d-bondchk failed: i=%d end(i)=%d str(i+1)=%d\n",
                 step, i, End_Index(i,bonds), comp );
        MPI_Abort( comm, INSUFFICIENT_MEMORY );
        lmp->error->all(FLERR,"Failure in bond list.");
      }
    }
  }
@@ -163,7 +167,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l
        if (End_Index(Hindex, hbonds) > comp) {
          fprintf(stderr,"step%d-hbondchk failed: H=%d end(H)=%d str(H+1)=%d\n",
                  step, Hindex, End_Index(Hindex,hbonds), comp );
          MPI_Abort( comm, INSUFFICIENT_MEMORY );
          lmp->error->all(FLERR, "Failure in hydrogen bonds.");
        }
      }
    }
@@ -171,7 +175,7 @@ void Validate_Lists( reax_system *system, storage * /*workspace*/, reax_list **l
}


void Init_Forces_noQEq( reax_system *system, control_params *control,
void Init_Forces_noQEq( LAMMPS *lmp, reax_system *system, control_params *control,
                        simulation_data *data, storage *workspace,
                        reax_list **lists, output_controls * /*out_control*/,
                        MPI_Comm comm ) {
@@ -307,7 +311,7 @@ void Init_Forces_noQEq( reax_system *system, control_params *control,
  workspace->realloc.num_bonds = num_bonds;
  workspace->realloc.num_hbonds = num_hbonds;

  Validate_Lists( system, workspace, lists, data->step,
  Validate_Lists( lmp, system, workspace, lists, data->step,
                  system->n, system->N, system->numH, comm );
}

@@ -431,14 +435,14 @@ void Estimate_Storages( reax_system *system, control_params *control,
}


void Compute_Forces( reax_system *system, control_params *control,
void Compute_Forces( LAMMPS *lmp, reax_system *system, control_params *control,
                     simulation_data *data, storage *workspace,
                     reax_list **lists, output_controls *out_control,
                     mpi_datatypes *mpi_data )
{
  MPI_Comm comm = mpi_data->world;

  Init_Forces_noQEq( system, control, data, workspace,
  Init_Forces_noQEq( lmp, system, control, data, workspace,
                       lists, out_control, comm );

  /********* bonded interactions ************/
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
extern interaction_function Interaction_Functions[NUM_INTRS];

void Init_Force_Functions( control_params* );
void Compute_Forces( reax_system*, control_params*, simulation_data*,
void Compute_Forces( LAMMPS_NS::LAMMPS *lmp, reax_system*, control_params*, simulation_data*,
                     storage*, reax_list**, output_controls*, mpi_datatypes* );
void Estimate_Storages( reax_system*, control_params*, reax_list**,
                        int*, int*, int*, int*, MPI_Comm );
Loading