Skip to content

Commit be1833c

Browse files
authored
Merge pull request #52 from nasa/pointwise
Pointwise
2 parents 6dbdadd + 412ade1 commit be1833c

24 files changed

+118085
-113
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ python/mesh.pickle
1212
python/examples/WELD/weld_ascii.bxyz
1313
python/connectivity.pickle
1414
python/connectivity_2x2x2.pickle
15+
python/examples/pointwise/saved_state.pickle

python/examples/glennht/ali_cmc_test.py

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from plot3d.glennht.export_functions import export_to_glennht_conn, export_to_boundary_condition, export_to_job_file
22
from plot3d.glennht.class_definitions import *
3-
from plot3d.gridpro import read_gridpro_to_blocks, read_gridpro_connectivity
3+
from plot3d.gridpro import read_gridpro_to_blocks, read_gridpro_connectivity, bc_faces_by_type
44
import glob
55
import os.path as osp
66
from plot3d import translational_periodicity, write_plot3D, write_ddcmp,partition_from_face_matches
@@ -23,11 +23,31 @@
2323
# Grid Grid Pro to Blocks
2424
blocks = read_gridpro_to_blocks(gridpro_file)
2525
connectivity = read_gridpro_connectivity(connectivity_file)
26-
outer_faces = connectivity['bc_group']['symm_slip'] # type: ignore
26+
outer_faces = bc_faces_by_type(connectivity['bc_group'], 'symm_slip')
2727

2828
# Add Translational Periodicity: symmetric slip faces should be periodic to each other now.
2929
z_periodic_faces_export, periodic_faces, outer_faces = translational_periodicity(blocks,outer_faces,translational_direction='z') # type: ignore
30-
connectivity['bc_group']['symm_slip'] = outer_faces # type: ignore # Add unmatched faces to symmetric slip
30+
# Replace existing slip groups with the updated periodic faces so we avoid duplicates
31+
slip_keys = []
32+
for name, entry in connectivity['bc_group'].items():
33+
if isinstance(entry, dict):
34+
entry_type = (entry.get('type') or '').lower()
35+
entry_faces = entry.get('faces', []) or []
36+
else:
37+
entry_faces = entry
38+
entry_type = ''
39+
if not entry_type and entry_faces:
40+
ftype = entry_faces[0].get('bc_type')
41+
entry_type = ftype.lower() if isinstance(ftype, str) else ''
42+
if entry_type == 'symm_slip':
43+
slip_keys.append(name)
44+
for key in slip_keys:
45+
del connectivity['bc_group'][key]
46+
connectivity['bc_group']['symm_slip'] = {
47+
'type': 'symm_slip',
48+
'pty_ids': [],
49+
'faces': outer_faces,
50+
}
3151

3252
# Write connectivity.json for debugging purposes
3353
with open(osp.join(folder,"connectivity.json"), "w") as json_file:
@@ -41,19 +61,19 @@
4161

4262
# Define the boundary conditions
4363
inlets = []
44-
for i,inlet in enumerate(connectivity['bc_group']['inlet']): # type: ignore
64+
for i,inlet in enumerate(bc_faces_by_type(connectivity['bc_group'], 'inlet')):
4565
inlets.append(InletBC(
4666
BCType=BoundaryConditionType.Inlet, SurfaceID=inlet['id'], Name=f"Inlet-{i}",
4767
P0_const=60.0, P0_const_unit="bar", T0_const=300.0, inlet_subType=inlet['id'],
4868
)) # Use absolute conditions, code will automatically normalize
4969
outlets = []
50-
for i,outlet in enumerate(connectivity['bc_group']['outlet']): # type: ignore
70+
for i,outlet in enumerate(bc_faces_by_type(connectivity['bc_group'], 'outlet')):
5171
outlets.append(OutletBC(
5272
BCType=BoundaryConditionType.Outlet, SurfaceID=outlet['id'], Name=f"Outlet-{i}",
5373
Pback_const=1.0, Pback_const_unit="bar", outlet_subType=outlet['id']
5474
)) # Use absolute conditions, code will automatically normalize
5575
walls = []
56-
for i,wall in enumerate(connectivity['bc_group']['wall']): # type: ignore
76+
for i,wall in enumerate(bc_faces_by_type(connectivity['bc_group'], 'wall')):
5777
walls.append(WallBC(
5878
BCType=BoundaryConditionType.Wall, SurfaceID=wall['id'], Name=f"Wall-{i}", wall_subType=wall['id']
5979
))
@@ -68,8 +88,9 @@
6888
job.ReferenceCondFull.reflen = 5.119 # inches, used to calculate the reynolds number should be same scale as mesh
6989

7090
outer_faces = []
71-
for k,v in connectivity['bc_group'].items():
72-
outer_faces.extend(v) # Export GlennHT connectivity file
91+
for entry in connectivity['bc_group'].values():
92+
faces = entry.get('faces', []) if isinstance(entry, dict) else entry
93+
outer_faces.extend(faces) # Export GlennHT connectivity file
7394
export_to_glennht_conn(connectivity['face_matches'], outer_faces, osp.join(folder, job.JobFiles.ConnFILE),connectivity['gif_faces'],connectivity['volume_zones']) # type: ignore
7495

7596
# Export GlennHT boundary conditions file
@@ -91,4 +112,4 @@
91112

92113
# Export the plot3d
93114
write_plot3D(osp.join(folder,job.JobFiles.GridFile),blocks,binary=False)
94-
115+

python/examples/glennht/pv_plot_bcs.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pv_library import Load, ExtractBlocks, CreateSubset, plot_faces_for_block
1414
from paraview.simple import *
1515
import random
16+
from plot3d.gridpro import bc_faces_by_type
1617

1718

1819
plot_face_matches = False
@@ -27,10 +28,10 @@
2728
volume_zones = data['volume_zones']
2829

2930
# Boundary Conditions
30-
inlets = data['bc_group']['inlet']
31-
outlets = data['bc_group']['outlet']
32-
symm_slip = data['bc_group']['symm_slip']
33-
walls = data['bc_group']['wall']
31+
inlets = bc_faces_by_type(data['bc_group'], 'inlet')
32+
outlets = bc_faces_by_type(data['bc_group'], 'outlet')
33+
symm_slip = bc_faces_by_type(data['bc_group'], 'symm_slip')
34+
walls = bc_faces_by_type(data['bc_group'], 'wall')
3435

3536
blocks_to_extract = [f['block1']['block_index'] for f in periodic_faces]
3637
blocks_to_extract.extend([f['block2']['block_index'] for f in periodic_faces])
@@ -84,4 +85,4 @@
8485
plot_faces_for_block(block_source,b,symm_slip,"symm_slip",rgb_symm_slip) # type: ignore
8586
plot_faces_for_block(block_source,b,outer_faces,"outer_faces",rgb_outer_faces) # type: ignore
8687

87-
88+

python/examples/glennht/pv_plot_facematch.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pv_library import Load, ExtractBlocks, CreateSubset, plot_face_matches_for_block
1414
from paraview.simple import *
1515
import random
16+
from plot3d.gridpro import bc_faces_by_type
1617

1718

1819
plot_face_matches = False
@@ -27,10 +28,10 @@
2728
volume_zones = data['volume_zones']
2829

2930
# Boundary Conditions
30-
inlets = data['bc_group']['inlet']
31-
outlets = data['bc_group']['outlet']
32-
symm_slip = data['bc_group']['symm_slip']
33-
walls = data['bc_group']['wall']
31+
inlets = bc_faces_by_type(data['bc_group'], 'inlet')
32+
outlets = bc_faces_by_type(data['bc_group'], 'outlet')
33+
symm_slip = bc_faces_by_type(data['bc_group'], 'symm_slip')
34+
walls = bc_faces_by_type(data['bc_group'], 'wall')
3435

3536
blocks_to_extract = [f['block1']['block_index'] for f in periodic_faces]
3637
blocks_to_extract.extend([f['block2']['block_index'] for f in periodic_faces])
@@ -66,4 +67,4 @@
6667

6768
plot_face_matches_for_block(block_source,b,face_matches,"face_match",rgb_facematch)
6869

69-
70+

python/examples/glennht/pv_plot_periodicity.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from pv_library import Load, ExtractBlocks, CreateSubset, plot_face_matches_for_block
1414
from paraview.simple import *
1515
import random
16+
from plot3d.gridpro import bc_faces_by_type
1617

1718

1819
plot_face_matches = False
@@ -27,10 +28,10 @@
2728
volume_zones = data['volume_zones']
2829

2930
# Boundary Conditions
30-
inlets = data['bc_group']['inlet']
31-
outlets = data['bc_group']['outlet']
32-
symm_slip = data['bc_group']['symm_slip']
33-
walls = data['bc_group']['wall']
31+
inlets = bc_faces_by_type(data['bc_group'], 'inlet')
32+
outlets = bc_faces_by_type(data['bc_group'], 'outlet')
33+
symm_slip = bc_faces_by_type(data['bc_group'], 'symm_slip')
34+
walls = bc_faces_by_type(data['bc_group'], 'wall')
3435

3536
blocks_to_extract = [f['block1']['block_index'] for f in periodic_faces]
3637
blocks_to_extract.extend([f['block2']['block_index'] for f in periodic_faces])
@@ -66,4 +67,4 @@
6667

6768
plot_face_matches_for_block(block_source,b,periodic_faces,"periodic-z",rgb_periodic)
6869

69-
70+
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
&BSurf_Spec
2+
BSurfID=1005, BCType=1, BSurfName='Inlet'
3+
&END
4+
5+
&BSurf_Spec
6+
BSurfID=1015, BCType=1, BSurfName='Pressure Plenum Inlet'
7+
&END
8+
9+
&BSurf_Spec
10+
BSurfID=1016, BCType=1, BSurfName='Cavity Inflow'
11+
&END
12+
13+
&BSurf_Spec
14+
BSurfID=1017, BCType=1, BSurfName='Suction Plenum Inlet'
15+
&END
16+
17+
&BSurf_Spec
18+
BSurfID=1006, BCType=2, BSurfName='Outlet'
19+
&END
20+
21+
&BSurf_Spec
22+
BSurfID=1008, BCType=4, BSurfName='Downstream Cavity'
23+
&END
24+
25+
&BSurf_Spec
26+
BSurfID=1007, BCType=4, BSurfName='Downstream Cavity'
27+
&END
28+
29+
&BSurf_Spec
30+
BSurfID=2008, BCType=4, BSurfName='Pressure Plenum Back'
31+
&END
32+
33+
&BSurf_Spec
34+
BSurfID=2007, BCType=4, BSurfName='Casing'
35+
&END
36+
37+
&BSurf_Spec
38+
BSurfID=3008, BCType=4, BSurfName='Blade'
39+
&END
40+
41+
&BSurf_Spec
42+
BSurfID=4008, BCType=4, BSurfName='Blade Top'
43+
&END
44+
45+
&BSurf_Spec
46+
BSurfID=5008, BCType=4, BSurfName='Downstream Hub'
47+
&END
48+
49+
&BSurf_Spec
50+
BSurfID=3007, BCType=4, BSurfName='Upstream Hub'
51+
&END
52+
53+
&BSurf_Spec
54+
BSurfID=4007, BCType=4, BSurfName='Upstream Cavity A'
55+
&END
56+
57+
&BSurf_Spec
58+
BSurfID=5007, BCType=4, BSurfName='Upstream Cavity B'
59+
&END
60+
61+
&VZConditions
62+
VZid=0, VZtype=1, OmegaVZ=0., VZMaterialName=Air,
63+
Fluid_Tref_prop=0., Fluid_k_Tref=285., Fluid_amu_Tref=285., Fluid_expnt=.7,UseDryAir=.TRUE.,
64+
!Fluid_cp=1002., Fluid_Pr=.7, Fluid_MW=28.964
65+
&END
66+
67+
&INLET_BC
68+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., inlet_subType=1005, inlet_ref_Mach_Nr=0.2, T0_const=1.0, P0_const=1.0, annular_inlet=.FALSE., have_inlet_prof=.FALSE.
69+
&END
70+
71+
&INLET_BC
72+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., inlet_subType=1015, inlet_ref_Mach_Nr=0.2, T0_const=1.0, P0_const=1.0, annular_inlet=.FALSE., have_inlet_prof=.FALSE.
73+
&END
74+
75+
&INLET_BC
76+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., inlet_subType=1016, inlet_ref_Mach_Nr=0.2, T0_const=1.0, P0_const=1.0, annular_inlet=.FALSE., have_inlet_prof=.FALSE.
77+
&END
78+
79+
&INLET_BC
80+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., inlet_subType=1017, inlet_ref_Mach_Nr=0.2, T0_const=1.0, P0_const=1.0, annular_inlet=.FALSE., have_inlet_prof=.FALSE.
81+
&END
82+
83+
&OUTLET_BC
84+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., outlet_subType=1006, Pback_extrapolate_profile=.FALSE., Pback_const=0.016666666666666666, have_Pback_prof=.FALSE., annular_outlet=.FALSE.
85+
&END
86+
87+
&WALL_BC
88+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=1008, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
89+
&END
90+
91+
&WALL_BC
92+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=1007, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
93+
&END
94+
95+
&WALL_BC
96+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=2008, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
97+
&END
98+
99+
&WALL_BC
100+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=2007, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
101+
&END
102+
103+
&WALL_BC
104+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=3008, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
105+
&END
106+
107+
&WALL_BC
108+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=4008, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
109+
&END
110+
111+
&WALL_BC
112+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=5008, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
113+
&END
114+
115+
&WALL_BC
116+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=3007, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
117+
&END
118+
119+
&WALL_BC
120+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=4007, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
121+
&END
122+
123+
&WALL_BC
124+
IsPostProcessing=.FALSE., IsCalculateMassFlow=.FALSE., ToggleProcessSurface=.FALSE., wall_subType=5007, have_Twall_prof=.FALSE., Qwall_const=0.0, have_Qwall_prof=.FALSE., BEM_coupled_surf=.FALSE.
125+
&END
126+

0 commit comments

Comments
 (0)