diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index aee70cdf5da..2c8d3673886 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -38,6 +38,9 @@ on: ENABLE_HYPRE_DEVICE: required: false type: string + ENABLE_PYGEOSX: + required: false + type: string ENABLE_TRILINOS: required: false type: string @@ -200,6 +203,9 @@ jobs: fi docker_args+=(--name ${CONTAINER_NAME}) + if [ ${{ inputs.ENABLE_PYGEOSX }} == "ON" ]; then + script_args+=(--build-pygeosx) + fi if ${{ inputs.CODE_COVERAGE }} == 'true'; then script_args+=(--code-coverage) diff --git a/.github/workflows/ci_tests.yml b/.github/workflows/ci_tests.yml index 7396cf889b9..d4ec79358cd 100644 --- a/.github/workflows/ci_tests.yml +++ b/.github/workflows/ci_tests.yml @@ -142,6 +142,7 @@ jobs: DOCKER_REPOSITORY: geosx/ubuntu22.04-gcc12 ENABLE_HYPRE: ON ENABLE_TRILINOS: OFF + ENABLE_PYGEOSX: ON - name: Ubuntu (22.04, clang 15.0.7, open-mpi 4.1.2) CMAKE_BUILD_TYPE: Release @@ -177,6 +178,7 @@ jobs: DOCKER_REPOSITORY: ${{ matrix.DOCKER_REPOSITORY }} ENABLE_HYPRE: ${{ matrix.ENABLE_HYPRE }} ENABLE_TRILINOS: ${{ matrix.ENABLE_TRILINOS }} + ENABLE_PYGEOSX: ${{ matrix.ENABLE_PYGEOSX }} GCP_BUCKET: ${{ matrix.GCP_BUCKET }} HOST_CONFIG: ${{ matrix.HOST_CONFIG }} RUNS_ON: ubuntu-22.04 @@ -198,6 +200,7 @@ jobs: DOCKER_REPOSITORY: geosx/ubuntu22.04-gcc11 ENABLE_HYPRE: ON ENABLE_TRILINOS: OFF + ENABLE_PYGEOSX: ON GCP_BUCKET: geosx/integratedTests RUNS_ON: streak2-32core NPROC: 32 diff --git a/inputFiles/pygeos/modified_sedov.xml b/inputFiles/pygeos/modified_sedov.xml new file mode 100644 index 00000000000..b3dcedb087f --- /dev/null +++ b/inputFiles/pygeos/modified_sedov.xml @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/inputFiles/pygeos/pygeos.ats b/inputFiles/pygeos/pygeos.ats new file mode 100644 index 00000000000..62f8a33c326 --- /dev/null +++ b/inputFiles/pygeos/pygeos.ats @@ -0,0 +1,32 @@ +# Integrated Test Docs Begin Parameters +import geos_ats +from geos_ats.test_builder import generate_geos_tests, RestartcheckParameters, TestDeck, CurveCheckParameters + +restartcheck_params = {} +restartcheck_params["atol"] = 2.0E-10 +restartcheck_params["rtol"] = 2.0E-13 + +curvecheck_params = {} +curvecheck_params['filename'] = 'veloc_history.hdf5' +curvecheck_params['tolerance'] = 1e-10 +curvecheck_params['time_units'] = 'milliseconds' +curvecheck_params['curves'] = [['velocity', 'source']] +# Integrated Test Docs End Parameters + +# Integrated Test Docs Begin Test Loop +partitions = ((1, 1, 1), (2, 2, 2), (3, 3, 3)) + +decks = [ + TestDeck( + name="modified_sedov", + pygeos_script="run_sedov_problem.py", + description="Sedov problem with initial conditions modified using pygeos", + partitions=partitions, + restart_step=50, + check_step=100, + restartcheck_params=RestartcheckParameters(**restartcheck_params), + curvecheck_params=CurveCheckParameters(**curvecheck_params)) +] + +generate_geos_tests(decks) +# Integrated Test Docs End Test Loop \ No newline at end of file diff --git a/inputFiles/pygeos/run_sedov_problem.py b/inputFiles/pygeos/run_sedov_problem.py new file mode 100644 index 00000000000..52914bf5404 --- /dev/null +++ b/inputFiles/pygeos/run_sedov_problem.py @@ -0,0 +1,80 @@ + +import numpy as np +from mpi4py import MPI +import pygeosx +from pygeosx_tools import wrapper +from geosx_xml_tools.main import preprocess_parallel + + +# PYGEOSX_STRESS_FN +def stress_fn(x): + """ + Function to set stress values + + Args: + x (np.ndarray) the element centers + + Returns: + np.ndarray: stress values + """ + R = x[:, 0]**2 + x[:, 1]**2 + x[:, 2]**2 + return np.sin(2.0 * np.pi * R / np.amax(R)) +# PYGEOSX_STRESS_FN_END + + +def run_problem(): + """ + Run the GEOSX problem + """ + # PYGEOSX_INITIALIZATION + # Get the MPI rank + comm = MPI.COMM_WORLD + rank = comm.Get_rank() + + # Initialize the code and set initial conditions + problem = pygeosx.initialize(rank, args) + pygeosx.apply_initial_conditions() + + # Rather than specifying the wrapper paths explicitly, + # search for them using a set of filters + location_key = wrapper.get_matching_wrapper_path(problem, ['Level0', 'Region2', 'elementCenter']) + stress_key = wrapper.get_matching_wrapper_path(problem, ['Level0', 'Region2', 'shale', 'stress']) + ghost_key = wrapper.get_matching_wrapper_path(problem, ['Level0', 'Region2', 'cb1', 'ghostRank']) + # PYGEOSX_INITIALIZATION_END + + # PYGEOSX_STRESS_IC + # Print initial stress + wrapper.print_global_value_range(problem, stress_key, 'stress') + + # Zero out stress + wrapper.set_wrapper_to_value(problem, stress_key, 0.0) + wrapper.print_global_value_range(problem, stress_key, 'stress') + + # Set stress via a function + wrapper.set_wrapper_with_function(problem, stress_key, location_key, stress_fn, target_index=0) + wrapper.set_wrapper_with_function(problem, stress_key, location_key, stress_fn, target_index=1) + wrapper.set_wrapper_with_function(problem, stress_key, location_key, stress_fn, target_index=2) + wrapper.print_global_value_range(problem, stress_key, 'stress') + # PYGEOSX_STRESS_IC_END + + # PYGEOSX_MAIN_LOOP + # Run the code + while pygeosx.run() != pygeosx.COMPLETED: + wrapper.print_global_value_range(problem, stress_key, 'stress') + + # Gather/allgather tests + tmp = wrapper.gather_wrapper(problem, stress_key) + print(wrapper.rank, 'gather', np.shape(tmp), flush=True) + + tmp = wrapper.allgather_wrapper(problem, stress_key) + print(wrapper.rank, 'allgather', np.shape(tmp), flush=True) + + tmp = wrapper.allgather_wrapper(problem, stress_key, ghost_key=ghost_key) + print(wrapper.rank, 'allgather_ghost_filtered', np.shape(tmp), flush=True) + # PYGEOSX_MAIN_LOOP_END + + +if __name__ == '__main__': + run_problem() + + diff --git a/inputFiles/solidMechanics/sedov_base.xml b/inputFiles/solidMechanics/sedov_base.xml index 49419832a75..5bb28956e42 100644 --- a/inputFiles/solidMechanics/sedov_base.xml +++ b/inputFiles/solidMechanics/sedov_base.xml @@ -90,13 +90,8 @@ - - - + diff --git a/scripts/ci_build_and_test_in_container.sh b/scripts/ci_build_and_test_in_container.sh index 33faba11f8c..0d34e9f0817 100755 --- a/scripts/ci_build_and_test_in_container.sh +++ b/scripts/ci_build_and_test_in_container.sh @@ -68,11 +68,12 @@ exit 1 or_die cd $(dirname $0)/.. # Parsing using getopt -args=$(or_die getopt -a -o h --long build-exe-only,cmake-build-type:,code-coverage,data-basename:,exchange-dir:,host-config:,install-dir-basename:,no-install-schema,no-run-unit-tests,nproc:,repository:,run-integrated-tests,sccache-credentials:,test-code-style,test-documentation,help -- "$@") +args=$(or_die getopt -a -o h --long build-exe-only,cmake-build-type:,code-coverage,data-basename:,exchange-dir:,host-config:,install-dir-basename:,no-install-schema,no-run-unit-tests,nproc:,repository:,build-pygeosx,run-integrated-tests,sccache-credentials:,test-code-style,test-documentation,help -- "$@") # Variables with default values BUILD_EXE_ONLY=false GEOSX_INSTALL_SCHEMA=true +BUILD_PYGEOSX=false HOST_CONFIG="host-configs/environment.cmake" RUN_UNIT_TESTS=true RUN_INTEGRATED_TESTS=false @@ -108,6 +109,7 @@ do --no-run-unit-tests) RUN_UNIT_TESTS=false; shift;; --nproc) NPROC=$2; shift 2;; --repository) GEOS_SRC_DIR=$2; shift 2;; + --build-pygeosx) BUILD_PYGEOSX=true; shift;; --run-integrated-tests) RUN_INTEGRATED_TESTS=true; shift;; --upload-test-baselines) UPLOAD_TEST_BASELINES=true; shift;; --code-coverage) CODE_COVERAGE=true; shift;; @@ -201,6 +203,15 @@ if [[ "${CODE_COVERAGE}" = true ]]; then fi +PYGEOSX_ARGS="" +if [[ "${BUILD_PYGEOSX}" = true ]]; then + echo "Enabling pygeosx." + or_die apt-get update + or_die apt-get install -y virtualenv python3-dev python3-numpy python3-mpi4py python3-venv + PYTHON_EXEC=$(which python3) + PYGEOSX_ARGS="-DENABLE_PYGEOSX=ON -DPython3_EXECUTABLE=$PYTHON_EXEC" +fi + # The -DBLT_MPI_COMMAND_APPEND="--allow-run-as-root;--oversubscribe" option is added for OpenMPI. # @@ -226,7 +237,8 @@ or_die python3 scripts/config-build.py \ -DGEOSX_INSTALL_SCHEMA=${GEOSX_INSTALL_SCHEMA} \ -DENABLE_COVERAGE=$([[ "${CODE_COVERAGE}" = true ]] && echo 1 || echo 0) \ ${SCCACHE_CMAKE_ARGS} \ - ${ATS_CMAKE_ARGS} + ${ATS_CMAKE_ARGS} \ + $PYGEOSX_ARGS # The configuration step is now over, we can now move to the build directory for the build! or_die cd ${GEOSX_BUILD_DIR} @@ -330,4 +342,4 @@ if [[ ! -z "${INTEGRATED_TEST_EXIT_STATUS+x}" ]]; then else echo "Exiting the build process with exit status 0." exit 0 -fi \ No newline at end of file +fi diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 54b7a3f9bfd..549f5ef77b2 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -232,8 +232,10 @@ install( FILES ${CMAKE_BINARY_DIR}/schema.xsd ################################ # Add python environment setup ################################ -# message(WARNING "Temporarily changing the geosPythonBranch to feature/packaging") -# set(GEOS_PYTHON_PACKAGES_BRANCH "feature/packaging" CACHE STRING "" FORCE) +# message(WARNING "Temporarily changing the geosPythonBranch to cusini/fix-streak-cert-fail") +# set(GEOS_PYTHON_PACKAGES_BRANCH "cusini/fix-streak-cert-fail" CACHE STRING "" FORCE) +message(WARNING "Temporarily changing the geosPythonBranch to feature/sherman/addPygeosxIntegratedTests") +set(GEOS_PYTHON_PACKAGES_BRANCH "feature/sherman/addPygeosxIntegratedTests" CACHE STRING "" FORCE) if ( Python3_EXECUTABLE )