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 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
34template<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 UPtrList<const IOobject> fieldObjects
44 (
45 lagrangianObjects.sorted<IOField<Type>>()
46 );
47
48 lagrangianFields.set
49 (
50 cloudi,
51 new PtrList<IOField<Type>>(fieldObjects.size())
52 );
53
54
55 label fieldi = 0;
56
57 for (const IOobject& io : fieldObjects)
58 {
59 lagrangianFields[cloudi].set(fieldi++, new IOField<Type>(io));
60 }
61}
62
63
64template<class Type>
66(
67 const label cloudi,
68 const IOobjectList& lagrangianObjects,
69 PtrList<PtrList<CompactIOField<Field<Type>, Type>>>& lagrangianFields
70)
71{
72 // List of lagrangian field objects
73 UPtrList<const IOobject> fieldObjects;
74
75 fieldObjects.append
76 (
77 lagrangianObjects.sorted<IOField<Field<Type>>>()
78 );
79
80 fieldObjects.append
81 (
82 lagrangianObjects.sorted<CompactIOField<Field<Type>, Type>>()
83 );
84
85 Foam::sort(fieldObjects, nameOp<IOobject>());
86
87
88 lagrangianFields.set
89 (
90 cloudi,
91 new PtrList<CompactIOField<Field<Type>, Type>>(fieldObjects.size())
92 );
93
94
95 label fieldi = 0;
96
97 for (const IOobject& io : fieldObjects)
98 {
99 lagrangianFields[cloudi].set
100 (
101 fieldi++,
102 new CompactIOField<Field<Type>, Type>(io)
103 );
104 }
105}
106
107
108// ************************************************************************* //
A Field of objects of type <T> with automated input and output using a compact storage....
Generic templated field type.
Definition: Field.H:82
A primitive field of type <T> with automated input and output.
Definition: IOField.H:58
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:59
UPtrList< const IOobject > sorted() const
The sorted list of IOobjects.
Definition: IOobjectList.C:336
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
void append(T *ptr)
Append an element to the end of the list.
Definition: UPtrListI.H:197
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:158
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.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, false)
void sort(UList< T > &list)
Sort the list.
Definition: UList.C:342
Extract name (as a word) from an object, typically using its name() method.
Definition: word.H:238