16#ifndef dealii_differentiation_ad_ad_drivers_h
17#define dealii_differentiation_ad_ad_drivers_h
30#ifdef DEAL_II_WITH_ADOLC
33# include <adolc/internal/usrparms.h>
59 "This function is called in a class that is expected to be specialized "
60 "for auto-differentiable numbers.");
67 "This function is only available if deal.II is compiled with ADOL-C.");
81 <<
"The number of derivative levels that this auto-differentiable number type supports is "
83 <<
", but to perform the intended operation the number must support at least "
84 << arg2 <<
" levels.");
93 template <
typename ADNumberType,
typename T =
void>
112 template <
typename ADNumberType,
typename T =
void>
128 std::numeric_limits<typename Types<ADNumberType>::tape_index>
::max();
147 template <
typename ADNumberType,
typename ScalarType,
typename T =
void>
251 const bool write_tapes_to_file);
256 std::vector<typename Types<ADNumberType>::tape_index>
366 reset(
const bool clear_registered_tapes);
377 print(std::ostream &stream)
const;
389 std::ostream & stream)
const;
410 const std::vector<ScalarType> &independent_variables)
const;
427 const std::vector<ScalarType> &independent_variables,
445 const std::vector<ScalarType> &independent_variables,
469 const unsigned int n_dependent_variables,
470 const std::vector<ScalarType> &independent_variables,
493 const unsigned int n_dependent_variables,
494 const std::vector<ScalarType> &independent_variables,
517 template <
typename ADNumberType,
typename ScalarType,
typename T =
void>
593 value(
const std::vector<ADNumberType> &dependent_variables)
const;
609 gradient(
const std::vector<ADNumberType> &independent_variables,
610 const std::vector<ADNumberType> &dependent_variables,
627 hessian(
const std::vector<ADNumberType> &independent_variables,
628 const std::vector<ADNumberType> &dependent_variables,
648 values(
const std::vector<ADNumberType> &dependent_variables,
669 jacobian(
const std::vector<ADNumberType> &independent_variables,
670 const std::vector<ADNumberType> &dependent_variables,
690# ifdef DEAL_II_WITH_ADOLC
695 template <
typename ADNumberType>
698 typename
std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
699 NumberTypes::adolc_taped>::type>
717 template <
typename ADNumberType>
720 typename
std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
721 NumberTypes::adolc_taped>::type>
764 template <
typename ADNumberType>
768 typename
std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
769 NumberTypes::adolc_taped>::type>
771 using scalar_type = double;
811 const bool write_tapes_to_file);
813 std::vector<typename Types<ADNumberType>::tape_index>
830 reset(
const bool clear_registered_tapes);
833 print(std::ostream &stream)
const;
838 std::ostream & stream)
const;
849 const std::vector<scalar_type> &independent_variables)
const;
853 const std::vector<scalar_type> &independent_variables,
858 const std::vector<scalar_type> &independent_variables,
870 const unsigned int n_dependent_variables,
871 const std::vector<scalar_type> &independent_variables,
876 const unsigned int n_dependent_variables,
877 const std::vector<scalar_type> &independent_variables,
901 bool is_recording_flag;
930 mutable std::map<typename Types<ADNumberType>::tape_index,
int> status;
938 bool use_stored_taped_buffer_sizes;
971 template <
typename ADNumberType>
975 typename
std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
976 NumberTypes::adolc_taped>::type>
978 using scalar_type = double;
1011 std::vector<typename Types<ADNumberType>::tape_index>
1030 print(std::ostream &stream)
const;
1034 std::ostream &)
const;
1045 const std::vector<scalar_type> &)
const;
1049 const std::vector<scalar_type> &,
1054 const std::vector<scalar_type> &,
1067 const std::vector<scalar_type> &,
1073 const std::vector<scalar_type> &,
1089 template <
typename ADNumberType>
1090 struct TapedDrivers<
1093 typename
std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
1094 NumberTypes::adolc_taped>::type>
1096 using scalar_type = float;
1130 const bool write_tapes_to_file);
1132 std::vector<typename Types<ADNumberType>::tape_index>
1149 reset(
const bool clear_registered_tapes);
1152 print(std::ostream &stream)
const;
1157 std::ostream & stream)
const;
1168 const std::vector<scalar_type> &independent_variables)
const;
1172 const std::vector<scalar_type> &independent_variables,
1177 const std::vector<scalar_type> &independent_variables,
1189 const unsigned int n_dependent_variables,
1190 const std::vector<scalar_type> &independent_variables,
1195 const unsigned int n_dependent_variables,
1196 const std::vector<scalar_type> &independent_variables,
1206 vector_float_to_double(
const std::vector<float> &in)
const;
1211 TapedDrivers<ADNumberType, double> taped_driver;
1223 template <
typename ADNumberType,
typename ScalarType>
1224 struct TapelessDrivers<
1227 typename
std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
1228 NumberTypes::sacado_rad ||
1229 ADNumberTraits<ADNumberType>::type_code ==
1230 NumberTypes::sacado_rad_dfad>::type>
1269 value(
const std::vector<ADNumberType> &dependent_variables)
const;
1272 gradient(
const std::vector<ADNumberType> &independent_variables,
1273 const std::vector<ADNumberType> &dependent_variables,
1277 hessian(
const std::vector<ADNumberType> &independent_variables,
1278 const std::vector<ADNumberType> &dependent_variables,
1289 values(
const std::vector<ADNumberType> &dependent_variables,
1293 jacobian(
const std::vector<ADNumberType> &independent_variables,
1294 const std::vector<ADNumberType> &dependent_variables,
1304 bool dependent_variable_marking_safe;
1313 template <
typename ADNumberType,
typename ScalarType>
1314 struct TapelessDrivers<
1317 typename
std::enable_if<ADNumberTraits<ADNumberType>::type_code ==
1318 NumberTypes::adolc_tapeless ||
1319 ADNumberTraits<ADNumberType>::type_code ==
1320 NumberTypes::sacado_dfad ||
1321 ADNumberTraits<ADNumberType>::type_code ==
1322 NumberTypes::sacado_dfad_dfad>::type>
1361 value(
const std::vector<ADNumberType> &dependent_variables)
const;
1364 gradient(
const std::vector<ADNumberType> &independent_variables,
1365 const std::vector<ADNumberType> &dependent_variables,
1369 hessian(
const std::vector<ADNumberType> &independent_variables,
1370 const std::vector<ADNumberType> &dependent_variables,
1381 values(
const std::vector<ADNumberType> &dependent_variables,
1385 jacobian(
const std::vector<ADNumberType> &independent_variables,
1386 const std::vector<ADNumberType> &dependent_variables,
1396 bool dependent_variable_marking_safe;
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
static ::ExceptionBase & ExcSupportedDerivativeLevels(std::size_t arg1, std::size_t arg2)
static ::ExceptionBase & ExcRequiresADNumberSpecialization()
static ::ExceptionBase & ExcRequiresADOLC()
#define DeclException2(Exception2, type1, type2, outsequence)
#define DeclExceptionMsg(Exception, defaulttext)
static const Types< ADNumberType >::tape_index max_tape_index
static const Types< ADNumberType >::tape_index invalid_tape_index
ScalarType value(const typename Types< ADNumberType >::tape_index active_tape_index, const std::vector< ScalarType > &independent_variables) const
void gradient(const typename Types< ADNumberType >::tape_index active_tape_index, const std::vector< ScalarType > &independent_variables, Vector< ScalarType > &gradient) const
bool is_recording() const
bool is_registered_tape(const typename Types< ADNumberType >::tape_index tape_index) const
void stop_taping(const typename Types< ADNumberType >::tape_index active_tape_index, const bool write_tapes_to_file)
void remove_tape(const typename Types< ADNumberType >::tape_index tape_index)
void start_taping(const typename Types< ADNumberType >::tape_index tape_index, const bool keep_independent_values)
void hessian(const typename Types< ADNumberType >::tape_index active_tape_index, const std::vector< ScalarType > &independent_variables, FullMatrix< ScalarType > &hessian) const
void set_tape_buffer_sizes(const typename Types< ADNumberType >::tape_buffer_sizes obufsize=64 *1024 *1024, const typename Types< ADNumberType >::tape_buffer_sizes lbufsize=64 *1024 *1024, const typename Types< ADNumberType >::tape_buffer_sizes vbufsize=64 *1024 *1024, const typename Types< ADNumberType >::tape_buffer_sizes tbufsize=64 *1024 *1024)
void activate_tape(const typename Types< ADNumberType >::tape_index tape_index)
bool last_action_requires_retaping() const
bool requires_retaping(const typename Types< ADNumberType >::tape_index tape_index) const
void print(std::ostream &stream) const
void print_tape_stats(const typename Types< ADNumberType >::tape_index tape_index, std::ostream &stream) const
bool keep_independent_values() const
Types< ADNumberType >::tape_index active_tape_index() const
void reset(const bool clear_registered_tapes)
std::vector< typename Types< ADNumberType >::tape_index > get_registered_tape_indices() const
void values(const typename Types< ADNumberType >::tape_index active_tape_index, const unsigned int n_dependent_variables, const std::vector< ScalarType > &independent_variables, Vector< ScalarType > &values) const
void jacobian(const typename Types< ADNumberType >::tape_index active_tape_index, const unsigned int n_dependent_variables, const std::vector< ScalarType > &independent_variables, FullMatrix< ScalarType > &jacobian) const
void gradient(const std::vector< ADNumberType > &independent_variables, const std::vector< ADNumberType > &dependent_variables, Vector< ScalarType > &gradient) const
void allow_dependent_variable_marking()
void hessian(const std::vector< ADNumberType > &independent_variables, const std::vector< ADNumberType > &dependent_variables, FullMatrix< ScalarType > &hessian) const
void values(const std::vector< ADNumberType > &dependent_variables, Vector< ScalarType > &values) const
void jacobian(const std::vector< ADNumberType > &independent_variables, const std::vector< ADNumberType > &dependent_variables, FullMatrix< ScalarType > &jacobian) const
static void initialize_global_environment(const unsigned int n_independent_variables)
bool is_dependent_variable_marking_allowed() const
ScalarType value(const std::vector< ADNumberType > &dependent_variables) const
void prevent_dependent_variable_marking()
unsigned int tape_buffer_sizes