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-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 "passiveParticleCloud.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const fvMesh& completeMesh,
34  const PtrList<fvMesh>& procMeshes,
35  const labelListList& faceProcAddressing,
36  const labelListList& cellProcAddressing,
37  const word& cloudName
38 )
39 :
40  completeMesh_(completeMesh),
41  procMeshes_(procMeshes),
42  cloudName_(cloudName)
43 {
44  // Construct and empty cloud for the complete positions
45  passiveParticleCloud completePositions
46  (
47  completeMesh_,
48  cloudName_,
49  IDLList<passiveParticle>()
50  );
51 
52  forAll(procMeshes_, proci)
53  {
54  // Read the processor positions
55  Cloud<passiveParticle> procPositions
56  (
57  procMeshes_[proci],
58  cloudName_,
59  false
60  );
61 
62  // Combine the processor's positions into the complete cloud
63  forAllConstIter(Cloud<passiveParticle>, procPositions, iter)
64  {
65  const passiveParticle& p = iter();
66  const label completeCelli = cellProcAddressing[proci][p.cell()];
67  const label completeFacei =
68  mag(faceProcAddressing[proci][p.tetFace()]) - 1;
69 
70  completePositions.append
71  (
72  new passiveParticle
73  (
74  completeMesh_,
75  p.coordinates(),
76  completeCelli,
77  completeFacei,
78  p.procTetPt
79  (
80  procMeshes_[proci],
81  completeMesh_,
82  completeCelli,
83  completeFacei
84  )
85  )
86  );
87  }
88  }
89 
90  // Write
91  IOPosition<Cloud<passiveParticle>>(completePositions).write();
92 }
93 
94 
95 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
103 bool Foam::lagrangianFieldReconstructor::reconstructs
104 (
105  const IOobjectList& objects,
106  const HashSet<word>& selectedFields
107 )
108 {
109  bool result = false;
110 
111  #define DO_LAGRANGIAN_FIELDS_TYPE(Type, nullArg) \
112  result = result \
113  || reconstructs<IOField<Type>>(objects, selectedFields) \
114  || reconstructs<IOField<Field<Type>>>(objects, selectedFields) \
115  || reconstructs<CompactIOField<Field<Type>>>(objects, selectedFields);
116  DO_LAGRANGIAN_FIELDS_TYPE(label, )
117  FOR_ALL_FIELD_TYPES(DO_LAGRANGIAN_FIELDS_TYPE)
118  #undef DO_LAGRANGIAN_FIELDS_TYPE
119 
120  return result;
121 }
122 
123 
124 // ************************************************************************* //
#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
lagrangianFieldReconstructor(const fvMesh &completeMesh, const PtrList< fvMesh > &procMeshes, const labelListList &faceProcAddressing, const labelListList &cellProcAddressing, const word &cloudName)
Construct from components.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
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
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
dimensioned< scalar > mag(const dimensioned< Type > &)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
objects
volScalarField & p
const word cloudName(propsDict.lookup("cloudName"))