libatomprobe
Library for Atom Probe Tomography (APT) computation
atomprobe.cpp
Go to the documentation of this file.
1 /*
2  * atomprobe.cpp - library-wide function implementations
3  * Copyright (C) 2015, D Haley
4 
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 
19 #include "atomprobe/atomprobe.h"
20 
21 #include <cstdlib>
22 #include <ctime>
23 #include <chrono>
24 
25 namespace AtomProbe
26 {
27 
30 
31 static uint64_t getUnixTimeStamp(const std::time_t* t = nullptr)
32 {
33  //if specific time is not passed then get current time
34  std::time_t st = t == nullptr ? std::time(nullptr) : *t;
35  auto secs = static_cast<std::chrono::seconds>(st).count();
36  return static_cast<uint64_t>(secs);
37 }
38 
40 {
41 #ifdef DEBUG
42  if(!isDebug)
43 #else
44  if(isDebug)
45 #endif
46  {
47  std::cerr << "DEBUG MISMATCH!" << std::endl;
48  abort();
49  }
50 }
51 
53 {
54  rng = gsl_rng_alloc(gsl_rng_mt19937);
55 
56  auto t = std::chrono::system_clock::now();
57 
58  time_t tt =std::chrono::system_clock::to_time_t(t);
59  gsl_rng_set(rng, tt); // set seed
60 }
61 
62 
64 {
65  gsl_rng_free(rng);
66 }
67 }
Class to hold the library version data.
Definition: version.h:37
LibVersion libVersion
Definition: atomprobe.cpp:28
RandNumGen randGen
Definition: atomprobe.cpp:29