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-2023 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 "IOobjectList.H"
28 #include "CompactIOField.H"
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 template<class Type, template<class> class IOContainer>
34 Foam::lagrangianFieldDecomposer::decomposeField
35 (
36  const IOobject& fieldIoObject
37 ) const
38 {
39  // Read the complete field
40  const IOContainer<Type> field(fieldIoObject);
41 
42  // Construct the processor fields
43  PtrList<IOContainer<Type>> procFields(procMeshes_.size());
44  forAll(procMeshes_, proci)
45  {
46  procFields.set
47  (
48  proci,
49  new IOContainer<Type>
50  (
51  IOobject
52  (
53  field.name(),
54  procMeshes_[proci].time().name(),
55  cloud::prefix/cloudName_,
56  procMeshes_[proci],
59  false
60  ),
61  Field<Type>(field, particleProcAddressing_[proci])
62  )
63  );
64  }
65 
66  return procFields;
67 }
68 
69 
70 template
71 <
72  class Type,
73  template<class> class IOContainer,
74  template<class> class IOContainerType
75 >
76 void Foam::lagrangianFieldDecomposer::decomposeFields
77 (
78  const IOobjectList& objects
79 )
80 {
81  const word& fieldClassName = IOContainerType<Type>::typeName;
82 
83  IOobjectList fields = objects.lookupClass(fieldClassName);
84 
85  if (fields.size())
86  {
87  Info<< nl << " Decomposing " << fieldClassName << "s" << nl << endl;
88 
89  forAllConstIter(IOobjectList, fields, fieldIter)
90  {
91  Info<< " " << fieldIter()->name() << endl;
92 
93  PtrList<IOContainer<Type>> procFields =
94  decomposeField<Type, IOContainer>(*fieldIter());
95 
96  forAll(procFields, proci)
97  {
98  procFields[proci].write();
99  }
100  }
101  }
102 }
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
107 template<class Type>
108 void Foam::lagrangianFieldDecomposer::decomposeFields
109 (
110  const IOobjectList& objects
111 )
112 {
113  decomposeFields<Type, IOField, IOField>(objects);
114  decomposeFields<Field<Type>, CompactIOField, IOField>(objects);
115  decomposeFields<Field<Type>, CompactIOField, CompactIOField>(objects);
116 }
117 
118 
119 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
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
static const word prefix
The prefix to local: lagrangian.
Definition: cloud.H:63
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:228
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:257
messageStream Info
static const char nl
Definition: Ostream.H:266
objects