forked from rikigigi/analisi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadlog.h
62 lines (54 loc) · 2.03 KB
/
readlog.h
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
*
* (c) Riccardo Bertossa, 2019
*
* Use at your own risk.
*
* If you modified the code, I could be happy if you contribute on github!
*
**/
#ifndef READLOG_H
#define READLOG_H
#include <string>
#include "traiettoria.h"
#include <vector>
template <class TFLOAT=double>
class ReadLog
{
public:
ReadLog(std::string filename,
Traiettoria * t=nullptr,
unsigned int skip=1,
unsigned int nthreads=0,
unsigned int nbatch=200,
std::vector<std::string> req_headers=std::vector<std::string>()
);
~ReadLog();
TFLOAT * line(unsigned int index); //
unsigned int n_timestep(){return data.size()/data_size;} //
unsigned int n_data(){return data_size;}
unsigned int timestep(unsigned int index);
/**
* introduco una sintassi strana per calcolare al volo la corrente di carica dal file binario della traiettoria:
* "#traj:JZ N q1 ... qN" --> calcola la corrente dalla traiettoria utilizzando le N cariche per gli atomi q1 ... qN
**/
std::pair<unsigned int,bool> get_index_of(std::string header); //
int need_binary(std::vector<std::string> headers);
void calc_currents(Traiettoria * t,unsigned int blocks);
private:
Traiettoria * traiettoria;
std::vector<std::string> headers;
std::vector<TFLOAT > data;
std::vector<unsigned int > timesteps;
unsigned int skip,size,step_index,nbatch;
size_t data_size,data_size_from_binary;
bool if_only_numbers(std::string str);
unsigned int natoms,nthreads;
///qui vengono memorizzati le stringhe delle correnti da calcolare e le cariche da utilizzare per calcolarle
std::vector< std::pair<std::string,std::vector<TFLOAT> > > q_current_type;
/// analizza la stringa che definisce la corrente da calcolare
std::pair<std::string,std::vector<TFLOAT> >qs(std::string header);
/// ritorna l'indice della corrente calcolata (da 0 a #correnti calcolate dalla traiettoria binaria)
unsigned int get_calc_j_index(std::string header);
};
#endif // READLOG_H