Skip to content

Commit a0f5ddb

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents c4d0639 + 42aa07f commit a0f5ddb

File tree

15 files changed

+403
-20
lines changed

15 files changed

+403
-20
lines changed

.github/workflows/build_and_pypi.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- run: pip install -U pip pipenv coverage
1515
- run: pip install -U numpy scipy matplotlib
1616
- name: Check out repository code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- run: set -o pipefail
1919
- name: Build and install fluidfoam
2020
run: |
@@ -38,8 +38,8 @@ jobs:
3838
if: startsWith(github.event.ref, 'refs/tags')
3939
steps:
4040
- name: Check out repository code
41-
uses: actions/checkout@v2
42-
- uses: actions/setup-python@v2
41+
uses: actions/checkout@v4
42+
- uses: actions/setup-python@v5
4343
- name: Deploy package
4444
uses: casperdcl/deploy-pypi@v2
4545
with:

.github/workflows/build_and_test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- run: pip install -U pip pipenv coverage
1515
- run: pip install -U numpy scipy matplotlib
1616
- name: Check out repository code
17-
uses: actions/checkout@v2
17+
uses: actions/checkout@v4
1818
- run: set -o pipefail
1919
- name: Build and install fluidfoam
2020
run: |

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ What is this repository for?
2626
----------------------------
2727

2828
* Openfoam Tools
29-
* Version : 0.2.7
30-
* Supported OpenFoam Versions : 2.4.0, 4.1 to 9, v1712plus to v2312plus
29+
* Version : 0.2.8
30+
* Supported OpenFoam Versions : 2.4.0, 4.1 to 9, v1712plus to v2406plus
3131
* Supported Python Versions : >= 3.8
3232

3333
Documentation and Examples

doc/index.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ What is this repository for?
1313
----------------------------
1414

1515
* Openfoam Tools
16-
* Version : 0.2.7
17-
* Supported OpenFoam Versions : 2.4.0, 4.1 to 9, v1712plus to v2312plus
16+
* Version : 0.2.8
17+
* Supported OpenFoam Versions : 2.4.0, 4.1 to 9, v1712plus to v2406plus
1818
* Supported Python Versions : >= 3.8
1919

2020
Deployment instructions

fluidfoam/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@
1111
'a' or 'alpha' means alpha version (internal testing),
1212
'b' or 'beta' means beta version (external testing).
1313
"""
14-
__version__ = "0.2.7"
14+
__version__ = "0.2.8"

fluidfoam/readof.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ def _parse_session(self, title):
205205
elif level == 2:
206206
if previous_line not in dict_session:
207207
dict_session[previous_line] = {}
208-
dict_session[previous_line][tmp[0]] = tmp[1]
208+
try:
209+
dict_session[previous_line][tmp[0]] = tmp[1]
210+
except TypeError:
211+
pass
209212
if level == 0:
210213
break
211214
previous_line = line
@@ -214,10 +217,26 @@ def _parse_session(self, title):
214217

215218
def _parse_data(self, boundary, datatype, precision=15):
216219

220+
import sys
217221
if boundary is not None:
218222
boun = str.encode(boundary)
219-
if b"value" in self.content.split(boun)[1].split(b"}")[0]:
220-
data = self.content.split(boun)[1].split(b"value")[1]
223+
if (np.size(self.content.split(boun))<=2):
224+
iboun =1
225+
else:
226+
lines = self.content.split(b"\n")
227+
iboun = 0
228+
for line in lines:
229+
if boun in line.strip():
230+
iboun += 1
231+
if boun == line.strip():
232+
break
233+
234+
if iboun >= np.size(self.content.split(boun)):
235+
print(R+"Error : No boundary/patch "+str(boun)+W)
236+
sys.exit(1)
237+
238+
elif b"value" in self.content.split(boun)[iboun].split(b"}")[0]:
239+
data = self.content.split(boun)[iboun].split(b"value")[1]
221240
else:
222241
if self.verbose:
223242
print(R+"Warning : No data on boundary/patch")
@@ -511,8 +530,8 @@ def _parse_points(self, precision):
511530
continue
512531
break
513532
self.nb_pts = int(line)
514-
data = self.content.split(line, 1)[1]
515-
533+
data = self.content.split(b'}', 1)[1]
534+
data = data.split(line, 1)[1]
516535
self.type_data = self.header[b"class"]
517536

518537
if not self.is_ascii:
@@ -552,8 +571,21 @@ def _parse_owner(self):
552571
except ValueError:
553572
continue
554573
break
555-
self.nb_faces = int(line)
556-
data = self.content.split(line, 2)[-1]
574+
try:
575+
self.nb_faces = int(line)
576+
data = self.content.split(line, 2)[-1]
577+
# for mesh with number of cells <= 10
578+
except ValueError:
579+
for line in self.lines_stripped:
580+
try:
581+
line.split(b"(")
582+
int(line.split(b"(")[0])
583+
break
584+
except ValueError or TypeError:
585+
continue
586+
break
587+
self.nb_faces = int(line.split(b"(")[0])
588+
data = b"\n(" + line.split(b"(", 2)[-1]
557589

558590
self.type_data = self.header[b"class"]
559591

fluidfoam/readpostpro.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def readforce(path, namepatch="forces", time_name="0", name="forces"):
4949
path_namepatch = path+namepatch
5050
else:
5151
path_namepatch = path+'/postProcessing/'+namepatch
52-
if time_name is "latestTime":
52+
if time_name == "latestTime":
5353
time_name = _find_latesttime(path_namepatch)
54-
elif time_name is "mergeTime":
54+
elif time_name == "mergeTime":
5555
time_list = []
5656
dir_list = os.listdir(path_namepatch)
5757
for directory in dir_list:
@@ -135,9 +135,9 @@ def readprobes(path, probes_name="probes", time_name="0", name="U"):
135135
path_probes_name = path+probes_name
136136
else:
137137
path_probes_name = path+'/postProcessing/'+probes_name
138-
if time_name is "latestTime":
138+
if time_name == "latestTime":
139139
time_name = _find_latesttime(path_probes_name)
140-
elif time_name is "mergeTime":
140+
elif time_name == "mergeTime":
141141
time_list = []
142142
dir_list = os.listdir(path_probes_name)
143143
for directory in dir_list:

fluidfoam/test_read.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def _test_functions(
6565
alphauniform = readscalar("output_samples/ascii", "0", "alphauniform")
6666
readvector("output_samples/ascii", "0", "Uuniform")
6767
alphauniform = readscalar("output_samples/bin", "0", "alphauniform")
68+
x, y, z = readmesh("output_samples/ascii/vsmall")
6869
x, y, z = readmesh("output_samples/ascii", boundary="bottom")
6970
x, y, z = readmesh("output_samples/ascii", sets="testSet")
7071
x, y, z = readmesh("output_samples/bin", boundary="bottom")
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
| ========= | |
3+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4+
| \\ / O peration | Version: 2406 |
5+
| \\ / A nd | Website: www.openfoam.com |
6+
| \\/ M anipulation | |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
arch "LSB;label=32;scalar=64";
13+
class polyBoundaryMesh;
14+
location "constant/polyMesh";
15+
object boundary;
16+
}
17+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
18+
19+
5
20+
(
21+
inlet
22+
{
23+
type cyclic;
24+
inGroups 1(cyclic);
25+
nFaces 10;
26+
startFace 9;
27+
matchTolerance 0.0001;
28+
transform unknown;
29+
neighbourPatch outlet;
30+
}
31+
outlet
32+
{
33+
type cyclic;
34+
inGroups 1(cyclic);
35+
nFaces 10;
36+
startFace 19;
37+
matchTolerance 0.0001;
38+
transform unknown;
39+
neighbourPatch inlet;
40+
}
41+
top
42+
{
43+
type wall;
44+
inGroups 1(wall);
45+
nFaces 1;
46+
startFace 29;
47+
}
48+
bottom
49+
{
50+
type wall;
51+
inGroups 1(wall);
52+
nFaces 1;
53+
startFace 30;
54+
}
55+
frontAndBackPlanes
56+
{
57+
type empty;
58+
inGroups 1(empty);
59+
nFaces 20;
60+
startFace 31;
61+
}
62+
)
63+
64+
// ************************************************************************* //
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*--------------------------------*- C++ -*----------------------------------*\
2+
| ========= | |
3+
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
4+
| \\ / O peration | Version: 2406 |
5+
| \\ / A nd | Website: www.openfoam.com |
6+
| \\/ M anipulation | |
7+
\*---------------------------------------------------------------------------*/
8+
FoamFile
9+
{
10+
version 2.0;
11+
format ascii;
12+
arch "LSB;label=32;scalar=64";
13+
class regIOobject;
14+
location "constant/polyMesh";
15+
object cellZones;
16+
}
17+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
18+
19+
0()
20+
21+
// ************************************************************************* //

0 commit comments

Comments
 (0)