GEOS
MimeticInnerProductDispatch.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2016-2024 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2024 TotalEnergies
7  * Copyright (c) 2018-2024 The Board of Trustees of the Leland Stanford Junior University
8  * Copyright (c) 2023-2024 Chevron
9  * Copyright (c) 2019- GEOS/GEOSX Contributors
10  * All rights reserved
11  *
12  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
13  * ------------------------------------------------------------------------------------------------------------
14  */
15 
20 #ifndef GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_
21 #define GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_
22 
30 #include "LvArray/src/system.hpp"
31 
32 namespace geos
33 {
34 namespace mimeticInnerProduct
35 {
36 
42 {
44  static constexpr auto TPFA = "TPFA";
46  static constexpr auto QuasiTPFA = "quasiTPFA";
48  static constexpr auto QuasiRT = "quasiRT";
50  static constexpr auto Simple = "simple";
52  static constexpr auto BdVLM = "beiraoDaVeigaLipnikovManzini";
54  static constexpr auto RT = "RT";
55 };
56 
63 template< typename LAMBDA >
64 void
66  LAMBDA && lambda )
67 {
68  if( auto const * const ptr1 = dynamic_cast< TPFAInnerProduct const * >(&input) )
69  {
70  lambda( *ptr1 );
71  }
72  else if( auto const * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct const * >(&input) )
73  {
74  lambda( *ptr2 );
75  }
76  else if( auto const * const ptr3 = dynamic_cast< QuasiRTInnerProduct const * >(&input) )
77  {
78  lambda( *ptr3 );
79  }
80  else if( auto const * const ptr4 = dynamic_cast< SimpleInnerProduct const * >(&input) )
81  {
82  lambda( *ptr4 );
83  }
84  else if( auto const * const ptr5 = dynamic_cast< BdVLMInnerProduct const * >(&input) )
85  {
86  lambda( *ptr5 );
87  }
88  else if( auto const * const ptr6 = dynamic_cast< RTInnerProduct const * >(&input) )
89  {
90  lambda( *ptr6 );
91  }
92  else
93  {
94  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductDispatch() is not implemented for input of {}",
95  LvArray::system::demangleType( input ) ) );
96  }
97 }
98 
105 template< typename LAMBDA >
106 void
108  LAMBDA && lambda )
109 {
110  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
111  {
112  lambda( *ptr1 );
113  }
114  else if( auto * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct * >(&input) )
115  {
116  lambda( *ptr2 );
117  }
118  else if( auto * const ptr3 = dynamic_cast< QuasiRTInnerProduct * >(&input) )
119  {
120  lambda( *ptr3 );
121  }
122  else if( auto * const ptr4 = dynamic_cast< SimpleInnerProduct * >(&input) )
123  {
124  lambda( *ptr4 );
125  }
126  else if( auto * const ptr5 = dynamic_cast< BdVLMInnerProduct * >(&input) )
127  {
128  lambda( *ptr5 );
129  }
130  else if( auto * const ptr6 = dynamic_cast< RTInnerProduct * >(&input) )
131  {
132  lambda( *ptr6 );
133  }
134  else
135  {
136  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductDispatch() is not implemented for input of {}",
137  LvArray::system::demangleType( input ) ) );
138  }
139 }
140 
149 template< typename LAMBDA >
150 void
152  LAMBDA && lambda )
153 {
154  if( auto const * const ptr1 = dynamic_cast< TPFAInnerProduct const * >(&input) )
155  {
156  lambda( *ptr1 );
157  }
158  else if( auto const * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct const * >(&input) )
159  {
160  lambda( *ptr2 );
161  }
162  else if( auto const * const ptr3 = dynamic_cast< BdVLMInnerProduct const * >(&input) )
163  {
164  lambda( *ptr3 );
165  }
166  else
167  {
168  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductReducedDispatch() is not implemented for input of {}",
169  LvArray::system::demangleType( input ) ) );
170  }
171 }
172 
181 template< typename LAMBDA >
182 void
184  LAMBDA && lambda )
185 {
186  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
187  {
188  lambda( *ptr1 );
189  }
190  else if( auto * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct * >(&input) )
191  {
192  lambda( *ptr2 );
193  }
194  else if( auto * const ptr3 = dynamic_cast< BdVLMInnerProduct * >(&input) )
195  {
196  lambda( *ptr3 );
197  }
198  else
199  {
200  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductReducedDispatch() is not supported for input of {}",
201  LvArray::system::demangleType( input ) ) );
202  }
203 }
204 
205 
206 } // end namespace mimeticInnerProduct
207 
208 } // end namespace geos
209 
210 #endif /* GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_ */
#define GEOS_ERROR(...)
Raise a hard error and terminate the program.
Definition: Logger.hpp:220
void mimeticInnerProductDispatch(MimeticInnerProductBase const &input, LAMBDA &&lambda)
Dispatch for the selection of the mimetic inner product.
void mimeticInnerProductReducedDispatch(MimeticInnerProductBase const &input, LAMBDA &&lambda)
Dispatch for the selection of the mimetic inner product (limited number of possible templates)....
Struct containing the keys to all the implemented inner products.
static constexpr auto QuasiTPFA
string for the quasi-TPFA inner product
static constexpr auto QuasiRT
string for the quasi-RT inner product
static constexpr auto Simple
string for the Simple inner product
static constexpr auto BdVLM
string for the inner product of Beirao da Veiga, Lipnikov, Manzini
static constexpr auto TPFA
string for the TPFA inner product
static constexpr auto RT
string for the Raviart-Thomas inner product (exact RT0 on simplices)