forked from haptork/easyLambda
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterstitialcount.cpp
More file actions
executable file
·74 lines (65 loc) · 1.89 KB
/
interstitialcount.cpp
File metadata and controls
executable file
·74 lines (65 loc) · 1.89 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
/*!
* @file
* Calculating interstitials i.e. atoms that are away from ideal lattice in
* each frame.
*
* default run cmd from project directory:
* `mpirun -n 4 ./bin/interstitialcount "data/lammps/dump*.txt" 3.165 0 bcc
* */
#include <array>
#include <iostream>
#include <stdexcept>
#include <tuple>
#include <vector>
#include <boost/mpi.hpp>
#include <ezl.hpp>
#include <ezl/algorithms/reduces.hpp>
#include <ezl/algorithms/filters.hpp>
#include <ezl/algorithms/fromFile.hpp>
#include "AddOffset.cpp"
void icount(int argc, char* argv[]) {
using namespace ezl;
using std::array;
using std::string;
using std::tuple;
using std::vector;
if (argc < 5) {
std::cerr << "Please give arguments as fileIn, latConst, origin, bcc/fcc, "
"output file tag(optional), check source for defaults.\n";
return;
}
string ftag = "";
if (argc > 5) ftag = string{argv[5]};
const string outFile = "data/output/icount" + ftag + ".txt";
const float toleranceRatio = 0.3;
auto latConst = float(std::stof(argv[2]));
auto o = std::stof(argv[3]);
auto origin = array<float, 3> {{o, 0, 0}};
auto obj = AddOffset(latConst, argv[4], origin);
// frame, coords
auto reader = fromFile<int, array<float, 3>>(argv[1])
.lammps().cols({6, 3, 4, 5});
rise(reader)
.map<2>(obj)
.filter<4>(gt(latConst * toleranceRatio))
.reduce<1>(count(), 0).inprocess().ordered()
.reduceAll([](vector<tuple<int, int>> a) { // sorting the time-step counts
sort(a.begin(), a.end());
return a;
})
.dump(outFile)
.run();
}
int main(int argc, char *argv[]) {
boost::mpi::environment env(argc, argv, false);
try {
icount(argc, argv);
} catch (const std::exception& ex) {
std::cerr<<"error: "<<ex.what()<<'\n';
env.abort(1);
} catch (...) {
std::cerr<<"unknown exception\n";
env.abort(2);
}
return 0;
}