Reference documentation for deal.II version 9.5.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
symengine_utilities.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2019 - 2022 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE at
12// the top level of the deal.II distribution.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_differentiation_sd_symengine_utilities_h
17#define dealii_differentiation_sd_symengine_utilities_h
18
19#include <deal.II/base/config.h>
20
21#ifdef DEAL_II_WITH_SYMENGINE
22
25
26# include <symengine/basic.h>
27# include <symengine/dict.h>
28
30
31namespace Differentiation
32{
33 namespace SD
34 {
35 namespace Utilities
36 {
40 SymEngine::map_basic_basic
42 const SD::types::substitution_map &substitution_map);
43
49 const SymEngine::map_basic_basic &substitution_map);
50
54 SymEngine::vec_basic
56 const SD::types::symbol_vector &symbol_vector);
57
63 const SymEngine::vec_basic &symbol_vector);
64
69 std::vector<std::pair<Expression, Expression>>
71 const SymEngine::vec_pair &symbol_value_vector);
72
83 extract_symbols(const SD::types::substitution_map &substitution_values);
84
96 template <typename NumberType, typename ExpressionType = SD::Expression>
97 std::vector<NumberType>
98 extract_values(const SD::types::substitution_map &substitution_values);
99
103 template <typename StreamType>
104 StreamType &
106 StreamType & stream,
107 const SD::types::substitution_map &symbol_value_map);
108
109 } // namespace Utilities
110
111 } // namespace SD
112} // namespace Differentiation
113
114
115/* -------------------- inline and template functions ------------------ */
116
117
118# ifndef DOXYGEN
119
120
121namespace Differentiation
122{
123 namespace SD
124 {
125 namespace Utilities
126 {
127 template <typename NumberType, typename ExpressionType>
128 std::vector<NumberType>
129 extract_values(const SD::types::substitution_map &substitution_values)
130 {
131 std::vector<NumberType> values;
132 values.reserve(substitution_values.size());
133
134 for (const auto &entry : substitution_values)
135 values.push_back(
136 static_cast<NumberType>(ExpressionType(entry.second)));
137
138 return values;
139 }
140
141
142 template <typename StreamType>
143 StreamType &
145 StreamType & stream,
146 const SD::types::substitution_map &symbol_value_map)
147 {
148 for (const auto &entry : symbol_value_map)
149 stream << entry.first << " = " << entry.second << '\n';
150
151 stream << std::flush;
152 return stream;
153 }
154
155 } // namespace Utilities
156
157 } // namespace SD
158} // namespace Differentiation
159
160
161# endif // DOXYGEN
162
163
165
166#endif // DEAL_II_WITH_SYMENGINE
167
168#endif // dealii_differentiation_sd_symengine_utilities_h
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
Point< 2 > second
Definition grid_out.cc:4616
Point< 2 > first
Definition grid_out.cc:4615
std::vector< NumberType > extract_values(const SD::types::substitution_map &substitution_values)
SD::types::symbol_vector extract_symbols(const SD::types::substitution_map &substitution_values)
StreamType & print_substitution_map(StreamType &stream, const SD::types::substitution_map &symbol_value_map)
std::vector< std::pair< Expression, Expression > > convert_basic_pair_vector_to_expression_pair_vector(const SymEngine::vec_pair &symbol_value_vector)
SD::types::substitution_map convert_basic_map_to_expression_map(const SymEngine::map_basic_basic &substitution_map)
SD::types::symbol_vector convert_basic_vector_to_expression_vector(const SymEngine::vec_basic &symbol_vector)
SymEngine::map_basic_basic convert_expression_map_to_basic_map(const SD::types::substitution_map &substitution_map)
SymEngine::vec_basic convert_expression_vector_to_basic_vector(const SD::types::symbol_vector &symbol_vector)
std::vector< SD::Expression > symbol_vector
std::map< SD::Expression, SD::Expression, internal::ExpressionKeyLess > substitution_map