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 "cells.hpp"
25 
26 namespace pFlow
27 {
28 
29 
30 
32 :
33  public cells<int32>
34 {
35 
36 public:
37 
38  TypeInfoNV("rectangleMesh");
39 
40 
43 
46  const realx3& minP,
47  const realx3& maxP,
48  int32 nx,
49  int32 ny,
50  int32 nz)
51  :
52  cells(
53  box(minP, maxP),
54  nx, ny, nz)
55  {}
56 
58  rectangleMesh(const dictionary & dict)
59  :
60  cells(
61  box(
62  dict.getVal<realx3>("min"),
63  dict.getVal<realx3>("max")),
64  dict.getVal<int32>("nx"),
65  dict.getVal<int32>("ny"),
66  dict.getVal<int32>("nz")
67  )
68  {}
69 
71  rectangleMesh(const rectangleMesh&) = default;
72 
74  rectangleMesh& operator = (const rectangleMesh&) = default;
75 
77  rectangleMesh(rectangleMesh&&) = default;
78 
81 
83  ~rectangleMesh() = default;
84 
85 
87  int64 size()const
88  {
89  return this->totalCells();
90  }
91 
93  real cellVol()const
94  {
95  auto [dx,dy,dz] = this->cellSize();
96  return dx*dy*dz;
97  }
98 
100  auto minPoint()const
101  {
102  return domain().minPoint();
103  }
104 
106  auto maxPoint()const
107  {
108  return domain().maxPoint();
109  }
110 
111  bool read(iIstream& is)
112  {
113  return true;
114  }
115 
116  bool write(iOstream& os)const
117  {
118  return true;
119  }
120 
121  bool writeToVtk(iOstream& os)const
122  {
123  os<<"DATASET RECTILINEAR_GRID"<<endl;
124  os<<"DIMENSIONS "<<nx()+1<<" "<< ny()+1 << " "<< nz()+1 <<endl;
125 
126  auto [x, y , z] = this->minPoint();
127  auto [dx, dy, dz] = this->cellSize();
128 
129  os<<"X_COORDINATES "<< nx()+1 <<" float\n";
130  for(int32 i=0; i<nx()+1; i++)
131  {
132  os<< x<<"\n";
133  x+= dx;
134  }
135 
136  os<<"Y_COORDINATES "<< ny()+1 <<" float\n";
137  for(int32 j=0; j<ny()+1; j++)
138  {
139  os<< y <<"\n";
140  y+= dy;
141  }
142 
143  os<<"Z_COORDINATES "<< nz()+1 <<" float\n";
144  for(int32 j=0; j<nz()+1; j++)
145  {
146  os<< z <<"\n";
147  z+= dz;
148  }
149 
150  os<<"CELL_DATA "<< nx()*ny()*nz()<<endl;
151 
152  return true;
153  }
154 
155 };
156 
157 
158 
159 }
160 
161 
162 #endif // __rectangleMesh_hpp__
pFlow::cells< int32 >::nz
INLINE_FUNCTION_HD int32 nz() const
Definition: cells.hpp:139
pFlow::real
float real
Definition: builtinTypes.hpp:46
pFlow::rectangleMesh::rectangleMesh
INLINE_FUNCTION_H rectangleMesh(const dictionary &dict)
Definition: rectangleMesh.hpp:58
pFlow::rectangleMesh::operator=
INLINE_FUNCTION_HD rectangleMesh & operator=(const rectangleMesh &)=default
pFlow::rectangleMesh::rectangleMesh
INLINE_FUNCTION_HD rectangleMesh()
Definition: rectangleMesh.hpp:42
pFlow::rectangleMesh::writeToVtk
bool writeToVtk(iOstream &os) const
Definition: rectangleMesh.hpp:121
pFlow::int64
long long int int64
Definition: builtinTypes.hpp:55
pFlow::cells< int32 >::nx
INLINE_FUNCTION_HD int32 nx() const
Definition: cells.hpp:127
pFlow::endl
iOstream & endl(iOstream &os)
Definition: iOstream.hpp:312
pFlow::rectangleMesh::minPoint
INLINE_FUNCTION_H auto minPoint() const
Definition: rectangleMesh.hpp:100
pFlow::rectangleMesh
Definition: rectangleMesh.hpp:31
pFlow
Definition: demComponent.hpp:28
pFlow::rectangleMesh::~rectangleMesh
INLINE_FUNCTION_HD ~rectangleMesh()=default
pFlow::iIstream
Definition: iIstream.hpp:33
pFlow::int32
int int32
Definition: builtinTypes.hpp:53
pFlow::cells< int32 >::domain
const auto & domain() const
Definition: cells.hpp:152
pFlow::rectangleMesh::write
bool write(iOstream &os) const
Definition: rectangleMesh.hpp:116
INLINE_FUNCTION_H
#define INLINE_FUNCTION_H
Definition: pFlowMacros.hpp:53
cells.hpp
pFlow::rectangleMesh::read
bool read(iIstream &is)
Definition: rectangleMesh.hpp:111
pFlow::rectangleMesh::cellVol
INLINE_FUNCTION_HD real cellVol() const
Definition: rectangleMesh.hpp:93
pFlow::rectangleMesh::rectangleMesh
INLINE_FUNCTION_HD rectangleMesh(const realx3 &minP, const realx3 &maxP, int32 nx, int32 ny, int32 nz)
Definition: rectangleMesh.hpp:45
pFlow::rectangleMesh::TypeInfoNV
TypeInfoNV("rectangleMesh")
pFlow::box
Definition: box.hpp:32
pFlow::cells< int32 >::ny
INLINE_FUNCTION_HD int32 ny() const
Definition: cells.hpp:133
pFlow::cells< int32 >::cellSize
INLINE_FUNCTION_HD realx3 cellSize() const
Definition: cells.hpp:115
pFlow::cells
Definition: cells.hpp:32
INLINE_FUNCTION_HD
#define INLINE_FUNCTION_HD
Definition: pFlowMacros.hpp:51
pFlow::triple< real >
pFlow::cells< int32 >::totalCells
INLINE_FUNCTION_HD int64 totalCells() const
Definition: cells.hpp:145
pFlow::rectangleMesh::size
INLINE_FUNCTION_HD int64 size() const
Definition: rectangleMesh.hpp:87
pFlow::iOstream
Definition: iOstream.hpp:53
pFlow::dictionary
Definition: dictionary.hpp:38
pFlow::rectangleMesh::maxPoint
INLINE_FUNCTION_H auto maxPoint() const
Definition: rectangleMesh.hpp:106