lagrangianFieldReconstructor.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 
26 #include "autoPtr.H"
28 #include "passiveParticleCloud.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const fvMesh& completeMesh,
35  const PtrList<fvMesh>& procMeshes,
36  const labelListList& faceProcAddressing,
37  const labelListList& cellProcAddressing,
38  const word& cloudName
39 )
40 :
41  completeMesh_(completeMesh),
42  procMeshes_(procMeshes),
43  faceProcAddressing_(faceProcAddressing),
44  cellProcAddressing_(cellProcAddressing),
45  cloudName_(cloudName)
46 {}
47 
48 
49 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
50 
52 {}
53 
54 
55 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
56 
57 bool Foam::lagrangianFieldReconstructor::reconstructs
58 (
59  const IOobjectList& objects,
60  const HashSet<word>& selectedFields
61 )
62 {
63  bool result = false;
64 
65  #define DO_LAGRANGIAN_FIELDS_TYPE(Type, nullArg) \
66  result = result \
67  || reconstructs<IOField<Type>>(objects, selectedFields) \
68  || reconstructs<IOField<Field<Type>>>(objects, selectedFields) \
69  || reconstructs<CompactIOField<Field<Type>>>(objects, selectedFields);
72  #undef DO_LAGRANGIAN_FIELDS_TYPE
73 
74  return result;
75 }
76 
77 
80 {
81  // Construct an empty cloud to add positions too
82  autoPtr<passiveParticleCloud> completeCloudPtr
83  (
85  (
86  completeMesh_,
87  cloudName_,
89  )
90  );
91  passiveParticleCloud& completeCloud = completeCloudPtr();
92 
93  forAll(procMeshes_, proci)
94  {
95  // Read the processor positions
97  (
98  procMeshes_[proci],
99  cloudName_,
100  false
101  );
102 
103  // Combine the processor's positions into the complete cloud
105  {
106  const passiveParticle& p = iter();
107  const label completeCelli =
108  cellProcAddressing_[proci][p.cell()];
109  const label completeFacei =
110  mag(faceProcAddressing_[proci][p.tetFace()]) - 1;
111 
112  completeCloud.append
113  (
114  new passiveParticle
115  (
116  completeMesh_,
117  p.coordinates(),
118  completeCelli,
119  completeFacei,
120  p.procTetPt
121  (
122  procMeshes_[proci],
123  completeMesh_,
124  completeCelli,
125  completeFacei
126  )
127  )
128  );
129  }
130  }
131 
132  return completeCloudPtr;
133 }
134 
135 
137 {
139 }
140 
141 
142 // ************************************************************************* //
#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 HashTable with keys but without contents.
Definition: HashSet.H:62
Template class for intrusive linked lists.
Definition: ILList.H:67
Helper IO class to read and write particle positions.
Definition: IOPosition.H:60
virtual bool write(const bool write=true) const
Write using setting from DB.
Definition: IOPosition.C:59
List of IOobjects with searching and retrieving facilities.
Definition: IOobjectList.H:53
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
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
void reconstructPositions() const
Write the reconstructed positions.
autoPtr< passiveParticleCloud > completeCloud() const
Generate the reconstructed cloud.
lagrangianFieldReconstructor(const fvMesh &completeMesh, const PtrList< fvMesh > &procMeshes, const labelListList &faceProcAddressing, const labelListList &cellProcAddressing, const word &cloudName)
Construct from components.
A Cloud of passive particles.
Copy of base particle.
A class for handling words, derived from string.
Definition: word.H:62
#define DO_LAGRANGIAN_FIELDS_TYPE(Type, nullArg)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
objects
volScalarField & p
const word cloudName(propsDict.lookup("cloudName"))