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-2026 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  template<class Type>
54  static bool isA(const Type& c)
55  {
56  return Foam::isA<Cloud>(c) || CloudTypes<Clouds ...>::isA(c);
57  }
58 
59  template<unsigned Size>
60  static void types(FixedList<word, Size>& result)
61  {
62  result[Size - sizeof...(Clouds) - 1] = Cloud::typeName;
64  }
65 
66  static FixedList<word, sizeof...(Clouds) + 1> types()
67  {
68  FixedList<word, sizeof...(Clouds) + 1> result;
69  types(result);
70  return result;
71  }
72 
73  static string typesString(const word& conjunction)
74  {
75  string result = '\'' + Cloud::typeName + '\'';
76  if (sizeof...(Clouds))
77  {
78  FixedList<word, sizeof...(Clouds) + 1> types =
80  for (label i = 1; i < types.size() - 1; ++ i)
81  {
82  result += ", '" + types[i] + '\'';
83  }
84  result += ' ' + conjunction + " '" + types.last() + '\'';
85  }
86  return result;
87  }
88 };
89 
90 
91 template<>
92 struct CloudTypes<>
93 {
94  template<class Type>
95  static bool isA(const Type& c)
96  {
97  return false;
98  }
99 
100  template<unsigned Size>
101  static void types(FixedList<word, Size>& result)
102  {}
103 };
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 } // End namespace Foam
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 #endif
112 
113 // ************************************************************************* //
Base cloud calls templated on particle type.
A 1D vector of objects of type <T> with a fixed size <Size>.
Definition: FixedList.H:78
A class for handling words, derived from string.
Definition: word.H:63
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
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
Definition: typeInfo.H:178
static bool isA(const Type &c)
Definition: CloudTypes.H:54
static FixedList< word, sizeof...(Clouds)+1 > types()
Definition: CloudTypes.H:66
static string typesString(const word &conjunction)
Definition: CloudTypes.H:73
static void types(FixedList< word, Size > &result)
Definition: CloudTypes.H:60
static bool isA(const Type &c)
Definition: CloudTypes.H:95
static void types(FixedList< word, Size > &result)
Definition: CloudTypes.H:101