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( "mimeticInnerProductDispatch() is not implemented for input of " << LvArray::system::demangleType( input ) );
88  }
89 }
90 
97 template< typename LAMBDA >
98 void
100  LAMBDA && lambda )
101 {
102  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
103  {
104  lambda( *ptr1 );
105  }
106  else if( auto * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct * >(&input) )
107  {
108  lambda( *ptr2 );
109  }
110  else if( auto * const ptr3 = dynamic_cast< QuasiRTInnerProduct * >(&input) )
111  {
112  lambda( *ptr3 );
113  }
114  else if( auto * const ptr4 = dynamic_cast< SimpleInnerProduct * >(&input) )
115  {
116  lambda( *ptr4 );
117  }
118  else if( auto * const ptr5 = dynamic_cast< BdVLMInnerProduct * >(&input) )
119  {
120  lambda( *ptr5 );
121  }
122  else
123  {
124  GEOS_ERROR( "mimeticInnerProductDispatch() is not implemented for input of " << LvArray::system::demangleType( input ) );
125  }
126 }
127 
136 template< typename LAMBDA >
137 void
139  LAMBDA && lambda )
140 {
141  if( auto const * const ptr1 = dynamic_cast< TPFAInnerProduct const * >(&input) )
142  {
143  lambda( *ptr1 );
144  }
145  else if( auto const * const ptr2 = dynamic_cast< BdVLMInnerProduct const * >(&input) )
146  {
147  lambda( *ptr2 );
148  }
149  else
150  {
151  GEOS_ERROR( "mimeticInnerProductReducedDispatch() is not implemented for input of " << LvArray::system::demangleType( input ) );
152  }
153 }
154 
163 template< typename LAMBDA >
164 void
166  LAMBDA && lambda )
167 {
168  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
169  {
170  lambda( *ptr1 );
171  }
172  else if( auto * const ptr2 = dynamic_cast< BdVLMInnerProduct * >(&input) )
173  {
174  lambda( *ptr2 );
175  }
176  else
177  {
178  GEOS_ERROR( "mimeticInnerProductReducedDispatch() is not supported for input of " << LvArray::system::demangleType( input ) );
179  }
180 }
181 
182 
183 } // end namespace mimeticInnerProduct
184 
185 } // end namespace geos
186 
187 #endif /* GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_ */
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:157
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