aurora-multiphysics / hippo

hippo is an integration of OpenFOAM and MOOSE to enable thermohydraulic simulations
GNU General Public License v3.0
3 stars 0 forks source link

Set face values on moose mesh #11

Closed hsaunders1904 closed 8 months ago

hsaunders1904 commented 8 months ago

Summary

Updates BuoyantFoamProblem::syncSolutions such that we set temperature values on the faces of the MOOSE mesh, rather than on the nodes.

hsaunders1904 commented 8 months ago

You can run this script to convince yourself that the values on the MOOSE mesh are equal to the values on the boundary of the OpenFOAM one.

Test script ```bash pip install fluidfoam git+https://github.com/sandialabs/exodusii@2024.01.09 ``` ```python import sys from pathlib import Path import fluidfoam as ff import numpy as np from exodusii.file import ExodusIIFile if "-par" in sys.argv: CASE_DIR = Path("./test/tests/buoyantFoam/buoyantFoam_par") else: CASE_DIR = Path("./test/tests/buoyantFoam/buoyantFoam_serial") FOAM_DIR = CASE_DIR / "buoyantCavity" T_VAR_NAME = "T" FRONT_AND_BACK = "frontAndBack" TOP_AND_BOTTOM = "topAndBottom" for time_step in (str(x) for x in range(1, 21)): # Read OpenFOAM mesh foam_t = ff.readfield(str(FOAM_DIR), time_name=time_step, name=T_VAR_NAME) foam_front_and_back = ff.readfield( str(FOAM_DIR), time_name=time_step, name=T_VAR_NAME, boundary=FRONT_AND_BACK ) foam_top_and_bottom = ff.readfield( str(FOAM_DIR), time_name=time_step, name=T_VAR_NAME, boundary=TOP_AND_BOTTOM ) # Read MOOSE mesh def get_element_values( mesh: ExodusIIFile, block_name: str, variable: str, time_step: int ) -> np.ndarray: idx = np.where(mesh.get_element_block_names() == block_name)[0][0] return mesh.get_element_variable_values(idx, variable, time_step) moose_mesh = ExodusIIFile(CASE_DIR / "run_out.e") moose_front_and_back = get_element_values( moose_mesh, FRONT_AND_BACK, "foamT_face", int(time_step) + 1 ) moose_top_and_bottom = get_element_values( moose_mesh, TOP_AND_BOTTOM, "foamT_face", int(time_step) + 1 ) if "-par" in sys.argv: # The coords are in different orders in the parallel meshes, so # we need to sort the values foam_front_and_back.sort() foam_top_and_bottom.sort() moose_front_and_back.sort() moose_top_and_bottom.sort() np.testing.assert_allclose( foam_front_and_back, moose_front_and_back, err_msg=f"time step {time_step} failed", ) np.testing.assert_allclose( foam_top_and_bottom, moose_top_and_bottom, err_msg=f"time step {time_step} failed", ) ```