From cb0c51f00d95c47ab9b1e482a743ed681d02bf1b Mon Sep 17 00:00:00 2001 From: Alex Lindsay Date: Wed, 9 Dec 2020 13:58:52 -0800 Subject: [PATCH] Make global AD indexing the default config Closes #16091 --- configure | 11 +++-------- configure.ac | 12 ++++-------- framework/include/base/MooseDefaultConfig.h | 8 ++++++-- .../src/fv/kernels/INSFVMomentumAdvection.C | 19 ++++++++++++------- unit/src/ADFParserTest.C | 4 ++-- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/configure b/configure index fb8db45a2808..daf41c7eedf3 100755 --- a/configure +++ b/configure @@ -1725,7 +1725,7 @@ if test "${with_derivative_type+set}" = set; then : else - derivative_type=nonsparse + derivative_type=sparse user_det_derivative_type=no fi @@ -1754,7 +1754,7 @@ $as_echo "configuring with derivative backing array size of $derivative_size" >& if test "${with_ad_indexing_type+set}" = set; then : withval=$with_ad_indexing_type; ad_indexing_type="$withval" else - ad_indexing_type=local + ad_indexing_type=global fi @@ -1763,12 +1763,7 @@ case "$ad_indexing_type" in #( if test "$derivative_type" = nonsparse; then : - if test "$user_set_derivative_type" = yes; then : - as_fn_error $? "cannot request global AD indexing and a nonsparse derivative container" "$LINENO" 5 -else - derivative_type=sparse - -fi + as_fn_error $? "cannot use global AD indexing with a nonsparse derivative container" "$LINENO" 5 fi diff --git a/configure.ac b/configure.ac index d43e9ee6326a..df546867a7d7 100644 --- a/configure.ac +++ b/configure.ac @@ -34,7 +34,7 @@ AC_ARG_WITH(derivative-type, user_set_derivative_type=yes ], [ - derivative_type=nonsparse + derivative_type=sparse user_det_derivative_type=no ]) @@ -50,19 +50,15 @@ AC_MSG_RESULT([configuring with derivative backing array size of $derivative_siz AC_ARG_WITH(ad-indexing-type, AS_HELP_STRING([--with-ad-indexing-type=local,global],[Specify the indexing scheme for AD derivatives]), [ad_indexing_type="$withval"], - [ad_indexing_type=local]) + [ad_indexing_type=global]) AS_CASE("$ad_indexing_type", [global], [ AS_IF([test "$derivative_type" = nonsparse], [ - AS_IF([test "$user_set_derivative_type" = yes], - dnl The user explicitly requested a nonsparse container which is incompatabile with global indexing - [AC_MSG_ERROR(cannot request global AD indexing and a nonsparse derivative container)], - dnl The user did not explicity request a container type so well set sparse for them - [derivative_type=sparse] - ) + dnl The user explicitly requested a nonsparse container which is incompatabile with global indexing + AC_MSG_ERROR(cannot use global AD indexing with a nonsparse derivative container) ]) AC_DEFINE(GLOBAL_AD_INDEXING, 1, [Whether to use a global indexing scheme for AD]) ], diff --git a/framework/include/base/MooseDefaultConfig.h b/framework/include/base/MooseDefaultConfig.h index 872e528c875b..fe376bfc6867 100644 --- a/framework/include/base/MooseDefaultConfig.h +++ b/framework/include/base/MooseDefaultConfig.h @@ -19,7 +19,9 @@ #endif /* Whether to use a global indexing scheme for AD */ -/* #undef GLOBAL_AD_INDEXING */ +#ifndef MOOSE_GLOBAL_AD_INDEXING +#define MOOSE_GLOBAL_AD_INDEXING 1 +#endif /* Whether or not libpng was detected on the system */ /* #undef HAVE_LIBPNG */ @@ -55,4 +57,6 @@ #endif /* Whether to use a sparse derivative type */ -/* #undef SPARSE_AD */ +#ifndef MOOSE_SPARSE_AD +#define MOOSE_SPARSE_AD 1 +#endif diff --git a/modules/navier_stokes/src/fv/kernels/INSFVMomentumAdvection.C b/modules/navier_stokes/src/fv/kernels/INSFVMomentumAdvection.C index 50244f2cfc5f..6a28467b2e1b 100644 --- a/modules/navier_stokes/src/fv/kernels/INSFVMomentumAdvection.C +++ b/modules/navier_stokes/src/fv/kernels/INSFVMomentumAdvection.C @@ -297,13 +297,18 @@ INSFVMomentumAdvection::coeffCalculator(const Elem & elem, const ADReal & mu) co if (_w_var) elem_velocity(2) = _w_var->getElemValue(&elem); - auto action_functor = [&coeff, &elem_velocity, &mu, &elem, this]( - const Elem & libmesh_dbg_var(functor_elem), - const Elem * const neighbor, - const FaceInfo * const fi, - const Point & surface_vector, - Real libmesh_dbg_var(coord), - const bool elem_has_info) { + auto action_functor = [&coeff, + &elem_velocity, + &mu, +#ifndef NDEBUG + &elem, +#endif + this](const Elem & libmesh_dbg_var(functor_elem), + const Elem * const neighbor, + const FaceInfo * const fi, + const Point & surface_vector, + Real libmesh_dbg_var(coord), + const bool elem_has_info) { mooseAssert(fi, "We need a non-null FaceInfo"); mooseAssert(&elem == &functor_elem, "Elems don't match"); diff --git a/unit/src/ADFParserTest.C b/unit/src/ADFParserTest.C index 15dda6b70cc7..67cd7e09686c 100644 --- a/unit/src/ADFParserTest.C +++ b/unit/src/ADFParserTest.C @@ -23,8 +23,8 @@ TEST(ADFparserTest, JITCompile) fparser.JITCompile(); ADReal v[2] = {1.5, 2.5}; - v[0].derivatives()[0] = 1; - v[1].derivatives()[1] = 1; + Moose::derivInsert(v[0].derivatives(), 0, 1); + Moose::derivInsert(v[1].derivatives(), 1, 1); // evaluate parsed function auto p = fparser.Eval(v);