Skip to content
Closed
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
11 changes: 11 additions & 0 deletions toolchain/mfc/case_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2669,6 +2669,16 @@ def check_surface_tension_post(self):

self.prohibit(cf_wrt and not surface_tension, "cf_wrt can only be enabled if surface_tension is enabled")

def check_sim_data(self):
"""Checks interface/energy data output constraints (post-process)"""
if self.get("sim_data", "F") != "T":
return

# s_write_energy_data_file uses dz and s_write_intf_data_file reads alpha_2 at eqn_idx%E + 2
self.prohibit(self.get("p", 0) == 0, "sim_data requires p > 0 (3D)")
self.prohibit(self.get("num_fluids") != 2, "sim_data requires num_fluids = 2")
self.prohibit(self.get("model_eqns") not in [2, 3], "sim_data requires model_eqns = 2 or 3")

def check_no_flow_variables(self):
"""Checks that at least one flow variable is selected (post-process)"""
rho_wrt = self.get("rho_wrt", "F") == "T"
Expand Down Expand Up @@ -3106,6 +3116,7 @@ def validate_post_process(self):
self.check_liutex_post()
self.check_schlieren()
self.check_surface_tension_post()
self.check_sim_data()
self.check_no_flow_variables()

def validate(self, stage: str = "simulation"):
Expand Down
1 change: 1 addition & 0 deletions toolchain/mfc/lint_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,7 @@ def check_physics_docs_coverage(repo_root: Path) -> list[str]:
"check_partial_domain", # output format settings
"check_perturb_density", # parameter pairing validation
"check_qm", # output dimension requirements
"check_sim_data", # output dimension requirements
"check_chemistry", # runtime Cantera validation only
# Awaiting proper physics documentation (math, references, explanation)
"check_adaptive_time_stepping",
Expand Down
47 changes: 47 additions & 0 deletions toolchain/mfc/test_case_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -704,3 +704,50 @@ def test_rejects_isothermal_wall_without_any_heat_path(self):
{**BASE, "bc_x%beg": -16, "bc_x%end": -16, "bc_x%isothermal_in": "T", "bc_x%Twall_in": 300.0},
"requires a heat-conduction path",
)


class TestSimData(ConstraintTestCase):
"""sim_data's interface and energy writers assume a 3D two-fluid 5- or 6-equation case."""

GOOD = {
**BASE_2D,
**{k: v for k, v in TWO_FLUID.items() if k not in BASE},
"num_fluids": 2,
"p": 50,
"bc_z%beg": -1,
"bc_z%end": -1,
"z_domain%beg": 0.0,
"z_domain%end": 1.0,
"patch_icpp(1)%z_centroid": 0.5,
"patch_icpp(1)%length_z": 1.0,
"patch_icpp(1)%vel(3)": 0.0,
"rho_wrt": "T",
"sim_data": "T",
}

def errors_for(self, params) -> str:
"""Validate at the post_process stage, where sim_data is read."""
validator = CaseValidator(dict(params))
try:
validator.validate("post_process")
except CaseConstraintError as exc:
return str(exc)
return ""

def test_accepts_3d_two_fluid(self):
self.assertAccepts(self.GOOD)

def test_accepts_six_equation(self):
self.assertAccepts({**self.GOOD, "model_eqns": 3})

def test_rejects_2d(self):
self.assertRejects({**self.GOOD, "p": 0}, "sim_data requires p > 0 (3D)")

def test_rejects_one_fluid(self):
self.assertRejects({**self.GOOD, "num_fluids": 1}, "sim_data requires num_fluids = 2")

def test_rejects_gamma_law(self):
self.assertRejects({**self.GOOD, "model_eqns": 1}, "sim_data requires model_eqns = 2 or 3")

def test_not_tripped_when_disabled(self):
self.assertAccepts({**BASE_2D, "rho_wrt": "T", "sim_data": "F"})
Loading