Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
CartesianGridGeometry.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
22 #include "fub/ext/Log.hpp"
25 
26 #include <AMReX_Geometry.H>
27 
28 #include <array>
29 #include <fmt/ranges.h>
30 
31 #ifndef FUB_AMREX_CARTESIAN_GRID_GEOMETRY_HPP
32 #define FUB_AMREX_CARTESIAN_GRID_GEOMETRY_HPP
33 
34 namespace fub {
35 namespace amrex {
36 
38  CartesianGridGeometry() = default;
40 
41  template <typename Log> void Print(Log& log);
42 
43  std::array<int, AMREX_SPACEDIM> cell_dimensions{AMREX_D_DECL(32, 32, 32)};
44  ::amrex::RealBox coordinates{
45  std::array<double, AMREX_SPACEDIM>{},
46  std::array<double, AMREX_SPACEDIM>{AMREX_D_DECL(1.0, 1.0, 1.0)}};
47  std::array<int, AMREX_SPACEDIM> periodicity{};
48 };
49 
50 template <typename Log> void CartesianGridGeometry::Print(Log& log) {
51  std::array<double, AMREX_SPACEDIM> xlo{};
52  std::array<double, AMREX_SPACEDIM> xup{};
53  std::copy_n(coordinates.lo(), AMREX_SPACEDIM, xlo.data());
54  std::copy_n(coordinates.hi(), AMREX_SPACEDIM, xup.data());
55  BOOST_LOG(log) << fmt::format(" - cell_dimensions = {{{}}}",
56  fmt::join(cell_dimensions, ", "));
57  BOOST_LOG(log) << fmt::format(" - coordinates:lower = {{{}}}", fmt::join(xlo, ", "));
58  BOOST_LOG(log) << fmt::format(" - coordinates:upper = {{{}}}", fmt::join(xup, ", "));
59  BOOST_LOG(log) << fmt::format(" - periodicity = {{{}}}",
60  fmt::join(periodicity, ", "));
61 }
62 
64 
65 ::amrex::RealBox DomainAroundCenter(const ::amrex::RealArray& x,
66  const ::amrex::RealArray& rx);
67 
68 ::amrex::Box BoxWhichContains(const ::amrex::RealBox& xbox,
69  const ::amrex::Geometry& geom);
70 
71 } // namespace amrex
72 } // namespace fub
73 
74 #endif
Definition: AMReX/Geometry.hpp:30
::amrex::RealBox DomainAroundCenter(const ::amrex::RealArray &x, const ::amrex::RealArray &rx)
::amrex::Geometry GetCoarseGeometry(const CartesianGridGeometry &grid_geometry)
::amrex::Box BoxWhichContains(const ::amrex::RealBox &xbox, const ::amrex::Geometry &geom)
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
void Log(std::string message, Duration timepoint, boost::log::trivial::severity_level level=boost::log::trivial::severity_level::info)
IndexBox< Rank > Box(const BasicView< State, Layout, Rank > &view)
Definition: State.hpp:486
std::map< std::string, pybind11::object > ProgramOptions
Definition: ProgramOptions.hpp:40
Definition: CartesianGridGeometry.hpp:37
CartesianGridGeometry(const ProgramOptions &options)
::amrex::RealBox coordinates
Definition: CartesianGridGeometry.hpp:44
void Print(Log &log)
Definition: CartesianGridGeometry.hpp:50
std::array< int, AMREX_SPACEDIM > periodicity
Definition: CartesianGridGeometry.hpp:47
std::array< int, AMREX_SPACEDIM > cell_dimensions
Definition: CartesianGridGeometry.hpp:43