GEOSX
MimeticInnerProductDispatch.hpp
Go to the documentation of this file.
1 /*
2  * ------------------------------------------------------------------------------------------------------------
3  * SPDX-License-Identifier: LGPL-2.1-only
4  *
5  * Copyright (c) 2018-2020 Lawrence Livermore National Security LLC
6  * Copyright (c) 2018-2020 The Board of Trustees of the Leland Stanford Junior University
7  * Copyright (c) 2018-2020 TotalEnergies
8  * Copyright (c) 2019- GEOSX Contributors
9  * All rights reserved
10  *
11  * See top level LICENSE, COPYRIGHT, CONTRIBUTORS, NOTICE, and ACKNOWLEDGEMENTS files for details.
12  * ------------------------------------------------------------------------------------------------------------
13  */
14 
19 #ifndef GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_
20 #define GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_
21 
28 #include "LvArray/src/system.hpp"
29 
30 namespace geos
31 {
32 namespace mimeticInnerProduct
33 {
34 
40 {
42  static constexpr auto TPFA = "TPFA";
44  static constexpr auto QuasiTPFA = "quasiTPFA";
46  static constexpr auto QuasiRT = "quasiRT";
48  static constexpr auto Simple = "simple";
50  static constexpr auto BdVLM = "beiraoDaVeigaLipnikovManzini";
51 };
52 
59 template< typename LAMBDA >
60 void
62  LAMBDA && lambda )
63 {
64  if( auto const * const ptr1 = dynamic_cast< TPFAInnerProduct const * >(&input) )
65  {
66  lambda( *ptr1 );
67  }
68  else if( auto const * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct const * >(&input) )
69  {
70  lambda( *ptr2 );
71  }
72  else if( auto const * const ptr3 = dynamic_cast< QuasiRTInnerProduct const * >(&input) )
73  {
74  lambda( *ptr3 );
75  }
76  else if( auto const * const ptr4 = dynamic_cast< SimpleInnerProduct const * >(&input) )
77  {
78  lambda( *ptr4 );
79  }
80  else if( auto const * const ptr5 = dynamic_cast< BdVLMInnerProduct const * >(&input) )
81  {
82  lambda( *ptr5 );
83  }
84  else
85  {
86  GEOS_ERROR( "mimeticInnerProductDispatch() is not implemented for input of " << LvArray::system::demangleType( input ) );
87  }
88 }
89 
96 template< typename LAMBDA >
97 void
99  LAMBDA && lambda )
100 {
101  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
102  {
103  lambda( *ptr1 );
104  }
105  else if( auto * const ptr2 = dynamic_cast< QuasiTPFAInnerProduct * >(&input) )
106  {
107  lambda( *ptr2 );
108  }
109  else if( auto * const ptr3 = dynamic_cast< QuasiRTInnerProduct * >(&input) )
110  {
111  lambda( *ptr3 );
112  }
113  else if( auto * const ptr4 = dynamic_cast< SimpleInnerProduct * >(&input) )
114  {
115  lambda( *ptr4 );
116  }
117  else if( auto * const ptr5 = dynamic_cast< BdVLMInnerProduct * >(&input) )
118  {
119  lambda( *ptr5 );
120  }
121  else
122  {
123  GEOS_ERROR( "mimeticInnerProductDispatch() is not implemented for input of " << LvArray::system::demangleType( input ) );
124  }
125 }
126 
135 template< typename LAMBDA >
136 void
138  LAMBDA && lambda )
139 {
140  if( auto const * const ptr1 = dynamic_cast< TPFAInnerProduct const * >(&input) )
141  {
142  lambda( *ptr1 );
143  }
144  else if( auto const * const ptr2 = dynamic_cast< BdVLMInnerProduct const * >(&input) )
145  {
146  lambda( *ptr2 );
147  }
148  else
149  {
150  GEOS_ERROR( "mimeticInnerProductReducedDispatch() is not implemented for input of " << LvArray::system::demangleType( input ) );
151  }
152 }
153 
162 template< typename LAMBDA >
163 void
165  LAMBDA && lambda )
166 {
167  if( auto * const ptr1 = dynamic_cast< TPFAInnerProduct * >(&input) )
168  {
169  lambda( *ptr1 );
170  }
171  else if( auto * const ptr2 = dynamic_cast< BdVLMInnerProduct * >(&input) )
172  {
173  lambda( *ptr2 );
174  }
175  else
176  {
177  GEOS_ERROR( "mimeticInnerProductReducedDispatch() is not supported for input of " << LvArray::system::demangleType( input ) );
178  }
179 }
180 
181 
182 } // end namespace mimeticInnerProduct
183 
184 } // end namespace geos
185 
186 #endif /* GEOS_FINITEVOLUME_MIMETICINNERPRODUCTS_MIMETICINNERPRODUCTDISPATCH_HPP_ */
#define GEOS_ERROR(msg)
Raise a hard error and terminate the program.
Definition: Logger.hpp:122
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