lagrangianFieldDecomposerTemplates.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) 2011-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 \*---------------------------------------------------------------------------*/
25 
27 #include "cloud.H"
28 #include "IOobjectList.H"
29 #include "CompactIOField.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 template
34 <
35  class Type,
36  template<class> class ReadIOContainer,
37  template<class> class IOContainer
38 >
39 void Foam::lagrangianFieldDecomposer::decomposeFields
40 (
41  const IOobjectList& objects
42 ) const
43 {
44  const word& fieldClassName = ReadIOContainer<Type>::typeName;
45 
46  IOobjectList fields = objects.lookupClass(fieldClassName);
47 
48  if (fields.size())
49  {
50  Info<< nl << " Decomposing " << fieldClassName << "s" << nl << endl;
51 
52  forAllConstIter(IOobjectList, fields, fieldIter)
53  {
54  Info<< " " << fieldIter()->name() << endl;
55 
56  const PtrList<IOContainer<Type>> procFields =
57  decomposeField<Type, ReadIOContainer, IOContainer>
58  (
59  *fieldIter()
60  );
61 
62  forAll(procFields, proci)
63  {
64  procFields[proci].write();
65  }
66  }
67  }
68 }
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
73 template
74 <
75  class Type,
76  template<class> class ReadIOContainer,
77  template<class> class IOContainer
78 >
81 (
82  const IOobject& fieldIoObject
83 ) const
84 {
85  // Read the complete field
86  const ReadIOContainer<Type> field(fieldIoObject);
87 
88  // Construct the processor fields
89  PtrList<IOContainer<Type>> procFields(procMeshes_.size());
90  forAll(procMeshes_, proci)
91  {
92  procFields.set
93  (
94  proci,
95  new IOContainer<Type>
96  (
97  IOobject
98  (
99  field.name(),
100  procMeshes_[proci].time().name(),
101  lagrangian::cloud::prefix/cloudName_,
102  procMeshes_[proci],
105  false
106  ),
107  Field<Type>(field, particleProcAddressing_[proci])
108  )
109  );
110  }
111 
112  return procFields;
113 }
114 
115 
116 template<class Type>
117 void Foam::lagrangianFieldDecomposer::decomposeFields
118 (
119  const IOobjectList& objects
120 ) const
121 {
122  decomposeFields<Type, IOField, IOField>(objects);
123  decomposeFields<Field<Type>, IOField, CompactIOField>(objects);
124  decomposeFields<Field<Type>, CompactIOField, CompactIOField>(objects);
125 }
126 
127 
128 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:476
A Field of objects of type <Type> with automated input and output using a compact storage....
Pre-declare SubField and related Field type.
Definition: Field.H:83
A primitive field of type <Type> with automated input and output.
Definition: IOField.H:53
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
bool set(const label) const
Is element set.
Definition: PtrListI.H:62
PtrList< IOContainer< Type > > decomposeField(const IOobject &) const
Read and Decompose a field.
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:69
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:234
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
static const char nl
Definition: Ostream.H:267
objects