# PhasicFlow: src/phasicFlow/structuredData/pointStructure/selectors/pStructSelector/fieldSelector.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.

fieldSelector.hpp
Go to the documentation of this file.
#ifndef __fieldSelector_hpp__
#define __fieldSelector_hpp__
#include "pStructSelector.hpp"
#include "pointFields.hpp"
#include "Time.hpp"
namespace pFlow
{
template<typename T>
inline
Vector<T> selectedFieldVals(const pStructSelector& selector, const word& name)
{
using FieldType = pointField_D<T>;
if(selector.selectedPoints().empty() )
{
return Vector<T>("selected-"+name);
}
if(!selector.pStruct().time().lookupObjectName(name))
{
fatalErrorInFunction<<
"Field "<< name << " does not exist in time repository"<<endl;
fatalExit;
}
if(
selector.pStruct().time().lookupObjectTypeName(name) !=
FieldType::TYPENAME())
{
fatalErrorInFunction<<
"Type of field "<< name << " in time repository does not match with"<<
FieldType::TYPENAME()<<endl;
fatalExit;
}
const FieldType& field = selector.pStruct().time().lookupObject<FieldType>(name);
auto fieldH = field.hostView();
const auto& selected = selector.selectedPoints();
Vector<T> selectedField(
"selected-"+name,
selected.size(),
selected.size(),
RESERVE());
for(uint32 i=0; i<selected.size(); i++)
{
selectedField[i] = fieldH[selected[i]];
}
return selectedField;
}
} // pFlow
#endif //__fieldSelector_hpp__
pFlow::pStructSelector::selectedPoints
virtual const uint32Vector & selectedPoints() const =0
fatalExit
#define fatalExit
Fatal exit.
Definition: error.hpp:98
pFlow::pointStructure::time
Time & time() override
Definition: pointStructure.hpp:128
pFlow::repository::lookupObject
T & lookupObject(const word &name)
return a ref to the underlaying data in the object
Definition: repositoryTemplates.cpp:40
pFlow::uint32
unsigned int uint32
Definition: builtinTypes.hpp:56
pFlow::repository::lookupObjectName
bool lookupObjectName(const word &nm) const
Definition: repository.cpp:157
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pointFields.hpp
pFlow::repository::lookupObjectTypeName
word lookupObjectTypeName(const word &nm) const
Definition: repository.cpp:163
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow
Definition: demGeometry.hpp:27
pStructSelector.hpp
RESERVE
Definition: Vector.hpp:40
pFlow::pointField
Definition: pointField.hpp:33
fatalErrorInFunction
#define fatalErrorInFunction
Report a fatal error and function name and exit the application.
Definition: error.hpp:77
pFlow::pStructSelector::pStruct
const pointStructure & pStruct() const
Definition: pStructSelector.cpp:45
Time.hpp
pFlow::Vector::empty
bool empty() const
If vector is empty.
Definition: Vector.hpp:277
pFlow::pStructSelector
Definition: pStructSelector.hpp:36
pFlow::Vector
Definition: Vector.hpp:48
pFlow::selectedFieldVals
Vector< T > selectedFieldVals(const pStructSelector &selector, const word &name)
Definition: fieldSelector.hpp:14