Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
LatticeSlice.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2023 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include "config/config.hpp"
23
24#ifdef WALBERLA
25
26#include "LatticeIndices.hpp"
27
29
31
32#include <utils/Vector.hpp>
33
34#include <cassert>
35#include <tuple>
36#include <vector>
37
39
40template <class FieldSerializer> class LatticeSlice : public LatticeIndices {
41protected:
44 std::vector<int> m_shape;
45
46public:
47 virtual ::LatticeWalberla const &get_lattice() const = 0;
48
49private:
50 auto get_sentinel_index(::LatticeWalberla const &lattice) const {
51 return -(static_cast<int>(lattice.get_ghost_layers()) + 1);
52 }
53
54 auto get_slices_bounding_boxes() const {
55 auto const &lattice = get_lattice();
58 assert(slice_upper_corner <= lattice.get_grid_dimensions());
60 auto const sentinel = get_sentinel_index(lattice);
62 lattice.get_local_grid_range();
63 for (auto const i : {0, 1, 2}) {
68 } else {
71 }
74 }
75 }
76 }
77 return std::make_tuple(slice_lower_corner, slice_upper_corner,
79 }
80
81protected:
82 template <class LatticeModel, typename T>
83 Variant gather_3d(VariantMap const &params, std::vector<int> const &data_dims,
85 std::vector<T> (LatticeModel::*getter)(
88
89 template <class LatticeModel, typename T>
90 void scatter_3d(VariantMap const &params, std::vector<int> const &data_dims,
94 std::vector<T> const &),
96};
97} // namespace ScriptInterface::walberla
98
99#endif // WALBERLA
Vector implementation and trait types for boost qvm interoperability.
Abstract representation of a lattice-based model.
Class that runs and controls the BlockForest in waLBerla.
Interface to carry out simple operations on lattice indices.
Variant gather_3d(VariantMap const &params, 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
void scatter_3d(VariantMap const &params, std::vector< int > const &data_dims, LatticeModel &lattice_model, void(LatticeModel::*setter)(Utils::Vector3i const &, Utils::Vector3i const &, std::vector< T > const &), double units_conversion=1.)
virtual ::LatticeWalberla const & get_lattice() const =0
static DEVICE_QUALIFIER constexpr Vector< T, N > broadcast(typename Base::value_type const &value) noexcept
Create a vector that has all entries set to the same value.
Definition Vector.hpp:111
This file contains the defaults for ESPResSo.
T get_value(Variant const &v)
Extract value of specific type T from a Variant.
std::unordered_map< std::string, Variant > VariantMap
Definition Variant.hpp:69
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.
Definition Variant.hpp:67
VectorXi< 3 > Vector3i
Definition Vector.hpp:174
std::vector< T, allocator< T > > vector
Definition vector.hpp:52
static SteepestDescentParameters params
Currently active steepest descent instance.