From: Jean-Paul Pelteret Date: Fri, 10 May 2019 20:35:00 +0000 (+0200) Subject: Instantiate ADHelpers classes with AD::NumberTypes::none. X-Git-Tag: v9.1.0-rc1~72^2~3 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b0c5be0d256986fc7468fbb49f9b6c67ece5fa0c;p=dealii.git Instantiate ADHelpers classes with AD::NumberTypes::none. The creation of a concrete instance of this class is, however, disabled. This is because the class will not be able to do anything useful. --- diff --git a/source/differentiation/ad/CMakeLists.txt b/source/differentiation/ad/CMakeLists.txt index 532ce9d291..c73400db0c 100644 --- a/source/differentiation/ad/CMakeLists.txt +++ b/source/differentiation/ad/CMakeLists.txt @@ -26,6 +26,7 @@ SET(_inst ad_drivers.inst.in ad_drivers.inst1.in ad_drivers.inst2.in + ad_helpers.inst.in ad_helpers.inst1.in ad_helpers.inst2.in adolc_number_types.inst.in diff --git a/source/differentiation/ad/ad_helpers.cc b/source/differentiation/ad/ad_helpers.cc index 948f00ba2f..08d7d1acd2 100644 --- a/source/differentiation/ad/ad_helpers.cc +++ b/source/differentiation/ad/ad_helpers.cc @@ -45,6 +45,19 @@ namespace Differentiation , registered_marked_independent_variables(n_independent_variables, false) , registered_marked_dependent_variables(n_dependent_variables, false) { + // We have enabled the compilation of this class for arithmetic + // types (i.e. ADNumberTypeCode == NumberTypes::none), but we + // can't actually do anything with them. Lets not advance any further + // and seemingly allow any operations that will not give any + // sensible results. + Assert(ADNumberTypeCode != NumberTypes::none, + ExcMessage( + "Floating point/arithmetic numbers have no derivatives.")); + Assert( + AD::ADNumberTraits::n_supported_derivative_levels >= 1, + ExcMessage( + "The AD number type does not support the calculation of any derivatives.")); + // Tapeless mode must be configured before any active live // variables are created. if (AD::is_tapeless_ad_number::value) @@ -1878,6 +1891,8 @@ namespace Differentiation /* --- Explicit instantiations --- */ +# include "ad_helpers.inst" + # ifdef DEAL_II_WITH_ADOLC # include "ad_helpers.inst1" # endif diff --git a/source/differentiation/ad/ad_helpers.inst.in b/source/differentiation/ad/ad_helpers.inst.in new file mode 100644 index 0000000000..2a0aa9df69 --- /dev/null +++ b/source/differentiation/ad/ad_helpers.inst.in @@ -0,0 +1,71 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + +// TODO: Include complex types + +for (number : REAL_SCALARS) + { + namespace Differentiation + \{ + namespace AD + \{ + // -------------------------- HelperBase ---------------------- + + template class HelperBase; + + // -------------------------- CellLevelBase ---------------------- + + template class CellLevelBase; + + // -------------------------- EnergyFunctional ---------------------- + + template class EnergyFunctional; + + // ------------------------ ResidualLinearization -------------------- + + template class ResidualLinearization; + + \} + \} + } + + +for (deal_II_dimension : DIMENSIONS; number : REAL_SCALARS) + { + namespace Differentiation + \{ + namespace AD + \{ + // ----------------------- PointLevelFunctionsBase ------------------- + + template class PointLevelFunctionsBase; + + // -------------------------- ScalarFunction ---------------------- + + template class ScalarFunction; + + // -------------------------- VectorFunction ---------------------- + + template class VectorFunction; + + \} + \} + }