carriedTemplates.C
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 \*---------------------------------------------------------------------------*/
25 
26 #include "carried.H"
27 #include "CarrierField.H"
28 
29 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const VolField<Type>& psi
35 ) const
36 {
37  return carrierField<Type, VolField<Type>>(psi);
38 }
39 
40 
41 template<class Type, class ... Args>
43 (
44  const Args& ... args
45 ) const
46 {
47  typename HashPtrTable<CarrierField<Type>>::iterator iter =
48  carrierFields<Type>().find(CarrierField<Type>(args ...).name());
49 
50  if (iter != carrierFields<Type>().end()) return **iter;
51 
53  carrierFields<Type>().insert(ptr->name(), ptr);
54 
55  return *ptr;
56 }
57 
58 
59 template<class Type>
61 (
62  const word& symbolicName,
63  const word& descriptiveName,
64  const bool isPhase
65 ) const
66 {
67  return
68  carrierField<Type>
69  (
70  nameToCarrierName
71  (
72  symbolicName,
73  isPhase ? phaseName(false) : carrierPhaseName()
74  ),
75  [this,descriptiveName,isPhase]()
76  {
78  << "Cloud " << cloud_.name() << " does not have a "
79  << (isPhase ? "corresponding Eulerian phase" : "carrier")
80  << ' ' << descriptiveName << exit(FatalError);
81  return tmp<volScalarField>(nullptr);
82  }
83  );
84 }
85 
86 
87 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
A field interpolated from the carrier to the cloud. Uses CloudDerivedField to provide flexible access...
Definition: CarrierField.H:207
Generic GeometricField class.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:68
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
Definition: HashTable.C:167
const CarrierField< Type > & carrierField(const VolField< Type > &) const
Add/get a carrier field to/from the cache.
const CarrierField< Type > & noCarrierField(const word &symbolicName, const word &descriptiveName, const bool isPhase) const
Generate a carrier field reference using a functor that raises.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const volScalarField & psi
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
error FatalError
Foam::argList args(argc, argv)