Skip to content

Commit

Permalink
Make global AD indexing the default config
Browse files Browse the repository at this point in the history
  • Loading branch information
lindsayad authored and jain651 committed Apr 19, 2021
1 parent 4462046 commit cb0c51f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 27 deletions.
11 changes: 3 additions & 8 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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


Expand All @@ -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

Expand Down
12 changes: 4 additions & 8 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
])

Expand All @@ -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])
],
Expand Down
8 changes: 6 additions & 2 deletions framework/include/base/MooseDefaultConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
19 changes: 12 additions & 7 deletions modules/navier_stokes/src/fv/kernels/INSFVMomentumAdvection.C
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down
4 changes: 2 additions & 2 deletions unit/src/ADFParserTest.C
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit cb0c51f

Please sign in to comment.