Skip to content

Commit

Permalink
Test added
Browse files Browse the repository at this point in the history
  • Loading branch information
GBenedett committed Nov 30, 2023
1 parent 1ad541f commit 4994432
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 59 deletions.
14 changes: 9 additions & 5 deletions ceasiompy/CPACS2GMSH/func/mesh_sizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,11 @@ def fuselage_size(cpacs_path):
prev_pos_x = pos_x_list[index_prev]
prev_pos_y = pos_y_list[index_prev]
prev_pos_z = pos_z_list[index_prev]
pos_x_list[j_pos] += prev_pos_x
pos_y_list[j_pos] += prev_pos_y
pos_z_list[j_pos] += prev_pos_z

if j_pos < len(pos_y_list):
pos_x_list[j_pos] += prev_pos_x
pos_y_list[j_pos] += prev_pos_y
pos_z_list[j_pos] += prev_pos_z

else:
log.error('No "positionings" have been found!')
Expand Down Expand Up @@ -142,8 +144,10 @@ def fuselage_size(cpacs_path):
prof_vect_y[:] = [y - 1 - prof_min_y for y in prof_vect_y]
prof_vect_z[:] = [z - 1 - prof_min_z for z in prof_vect_z]

pos_y_list[i_sec] += ((1 + prof_min_y) * prof_size_y) * elem_transf.scaling.y
pos_z_list[i_sec] += ((1 + prof_min_z) * prof_size_z) * elem_transf.scaling.z
if i_sec < len(pos_y_list):
pos_y_list[i_sec] += ((1 + prof_min_y) * prof_size_y) * elem_transf.scaling.y
if i_sec < len(pos_z_list):
pos_z_list[i_sec] += ((1 + prof_min_z) * prof_size_z) * elem_transf.scaling.z

body_frm_height = (
prof_size_z
Expand Down
26 changes: 17 additions & 9 deletions ceasiompy/CPACS2GMSH/tests/test_advancemeshing.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,19 @@ def test_refine_wing_section():

generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
mesh_size_farfield=5,
mesh_size_fuselage=0.5,
mesh_size_wings=0.5,
farfield_factor=2,
symmetry=False,
farfield_size_factor=30,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=5,
wing_mesh_size_factor=5,
mesh_size_engines=0.5,
mesh_size_propellers=0.5,
symmetry=False,
refine_factor=2.0,
refine_truncated=False,
auto_refine=False,
Expand All @@ -245,7 +249,7 @@ def test_refine_wing_section():
)

# Check if a Matheval field was generated with the correct formula
assert gmsh.model.mesh.field.getString(2, "F") == "(0.5/2.0) + 0.5*(1-(1/2.0))*(F1/0.25)^2"
assert gmsh.model.mesh.field.getString(2, "F") == "(0.06/2.0) + 0.06*(1-(1/2.0))*(F1/0.25)^2"
assert gmsh.model.mesh.field.getType(2) == "MathEval"

# Check if the restrict field was applied on the wing
Expand Down Expand Up @@ -277,15 +281,19 @@ def test_auto_refine():

generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
mesh_size_farfield=5,
mesh_size_fuselage=0.5,
mesh_size_wings=0.5,
farfield_factor=5,
symmetry=False,
farfield_size_factor=17,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=10,
wing_mesh_size_factor=10,
mesh_size_engines=0.5,
mesh_size_propellers=0.5,
symmetry=False,
refine_factor=2.0,
refine_truncated=False,
auto_refine=True,
Expand Down
1 change: 0 additions & 1 deletion ceasiompy/CPACS2GMSH/tests/test_engineconversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ def test_close_engine():
# =================================================================================================

if __name__ == "__main__":

print("Test CPACS2GMSH")
print("To run test use the following command:")
print(">> pytest -v")
89 changes: 53 additions & 36 deletions ceasiompy/CPACS2GMSH/tests/test_generatemesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,19 @@ def test_generate_gmsh():

generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
farfield_factor=5,
farfield_factor=2,
symmetry=False,
mesh_size_farfield=5,
mesh_size_fuselage=0.5,
mesh_size_wings=0.5,
mesh_size_engines=0.5,
mesh_size_propellers=0.5,
farfield_size_factor=17,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=5,
wing_mesh_size_factor=5,
mesh_size_engines=0.2,
mesh_size_propellers=0.2,
refine_factor=1.0,
refine_truncated=False,
auto_refine=False,
Expand Down Expand Up @@ -104,14 +107,17 @@ def test_generate_gmsh_symm():

generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
farfield_factor=5,
symmetry=True,
mesh_size_farfield=5,
mesh_size_fuselage=0.5,
mesh_size_wings=0.5,
farfield_size_factor=17,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=5,
wing_mesh_size_factor=5,
mesh_size_engines=0.5,
mesh_size_propellers=0.5,
refine_factor=1.0,
Expand Down Expand Up @@ -209,14 +215,17 @@ def test_assignation():

_, aircraft_parts = generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
farfield_factor=5,
symmetry=False,
mesh_size_farfield=5,
mesh_size_fuselage=0.5,
mesh_size_wings=0.5,
farfield_size_factor=17,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=5,
wing_mesh_size_factor=5,
mesh_size_engines=0.5,
mesh_size_propellers=0.5,
refine_factor=1.0,
Expand Down Expand Up @@ -265,14 +274,17 @@ def test_define_engine_bc():

generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_SIMPLE_ENGINE_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
farfield_factor=2,
symmetry=False,
mesh_size_farfield=2,
mesh_size_fuselage=0.2,
mesh_size_wings=0.2,
farfield_size_factor=17,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=8,
wing_mesh_size_factor=8,
mesh_size_engines=0.2,
mesh_size_propellers=0.2,
refine_factor=1.0,
Expand All @@ -288,11 +300,11 @@ def test_define_engine_bc():
assert gmsh.model.getPhysicalName(*physical_groups[0]) == "Pylon"
assert gmsh.model.getPhysicalName(*physical_groups[1]) == "Pylon_mirrored"
assert gmsh.model.getPhysicalName(*physical_groups[2]) == "SimpleEngine"
assert gmsh.model.getPhysicalName(*physical_groups[3]) == "SimpleEngine_fan_Intake"
assert gmsh.model.getPhysicalName(*physical_groups[4]) == "SimpleEngine_fan_Exhaust"
assert gmsh.model.getPhysicalName(*physical_groups[3]) == "SimpleEngine_fan_In"
assert gmsh.model.getPhysicalName(*physical_groups[4]) == "SimpleEngine_fan_Ex"
assert gmsh.model.getPhysicalName(*physical_groups[5]) == "SimpleEngine_mirrored"
assert gmsh.model.getPhysicalName(*physical_groups[6]) == "SimpleEngine_mirrored_fan_Intake"
assert gmsh.model.getPhysicalName(*physical_groups[7]) == "SimpleEngine_mirrored_fan_Exhaust"
assert gmsh.model.getPhysicalName(*physical_groups[6]) == "SimpleEngine_mirrored_fan_In"
assert gmsh.model.getPhysicalName(*physical_groups[7]) == "SimpleEngine_mirrored_fan_Ex"
assert gmsh.model.getPhysicalName(*physical_groups[8]) == "SimpleFuselage"
assert gmsh.model.getPhysicalName(*physical_groups[9]) == "Wing"
assert gmsh.model.getPhysicalName(*physical_groups[10]) == "Wing_mirrored"
Expand Down Expand Up @@ -327,14 +339,17 @@ def test_define_doubleflux_engine_bc():

generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_SIMPLE_ENGINE_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
farfield_factor=2,
farfield_factor=3,
symmetry=False,
mesh_size_farfield=2,
mesh_size_fuselage=0.5,
mesh_size_wings=0.05,
farfield_size_factor=13,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=10,
wing_mesh_size_factor=10,
mesh_size_engines=0.05,
mesh_size_propellers=0.05,
refine_factor=1.0,
Expand All @@ -347,12 +362,12 @@ def test_define_doubleflux_engine_bc():
# Check if the engine integration did not disturb the BC assignation
assert len(physical_groups) == 15

assert gmsh.model.getPhysicalName(*physical_groups[3]) == "SimpleEngine_fan_Intake"
assert gmsh.model.getPhysicalName(*physical_groups[4]) == "SimpleEngine_fan_Exhaust"
assert gmsh.model.getPhysicalName(*physical_groups[5]) == "SimpleEngine_core_Exhaust"
assert gmsh.model.getPhysicalName(*physical_groups[7]) == "SimpleEngine_mirrored_fan_Intake"
assert gmsh.model.getPhysicalName(*physical_groups[8]) == "SimpleEngine_mirrored_fan_Exhaust"
assert gmsh.model.getPhysicalName(*physical_groups[9]) == "SimpleEngine_mirrored_core_Exhaust"
assert gmsh.model.getPhysicalName(*physical_groups[3]) == "SimpleEngine_fan_In"
assert gmsh.model.getPhysicalName(*physical_groups[4]) == "SimpleEngine_fan_Ex"
assert gmsh.model.getPhysicalName(*physical_groups[5]) == "SimpleEngine_core_Ex"
assert gmsh.model.getPhysicalName(*physical_groups[7]) == "SimpleEngine_mirrored_fan_In"
assert gmsh.model.getPhysicalName(*physical_groups[8]) == "SimpleEngine_mirrored_fan_Ex"
assert gmsh.model.getPhysicalName(*physical_groups[9]) == "SimpleEngine_mirrored_core_Ex"

# Check that the correct surfaces were assigned to the engine inlet outlet bc
assert gmsh.model.getEntitiesForPhysicalGroup(*physical_groups[3]) == [22]
Expand Down Expand Up @@ -385,16 +400,19 @@ def test_disk_actuator_conversion():

generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_PROPELLER_ENGINE_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
farfield_factor=5,
farfield_factor=3,
symmetry=False,
mesh_size_farfield=5,
mesh_size_fuselage=0.5,
mesh_size_wings=0.5,
mesh_size_engines=0.5,
mesh_size_propellers=0.5,
farfield_size_factor=10,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=100,
wing_mesh_size_factor=100,
mesh_size_engines=0.2,
mesh_size_propellers=0.1,
refine_factor=1.0,
refine_truncated=False,
auto_refine=False,
Expand Down Expand Up @@ -423,7 +441,6 @@ def test_disk_actuator_conversion():
# =================================================================================================

if __name__ == "__main__":

print("Test CPACS2GMSH")
print("To run test use the following command:")
print(">> pytest -v")
15 changes: 9 additions & 6 deletions ceasiompy/CPACS2GMSH/tests/test_wingclassification.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,16 +233,19 @@ def test_classify_wing():

_, aircraft_parts = generate_gmsh(
cpacs=cpacs,
cpacs_path=CPACS_IN_PATH,
brep_dir=TEST_OUT_PATH,
results_dir=TEST_OUT_PATH,
open_gmsh=False,
farfield_factor=5,
farfield_factor=2,
symmetry=False,
mesh_size_farfield=5,
mesh_size_fuselage=0.5,
mesh_size_wings=0.5,
mesh_size_engines=0.5,
mesh_size_propellers=0.5,
farfield_size_factor=17,
n_power_factor=2,
n_power_field=0.9,
fuselage_mesh_size_factor=1,
wing_mesh_size_factor=1,
mesh_size_engines=0.2,
mesh_size_propellers=0.2,
refine_factor=1.0,
refine_truncated=False,
auto_refine=False,
Expand Down
4 changes: 2 additions & 2 deletions ceasiompy/utils/commonnames.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
SURFACE_FLOW_FORCE_FILE_NAME = "surface_flow_forces.vtu"
FORCE_FILE_NAME = "forces.csv"

ENGINE_INTAKE_SUFFIX = "_Intake"
ENGINE_EXHAUST_SUFFIX = "_Exhaust"
ENGINE_INTAKE_SUFFIX = "_In"
ENGINE_EXHAUST_SUFFIX = "_Ex"

ACTUATOR_DISK_FILE_NAME = "ActuatorDisk.dat"
ACTUATOR_DISK_INLET_SUFFIX = "_AD_Inlet"
Expand Down

0 comments on commit 4994432

Please sign in to comment.