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

rectangleMesh.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 __rectangleMesh_hpp__
#define __rectangleMesh_hpp__
#include "types.hpp"
#include "error.hpp"
#include "box.hpp"
#include "IOobject.hpp"
class repository;
namespace pFlow
{
class rectangleMesh
:
public IOobject
{
private:
box meshBox_;
int32x3 numCells_;
realx3 dx_;
public:
TypeInfo("rectangleMesh");
rectangleMesh(
const box& mshBox,
int32 nx,
int32 ny,
int32 nz,
repository* rep);
rectangleMesh(const dictionary & dict, repository* rep);
rectangleMesh(const rectangleMesh&) = default;
rectangleMesh& operator = (const rectangleMesh&) = default;
rectangleMesh(rectangleMesh&&) = default;
rectangleMesh& operator = (rectangleMesh&&) = default;
~rectangleMesh() override = default;
int64 size()const
{
return numCells_.x_*numCells_.y_*numCells_.z_;
}
int32 nx()const
{
return numCells_.x();
}
int32 ny()const
{
return numCells_.y();
}
int32 nz()const
{
return numCells_.z();
}
real cellVol()const
{
return dx_.x_*dx_.y_*dx_.z_;
}
realx3 minPoint()const
{
return meshBox_.minPoint();
}
realx3 maxPoint()const
{
return meshBox_.maxPoint();
}
inline
bool isInsideIndex(const realx3 p, int32x3 & ind )const
{
if(meshBox_.isInside(p))
{
ind = (p - meshBox_.minPoint())/dx_ ;
return true;
}
else
{
return false;
}
}
bool write(iOstream& is, const IOPattern& iop)const override
{
notImplementedFunction;
return true;
}
bool read(iIstream& is, const IOPattern& iop) override
{
notImplementedFunction;
return true;
}
bool writeToVtk(iOstream& os)const
{
os<<"DATASET RECTILINEAR_GRID"<<endl;
os<<"DIMENSIONS "<<nx()+1<<" "<< ny()+1 << " "<< nz()+1 <<endl;
auto [x, y , z] = this->minPoint();
auto [dx, dy, dz] = dx_;
os<<"X_COORDINATES "<< nx()+1 <<" float\n";
for(int32 i=0; i<nx()+1; i++)
{
os<< x<<"\n";
x+= dx;
}
os<<"Y_COORDINATES "<< ny()+1 <<" float\n";
for(int32 j=0; j<ny()+1; j++)
{
os<< y <<"\n";
y+= dy;
}
os<<"Z_COORDINATES "<< nz()+1 <<" float\n";
for(int32 j=0; j<nz()+1; j++)
{
os<< z <<"\n";
z+= dz;
}
os<<"CELL_DATA "<< nx()*ny()*nz()<<endl;
return true;
}
};
}
#endif // __rectangleMesh_hpp__
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::rectangleMesh::cellVol
real cellVol() const
Definition: rectangleMesh.hpp:92
pFlow::rectangleMesh::minPoint
realx3 minPoint() const
Definition: rectangleMesh.hpp:97
pFlow::real
float real
Definition: builtinTypes.hpp:45
pFlow::rectangleMesh::ny
int32 ny() const
Definition: rectangleMesh.hpp:82
IOobject.hpp
types.hpp
pFlow::rectangleMesh::writeToVtk
bool writeToVtk(iOstream &os) const
Definition: rectangleMesh.hpp:133
box.hpp
pFlow::rectangleMesh::rectangleMesh
rectangleMesh(const box &mshBox, int32 nx, int32 ny, int32 nz, repository *rep)
Definition: rectangleMesh.cpp:5
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:52
pFlow::rectangleMesh::meshBox_
box meshBox_
Definition: rectangleMesh.hpp:40
pFlow::rectangleMesh::numCells_
int32x3 numCells_
Definition: rectangleMesh.hpp:42
pFlow::endl
iOstream & endl(iOstream &os)
Add newline and flush stream.
Definition: iOstream.hpp:341
pFlow::box::maxPoint
const INLINE_FUNCTION_HD realx3 & maxPoint() const
Definition: box.hpp:97
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:34
pFlow::triple::y
INLINE_FUNCTION_HD T & y()
access component
Definition: triple.hpp:144
pFlow
Definition: demGeometry.hpp:27
pFlow::rectangleMesh::maxPoint
realx3 maxPoint() const
Definition: rectangleMesh.hpp:102
pFlow::IOobject
Definition: IOobject.hpp:35
pFlow::rectangleMesh::isInsideIndex
bool isInsideIndex(const realx3 p, int32x3 &ind) const
Definition: rectangleMesh.hpp:108
pFlow::iIstream
Interface class for any input stream
Definition: iIstream.hpp:37
pFlow::rectangleMesh::write
bool write(iOstream &is, const IOPattern &iop) const override
Definition: rectangleMesh.hpp:121
pFlow::int32
int int32
Definition: builtinTypes.hpp:50
pFlow::IOPattern
Definition: IOPattern.hpp:32
pFlow::rectangleMesh::nz
int32 nz() const
Definition: rectangleMesh.hpp:87
pFlow::rectangleMesh::~rectangleMesh
~rectangleMesh() override=default
pFlow::triple::x_
T x_
data members
Definition: triple.hpp:49
pFlow::triple::z
INLINE_FUNCTION_HD T & z()
access component
Definition: triple.hpp:156
pFlow::triple::y_
T y_
Definition: triple.hpp:50
pFlow::triple::z_
T z_
Definition: triple.hpp:51
pFlow::box::minPoint
const INLINE_FUNCTION_HD realx3 & minPoint() const
Definition: box.hpp:91
pFlow::box
Definition: box.hpp:32
pFlow::rectangleMesh::operator=
rectangleMesh & operator=(const rectangleMesh &)=default
pFlow::repository
Definition: repository.hpp:34
pFlow::rectangleMesh::dx_
realx3 dx_
Definition: rectangleMesh.hpp:44
pFlow::triple::x
INLINE_FUNCTION_HD T & x()
access component
Definition: triple.hpp:132
pFlow::triple< int32 >
pFlow::box::isInside
INLINE_FUNCTION_HD bool isInside(const realx3 &point) const
Definition: box.hpp:84
pFlow::rectangleMesh::TypeInfo
TypeInfo("rectangleMesh")
pFlow::iOstream
Interface class for any output stream.
Definition: iOstream.hpp:59
pFlow::rectangleMesh::read
bool read(iIstream &is, const IOPattern &iop) override
Definition: rectangleMesh.hpp:127
pFlow::dictionary
Dictionary holds a set of data entries or sub-dictionaries that are enclosed in a curely braces or ar...
Definition: dictionary.hpp:67
error.hpp
pFlow::rectangleMesh::nx
int32 nx() const
Definition: rectangleMesh.hpp:77