Skip to content

Adding pygeosx integrated test #3174

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
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
6 changes: 6 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ on:
ENABLE_HYPRE_DEVICE:
required: false
type: string
ENABLE_PYGEOSX:
required: false
type: string
ENABLE_TRILINOS:
required: false
type: string
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
65 changes: 65 additions & 0 deletions inputFiles/pygeos/modified_sedov.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" ?>

<Problem>

<Included>
<File
name="../solidMechanics/sedov_base.xml"/>
</Included>

<Mesh>
<InternalMesh
name="mesh1"
elementTypes="{ C3D8 }"
xCoords="{ 0, 10 }"
yCoords="{ 0, 10 }"
zCoords="{ 0, 10 }"
nx="{ 10 }"
ny="{ 10 }"
nz="{ 10 }"
cellBlockNames="{ cb1 }"/>
</Mesh>

<Solvers>
<SolidMechanics_LagrangianFEM
name="lagsolve"
strainTheory="1"
cflFactor="0.25"
discretization="FE1"
targetRegions="{ Region2 }"
/>
</Solvers>

<Events
maxTime="1.0e-3">
<!-- This event is applied every cycle, and overrides the
solver time-step request -->
<PeriodicEvent
name="solverApplications"
forceDt="1.0e-5"
target="/Solvers/lagsolve"/>

<PeriodicEvent
name="timeHistoryCollection"
target="/Tasks/velocityCollection"/>

<PeriodicEvent
name="timeHistoryOutput"
timeFrequency="5.0e-4"
targetExactTimestep="0"
target="/Outputs/timeHistoryOutput"/>

<PeriodicEvent
name="restarts"
timeFrequency="5.0e-4"
targetExactTimestep="0"
target="/Outputs/restartOutput"/>

<PeriodicEvent
name="python"
cycleFrequency="5"
target="/Outputs/pythonOutput"/>
</Events>

</Problem>

32 changes: 32 additions & 0 deletions inputFiles/pygeos/pygeos.ats
Original file line number Diff line number Diff line change
@@ -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
80 changes: 80 additions & 0 deletions inputFiles/pygeos/run_sedov_problem.py
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you need this? It does not seem to be used.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I missed cleaning up the import list when I removed the pre-processor from this example



# 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Run the GEOSX problem
Run the GEOS 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()


9 changes: 2 additions & 7 deletions inputFiles/solidMechanics/sedov_base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,8 @@
</FieldSpecifications>

<Outputs>
<Blueprint
name="blueprint"
plotLevel="3"/>

<Silo
name="siloOutput"
plotLevel="3"/>
<Python
name="pythonOutput"/>

<Restart
name="restartOutput"/>
Expand Down
18 changes: 15 additions & 3 deletions scripts/ci_build_and_test_in_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;;
Expand Down Expand Up @@ -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.
#
Expand All @@ -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}
Expand Down Expand Up @@ -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
fi
6 changes: 4 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
Loading