TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
TPPI_tools.h
1/****************************************************************************
2* Copyright (c) 2023, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef TPPI_tools_included
17#define TPPI_tools_included
18
19#include <Motcle.h>
20#include <span.hpp>
21#include <vector>
22#include <map>
23
24static constexpr double EPS = 1.e-6;
25
26using MRange = std::map<std::string, std::array<double, 2>>;
27using MSpanD = std::map<std::string, tcb::span<double>>;
28using PairCharArray = std::array<const char*, 2>;
29using ArrayD = std::array<double,1>;
30using VectorD = std::vector<double>;
31using SpanD = tcb::span<double>;
32
33// convert Temp span to kelvin ...
34inline SpanD Tk_(const SpanD& T)
35{
36 for (auto& itr : T) itr += 273.15;
37 return T;
38}
39
40// convert Temp span to Celsius ...
41inline SpanD Tc_(const SpanD& T)
42{
43 for (auto& itr : T) itr -= 273.15;
44 return T;
45}
46
47// XXX : Elie Saikali : ATTENTION A L'ORDRE SINON RIEN VA MARCHER
48enum class Loi_en_T
49{
50 RHO, RHO_DP, RHO_DT,
51 H, H_DP, H_DT,
52 CP, CP_DP, CP_DT,
53 MU, MU_DP, MU_DT,
54 LAMBDA, LAMBDA_DP, LAMBDA_DT,
55 SIGMA, SIGMA_DP, SIGMA_DT,
56 BETA /* pour l'incompressible si besoin */
57};
58
59static constexpr std::array<PairCharArray, 19> EOS_prop_en_T =
60{
61 {
62 { "rho", "rho" }, { "drhodp", "d_rho_d_p_T" }, { "drhodT", "d_rho_d_T_p" },
63 { "enthalpie", "h" }, { "dhdp", "d_h_d_p_T" }, { "dhdT", "d_h_d_T_p" },
64 { "cp", "cp" }, { "dcpdp", "d_cp_d_p_T" }, { "dcpdT", "d_cp_d_T_p" },
65 { "mu", "mu" }, { "dmudp", "d_mu_d_p_T" }, { "dmudT", "d_mu_d_T_p" },
66 { "lambda", "lambda" }, { "dlambdadp", "d_lambda_d_p_T" }, { "dlambdadT", "d_lambda_d_T_p" },
67 { "sigma", "sigma" }, { "dsigmadp", "d_sigma_d_p_T" }, { "dsigmadT", "d_sigma_d_T_p" },
68 { "beta", "beta" }
69 }
70};
71
72enum class Loi_en_h
73{
74 RHO, RHO_DP, RHO_DH,
75 T, T_DP, T_DH,
76 CP, CP_DP, CP_DH,
77 MU, MU_DP, MU_DH,
78 LAMBDA, LAMBDA_DP, LAMBDA_DH,
79 SIGMA, SIGMA_DP, SIGMA_DH,
80 BETA /* pour l'incompressible si besoin */
81};
82
83static constexpr std::array<PairCharArray, 19> EOS_prop_en_h =
84{
85 {
86 { "rho", "rho" }, { "drhodp", "d_rho_d_p_h" }, { "drhodh", "d_rho_d_h_p" },
87 { "temperature", "T" }, { "dTdp", "d_T_d_p_h" }, { "dTdh", "d_T_d_h_p" },
88 { "cp", "cp" }, { "dcpdp", "d_cp_d_p_h" }, { "dcpdh", "d_cp_d_h_p" },
89 { "mu", "mu" }, { "dmudp", "d_mu_d_p_h" }, { "dmudh", "d_mu_d_h_p" },
90 { "lambda", "lambda" }, { "dlambdadp", "d_lambda_d_p_h" }, { "dlambdadh", "d_lambda_d_h_p" },
91 { "sigma", "sigma" }, { "dsigmadp", "d_sigma_d_p_h" }, { "dsigmadh", "d_sigma_d_h_p" },
92 { "beta", "beta" }
93 }
94};
95
96enum class SAT
97{
98 T_SAT, T_SAT_DP,
99 P_SAT, P_SAT_DT,
100 HL_SAT, HL_SAT_DP,
101 HV_SAT, HV_SAT_DP,
102 RHOL_SAT, RHOL_SAT_DP,
103 RHOV_SAT, RHOV_SAT_DP,
104 CPL_SAT, CPL_SAT_DP,
105 CPV_SAT, CPV_SAT_DP,
106 SIGMA, SIGMA_DP, /* pour coco seulement */
107 LV_SAT, LV_SAT_DP,
108 LAMBDA, MU
109};
110
111static constexpr std::array<PairCharArray, 18> EOS_prop_sat =
112{
113 {
114 { "tsat", "T_sat" }, { "dtsatdp", "d_T_sat_d_p" },
115 { "psat", "P_sat" }, { "dpsatdt", "d_P_sat_d_T" },
116 { "hlsat", "h_l_sat" }, { "dhlsatdp", "d_h_l_sat_d_p" },
117 { "hvsat", "h_v_sat" }, { "dhvsatdp", "d_h_v_sat_d_p" },
118 { "rholsat", "rho_l_sat" }, { "drholsatdp", "d_rho_l_sat_d_p" },
119 { "rhovsat", "rho_v_sat" }, { "drhovsatdp", "d_rho_v_sat_d_p" },
120 { "cplsat", "cp_l_sat" }, { "dcplsatdp", "d_cp_l_sat_d_p" },
121 { "cpvsat", "cp_v_sat" }, { "dcpvsatdp", "d_cp_v_sat_d_p" },
122 { "sigma", "sigma" }, { "dsigmadp", "d_sigma_d_p_h" } /* on utilise h la */
123 }
124};
125
126using MLoiSpanD_h = std::map<Loi_en_h, tcb::span<double>>;
127using MLoiSpanD_T = std::map<Loi_en_T, tcb::span<double>>;
128using MLoiSpanD = std::map<Loi_en_T, tcb::span<double>>;
129using MSatSpanD = std::map<SAT, tcb::span<double>>;
130
131#endif /* TPPI_tools_included */