Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
BoundaryConditionRef.hpp
Go to the documentation of this file.
1 // Copyright (c) 2020 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 
21 #ifndef FUB_AMREX_BOUNDARY_CONDITION_REF_HPP
22 #define FUB_AMREX_BOUNDARY_CONDITION_REF_HPP
23 
25 
26 #include <AMReX_PhysBCFunct.H>
27 
28 namespace fub::amrex {
29 
30 /// \ingroup BoundaryCondition
31 ///
32 /// \brief This class references a BoundaryCondition object and acts as an
33 /// adapter such that it is enabled to be used as an AMReX boundary condition
34 template <typename BC, typename GriddingAlgorithm>
36 public:
37  /// @{
38  /// \name Constructors
39 
40  /// \brief This adapter class is not default constructible.
42 
43  /// \brief Constructs a reference to `condition` and stores a pointer to
44  /// `grid` at refinement level `level`.
45  ///
46  /// \param[in] condition The condition that will be invoked
47  ///
48  /// \param[in] grid The reference gridding algorithm can be used if a Geometry
49  /// object or boundary conditions are needed
50  ///
51  /// \param[in] level The refinement level for which this boundary conditions
52  /// will be applied to.
53  ///
54  /// \throw Nothing.
55  BoundaryConditionRef(BC& condition, const GriddingAlgorithm& grid, int level);
56  /// @}
57 
58  /// \name Actions
59 
60  /// \brief This function fills the ghost layer of the specified MultiFab `mf`.
61  ///
62  /// \throw Throws any exception that is thrown by the reference boundary
63  /// condition.
64  void operator() (::amrex::MultiFab& mf, int dcomp, int ncomp,
65  ::amrex::IntVect const& nghost, ::amrex::Real time,
66  int bccomp);
67 
68  BC* pointer;
70  int level;
71 };
72 
73 template <typename BC, typename GriddingAlgorithm>
75  BC& condition, const GriddingAlgorithm& grid, int lvl)
76  : pointer{&condition}, gridding{&grid}, level{lvl} {}
77 
78 template <typename BC, typename GriddingAlgorithm>
79 void BoundaryConditionRef<BC, GriddingAlgorithm>::operator() (::amrex::MultiFab& mf, int, int,
80  ::amrex::IntVect const&, ::amrex::Real,
81  int) {
82  if (pointer && gridding) {
83  pointer->FillBoundary(mf, *gridding, level);
84  }
85 }
86 
87 } // namespace fub::amrex
88 
89 #endif
This class references a BoundaryCondition object and acts as an adapter such that it is enabled to be...
Definition: BoundaryConditionRef.hpp:35
BC * pointer
This function fills the ghost layer of the specified MultiFab mf.
Definition: BoundaryConditionRef.hpp:68
void operator()(::amrex::MultiFab &mf, int dcomp, int ncomp, ::amrex::IntVect const &nghost, ::amrex::Real time, int bccomp)
This function fills the ghost layer of the specified MultiFab mf.
Definition: BoundaryConditionRef.hpp:79
BoundaryConditionRef()=delete
This adapter class is not default constructible.
const GriddingAlgorithm * gridding
This function fills the ghost layer of the specified MultiFab mf.
Definition: BoundaryConditionRef.hpp:69
int level
This function fills the ghost layer of the specified MultiFab mf.
Definition: BoundaryConditionRef.hpp:70
This class modifies and initializes a PatchLevel in a PatchHierarchy.
Definition: AMReX/GriddingAlgorithm.hpp:60
The amrex namespace.
Definition: AverageState.hpp:33