Merge pull request #3162 from phankl/mesocnt_memory
Optimized memory usage for pair style mesocnt
This commit is contained in:
@ -94,10 +94,6 @@ boron nitride nanotubes.
|
||||
Atoms belonging to different CNTs need to be assigned
|
||||
different molecule IDs.
|
||||
|
||||
A full summary of the method and LAMMPS implementation details
|
||||
is expected to soon become available in Computer Physics
|
||||
Communications.
|
||||
|
||||
----------
|
||||
|
||||
Mixing, shift, table, tail correction, restart, rRESPA info
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -12,9 +12,7 @@
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
#ifdef PAIR_CLASS
|
||||
// clang-format off
|
||||
PairStyle(mesocnt, PairMesoCNT);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
#ifndef LMP_PAIR_MESOCNT_H
|
||||
@ -23,7 +21,7 @@ PairStyle(mesocnt, PairMesoCNT);
|
||||
#include "pair.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class PotentialFileReader;
|
||||
class PairMesoCNT : public Pair {
|
||||
public:
|
||||
PairMesoCNT(class LAMMPS *);
|
||||
@ -36,7 +34,6 @@ class PairMesoCNT : public Pair {
|
||||
|
||||
protected:
|
||||
int uinf_points, gamma_points, phi_points, usemi_points;
|
||||
int nlocal_size, reduced_neigh_size;
|
||||
int *reduced_nlist, *numchainlist;
|
||||
int **reduced_neighlist, **nchainlist, **endlist;
|
||||
int ***chainlist;
|
||||
@ -57,16 +54,18 @@ class PairMesoCNT : public Pair {
|
||||
double **uinf_coeff, **gamma_coeff, ****phi_coeff, ****usemi_coeff;
|
||||
double **flocal, **fglobal, **basis;
|
||||
|
||||
char *file;
|
||||
int count_chains(int *, int);
|
||||
|
||||
void allocate();
|
||||
void bond_neigh();
|
||||
void neigh_common(int, int, int &, int *);
|
||||
void chain_split(int *, int, int &, int **, int *, int *);
|
||||
void chain_lengths(int *, int, int *);
|
||||
void chain_split(int *, int, int *, int **, int *);
|
||||
void sort(int *, int);
|
||||
void read_file();
|
||||
void read_data(FILE *, double *, double &, double &, int);
|
||||
void read_data(FILE *, double **, double &, double &, double &, double &, int);
|
||||
void read_file(const char *);
|
||||
void read_data(PotentialFileReader &, double *, double &, double &, int);
|
||||
void read_data(PotentialFileReader &, double **, double &, double &, double &, double &,
|
||||
int);
|
||||
|
||||
void spline_coeff(double *, double **, double, int);
|
||||
void spline_coeff(double **, double ****, double, double, int);
|
||||
|
||||
34
src/memory.h
34
src/memory.h
@ -226,10 +226,38 @@ class Memory : protected Pointers {
|
||||
}
|
||||
|
||||
template <typename TYPE>
|
||||
TYPE ***create_ragged(TYPE ***& /*array*/, int /*n1*/, int * /*n2*/, const char *name)
|
||||
TYPE ***create_ragged(TYPE ***& array, int n1, int *n2, int **n3, const char *name)
|
||||
{
|
||||
fail(name);
|
||||
return nullptr;
|
||||
bigint size, nbytes;
|
||||
int i, j;
|
||||
|
||||
size = 0;
|
||||
for (i = 0; i < n1; i++)
|
||||
for (j = 0; j < n2[i]; j++)
|
||||
size += n3[i][j];
|
||||
nbytes = ((bigint) sizeof(TYPE)) * size;
|
||||
TYPE *data = (TYPE *) smalloc(nbytes, name);
|
||||
|
||||
size = 0;
|
||||
for (i = 0; i < n1; i++) size += n2[i];
|
||||
nbytes = ((bigint) sizeof(TYPE *)) * size;
|
||||
TYPE **plane = (TYPE **) smalloc(nbytes, name);
|
||||
|
||||
nbytes = ((bigint) sizeof(TYPE **)) * n1;
|
||||
array = (TYPE ***) smalloc(nbytes, name);
|
||||
|
||||
bigint m = 0;
|
||||
bigint n = 0;
|
||||
for (i = 0; i < n1; i++) {
|
||||
array[i] = &plane[m];
|
||||
for (j = 0; j < n2[i]; j++) {
|
||||
plane[m + j] = &data[n];
|
||||
n += n3[i][j];
|
||||
}
|
||||
m += n2[i];
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user