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 
29 #include "LvArray/src/system.hpp"
30 
31 namespace geos
32 {
33 namespace mimeticInnerProduct
34 {
35 
41 {
43  static constexpr auto TPFA = "TPFA";
45  static constexpr auto QuasiTPFA = "quasiTPFA";
47  static constexpr auto QuasiRT = "quasiRT";
49  static constexpr auto Simple = "simple";
51  static constexpr auto BdVLM = "beiraoDaVeigaLipnikovManzini";
52 };
53 
60 template< typename LAMBDA >
61 void
63  LAMBDA && lambda )
64 {
65  if( auto const * const ptr1 = dynamic_cast< TPFAInnerProduct const * >(&input) )
66  {
67  lambda( *ptr1 );
68  }
69  else if( auto const * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct const * >(&input) )
70  {
71  lambda( *ptr2 );
72  }
73  else if( auto const * const ptr3 = dynamic_cast< QuasiRTInnerProduct const * >(&input) )
74  {
75  lambda( *ptr3 );
76  }
77  else if( auto const * const ptr4 = dynamic_cast< SimpleInnerProduct const * >(&input) )
78  {
79  lambda( *ptr4 );
80  }
81  else if( auto const * const ptr5 = dynamic_cast< BdVLMInnerProduct const * >(&input) )
82  {
83  lambda( *ptr5 );
84  }
85  else
86  {
87  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductDispatch() is not implemented for input of {}",
88  LvArray::system::demangleType( input ) ) );
89  }
90 }
91 
98 template< typename LAMBDA >
99 void
101  LAMBDA && lambda )
102 {
103  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
104  {
105  lambda( *ptr1 );
106  }
107  else if( auto * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct * >(&input) )
108  {
109  lambda( *ptr2 );
110  }
111  else if( auto * const ptr3 = dynamic_cast< QuasiRTInnerProduct * >(&input) )
112  {
113  lambda( *ptr3 );
114  }
115  else if( auto * const ptr4 = dynamic_cast< SimpleInnerProduct * >(&input) )
116  {
117  lambda( *ptr4 );
118  }
119  else if( auto * const ptr5 = dynamic_cast< BdVLMInnerProduct * >(&input) )
120  {
121  lambda( *ptr5 );
122  }
123  else
124  {
125  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductDispatch() is not implemented for input of {}",
126  LvArray::system::demangleType( input ) ) );
127  }
128 }
129 
138 template< typename LAMBDA >
139 void
141  LAMBDA && lambda )
142 {
143  if( auto const * const ptr1 = dynamic_cast< TPFAInnerProduct const * >(&input) )
144  {
145  lambda( *ptr1 );
146  }
147  else if( auto const * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct const * >(&input) )
148  {
149  lambda( *ptr2 );
150  }
151  else if( auto const * const ptr3 = dynamic_cast< BdVLMInnerProduct const * >(&input) )
152  {
153  lambda( *ptr3 );
154  }
155  else
156  {
157  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductReducedDispatch() is not implemented for input of {}",
158  LvArray::system::demangleType( input ) ) );
159  }
160 }
161 
170 template< typename LAMBDA >
171 void
173  LAMBDA && lambda )
174 {
175  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
176  {
177  lambda( *ptr1 );
178  }
179  else if( auto * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct * >(&input) )
180  {
181  lambda( *ptr2 );
182  }
183  else if( auto * const ptr3 = dynamic_cast< BdVLMInnerProduct * >(&input) )
184  {
185  lambda( *ptr3 );
186  }
187  else
188  {
189  GEOS_ERROR( GEOS_FMT( "mimeticInnerProductReducedDispatch() is not supported for input of {}",
190  LvArray::system::demangleType( input ) ) );
191  }
192 }
193 
194 
195 } // end namespace mimeticInnerProduct
196 
197 } // end namespace geos
198 
199 #endif /* GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_ */
#define GEOS_ERROR(...)
Raise a hard error and terminate the program.
Definition: Logger.hpp:226
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