From: Jean-Paul Pelteret Date: Sat, 4 May 2019 19:56:38 +0000 (+0200) Subject: Implement functions to make symbol maps X-Git-Tag: v9.1.0-rc1~68^2~9 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e4ba83b8b11b1c58f82cbfedbfd358963580ccea;p=dealii.git Implement functions to make symbol maps --- diff --git a/include/deal.II/differentiation/sd/symengine_scalar_operations.h b/include/deal.II/differentiation/sd/symengine_scalar_operations.h index 69adbca82f..a2e6a87b1f 100644 --- a/include/deal.II/differentiation/sd/symengine_scalar_operations.h +++ b/include/deal.II/differentiation/sd/symengine_scalar_operations.h @@ -148,6 +148,44 @@ namespace Differentiation is_valid_substitution_symbol(const SymEngine::Basic &entry); } // namespace internal + /** + * Return a symbolic map that has the entry key given by @p symbol. + * It is expected that all entries be valid symbols or symbolic expressions. + * + * @tparam SymbolicType Any symbolic type that is understood by the + * add_to_symbol_map() functions. This includes individual + * Expression, std::vector, as well as + * Tensors and SymmetricTensors of Expressions. + */ + template + types::substitution_map + make_symbol_map(const SymbolicType &symbol); + + /** + * Return a symbolic map that has the entry keys given by @p symbol and all + * @p other_symbols. It is expected that all entries be valid symbols or + * symbolic expressions. + * + * With this function it is possible to construct a symbolic map from + * different types. An example may be as follows: + * + * @code + * const types::substitution_map symbol_map + * = make_symbol_map( + * Expression(...), + * Tensor<1,dim,Expression>(...), + * SymmetricTensor<2,dim,Expression>(...)); + * @endcode + * + * @tparam SymbolicType Any symbolic type that is understood by the + * add_to_symbol_map() functions. This includes individual + * Expression, std::vector, as well as + * Tensors and SymmetricTensors of Expressions. + */ + template + types::substitution_map + make_symbol_map(const SymbolicType &symbol, const Args &... other_symbols); + /** * A convenience function for an adding empty entry, with the key value * given by @p symbol, to the symbolic map @p substitution_map. @@ -753,6 +791,26 @@ namespace Differentiation /* ---------------- Symbol map creation and manipulation --------------*/ + template + types::substitution_map + make_symbol_map(const SymbolicType &symbol) + { + types::substitution_map symbol_map; + add_to_symbol_map(symbol_map, symbol); + return symbol_map; + } + + + template + types::substitution_map + make_symbol_map(const SymbolicType &symbol, const Args &... other_symbols) + { + types::substitution_map symbol_map; + add_to_symbol_map(symbol_map, symbol, other_symbols...); + return symbol_map; + } + + template void add_to_symbol_map(types::substitution_map &symbol_map,