# PhasicFlow: src/Particles/SphereParticles/sphereShape/sphereShape.hpp Source File

sphereShape.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 __sphereShape_hpp__
#define __sphereShape_hpp__
#include "Vectors.hpp"
#include "hashMap.hpp"
namespace pFlow
{
class dictionary;
class sphereShape
{
protected:
// - diameter of spheres
realVector diameters_;
// - property name of spheres
wordVector materials_;
// - hashed list of spheres names
wordHashMap<uint32> names_;
size_t numShapes_;
bool insertNames(const wordVector& names);
bool readDictionary(const dictionary& dict);
bool writeDictionary(dictionary& dict)const;
public:
// - type info
TypeInfoNV("sphereShape");
sphereShape(){}
sphereShape(
const realVector& diameter,
const wordVector& property,
const wordVector& name
);
sphereShape(const sphereShape&) = default;
sphereShape(sphereShape&&) = default;
sphereShape& operator=(const sphereShape&) = default;
sphereShape& operator=(sphereShape&&) = default;
auto clone()const
{
return makeUnique<sphereShape>(*this);
}
sphereShape* clonePtr()const
{
return new sphereShape(*this);
}
~sphereShape() = default;
const auto& names()const{
return names_;
}
const auto& diameters()const{
return diameters_;
}
const auto& materials()const{
return materials_;
}
const auto diameter(label i)const{
return diameters_[i];
}
const auto material(label i)const{
return materials_[i];
}
// name to index
bool nameToIndex(const word& name, uint32& index)const
{
if(auto[iter, found] = names_.findIf(name); found )
{
index = iter->second;
return true;
}
else
{
index = 0;
return false;
}
}
uint32 nameToIndex(const word& name)const
{
return names_.at(name);
}
bool indexToName(uint32 i, word& name)const
{
for(auto& nm: names_)
{
if(nm.second == i)
{
name = nm.first;
return true;
}
}
name = "";
return false;
}
bool shapeToDiameter(wordVector& names, realVector& diams)const;
void diameterMinMax(real& minD, real& maxD)const
{
minD = min(diameters_);
maxD = max(diameters_);
}
// - read from stream/file
bool read(iIstream& is);
// - write to stream/file
bool write(iOstream& os)const;
// - read from dictionary
bool read(const dictionary& dict)
{
return readDictionary(dict);
}
// - write to dictionary
bool write(dictionary& dict)const
{
return writeDictionary(dict);
}
};
} // pFlow
#endif //__sphereShape_hpp__
pFlow::sphereShape::diameter
const auto diameter(label i) const
Definition: sphereShape.hpp:101
pFlow::sphereShape::write
bool write(dictionary &dict) const
Definition: sphereShape.hpp:167
hashMap.hpp
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::sphereShape
Definition: sphereShape.hpp:32
pFlow::sphereShape::diameters
const auto & diameters() const
Definition: sphereShape.hpp:93
pFlow::hashMap
Definition: hashMap.hpp:36
pFlow::sphereShape::write
bool write(iOstream &os) const
Definition: sphereShape.cpp:186
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:59
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::sphereShape::numShapes_
size_t numShapes_
Definition: sphereShape.hpp:45
pFlow::sphereShape::~sphereShape
~sphereShape()=default
Vectors.hpp
pFlow::sphereShape::clone
auto clone() const
Definition: sphereShape.hpp:76
pFlow::sphereShape::materials
const auto & materials() const
Definition: sphereShape.hpp:97
pFlow::sphereShape::names_
wordHashMap< uint32 > names_
Definition: sphereShape.hpp:43
pFlow::sphereShape::diameters_
realVector diameters_
Definition: sphereShape.hpp:37
pFlow
Definition: demComponent.hpp:28
pFlow::sphereShape::nameToIndex
uint32 nameToIndex(const word &name) const
Definition: sphereShape.hpp:125
pFlow::sphereShape::read
bool read(const dictionary &dict)
Definition: sphereShape.hpp:161
pFlow::sphereShape::read
bool read(iIstream &is)
Definition: sphereShape.cpp:166
pFlow::sphereShape::indexToName
bool indexToName(uint32 i, word &name) const
Definition: sphereShape.hpp:130
pFlow::sphereShape::names
const auto & names() const
Definition: sphereShape.hpp:89
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::sphereShape::clonePtr
sphereShape * clonePtr() const
Definition: sphereShape.hpp:81
pFlow::sphereShape::sphereShape
sphereShape()
Definition: sphereShape.hpp:60
pFlow::sphereShape::writeDictionary
bool writeDictionary(dictionary &dict) const
Definition: sphereShape.cpp:85
pFlow::sphereShape::operator=
sphereShape & operator=(const sphereShape &)=default
pFlow::sphereShape::nameToIndex
bool nameToIndex(const word &name, uint32 &index) const
Definition: sphereShape.hpp:111
pFlow::max
T max(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:164
pFlow::property
property holds the pure properties of materials.
Definition: property.hpp:40
pFlow::sphereShape::TypeInfoNV
TypeInfoNV("sphereShape")
pFlow::sphereShape::insertNames
bool insertNames(const wordVector &names)
Definition: sphereShape.cpp:28
pFlow::label
std::size_t label
Definition: builtinTypes.hpp:61
pFlow::sphereShape::readDictionary
bool readDictionary(const dictionary &dict)
Definition: sphereShape.cpp:53
pFlow::Vector< real >
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::sphereShape::shapeToDiameter
bool shapeToDiameter(wordVector &names, realVector &diams) const
Definition: sphereShape.cpp:144
pFlow::min
T min(const Vector< T, Allocator > &v)
Definition: VectorMath.hpp:138
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::sphereShape::diameterMinMax
void diameterMinMax(real &minD, real &maxD) const
Definition: sphereShape.hpp:146
pFlow::sphereShape::materials_
wordVector materials_
Definition: sphereShape.hpp:40
pFlow::sphereShape::material
const auto material(label i) const
Definition: sphereShape.hpp:105