|
| 1 | +// Copyright 2018-2025 the samurai's authors |
| 2 | +// SPDX-License-Identifier: BSD-3-Clause |
| 3 | + |
| 4 | +#pragma once |
| 5 | + |
| 6 | +#include "arguments.hpp" |
| 7 | +#include <array> |
| 8 | + |
| 9 | +namespace samurai |
| 10 | +{ |
| 11 | + |
| 12 | + template <std::size_t dim_> |
| 13 | + class mesh_config |
| 14 | + { |
| 15 | + public: |
| 16 | + |
| 17 | + static constexpr std::size_t dim = dim_; |
| 18 | + |
| 19 | + mesh_config() |
| 20 | + { |
| 21 | + m_periodic.fill(false); |
| 22 | + } |
| 23 | + |
| 24 | + auto& max_stencil_width(std::size_t stencil_width) |
| 25 | + { |
| 26 | + m_max_stencil_width = stencil_width; |
| 27 | + return *this; |
| 28 | + } |
| 29 | + |
| 30 | + auto& max_stencil_width() const |
| 31 | + { |
| 32 | + return m_max_stencil_width; |
| 33 | + } |
| 34 | + |
| 35 | + auto& graduation_width(std::size_t grad_width) |
| 36 | + { |
| 37 | + m_graduation_width = grad_width; |
| 38 | + return *this; |
| 39 | + } |
| 40 | + |
| 41 | + auto& graduation_width() const |
| 42 | + { |
| 43 | + return m_graduation_width; |
| 44 | + } |
| 45 | + |
| 46 | + auto& min_level(std::size_t level) |
| 47 | + { |
| 48 | + m_min_level = level; |
| 49 | + return *this; |
| 50 | + } |
| 51 | + |
| 52 | + auto& min_level() const |
| 53 | + { |
| 54 | + return m_min_level; |
| 55 | + } |
| 56 | + |
| 57 | + auto& max_level(std::size_t level) |
| 58 | + { |
| 59 | + m_max_level = level; |
| 60 | + return *this; |
| 61 | + } |
| 62 | + |
| 63 | + auto& max_level() const |
| 64 | + { |
| 65 | + return m_max_level; |
| 66 | + } |
| 67 | + |
| 68 | + auto& approx_box_tol(double tol) |
| 69 | + { |
| 70 | + m_approx_box_tol = tol; |
| 71 | + return *this; |
| 72 | + } |
| 73 | + |
| 74 | + auto& approx_box_tol() const |
| 75 | + { |
| 76 | + return m_approx_box_tol; |
| 77 | + } |
| 78 | + |
| 79 | + auto& scaling_factor(double factor) |
| 80 | + { |
| 81 | + m_scaling_factor = factor; |
| 82 | + return *this; |
| 83 | + } |
| 84 | + |
| 85 | + auto& scaling_factor() const |
| 86 | + { |
| 87 | + return m_scaling_factor; |
| 88 | + } |
| 89 | + |
| 90 | + auto& periodic(std::array<bool, dim> const& periodicity) |
| 91 | + { |
| 92 | + m_periodic = periodicity; |
| 93 | + return *this; |
| 94 | + } |
| 95 | + |
| 96 | + auto& periodic() const |
| 97 | + { |
| 98 | + return m_periodic; |
| 99 | + } |
| 100 | + |
| 101 | + auto& periodic(std::size_t i) const |
| 102 | + { |
| 103 | + return m_periodic[i]; |
| 104 | + } |
| 105 | + |
| 106 | + void parse_args() |
| 107 | + { |
| 108 | + // if (args::max_stencil_width != std::numeric_limits<std::size_t>::max()) |
| 109 | + // { |
| 110 | + // m_max_stencil_width = args::max_stencil_width; |
| 111 | + // } |
| 112 | + // if (args::graduation_width != std::numeric_limits<std::size_t>::max()) |
| 113 | + // { |
| 114 | + // m_graduation_width = args::graduation_width; |
| 115 | + // } |
| 116 | + if (args::min_level != std::numeric_limits<std::size_t>::max()) |
| 117 | + { |
| 118 | + m_min_level = args::min_level; |
| 119 | + } |
| 120 | + if (args::max_level != std::numeric_limits<std::size_t>::max()) |
| 121 | + { |
| 122 | + m_max_level = args::max_level; |
| 123 | + } |
| 124 | + // if (args::approx_box_tol != std::numeric_limits<double>::infinity()) |
| 125 | + // { |
| 126 | + // m_approx_box_tol = args::approx_box_tol; |
| 127 | + // } |
| 128 | + // if (args::scaling_factor != std::numeric_limits<double>::infinity()) |
| 129 | + // { |
| 130 | + // m_scaling_factor = args::scaling_factor; |
| 131 | + // } |
| 132 | + } |
| 133 | + |
| 134 | + private: |
| 135 | + |
| 136 | + std::size_t m_max_stencil_width = 1; |
| 137 | + std::size_t m_graduation_width = 1; |
| 138 | + |
| 139 | + std::size_t m_min_level; |
| 140 | + std::size_t m_max_level; |
| 141 | + |
| 142 | + double m_approx_box_tol = 0.05; |
| 143 | + double m_scaling_factor = 0; |
| 144 | + |
| 145 | + std::array<bool, dim> m_periodic; |
| 146 | + }; |
| 147 | +} |
0 commit comments