# PhasicFlow: src/phasicFlow/repository/repository/repositoryTemplates.cpp Source File
PhasicFlow is an open-source parallel DEM (discrete element method) package for simulating granular flow. It is developed in C++ and can be exectued on both GPU (like CUDA) and CPU.

repositoryTemplates.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.
-----------------------------------------------------------------------------*/
template <typename Type1>
pFlow::word pFlow::repository::reportTypeError(IOobject& object)const
{
word err;
err = "Object " + object.name() + " with type " + Type1::TYPENAME() +
"is requested, while the type " +
object.typeName() + "is found in repository " + this->name()+".";
return err;
}
template <typename Type>
bool pFlow::repository::checkForObjectType(IOobject& object)
{
return Type::TYPENAME() == object.typeName();
}
template<typename T>
T& pFlow::repository::lookupObject(const word& name)
{
if( auto [iter, success] = objects_.findIf(name); success )
{
if( checkType<T>(iter->second) )
{
return static_cast<T&>(*iter->second);
}else
{
fatalErrorInFunction <<
reportTypeError<T>(*iter->second)<<endl;
fatalExit;
return static_cast<T&>(*iter->second);
}
}
else
{
fatalErrorInFunction <<
"Object with name " << name << " is not found in repository " << this->name()<<endl <<
"list of avaiable objest is \n" << objectNames();
fatalExit;
return static_cast<T&>(*iter->second);
}
}
template<typename T>
const T& pFlow::repository::lookupObject(const word& name)const
{
if( auto [iter, success] = objects_.findIf(name); success )
{
if( checkType<T>(iter->second) )
{
return static_cast<const T&>(*iter->second);
}
else
{
fatalErrorInFunction <<
reportTypeError<T>(*iter->second)<<endl;
fatalExit;
return static_cast<T&>(*iter->second);
}
}
else
{
fatalErrorInFunction <<
"Object with name " << name << " is not found in repository " << this->name()<<endl <<
"list of avaiable objest is \n" << objectNames();
fatalExit;
return static_cast<T&>(*iter->second);
}
}
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::repository::checkForObjectType
static bool checkForObjectType(IOobject &object)
Definition: repositoryTemplates.cpp:34
pFlow::repository::reportTypeError
word reportTypeError(IOobject &object) const
pFlow::repository::lookupObject
T & lookupObject(const word &name)
return a ref to the underlaying data in the object
Definition: repositoryTemplates.cpp:40
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::IOobject
Definition: IOobject.hpp:35
pFlow::repository::name
word name() const
Definition: repository.cpp:60
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77