www.cemf.ir
rectangleMesh.hpp
Go to the documentation of this file.
1 /*------------------------------- phasicFlow ---------------------------------
2  O C enter of
3  O O E ngineering and
4  O O M ultiscale modeling of
5  OOOOOOO F luid flow
6 ------------------------------------------------------------------------------
7  Copyright (C): www.cemf.ir
8  email: hamid.r.norouzi AT gmail.com
9 ------------------------------------------------------------------------------
10 Licence:
11  This file is part of phasicFlow code. It is a free software for simulating
12  granular and multiphase flows. You can redistribute it and/or modify it under
13  the terms of GNU General Public License v3 or any other later versions.
14 
15  phasicFlow is distributed to help others in their research in the field of
16  granular and multiphase flows, but WITHOUT ANY WARRANTY; without even the
17  implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 
19 -----------------------------------------------------------------------------*/
20 
21 #ifndef __rectangleMesh_hpp__
22 #define __rectangleMesh_hpp__
23 
24 #include "types.hpp"
25 #include "error.hpp"
26 #include "box.hpp"
27 #include "IOobject.hpp"
28 
29 class repository;
30 
31 namespace pFlow
32 {
33 
35 :
36  public IOobject
37 {
38 private:
39 
41 
43 
45 
46 public:
47 
48  TypeInfo("rectangleMesh");
49 
51  const box& mshBox,
52  int32 nx,
53  int32 ny,
54  int32 nz,
55  repository* rep);
56 
57  rectangleMesh(const dictionary & dict, repository* rep);
58 
59 
60  rectangleMesh(const rectangleMesh&) = default;
61 
62 
63  rectangleMesh& operator = (const rectangleMesh&) = default;
64 
65  rectangleMesh(rectangleMesh&&) = default;
66 
67 
69 
70  ~rectangleMesh() override = default;
71 
72  int64 size()const
73  {
75  }
76 
77  int32 nx()const
78  {
79  return numCells_.x();
80  }
81 
82  int32 ny()const
83  {
84  return numCells_.y();
85  }
86 
87  int32 nz()const
88  {
89  return numCells_.z();
90  }
91 
92  real cellVol()const
93  {
94  return dx_.x_*dx_.y_*dx_.z_;
95  }
96 
98  {
99  return meshBox_.minPoint();
100  }
101 
103  {
104  return meshBox_.maxPoint();
105  }
106 
107  inline
108  bool isInsideIndex(const realx3 p, int32x3 & ind )const
109  {
110  if(meshBox_.isInside(p))
111  {
112  ind = (p - meshBox_.minPoint())/dx_ ;
113  return true;
114  }
115  else
116  {
117  return false;
118  }
119  }
120 
121  bool write(iOstream& is, const IOPattern& iop)const override
122  {
124  return true;
125  }
126 
127  bool read(iIstream& is, const IOPattern& iop) override
128  {
130  return true;
131  }
132 
133  bool writeToVtk(iOstream& os)const
134  {
135  os<<"DATASET RECTILINEAR_GRID"<<endl;
136  os<<"DIMENSIONS "<<nx()+1<<" "<< ny()+1 << " "<< nz()+1 <<endl;
137 
138  auto [x, y , z] = this->minPoint();
139  auto [dx, dy, dz] = dx_;
140 
141  os<<"X_COORDINATES "<< nx()+1 <<" float\n";
142  for(int32 i=0; i<nx()+1; i++)
143  {
144  os<< x<<"\n";
145  x+= dx;
146  }
147 
148  os<<"Y_COORDINATES "<< ny()+1 <<" float\n";
149  for(int32 j=0; j<ny()+1; j++)
150  {
151  os<< y <<"\n";
152  y+= dy;
153  }
154 
155  os<<"Z_COORDINATES "<< nz()+1 <<" float\n";
156  for(int32 j=0; j<nz()+1; j++)
157  {
158  os<< z <<"\n";
159  z+= dz;
160  }
161 
162  os<<"CELL_DATA "<< nx()*ny()*nz()<<endl;
163 
164  return true;
165  }
166 
167 };
168 
169 
170 
171 }
172 
173 
174 #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