TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
Convection_tools.h
1/****************************************************************************
2* Copyright (c) 2025, 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 Convection_tools_included
17#define Convection_tools_included
18#include <kokkos++.h>
19
20//////////////////////////////////////////////////////////////
21// Fonctions limiteurs de MUSCL
22////////////////////////////////////////////////////////////////
23
24KOKKOS_INLINE_FUNCTION
25double minmod(double grad1, double grad2)
26{
27 double gradlim=0.;
28 if(grad1*grad2>0.) (std::fabs(grad1)<std::fabs(grad2)) ? gradlim=grad1 : gradlim=grad2 ;
29 return gradlim;
30}
31
32KOKKOS_INLINE_FUNCTION double vanleer(double grad1, double grad2)
33{
34 double gradlim=0.;
35 if(grad1*grad2>0.) gradlim=2.*grad1*grad2/(grad1+grad2) ;
36 return gradlim;
37}
38
39KOKKOS_INLINE_FUNCTION double vanalbada(double grad1, double grad2)
40{
41 double gradlim=0.;
42 if(grad1*grad2>0.) gradlim=grad1*grad2*(grad1+grad2)/(grad1*grad1+grad2*grad2) ;
43 return gradlim;
44}
45
46KOKKOS_INLINE_FUNCTION double chakravarthy(double grad1, double grad2)
47{
48 /*
49 Cerr << " limiteur chakavarthy non preconise (non symetrique) " << finl;
50 exit();
51 return 0;
52 */
53 double gradlim=0.;
54 if ((grad1*grad2)>0)
55 {
56 gradlim=Kokkos::min(grad1/grad2,1.8); // 1<<beta<<2
57 gradlim=Kokkos::max(gradlim,0.);
58 gradlim*=grad2;
59 }
60 return gradlim;
61}
62
63KOKKOS_INLINE_FUNCTION double superbee(double grad1, double grad2)
64{
65 /*
66 Cerr << " limiteur superbee non preconise (source d'instabilites) " << finl;
67 exit();
68 return 0;
69 */
70 double gradlim=0.;
71 if ((grad1*grad2)>0)
72 {
73 double gradlim1,gradlim2;
74 gradlim1=Kokkos::min(2*(grad1/grad2),1.);
75 gradlim2=Kokkos::min(grad1/grad2,2.);
76 gradlim=Kokkos::max(gradlim1,gradlim2);
77 gradlim=Kokkos::max(gradlim,0.);
78 gradlim*=grad2;
79 }
80 return gradlim;
81}
82
83KOKKOS_INLINE_FUNCTION
84double FCT_LIMITEUR(double grad1, double grad2, int cas)
85{
86 switch(cas)
87 {
88 case 1:
89 return minmod(grad1, grad2);
90 case 2:
91 return vanleer(grad1, grad2);
92 case 3:
93 return vanalbada(grad1, grad2);
94 case 4:
95 return chakravarthy(grad1, grad2);
96 case 5:
97 return superbee(grad1, grad2);
98 default:
99 return -1;
100 }
101}
102
103#endif