# PhasicFlow: src/phasicFlow/repository/repository/repository.hpp 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.

repository.hpp
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.
-----------------------------------------------------------------------------*/
#ifndef __repository_hpp__
#define __repository_hpp__
#include "fileSystem.hpp"
#include "Maps.hpp"
#include "Lists.hpp"
#include "IOobject.hpp"
namespace pFlow
{
class repository
{
private:
// - repository name
word name_;
// - local path of repository, relative to owner
fileSystem localPath_;
// - owner of this repository, if any
repository* owner_;
// - sorted names of objects with object index in vector of objects
wordMap<IOobject*> objects_;
// - list of repositories that this repository owns
// - it is not a managed list of pointers!
wordMap<repository*> repositories_;
template <typename Type1>
word reportTypeError (IOobject& object)const;
template <typename Type>
static
bool checkForObjectType(IOobject& object);
public:
TypeInfo("repository");
// - from a name, local path, and owner
repository(const word& name, const fileSystem& localPath, repository* owner = nullptr);
// - no copy
repository(const repository&) = delete;
// - no assignment
repository& operator=(const repository& )= delete;
// - destructor
virtual ~repository();
// - name of repository
word name()const;
// - local path of repository
virtual fileSystem localPath()const;
// full path of repository
virtual fileSystem path()const ;
// - const pointer to the owner
const repository* owner()const;
// - pointer to the owner
repository* owner();
// - const ref to this repository
const repository& thisRepository()const;
// - ref to this repository
repository& thisRepository();
bool addToRepository(repository* rep);
bool removeFromRepository(repository* rep);
bool addToRepository(IOobject* io);
bool removeFromRepository(IOobject* io);
repository* releaseOwner(bool fromOwner = false);
virtual
bool isIncluded(const word& objName)const
{
if(owner_)
return owner_->isIncluded(objName);
return false;
}
virtual
bool isExcluded(const word& objName)const
{
if(owner_)
return owner_->isExcluded(objName);
return false;
}
// - check if name of object exists
bool lookupObjectName(const word& nm)const;
// - find the object and return the typeName of the object
word lookupObjectTypeName(const word& nm)const;
// - check if name of object exists
// search all the repositories under the hood of Control (master repository)
bool globalLookupObjectName(const word& nm, bool downward = false)const;
// - check if name of the repository exists
bool lookupRepositoryName(const word& nm)const;
// - check if name (object and repository) exists
bool lookupName(const word nm)const;
// - return number of objects
size_t numObjects()const;
// - return number of repositories
size_t numRepositories()const;
virtual
size_t outFilePrecision() const
{
if(owner_)
{
return owner_->outFilePrecision();
}else
{
return 6;
}
}
template<typename T>
T& lookupObject(const word& name);
template<typename T>
const T& lookupObject(const word& name)const;
// - search the name and return a ref to repository
repository& lookupRepository(const word& name);
// list of object names in this repository
wordList objectNames()const;
// list of repository names in this repository
wordList repositoryNames()const;
virtual bool outFileBinary()const
{
if(owner_)
return owner_->outFileBinary();
else
return false;
}
virtual bool write(bool verbose = false) const;
};
}
#include "repositoryTemplates.cpp"
#endif //__repository_hpp__
pFlow::repository::releaseOwner
repository * releaseOwner(bool fromOwner=false)
Definition: repository.cpp:131
repositoryTemplates.cpp
pFlow::List< word >
pFlow::repository::localPath
virtual fileSystem localPath() const
Definition: repository.cpp:65
pFlow::repository::TypeInfo
TypeInfo("repository")
pFlow::repository::isExcluded
virtual bool isExcluded(const word &objName) const
Definition: repository.hpp:128
Lists.hpp
IOobject.hpp
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::repository::owner_
repository * owner_
Definition: repository.hpp:45
pFlow::repository::outFileBinary
virtual bool outFileBinary() const
Definition: repository.hpp:190
pFlow::repository::repositories_
wordMap< repository * > repositories_
Definition: repository.hpp:52
pFlow::repository::~repository
virtual ~repository()
Definition: repository.cpp:42
pFlow::repository::isIncluded
virtual bool isIncluded(const word &objName) const
Definition: repository.hpp:120
pFlow::repository::owner
const repository * owner() const
Definition: repository.cpp:82
pFlow::repository::lookupObjectName
bool lookupObjectName(const word &nm) const
Definition: repository.cpp:157
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::repository::lookupObjectTypeName
word lookupObjectTypeName(const word &nm) const
Definition: repository.cpp:163
pFlow::repository::outFilePrecision
virtual size_t outFilePrecision() const
Definition: repository.hpp:160
pFlow::repository::numRepositories
size_t numRepositories() const
Definition: repository.cpp:234
fileSystem.hpp
pFlow::repository::write
virtual bool write(bool verbose=false) const
Definition: repository.cpp:278
pFlow
Definition: demGeometry.hpp:27
pFlow::IOobject
Definition: IOobject.hpp:35
pFlow::repository::lookupRepositoryName
bool lookupRepositoryName(const word &nm) const
Definition: repository.cpp:217
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
pFlow::repository::name
word name() const
Definition: repository.cpp:60
pFlow::repository::globalLookupObjectName
bool globalLookupObjectName(const word &nm, bool downward=false) const
Definition: repository.cpp:181
pFlow::repository::repositoryNames
wordList repositoryNames() const
Definition: repository.cpp:266
pFlow::repository::thisRepository
const repository & thisRepository() const
Definition: repository.cpp:92
pFlow::repository::localPath_
fileSystem localPath_
Definition: repository.hpp:42
pFlow::repository::objects_
wordMap< IOobject * > objects_
Definition: repository.hpp:48
pFlow::repository::repository
repository(const word &name, const fileSystem &localPath, repository *owner=nullptr)
Definition: repository.cpp:25
pFlow::repository::addToRepository
bool addToRepository(repository *rep)
add repository to this repository return false if the name already exists
Definition: repository.cpp:102
pFlow::repository::name_
word name_
Definition: repository.hpp:39
pFlow::repository::operator=
repository & operator=(const repository &)=delete
pFlow::repository::path
virtual fileSystem path() const
Definition: repository.cpp:70
pFlow::repository::removeFromRepository
bool removeFromRepository(repository *rep)
remove rep from the list of repositories
Definition: repository.cpp:118
pFlow::repository::lookupName
bool lookupName(const word nm) const
Definition: repository.cpp:222
pFlow::repository::lookupRepository
repository & lookupRepository(const word &name)
Definition: repository.cpp:239
pFlow::repository::numObjects
size_t numObjects() const
Definition: repository.cpp:229
Maps.hpp
pFlow::repository::objectNames
wordList objectNames() const
Definition: repository.cpp:256
pFlow::Map
Definition: Map.hpp:36
pFlow::repository
Definition: repository.hpp:34