# PhasicFlow: utilities/Utilities/readFromTimeFolder.cpp Source File

readFromTimeFolder.cpp
Go to the documentation of this file.
/*------------------------------- phasicFlow ---------------------------------
O C enter of
O O E ngineering and
O O M ultiscale modeling of
OOOOOOO F luid flow
------------------------------------------------------------------------------
Copyright (C): www.cemf.ir
email: hamid.r.norouzi AT gmail.com
------------------------------------------------------------------------------
Licence:
This file is part of phasicFlow code. It is a free software for simulating
granular and multiphase flows. You can redistribute it and/or modify it under
the terms of GNU General Public License v3 or any other later versions.
phasicFlow is distributed to help others in their research in the field of
granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-----------------------------------------------------------------------------*/
#include "readFromTimeFolder.hpp"
pFlow::readFromTimeFolder::readFromTimeFolder(repository& rep)
:
repository_(rep)
{}
std::pair<bool, pFlow::IOfileHeader>
pFlow::readFromTimeFolder::fieldExists(word fieldName)const
{
IOfileHeader fieldHeader(
objectFile(
fieldName,
repository_.path(),
objectFile::READ_ALWAYS,
objectFile::WRITE_NEVER)
);
return std::make_pair( fieldHeader.headerOk(true), fieldHeader);
}
bool pFlow::readFromTimeFolder::pointFieldFileGetType(
word fieldName,
word& typeName) const
{
word fileTypeName, space;
if( auto [exist, fieldHeader]= fieldExists(fieldName); !exist )
{
fatalErrorInFunction<< "Folder "<< repository_.path() <<
" does not contain " << fieldName << " field."<<endl;
fatalExit;
return false;
}
else
{
fileTypeName = fieldHeader.objectType();
}
typeName.clear();
word flType{};
if( !pFlow::utilities::pointFieldGetType(
fileTypeName, flType, space) )
{
fatalErrorInFunction<<
"error in extracting type from "<<fileTypeName<<endl;
fatalExit;
return false;
}
typeName = flType;
return true;
}
pFlow::readFromTimeFolder::fieldExists
std::pair< bool, IOfileHeader > fieldExists(word fieldName) const
Definition: readFromTimeFolder.cpp:30
fatalExit
#define fatalExit
Definition: error.hpp:57
pFlow::readFromTimeFolder::pointFieldFileGetType
bool pointFieldFileGetType(word fieldName, word &typeName) const
Definition: readFromTimeFolder.cpp:43
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
readFromTimeFolder.hpp
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:47
fatalErrorInFunction
#define fatalErrorInFunction
Definition: error.hpp:42
pFlow::objectFile::READ_ALWAYS
@ READ_ALWAYS
Definition: objectFile.hpp:39
pFlow::objectFile
Definition: objectFile.hpp:33
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:71
pFlow::repository
Definition: repository.hpp:34