# PhasicFlow: utilities/postprocessPhasicFlow/rectMeshField.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.

rectMeshField.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 __rectMeshField_hpp__
#define __rectMeshField_hpp__
#include "rectangleMesh.hpp"
#include "ViewAlgorithms.hpp"
namespace pFlow
{
template<typename T>
class rectMeshField
:
public IOobject
{
public:
using viewType = ViewType3D<T,HostSpace>;
using memory_space = typename viewType::memory_space;
protected:
const rectangleMesh* mesh_;
word name_="noName";
viewType field_;
T defaultValue_{};
constexpr static inline const char* memoerySpaceName()
{
return memory_space::name();
}
public:
TypeInfoTemplateNV111("rectMeshField", T, memoerySpaceName());
rectMeshField(rectangleMesh& mesh, const word& name ,const T& defVal)
:
IOobject(
objectFile
(
name,
"",
objectFile::READ_NEVER,
objectFile::WRITE_NEVER
),
IOPattern::MasterProcessorOnly,
nullptr
),
mesh_(&mesh),
name_(name),
field_("reactMeshField."+name, mesh_->nx(), mesh_->ny(), mesh_->nz()),
defaultValue_(defVal)
{
this->fill(defaultValue_);
}
rectMeshField(rectangleMesh& mesh, const T& defVal)
:
IOobject(
objectFile
(
"noName",
"",
objectFile::READ_NEVER,
objectFile::WRITE_NEVER
),
IOPattern::MasterProcessorOnly,
nullptr
),
mesh_(&mesh),
name_("noName"),
field_("reactMeshField.noName", mesh_->nx(), mesh_->ny(), mesh_->nz()),
defaultValue_(defVal)
{
this->fill(defaultValue_);
}
rectMeshField(const rectMeshField&) = default;
rectMeshField& operator = (const rectMeshField&) = default;
rectMeshField(rectMeshField&&) = default;
rectMeshField& operator =(rectMeshField&&) = default;
inline uniquePtr<rectMeshField> clone() const
{
return makeUnique<rectMeshField>(*this);
}
inline rectMeshField* clonePtr()const
{
return new rectMeshField(*this);
}
INLINE_FUNCTION_H
const word& name()const
{
return name_;
}
INLINE_FUNCTION_HD
int64 size()const
{
return mesh_->size();
}
auto nx()const
{
return mesh_->nx();
}
auto ny()const
{
return mesh_->ny();
}
auto nz()const
{
return mesh_->nz();
}
const auto& mesh()
{
return *mesh_;
}
INLINE_FUNCTION_HD
real cellVol()const
{
return mesh_->cellVol();
}
INLINE_FUNCTION_HD
T& operator()(int32 i, int32 j, int32 k)
{
return field_(i,j,k);
}
INLINE_FUNCTION_HD
const T& operator()(int32 i, int32 j, int32 k)const
{
return field_(i,j,k);
}
void fill(T val)
{
pFlow::fill(
field_,
val
);
}
bool write(iOstream& is, const IOPattern& iop)const override
{
notImplementedFunction;
return true;
}
bool read(iIstream& is, const IOPattern& iop) override
{
notImplementedFunction;
return true;
}
bool read(iIstream& is)
{
notImplementedFunction;
return true;
}
bool write(iOstream& os)const
{
notImplementedFunction;
return true;
}
};
}
#endif // __rectMeshField_hpp__
pFlow::rectMeshField::write
bool write(iOstream &is, const IOPattern &iop) const override
Definition: rectMeshField.hpp:181
notImplementedFunction
#define notImplementedFunction
Report that a function is yet not implemented.
Definition: error.hpp:84
pFlow::rectangleMesh::size
int64 size() const
Definition: rectangleMesh.hpp:72
pFlow::rectMeshField::size
INLINE_FUNCTION_HD int64 size() const
Definition: rectMeshField.hpp:129
pFlow::rectangleMesh::cellVol
real cellVol() const
Definition: rectangleMesh.hpp:92
pFlow::rectMeshField::operator()
const INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k) const
Definition: rectMeshField.hpp:167
pFlow::rectMeshField::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: rectMeshField.hpp:187
pFlow::rectMeshField::mesh
const auto & mesh()
Definition: rectMeshField.hpp:149
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::rectangleMesh::ny
int32 ny() const
Definition: rectangleMesh.hpp:82
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::rectMeshField< int32 >::viewType
ViewType3D< int32, HostSpace > viewType
Definition: rectMeshField.hpp:37
pFlow::rectMeshField::operator()
INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k)
Definition: rectMeshField.hpp:161
pFlow::rectMeshField::TypeInfoTemplateNV111
TypeInfoTemplateNV111("rectMeshField", T, memoerySpaceName())
pFlow::rectMeshField
Definition: rectMeshField.hpp:31
ViewAlgorithms.hpp
pFlow::rectMeshField< int32 >::memory_space
typename viewType::memory_space memory_space
Definition: rectMeshField.hpp:39
pFlow::word
std::string word
Definition: builtinTypes.hpp:64
pFlow::rectMeshField::rectMeshField
rectMeshField(rectangleMesh &mesh, const word &name, const T &defVal)
Definition: rectMeshField.hpp:61
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
rectangleMesh.hpp
pFlow::rectMeshField::fill
void fill(T val)
Definition: rectMeshField.hpp:172
pFlow::rectMeshField::defaultValue_
T defaultValue_
Definition: rectMeshField.hpp:49
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:34
pFlow::rectMeshField::write
bool write(iOstream &os) const
Definition: rectMeshField.hpp:199
pFlow
Definition: demGeometry.hpp:27
pFlow::objectFile::WRITE_NEVER
@ WRITE_NEVER
Definition: objectFile.hpp:44
pFlow::IOobject
Definition: IOobject.hpp:35
pFlow::rectMeshField::clone
uniquePtr< rectMeshField > clone() const
Definition: rectMeshField.hpp:112
pFlow::rectMeshField::nx
auto nx() const
Definition: rectMeshField.hpp:134
pFlow::rectMeshField::ny
auto ny() const
Definition: rectMeshField.hpp:139
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::rectMeshField::name
const INLINE_FUNCTION_H word & name() const
Definition: rectMeshField.hpp:123
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::rectangleMesh::nz
int32 nz() const
Definition: rectangleMesh.hpp:87
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:57
pFlow::rectMeshField::rectMeshField
rectMeshField(rectangleMesh &mesh, const T &defVal)
Definition: rectMeshField.hpp:82
pFlow::rectMeshField::read
bool read(iIstream &is)
Definition: rectMeshField.hpp:193
pFlow::rectMeshField::cellVol
INLINE_FUNCTION_HD real cellVol() const
Definition: rectMeshField.hpp:155
pFlow::objectFile
Definition: objectFile.hpp:30
pFlow::rectMeshField::clonePtr
rectMeshField * clonePtr() const
Definition: rectMeshField.hpp:117
pFlow::ViewType3D
Kokkos::View< T ***, properties... > ViewType3D
3D view as an array
Definition: KokkosTypes.hpp:101
pFlow::objectFile::READ_NEVER
@ READ_NEVER
Definition: objectFile.hpp:37
pFlow::rectMeshField::nz
auto nz() const
Definition: rectMeshField.hpp:144
pFlow::uniquePtr
Definition: uniquePtr.hpp:42
pFlow::rectMeshField::operator=
rectMeshField & operator=(const rectMeshField &)=default
pFlow::rectMeshField::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: rectMeshField.hpp:51
pFlow::rectMeshField::mesh_
const rectangleMesh * mesh_
Definition: rectMeshField.hpp:43
pFlow::rectMeshField::name_
word name_
Definition: rectMeshField.hpp:45
pFlow::rectMeshField::field_
viewType field_
Definition: rectMeshField.hpp:47
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:55
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::rectangleMesh::nx
int32 nx() const
Definition: rectangleMesh.hpp:77