# PhasicFlow: src/Property/property.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.

property.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 __property_hpp__
#define __property_hpp__
#include "Vectors.hpp"
#include "hashMap.hpp"
#include "fileDictionary.hpp"
#include "iFstream.hpp"
namespace pFlow
{
class property
:
public fileDictionary
{
private:
// - protected data members
wordVector materials_;
realVector densities_;
wordHashMap<uint32> nameIndex_;
uint32 numMaterials_ = 0;
// - protected member functions
bool readDictionary();
bool writeDictionary();
bool makeNameIndex();
public:
TypeInfo("property");
// - Constructors
explicit
property(
const word& fileName,
repository* owner=nullptr);
property(
const word& fileName,
const fileSystem& dir
);
property(const word& fileName,
const wordVector& materials,
const realVector& densities,
repository* owner=nullptr);
property(const property& ) = default;
property(property&& ) = default;
property& operator= (const property&) = default;
property& operator= (property&&) = default;
~property() override = default;
// - Methods
inline auto numMaterials()const
{
return numMaterials_;
}
inline const auto& materials()const{
return materials_;
}
inline const auto& densities()const{
return densities_;
}
inline const word& material(uint32 i)const
{
return materials_[i];
}
inline bool material(uint32 i, word& name)const
{
if(i<numMaterials_)
{
name = material(i);
return true;
}
else
{
name.clear();
return false;
}
}
inline real density(uint32 i)const
{
return densities_[i];
}
inline bool density(uint32 i, real& rho)const
{
if(i<numMaterials_)
{
rho = density(i);
return true;
}
else
{
rho = 0.00001;
return false;
}
}
inline bool nameToIndex(const word& name, uint32& idx)const
{
if(auto[iter, found] = nameIndex_.findIf(name); found )
{
idx = iter->second;
return true;
}
else
{
idx = 0;
return false;
}
}
};
}
#endif // __property_hpp__
pFlow::property::densities_
realVector densities_
list of density of materials
Definition: property.hpp:49
hashMap.hpp
pFlow::property::makeNameIndex
bool makeNameIndex()
creates a mapp
Definition: property.cpp:63
pFlow::property::readDictionary
bool readDictionary()
read from dict
Definition: property.cpp:24
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::property::materials_
wordVector materials_
list of name of materials
Definition: property.hpp:46
pFlow::hashMap
Definition: hashMap.hpp:36
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::property::~property
~property() override=default
Default destructor.
pFlow::property::densities
const auto & densities() const
Return the list of densities.
Definition: property.hpp:122
pFlow::property::property
property(const word &fileName, repository *owner=nullptr)
Definition: property.cpp:122
Vectors.hpp
pFlow::property::material
const word & material(uint32 i) const
Return the material name of material i.
Definition: property.hpp:127
pFlow
Definition: demGeometry.hpp:27
pFlow::fileSystem
Manages file pathes, manupulate and combines them.
Definition: fileSystem.hpp:71
pFlow::property::materials
const auto & materials() const
Return list of material names.
Definition: property.hpp:117
pFlow::property::writeDictionary
bool writeDictionary()
write to dict
Definition: property.cpp:43
pFlow::property::material
bool material(uint32 i, word &name) const
Get the name of material i.
Definition: property.hpp:134
pFlow::property::nameIndex_
wordHashMap< uint32 > nameIndex_
rapid mapping from name to index
Definition: property.hpp:52
pFlow::property::operator=
property & operator=(const property &)=default
Default copy assignment.
pFlow::IOobject::owner
const repository * owner() const override
Definition: IOobject.hpp:76
pFlow::property::nameToIndex
bool nameToIndex(const word &name, uint32 &idx) const
Get the name of material in index idx Return true, if the name found, otherwise false.
Definition: property.hpp:172
pFlow::property::numMaterials
auto numMaterials() const
Return number of materials.
Definition: property.hpp:111
pFlow::iEntry::name
virtual word name() const
name/keyword of entry
Definition: iEntry.hpp:100
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:37
pFlow::property::density
bool density(uint32 i, real &rho) const
Get the density of material i.
Definition: property.hpp:156
fileDictionary.hpp
pFlow::fileDictionary
Definition: fileDictionary.hpp:29
pFlow::property::numMaterials_
uint32 numMaterials_
number of materials
Definition: property.hpp:56
pFlow::repository
Definition: repository.hpp:34
pFlow::property::density
real density(uint32 i) const
Return density of material i.
Definition: property.hpp:149
iFstream.hpp
pFlow::Vector< word >
pFlow::property::TypeInfo
TypeInfo("property")
Type info.