CEPS  24.01
Cardiac ElectroPhysiology Simulator
FEType.hpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
30 #pragma once
31 
33 
35 using CepsFeLagrangeType = std::pair<CepsCellType,CepsUInt>;
36 
38 inline CepsString
40 {
41  if (cat == CepsCellType::Quad)
42  return "Q" + ceps::toString(order);
43  return "P" + ceps::toString(order);
44 }
45 
47 inline CepsFeLagrangeType
49 {
50  CepsChar k = ceps::toKey (type).at (0);
51  CepsUInt i = ceps::toUInt(type.substr (1));
52 
53  CepsBool ok = (k=='P' or k=='Q');
54  CEPS_ABORT_IF(not ok,
55  "Unknown finite element type. Valid types are P[1,2,...] and Q[1,2,...]."
56  );
57 
58  if (k == 'P')
59  return {CepsCellType::Simplex,i};
60  return {CepsCellType::Quad,i};
61 
62 }
63 
65 inline CepsCellType
67 {
68  return type.first;
69 }
70 
72 inline CepsUInt
74 {
75  return type.second;
76 }
CepsCellType
Enum for different shapes of cells.
Definition: CepsEnums.hpp:128
@ Simplex
Simplices.
@ Quad
Quadrilaterals.
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
char CepsChar
Char.
Definition: CepsTypes.hpp:125
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
CepsFeLagrangeType fromString(CepsString type)
Deduce the cell type and order of polynomials from string.
Definition: FEType.hpp:48
CepsCellType getCategory(const CepsFeLagrangeType &type)
Returns either Simplex, of Quad, the type of Lagrange finite element.
Definition: FEType.hpp:66
CepsString toString(CepsCellType cat, CepsUInt order)
Converts inputs into a string ("P1", "P2", "Q1", "Q2", etc)
Definition: FEType.hpp:39
CepsUInt getOrder(const CepsFeLagrangeType &type)
Returns the order of the Lagrange finite element.
Definition: FEType.hpp:73
std::pair< CepsCellType, CepsUInt > CepsFeLagrangeType
Typedef for descriptor of Lagrange finite elements type.
Definition: FEType.hpp:35
CepsString toString(_Tp value)
Convert a given value to a string (input has to be compatible with std::to_string)
Definition: CepsString.hpp:409
CepsString toKey(const CepsString &s)
Transform to key type a std::string, upper case and no spaces.
Definition: CepsString.cpp:157
CepsUInt toUInt(const CepsString &s)
Cast CepsString to CepsUInt.
Definition: CepsString.cpp:296