Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 4C thermo elements to cubitpy #54

Merged
merged 5 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions cubitpy/cubitpy_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,24 @@ class ElementType(Enum):
hex8sh = auto()
hex8_fluid = auto()
tet4_fluid = auto()
hex8_thermo = auto()
tet4_thermo = auto()
hex8_scatra = auto()
tet4_scatra = auto()
quad4 = auto()

def get_cubit_names(self):
"""Get the strings that are needed to mesh and describe this element in
cubit."""

# Get the element type parameters.
if self == self.hex8 or self == self.hex8sh or self == self.hex8_fluid:
if (
self == self.hex8
or self == self.hex8sh
or self == self.hex8_fluid
or self == self.hex8_thermo
or self == self.hex8_scatra
):
cubit_scheme = "Auto"
cubit_element_type = "HEX8"
elif self == self.hex20:
Expand All @@ -144,7 +154,12 @@ def get_cubit_names(self):
elif self == self.hex27:
cubit_scheme = "Auto"
cubit_element_type = "HEX27"
elif self == self.tet4 or self == self.tet4_fluid:
elif (
self == self.tet4
or self == self.tet4_fluid
or self == self.tet4_thermo
or self == self.tet4_scatra
):
cubit_scheme = "Tetmesh"
cubit_element_type = "TETRA4"
elif self == self.tet10:
Expand Down Expand Up @@ -174,6 +189,10 @@ def get_four_c_name(self):
return "SOLID"
elif self == self.hex8_fluid or self == self.tet4_fluid:
return "FLUID"
elif self == self.hex8_thermo or self == self.tet4_thermo:
return "THERMO"
elif self == self.hex8_scatra or self == self.tet4_scatra:
return "TRANSP"
if self == self.quad4:
return "WALL"
else:
Expand All @@ -195,19 +214,34 @@ def get_four_c_section(self):
or self == self.quad4
):
return "STRUCTURE"
elif self == self.hex8_thermo or self == self.tet4_thermo:
return "THERMO"
elif self == self.hex8_scatra or self == self.tet4_scatra:
return "TRANSPORT"
else:
raise ValueError("Got wrong element type {}!".format(self))

def get_four_c_type(self):
"""Get the correct element shape name of this element in 4C."""

if self == self.hex8 or self == self.hex8sh or self == self.hex8_fluid:
if (
self == self.hex8
or self == self.hex8sh
or self == self.hex8_fluid
or self == self.hex8_thermo
or self == self.hex8_scatra
):
return "HEX8"
elif self == self.hex20:
return "HEX20"
elif self == self.hex27:
return "HEX27"
elif self == self.tet4 or self == self.tet4_fluid:
elif (
self == self.tet4
or self == self.tet4_fluid
or self == self.tet4_thermo
or self == self.tet4_scatra
):
return "TET4"
elif self == self.tet10:
return "TET10"
Expand All @@ -231,8 +265,12 @@ def get_default_four_c_description(self):
return "KINEM nonlinear"
elif self == self.hex8sh:
return "KINEM nonlinear EAS none ANS none THICKDIR auto"
elif self == self.hex8_fluid or self.tet4_fluid:
elif self == self.hex8_fluid or self == self.tet4_fluid:
return "NA ALE"
elif self == self.hex8_thermo or self == self.tet4_thermo:
return ""
elif self == self.hex8_scatra or self == self.tet4_scatra:
return ""
else:
raise ValueError("Got wrong element type {}!".format(self))

Expand Down
12 changes: 12 additions & 0 deletions tests/input-files-ref/test_scatra_functionality.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

-------------------------------------------------------NODE COORDS
NODE 1 COORD -5.0000000000000000e-01 -5.0000000000000000e-01 5.0000000000000000e-01
NODE 2 COORD -5.0000000000000000e-01 -5.0000000000000000e-01 -5.0000000000000000e-01
NODE 3 COORD -5.0000000000000000e-01 5.0000000000000000e-01 -5.0000000000000000e-01
NODE 4 COORD -5.0000000000000000e-01 5.0000000000000000e-01 5.0000000000000000e-01
NODE 5 COORD 5.0000000000000000e-01 -5.0000000000000000e-01 5.0000000000000000e-01
NODE 6 COORD 5.0000000000000000e-01 -5.0000000000000000e-01 -5.0000000000000000e-01
NODE 7 COORD 5.0000000000000000e-01 5.0000000000000000e-01 -5.0000000000000000e-01
NODE 8 COORD 5.0000000000000000e-01 5.0000000000000000e-01 5.0000000000000000e-01
------------------------------------------------TRANSPORT ELEMENTS
1 TRANSP HEX8 1 2 3 4 5 6 7 8 MAT 1
12 changes: 12 additions & 0 deletions tests/input-files-ref/test_thermo_functionality.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@

-------------------------------------------------------NODE COORDS
NODE 1 COORD -5.0000000000000000e-01 -5.0000000000000000e-01 5.0000000000000000e-01
NODE 2 COORD -5.0000000000000000e-01 -5.0000000000000000e-01 -5.0000000000000000e-01
NODE 3 COORD -5.0000000000000000e-01 5.0000000000000000e-01 -5.0000000000000000e-01
NODE 4 COORD -5.0000000000000000e-01 5.0000000000000000e-01 5.0000000000000000e-01
NODE 5 COORD 5.0000000000000000e-01 -5.0000000000000000e-01 5.0000000000000000e-01
NODE 6 COORD 5.0000000000000000e-01 -5.0000000000000000e-01 -5.0000000000000000e-01
NODE 7 COORD 5.0000000000000000e-01 5.0000000000000000e-01 -5.0000000000000000e-01
NODE 8 COORD 5.0000000000000000e-01 5.0000000000000000e-01 5.0000000000000000e-01
------------------------------------------------THERMO ELEMENTS
1 THERMO HEX8 1 2 3 4 5 6 7 8 MAT 1
34 changes: 34 additions & 0 deletions tests/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,40 @@ def test_fluid_functionality():
compare(cubit)


def test_thermo_functionality():
"""Test thermo mesh creation."""

cubit = CubitPy()
thermo = create_brick(
cubit,
1,
1,
1,
mesh_interval=[1, 1, 1],
element_type=cupy.element_type.hex8_thermo,
)

# Compare the input file created for 4C.
compare(cubit)


def test_scatra_functionality():
"""Test scatra mesh creation."""

cubit = CubitPy()
thermo = create_brick(
cubit,
1,
1,
1,
mesh_interval=[1, 1, 1],
element_type=cupy.element_type.hex8_scatra,
)

# Compare the input file created for 4C.
compare(cubit)


def test_fsi_functionality():
"""Test fsi and ale conditions and fluid mesh creation."""

Expand Down