-
Notifications
You must be signed in to change notification settings - Fork 0
/
initializenl.cpp
45 lines (38 loc) · 920 Bytes
/
initializenl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <string>
#include "initializenl.h"
#include "constants.h"
using namespace std;
void initializenl(neighborlist_type *neighlist, int neighmax)
{
// (re)initialising the neighborlist with the required number of neighbors
if (neighmax>0)
{
neighlist->xyz = new int *[neighmax];
neighlist->numb = new long [neighmax];
neighlist->countsn = 0;
for (long j=0; j<neighmax; j++)
{
neighlist->numb[j] =-1;
neighlist->xyz[j] = new int [Dim];
for (int k=0; k<Dim; k++)
{
neighlist->xyz[j][k]=0;
}
}
}
else
{
//deleting the dynamic memories of neighborlist
int i;
for (i=0; i<((neighlist)->countsn);i++)
{
delete [] neighlist->xyz[i];
}
delete [] neighlist->xyz;
delete neighlist->numb;
}
}