# PhasicFlow: utilities/postprocessPhasicFlow/rectMeshField.hpp Source File

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 "baseAlgorithms.hpp"
namespace pFlow
{
template<typename T, typename MemorySpace=void>
class rectMeshField
{
public:
using viewType = ViewType3D<T,MemorySpace>;
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:
TypeInfoTemplateNV2("rectMeshField", T, memoerySpaceName());
rectMeshField(const rectangleMesh& mesh, const word& name ,const T& defVal)
:
mesh_(&mesh),
name_(name),
field_("pFlow::reactMeshField", mesh_->nx(), mesh_->ny(), mesh_->nz()),
defaultValue_(defVal)
{
this->fill(defaultValue_);
}
rectMeshField(const rectangleMesh& mesh, const T& defVal)
:
rectMeshField(mesh, "noName", defVal)
{}
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_,
range(0,mesh_->nx()),
range(0,mesh_->ny()),
range(0,mesh_->nz()),
val
);
}
bool read(iIstream& is)
{
notImplementedFunction;
return true;
}
bool write(iOstream& os)const
{
notImplementedFunction;
return true;
}
};
}
#endif // __rectMeshField_hpp__
pFlow::cells::nz
INLINE_FUNCTION_HD indexType nz() const
Definition: cells.hpp:139
notImplementedFunction
#define notImplementedFunction
Definition: error.hpp:47
pFlow::rectMeshField::size
INLINE_FUNCTION_HD int64 size() const
Definition: rectMeshField.hpp:100
pFlow::rectMeshField::operator()
const INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k) const
Definition: rectMeshField.hpp:138
pFlow::rectMeshField::mesh
const auto & mesh()
Definition: rectMeshField.hpp:120
pFlow::rectMeshField::TypeInfoTemplateNV2
TypeInfoTemplateNV2("rectMeshField", T, memoerySpaceName())
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::fill
void fill(Vector< T, Allocator > &vec, const T &val)
Definition: VectorAlgorithm.hpp:44
pFlow::rectMeshField::operator()
INLINE_FUNCTION_HD T & operator()(int32 i, int32 j, int32 k)
Definition: rectMeshField.hpp:132
pFlow::rectMeshField
Definition: rectMeshField.hpp:31
pFlow::rectMeshField< int32, HostSpace >::memory_space
typename viewType::memory_space memory_space
Definition: rectMeshField.hpp:37
pFlow::word
std::string word
Definition: builtinTypes.hpp:63
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::cells::nx
INLINE_FUNCTION_HD indexType nx() const
Definition: cells.hpp:127
rectangleMesh.hpp
pFlow::rectMeshField::fill
void fill(T val)
Definition: rectMeshField.hpp:143
pFlow::rectMeshField::defaultValue_
T defaultValue_
Definition: rectMeshField.hpp:47
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:31
pFlow::rectMeshField::write
bool write(iOstream &os) const
Definition: rectMeshField.hpp:160
pFlow::rectMeshField::rectMeshField
rectMeshField(const rectangleMesh &mesh, const word &name, const T &defVal)
Definition: rectMeshField.hpp:59
pFlow
Definition: demComponent.hpp:28
pFlow::rectMeshField::rectMeshField
rectMeshField(const rectangleMesh &mesh, const T &defVal)
Definition: rectMeshField.hpp:69
pFlow::rectMeshField::clone
uniquePtr< rectMeshField > clone() const
Definition: rectMeshField.hpp:83
pFlow::rectMeshField::nx
auto nx() const
Definition: rectMeshField.hpp:105
pFlow::rectMeshField::ny
auto ny() const
Definition: rectMeshField.hpp:110
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::rectMeshField::name
const INLINE_FUNCTION_H word & name() const
Definition: rectMeshField.hpp:94
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
pFlow::rectMeshField::read
bool read(iIstream &is)
Definition: rectMeshField.hpp:154
pFlow::rectMeshField::cellVol
INLINE_FUNCTION_HD real cellVol() const
Definition: rectMeshField.hpp:126
pFlow::rectangleMesh::cellVol
INLINE_FUNCTION_HD real cellVol() const
Definition: rectangleMesh.hpp:93
pFlow::rectMeshField::clonePtr
rectMeshField * clonePtr() const
Definition: rectMeshField.hpp:88
pFlow::rectMeshField::nz
auto nz() const
Definition: rectMeshField.hpp:115
pFlow::uniquePtr
Definition: uniquePtr.hpp:44
pFlow::rectMeshField::operator=
rectMeshField & operator=(const rectMeshField &)=default
pFlow::rectMeshField::memoerySpaceName
constexpr static const char * memoerySpaceName()
Definition: rectMeshField.hpp:49
pFlow::rectMeshField::mesh_
const rectangleMesh * mesh_
Definition: rectMeshField.hpp:41
pFlow::rectMeshField::name_
word name_
Definition: rectMeshField.hpp:43
pFlow::cells::ny
INLINE_FUNCTION_HD indexType ny() const
Definition: cells.hpp:133
pFlow::rectMeshField< int32, HostSpace >::viewType
ViewType3D< int32, HostSpace > viewType
Definition: rectMeshField.hpp:35
pFlow::rectMeshField::field_
viewType field_
Definition: rectMeshField.hpp:45
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
baseAlgorithms.hpp
pFlow::rectangleMesh::size
INLINE_FUNCTION_HD int64 size() const
Definition: rectangleMesh.hpp:87
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::range
kPair< int, int > range
Definition: KokkosTypes.hpp:54
pFlow::ViewType3D
Kokkos::View< T ***, properties... > ViewType3D
Definition: KokkosTypes.hpp:68