www.cemf.ir
readFromTimeFolder.cpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #include "readFromTimeFolder.hpp"
22 
24 :
25  repository_(rep)
26 {}
27 
28 
29 std::pair<bool, pFlow::IOfileHeader>
31 {
32  IOfileHeader fieldHeader(
33  objectFile(
34  fieldName,
35  repository_.path(),
38  );
39 
40  return std::make_pair( fieldHeader.headerOk(true), fieldHeader);
41 }
42 
44  word fieldName,
45  word& typeName) const
46 {
47 
48  word fileTypeName, space;
49  if( auto [exist, fieldHeader]= fieldExists(fieldName); !exist )
50  {
51  fatalErrorInFunction<< "Folder "<< repository_.path() <<
52  " does not contain " << fieldName << " field."<<endl;
53  fatalExit;
54  return false;
55  }
56  else
57  {
58  fileTypeName = fieldHeader.objectType();
59  }
60 
61  typeName.clear();
62  word flType{};
63 
65  fileTypeName, flType, space) )
66  {
68  "error in extracting type from "<<fileTypeName<<endl;
69  fatalExit;
70  return false;
71  }
72 
73  typeName = flType;
74  return true;
75 }
pFlow::readFromTimeFolder::fieldExists
std::pair< bool, IOfileHeader > fieldExists(word fieldName) const
Definition: readFromTimeFolder.cpp:30
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::readFromTimeFolder::pointFieldFileGetType
bool pointFieldFileGetType(word fieldName, word &typeName) const
Definition: readFromTimeFolder.cpp:43
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
readFromTimeFolder.hpp
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:44
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::objectFile::READ_ALWAYS
@ READ_ALWAYS
Definition: objectFile.hpp:36
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::readFromTimeFolder::readFromTimeFolder
readFromTimeFolder(repository &rep)
Definition: readFromTimeFolder.cpp:23
pFlow::utilities::pointFieldGetType
bool pointFieldGetType(std::string TYPENAME, std::string &fieldType, std::string &fieldSpace)
Definition: utilityFunctions.hpp:30
pFlow::IOfileHeader
Definition: IOfileHeader.hpp:35
pFlow::IOfileHeader::headerOk
bool headerOk(bool silent=false)
Definition: IOfileHeader.cpp:92
pFlow::repository
Definition: repository.hpp:34