25#include <boost/mpi/collectives/gather.hpp>
26#include <boost/mpi/collectives/scatter.hpp>
27#include <boost/mpi/communicator.hpp>
28#include <boost/multi_array.hpp>
29#include <boost/serialization/vector.hpp>
44template <
class>
struct is_optional_type :
public std::false_type {};
46struct is_optional_type<std::
optional<T>> :
public std::true_type {};
48template <
class ArrayView,
typename T>
50 using array_type = boost::multi_array<T, 4>;
56 for (
typename array_type::index i = 0; i !=
dim_i; ++i) {
57 for (
typename array_type::index
j = 0;
j !=
dim_j; ++
j) {
58 for (
typename array_type::index k = 0; k !=
dim_k; ++k) {
59 for (
typename array_type::index t = 0; t !=
dim_t; ++t) {
68template <
class FieldSerializer,
class ArrayView,
typename T>
71 using array_type = boost::multi_array<T, 4>;
72 out.reserve(
view.num_elements());
77 for (
typename array_type::index i = 0; i !=
dim_i; ++i) {
78 for (
typename array_type::index
j = 0;
j !=
dim_j; ++
j) {
79 for (
typename array_type::index k = 0; k !=
dim_k; ++k) {
80 for (
typename array_type::index t = 0; t !=
dim_t; ++t) {
81 if constexpr (std::is_floating_point_v<T>) {
84 if (
view[i][
j][k][t]) {
87 out.emplace_back(std::nullopt);
110template <
class FieldSerializer>
111template <
class LatticeModel,
typename T>
118 auto const &comm = context()->get_comm();
124 1, std::multiplies<>());
129 if (comm.rank() == 0) {
131 using index_range = boost::multi_array_types::index_range;
132 using array_type = boost::multi_array<T, 4>;
133 array_type array(boost::extents[dims[0]][dims[1]][dims[2]][
data_size]);
135 for (std::size_t rank = 0; rank <
nodes_values.size(); ++rank) {
146 typename array_type::template array_view<4>::type
view =
154 std::vector<int> shape = {m_shape.begin(), m_shape.end()};
158 auto const variant = FieldSerializer::serialize(
out);
164template <
class FieldSerializer>
165template <
class LatticeModel,
typename T>
170 Utils::Vector3i const &,
171 std::vector<T> const &),
172 double units_conversion) {
179 1, std::multiplies<>());
182 if (comm.rank() == 0) {
186 using index_range = boost::multi_array_types::index_range;
187 using array_type = boost::multi_array<T, 4>;
188 array_type array(boost::extents[dims[0]][dims[1]][dims[2]][
data_size]);
190 detail::unflatten_grid(array,
values);
201 typename array_type::template array_view<4>::type
view =
Vector implementation and trait types for boost qvm interoperability.
virtual boost::mpi::communicator const & get_comm() const =0
Context * context() const
Responsible context.
Variant gather_3d(VariantMap const ¶ms, std::vector< int > const &data_dims, LatticeModel const &lattice_model, std::vector< T >(LatticeModel::*getter)(Utils::Vector3i const &, Utils::Vector3i const &) const, double units_conversion=1.) const
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value)
Create a vector that has all entries set to the same value.
auto gather_slices_topology(boost::mpi::communicator const &comm, Utils::Vector3i const &local_lower_corner, Utils::Vector3i const &local_upper_corner)
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
boost::make_recursive_variant< None, bool, int, std::size_t, double, std::string, ObjectRef, Utils::Vector3b, Utils::Vector3i, Utils::Vector2d, Utils::Vector3d, Utils::Vector4d, std::vector< int >, std::vector< double >, std::vector< boost::recursive_variant_ >, std::unordered_map< int, boost::recursive_variant_ >, std::unordered_map< std::string, boost::recursive_variant_ > >::type Variant
Possible types for parameters.
static SteepestDescentParameters params
Currently active steepest descent instance.