Mechanics of Defect Evolution Library
Loading...
Searching...
No Matches
DefectiveCrystalBaseIO.cpp
Go to the documentation of this file.
1/* This file is part of MoDELib, the Mechanics Of Defects Evolution Library.
2 *
3 *
4 * MoDELib is distributed without any warranty under the
5 * GNU General Public License (GPL) v2 <http://www.gnu.org/licenses/>.
6 */
7
8#ifndef model_DefectiveCrystalBaseIO_cpp_
9#define model_DefectiveCrystalBaseIO_cpp_
10
11
12#include <iostream> // std::cout
13#include <fstream> // std::ifstream
14#include <string> // std::ifstream
16
17namespace model
18{
19
20
21 DefectiveCrystalBaseIO::DefectiveCrystalBaseIO(const std::string& outFolderName_in,
22 const std::string& fileNamePrefix_in,
23 const std::string& outFolderSuffix_in) :
24 /* init */ outFolderName(outFolderName_in)
25 /* init */,fileNamePrefix(fileNamePrefix_in)
26 /* init */,outFolderSuffix(outFolderSuffix_in)
27 {
28 }
29
30
31 std::string DefectiveCrystalBaseIO::getBinFilename(const size_t& runID)
32 {
33 return outFolderName+outFolderSuffix+"/"+fileNamePrefix+"_"+std::to_string(runID)+".bin";
34 }
35
36 std::string DefectiveCrystalBaseIO::getTxtFilename(const size_t& runID)
37 {
38 return outFolderName+outFolderSuffix+"/"+fileNamePrefix+"_"+std::to_string(runID)+".txt";
39 }
40
41 std::string DefectiveCrystalBaseIO::getTxtSegmentFilename(const size_t& runID)
42 {
43 return outFolderName+outFolderSuffix+"/"+"segments"+std::to_string(runID)+".txt";
44 }
45
46 bool DefectiveCrystalBaseIO::isBinGood(const size_t& frameID)
47 {
48 return std::ifstream(getBinFilename(frameID).c_str(), std::ios::in|std::ios::binary).good();
49
50 }
51
52 bool DefectiveCrystalBaseIO::isTxtGood(const size_t& frameID)
53 {
54 return std::ifstream(getTxtFilename(frameID).c_str(), std::ios::in).good();
55
56 }
57
58
59}
60#endif
61
bool isBinGood(const size_t &frameID)
bool isTxtGood(const size_t &frameID)
std::string getTxtSegmentFilename(const size_t &runID)
DefectiveCrystalBaseIO(const std::string &outFolderName_in, const std::string &fileNamePrefix_in, const std::string &outFolderSuffix_in="")
std::string getBinFilename(const size_t &runID)
std::string getTxtFilename(const size_t &runID)