| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2019 - 2024 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
#ifndef dealii_differentiation_sd_symengine_types_h |
| 16 |
#define dealii_differentiation_sd_symengine_types_h |
| 17 |
|
| 18 |
#include <deal.II/base/config.h> |
| 19 |
|
| 20 |
#ifdef DEAL_II_WITH_SYMENGINE |
| 21 |
|
| 22 |
# include <boost/serialization/map.hpp> |
| 23 |
|
| 24 |
# include <map> |
| 25 |
# include <vector> |
| 26 |
|
| 27 |
DEAL_II_NAMESPACE_OPEN |
| 28 |
|
| 29 |
namespace Differentiation |
| 30 |
{ |
| 31 |
namespace SD |
| 32 |
{ |
| 33 |
// Forward declarations |
| 34 |
class Expression; |
| 35 |
|
| 36 |
|
| 37 |
namespace types |
| 38 |
{ |
| 39 |
namespace internal |
| 40 |
{ |
| 41 |
/** |
| 42 |
* A comparator for Expressions used as keys in maps. |
| 43 |
*/ |
| 44 |
struct ExpressionKeyLess |
| 45 |
{ |
| 46 |
bool |
| 47 |
operator()(const SD::Expression &lhs, |
| 48 |
const SD::Expression &rhs) const; |
| 49 |
}; |
| 50 |
} // namespace internal |
| 51 |
|
| 52 |
/** |
| 53 |
* Type definition for a value substitution map. |
| 54 |
* |
| 55 |
* This serves the same purpose as a `SymEngine::map_basic_basic`, which |
| 56 |
* is equivalent to a `std::map<SymEngine::RCP<const SymEngine::Basic>, |
| 57 |
* SymEngine::RCP<const SymEngine::Basic>>`. |
| 58 |
*/ |
| 59 |
using substitution_map = |
| 60 |
std::map<SD::Expression, SD::Expression, internal::ExpressionKeyLess>; |
| 61 |
|
| 62 |
/** |
| 63 |
* Type definition for a vector of symbols. |
| 64 |
* |
| 65 |
* This serves the same purpose as a `SymEngine::vec_basic`, which is |
| 66 |
* equivalent to a `std::vector<SymEngine::RCP<const SymEngine::Basic>>`. |
| 67 |
*/ |
| 68 |
using symbol_vector = std::vector<SD::Expression>; |
| 69 |
|
| 70 |
} // namespace types |
| 71 |
|
| 72 |
} // namespace SD |
| 73 |
} // namespace Differentiation |
| 74 |
|
| 75 |
|
| 76 |
DEAL_II_NAMESPACE_CLOSE |
| 77 |
|
| 78 |
|
| 79 |
# ifndef DOXYGEN |
| 80 |
|
| 81 |
// Add serialization capability for SD::types::internal::ExpressionKeyLess |
| 82 |
// We need to define this so that we can use this comparator in maps that |
| 83 |
// are to be serialized. |
| 84 |
namespace boost |
| 85 |
{ |
| 86 |
namespace serialization |
| 87 |
{ |
| 88 |
namespace SD = dealii::Differentiation::SD; |
| 89 |
|
| 90 |
template <typename Archive> |
| 91 |
void |
| 92 |
serialize(Archive & /*ar*/, |
| 93 |
SD::types::internal::ExpressionKeyLess & /*cmp*/, |
| 94 |
unsigned int /*version*/) |
| 95 |
{ |
| 96 |
// Nothing to do. |
| 97 |
} |
| 98 |
} // namespace serialization |
| 99 |
} // namespace boost |
| 100 |
|
| 101 |
# endif // DOXYGEN |
| 102 |
|
| 103 |
#else |
| 104 |
|
| 105 |
// Make sure the scripts that create the C++20 module input files have |
| 106 |
// something to latch on if the preprocessor #ifdef above would |
| 107 |
// otherwise lead to an empty content of the file. |
| 108 |
DEAL_II_NAMESPACE_OPEN |
| 109 |
DEAL_II_NAMESPACE_CLOSE |
| 110 |
|
| 111 |
#endif // DEAL_II_WITH_SYMENGINE |
| 112 |
|
| 113 |
#endif // dealii_differentiation_sd_symengine_types_h |