Skip to content
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

Fix broken ADOL-C tests #14617

Merged
merged 3 commits into from
Dec 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 0 additions & 1 deletion contrib/ci/Jenkinsfile.serial
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ pipeline
-D DEAL_II_CXX_FLAGS_DEBUG='-Og' \
-D DEAL_II_EARLY_DEPRECATIONS=ON \
-D CMAKE_BUILD_TYPE=Debug \
-D DEAL_II_WITH_ADOLC=OFF \
-D DEAL_II_WITH_MPI=OFF \
-D DEAL_II_UNITY_BUILD=ON \
$WORKSPACE/
Expand Down
55 changes: 24 additions & 31 deletions include/deal.II/base/symmetric_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1947,21 +1947,6 @@ DEAL_II_CONSTEXPR inline typename internal::SymmetricTensorAccessors::
// into a separate namespace
namespace internal
{
// The variables within this struct will be referenced in the next functions.
// It is a workaround that allows returning a reference to a static variable
// while allowing constexpr evaluation of the function.
// It has to be defined outside the function because constexpr functions
// cannot define static variables.
// A similar struct has also been defined in tensor.h
template <typename Type>
struct Uninitialized
{
static Type value;
};

template <typename Type>
Type Uninitialized<Type>::value;

template <int dim, typename Number>
constexpr inline DEAL_II_ALWAYS_INLINE Number &
symmetric_tensor_access(const TableIndices<2> &indices,
Expand Down Expand Up @@ -2000,10 +1985,12 @@ namespace internal
}
}

// The code should never reach there.
// Returns a dummy reference to a dummy variable just to make the
// compiler happy.
return Uninitialized<Number>::value;
// The code should never reach here.
// We cannot return a static variable, as this class must support number
// types that require no instances of the number type to be in scope during
// a reinitialization procedure (e.g. ADOL-C adtl::adouble).
Assert(false, ExcInternalError());
return data[0];
}


Expand Down Expand Up @@ -2046,10 +2033,12 @@ namespace internal
}
}

// The code should never reach there.
// Returns a dummy reference to a dummy variable just to make the
// compiler happy.
return Uninitialized<Number>::value;
// The code should never reach here.
// We cannot return a static variable, as this class must support number
// types that require no instances of the number type to be in scope during
// a reinitialization procedure (e.g. ADOL-C adtl::adouble).
Assert(false, ExcInternalError());
return data[0];
}


Expand Down Expand Up @@ -2094,10 +2083,12 @@ namespace internal
Assert(false, ExcNotImplemented());
}

// The code should never reach there.
// Returns a dummy reference to a dummy variable just to make the
// compiler happy.
return Uninitialized<Number>::value;
// The code should never reach here.
// We cannot return a static variable, as this class must support number
// types that require no instances of the number type to be in scope during
// a reinitialization procedure (e.g. ADOL-C adtl::adouble).
Assert(false, ExcInternalError());
return data[0][0];
}


Expand Down Expand Up @@ -2141,10 +2132,12 @@ namespace internal
Assert(false, ExcNotImplemented());
}

// The code should never reach there.
// Returns a dummy reference to a dummy variable just to make the
// compiler happy.
return Uninitialized<Number>::value;
// The code should never reach here.
// We cannot return a static variable, as this class must support number
// types that require no instances of the number type to be in scope during
// a reinitialization procedure (e.g. ADOL-C adtl::adouble).
Assert(false, ExcInternalError());
return data[0][0];
}

} // end of namespace internal
Expand Down
4 changes: 2 additions & 2 deletions include/deal.II/base/tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3054,7 +3054,7 @@ l1_norm(const Tensor<2, dim, adouble> &t)
{
adouble sum = internal::NumberType<adouble>::value(0.0);
for (unsigned int i = 0; i < dim; ++i)
sum += std::fabs(t[i][j]);
sum += fabs(t[i][j]);

condassign(max, (sum > max), sum, max);
}
Expand All @@ -3072,7 +3072,7 @@ linfty_norm(const Tensor<2, dim, adouble> &t)
{
adouble sum = internal::NumberType<adouble>::value(0.0);
for (unsigned int j = 0; j < dim; ++j)
sum += std::fabs(t[i][j]);
sum += fabs(t[i][j]);

condassign(max, (sum > max), sum, max);
}
Expand Down