CloudTypes.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Struct
25  Foam::CloudTypes
26 
27 Description
28  Struct to aid casting of the cloud to a derived type
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #ifndef CloudTypes_H
33 #define CloudTypes_H
34 
35 #include "cloud.H"
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace Foam
40 {
41 
42 /*---------------------------------------------------------------------------*\
43  Class CloudTypes Declaration
44 \*---------------------------------------------------------------------------*/
45 
46 template<class ... Clouds>
47 struct CloudTypes;
48 
49 
50 template<class Cloud, class ... Clouds>
51 struct CloudTypes<Cloud, Clouds ...>
52 {
53  static bool isA(const class cloud& c)
54  {
55  return Foam::isA<Cloud>(c) || CloudTypes<Clouds ...>::isA(c);
56  }
57 
58  template<unsigned Size>
59  static void types(FixedList<word, Size>& result)
60  {
61  result[Size - sizeof...(Clouds) - 1] = Cloud::typeName;
63  }
64 
65  static FixedList<word, sizeof...(Clouds) + 1> types()
66  {
67  FixedList<word, sizeof...(Clouds) + 1> result;
68  types(result);
69  return result;
70  }
71 
72  static string typesString(const word& conjunction)
73  {
74  string result = '\'' + Cloud::typeName + '\'';
75  if (sizeof...(Clouds))
76  {
77  FixedList<word, sizeof...(Clouds) + 1> types =
79  for (label i = 1; i < types.size() - 1; ++ i)
80  {
81  result += ", '" + types[i] + '\'';
82  }
83  result += ' ' + conjunction + " '" + types.last() + '\'';
84  }
85  return result;
86  }
87 };
88 
89 
90 template<>
91 struct CloudTypes<>
92 {
93  static bool isA(const class cloud& c)
94  {
95  return false;
96  }
97 
98  template<unsigned Size>
99  static void types(FixedList<word, Size>& result)
100  {}
101 };
102 
103 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
104 
105 } // End namespace Foam
106 
107 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
108 
109 #endif
110 
111 // ************************************************************************* //
Base cloud calls templated on particle type.
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:78
Base class for clouds. Provides a basic evolution algorithm, models, and a database for caching deriv...
Definition: cloud.H:63
A class for handling words, derived from string.
Definition: word.H:62
const dimensionedScalar c
Speed of light in a vacuum.
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:171
static FixedList< word, sizeof...(Clouds)+1 > types()
Definition: CloudTypes.H:65
static bool isA(const class cloud &c)
Definition: CloudTypes.H:53
static string typesString(const word &conjunction)
Definition: CloudTypes.H:72
static void types(FixedList< word, Size > &result)
Definition: CloudTypes.H:59
static bool isA(const class cloud &c)
Definition: CloudTypes.H:93
static void types(FixedList< word, Size > &result)
Definition: CloudTypes.H:99