lagrangianFieldDecomposerReadFields.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2022-2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "IOobjectList.H"
31 
32 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const label cloudi,
38  const IOobjectList& lagrangianObjects,
39  PtrList<PtrList<IOField<Type>>>& lagrangianFields
40 )
41 {
42  // List of lagrangian field objects
43  const UPtrList<const IOobject> fieldObjects
44  (
45  lagrangianObjects.csorted<IOField<Type>>()
46  );
47 
48  auto& cloudFields =
49  lagrangianFields.emplace_set(cloudi, fieldObjects.size());
50 
51  forAll(fieldObjects, fieldi)
52  {
53  cloudFields.emplace_set(fieldi, fieldObjects[fieldi]);
54  }
55 }
56 
57 
58 template<class Type>
60 (
61  const label cloudi,
62  const IOobjectList& lagrangianObjects,
63  PtrList<PtrList<CompactIOField<Field<Type>, Type>>>& lagrangianFields
64 )
65 {
66  // List of lagrangian field objects
67  UPtrList<const IOobject> fieldObjects
68  (
69  lagrangianObjects.cobjects<IOField<Field<Type>>>()
70  );
71 
72  fieldObjects.push_back
73  (
74  lagrangianObjects.cobjects<CompactIOField<Field<Type>, Type>>()
75  );
76 
77  Foam::sort(fieldObjects, nameOp<IOobject>());
78 
79 
80  auto& cloudFields =
81  lagrangianFields.emplace_set(cloudi, fieldObjects.size());
82 
83  forAll(fieldObjects, fieldi)
84  {
85  cloudFields.emplace_set(fieldi, fieldObjects[fieldi]);
86  }
87 }
88 
89 
90 // ************************************************************************* //
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
static void readFieldFields(const label cloudi, const IOobjectList &lagrangianObjects, PtrList< PtrList< CompactIOField< Field< Type >, Type >>> &cloudFields)
Read the field-fields and store on the pointer list.
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:296
static void readFields(const label cloudi, const IOobjectList &lagrangianObjects, PtrList< PtrList< IOField< Type >>> &cloudFields)
Read the fields and store on the pointer list.
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:106
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:106
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
UPtrList< const IOobject > csorted() const
The sorted list of IOobjects with headerClassName == Type::typeName.
A primitive field of type <T> with automated input and output.