Skip to content

Commit 51c6f92

Browse files
committed
add box region
1 parent 90a8fff commit 51c6f92

3 files changed

Lines changed: 219 additions & 0 deletions

File tree

src/PostprocessData/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ set(SourceFiles
99
# Regions
1010
region/regionPoints/regionPoints/regionPoints.cpp
1111
region/regionPoints/sphereRegionPoints/sphereRegionPoints.cpp
12+
region/regionPoints/boxRegionPoints/boxRegionPoints.cpp
1213
region/regionPoints/lineRegionPoints/lineRegionPoints.cpp
1314
region/regionPoints/centerPointsRegionPoints/centerPointsRegionPoints.cpp
1415
region/regionPoints/multipleSpheresRegionPoints/multipleSpheresRegionPoints.cpp
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#include "boxRegionPoints.hpp"
2+
#include "fieldsDataBase.hpp"
3+
#include "numericConstants.hpp"
4+
5+
namespace pFlow::postprocessData
6+
{
7+
8+
boxRegionPoints::boxRegionPoints
9+
(
10+
const dictionary &dict,
11+
fieldsDataBase &fieldsDataBase
12+
)
13+
:
14+
regionPoints(dict, fieldsDataBase),
15+
boxRegion_(dict.subDict("boxInfo")),
16+
volume_((boxRegion_.maxPoint().x() - boxRegion_.minPoint().x()) * (boxRegion_.maxPoint().y() - boxRegion_.minPoint().y()) * (boxRegion_.maxPoint().z() - boxRegion_.minPoint().z())),
17+
diameter_(pow(3 * volume_ / 4.0 / Pi, 1.0 / 3.0)),
18+
selectedPoints_("selectedPoints")
19+
{
20+
}
21+
22+
bool boxRegionPoints::update()
23+
{
24+
const auto points = database().updatePoints();
25+
selectedPoints_.clear();
26+
for(uint32 i = 0; i < points.size(); ++i)
27+
{
28+
if( boxRegion_.isInside(points[i]))
29+
{
30+
selectedPoints_.push_back(i);
31+
}
32+
}
33+
34+
return true;
35+
}
36+
37+
bool boxRegionPoints::write(iOstream &os) const
38+
{
39+
os <<"# Single box\n";
40+
os <<"# min point: "<< boxRegion_.minPoint() <<endl;
41+
os <<"# max point: "<< boxRegion_.maxPoint() << endl;
42+
os <<"time"<< tab <<"value"<<endl;
43+
44+
return true;
45+
}
46+
47+
} // End namespace pFlow::postprocessData
Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
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+
/**
22+
* @file boxRegionPoints.hpp
23+
* @brief A class representing a box region for point selection
24+
*
25+
* This class provides functionality to select points within a box region
26+
* and to compute related properties such as volume and equivalent diameter.
27+
* It inherits from regionPoints and implements all required virtual methods.
28+
*
29+
* @see regionPoints
30+
* @see box
31+
* @see fieldsDataBase
32+
*/
33+
34+
#ifndef __boxRegionPoints_hpp__
35+
#define __boxRegionPoints_hpp__
36+
37+
#include "regionPoints.hpp"
38+
#include "box.hpp"
39+
#include "Vectors.hpp"
40+
41+
namespace pFlow::postprocessData
42+
{
43+
44+
class boxRegionPoints
45+
:
46+
public regionPoints
47+
{
48+
private:
49+
50+
/// box object defining the region for point selection
51+
box boxRegion_;
52+
53+
/// Volume of the box region
54+
real volume_;
55+
56+
/// Diameter of the box region
57+
real diameter_;
58+
59+
/// Indices of points that are selected by this region
60+
uint32Vector selectedPoints_;
61+
62+
public:
63+
64+
TypeInfo(box::TYPENAME());
65+
66+
/**
67+
* @brief Construct a box region for point selection
68+
*
69+
* @param dict Dictionary containing boxInfo dictionary
70+
* @param fieldsDataBase Database containing fields data
71+
*/
72+
boxRegionPoints(
73+
const dictionary& dict,
74+
fieldsDataBase& fieldsDataBase);
75+
76+
/// Destructor
77+
~boxRegionPoints() override = default;
78+
79+
/**
80+
* @brief Get the number of regions (always 1 for box)
81+
* @return Always returns 1
82+
*/
83+
uint32 size()const override
84+
{
85+
return 1;
86+
}
87+
88+
/**
89+
* @brief Check if the region is empty
90+
* @return Always returns false
91+
*/
92+
bool empty()const override
93+
{
94+
return false;
95+
}
96+
97+
/**
98+
* @brief Get the volume of the box region
99+
* @return A span containing the volume of the region
100+
*/
101+
span<const real> volumes()const override
102+
{
103+
return span<const real>(&volume_, 1);
104+
}
105+
106+
/**
107+
* @brief Get the equivalent diameter of the box region
108+
* @return A span containing the diameter of the region
109+
*/
110+
span<const real> eqDiameters()const override
111+
{
112+
return span<const real>(&diameter_, 1);
113+
}
114+
115+
/**
116+
* @brief Get the center of the box region
117+
* @return A span containing the center point of the region
118+
*/
119+
span<const realx3> centers()const override
120+
{
121+
realx3 center = 0.5 * (boxRegion_.minPoint() + boxRegion_.maxPoint());
122+
return span<const realx3>(&center, 1);
123+
}
124+
125+
/**
126+
* @brief Get the indices of points within the region (const version)
127+
* @param elem Element index (ignored as there's only one box)
128+
* @return A span containing indices of points within the region
129+
*/
130+
span<const uint32> indices(uint32 elem)const override
131+
{
132+
return span<const uint32>(selectedPoints_.data(), selectedPoints_.size());
133+
}
134+
135+
/**
136+
* @brief Get the indices of points within the region (non-const version)
137+
* @param elem Element index (ignored as there's only one box)
138+
* @return A span containing indices of points within the region
139+
*/
140+
span<uint32> indices(uint32 elem) override
141+
{
142+
return span<uint32>(selectedPoints_.data(), selectedPoints_.size());
143+
}
144+
145+
/**
146+
* @brief Update the points selected by this region
147+
* @return True if update was successful
148+
*/
149+
bool update()override;
150+
151+
/**
152+
* @brief Determine if data should be written to the same time file
153+
* @return Always returns true
154+
*/
155+
bool writeToSameTimeFile()const override
156+
{
157+
return true;
158+
}
159+
160+
/**
161+
* @brief Write region data to output stream
162+
* @param os Output stream to write to
163+
* @return True if write was successful
164+
*/
165+
bool write(iOstream& os)const override;
166+
167+
};
168+
169+
}
170+
171+
#endif // __boxRegionPoints_hpp__

0 commit comments

Comments
 (0)