lagrangianReconstructor.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) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "labelIOList.H"
31 #include "passiveParticleCloud.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 Foam::lagrangianReconstructor::lagrangianReconstructor
36 (
37  const fvMesh& mesh,
38  const PtrList<fvMesh>& procMeshes,
40  const PtrList<labelIOList>& cellProcAddressing
41 )
42 :
43  mesh_(mesh),
44  procMeshes_(procMeshes),
45  faceProcAddressing_(faceProcAddressing),
46  cellProcAddressing_(cellProcAddressing)
47 {}
48 
49 
50 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
51 
53 (
54  const word& cloudName
55 ) const
56 {
57  passiveParticleCloud lagrangianPositions
58  (
59  mesh_,
60  cloudName,
62  );
63 
64  forAll(procMeshes_, meshi)
65  {
66  const labelList& cellMap = cellProcAddressing_[meshi];
67  const labelList& faceMap = faceProcAddressing_[meshi];
68 
69  Cloud<passiveParticle> lpi(procMeshes_[meshi], cloudName, false);
70 
71  forAllConstIters(lpi, iter)
72  {
73  const passiveParticle& ppi = *iter;
74 
75  const label mappedCell = cellMap[ppi.cell()];
76 
77  // Inverting sign if necessary and subtracting 1 from
78  // faceProcAddressing
79  const label mappedTetFace = mag(faceMap[ppi.tetFace()]) - 1;
80 
81  lagrangianPositions.append
82  (
83  new passiveParticle
84  (
85  mesh_,
86  ppi.coordinates(),
87  mappedCell,
88  mappedTetFace,
89  ppi.procTetPt(mesh_, mappedCell, mappedTetFace)
90  )
91  );
92  }
93  }
94 
95  IOPosition<Cloud<passiveParticle>>(lagrangianPositions).write();
96 
97  // Force writing of "positions" too, if specified via the InfoSwitch
98  if (particle::writeLagrangianPositions)
99  {
101  (
102  lagrangianPositions,
103  cloud::geometryType::POSITIONS
104  ).write();
105  }
106 
107  return lagrangianPositions.size();
108 }
109 
110 
111 // ************************************************************************* //
Foam::lagrangianReconstructor::reconstructPositions
label reconstructPositions(const word &cloudName) const
Reconstruct positions for given cloud.
Definition: lagrangianReconstructor.C:53
faceProcAddressing
PtrList< labelIOList > & faceProcAddressing
Definition: checkFaceAddressingComp.H:9
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeTopological.C:94
cloudName
const word cloudName(propsDict.get< word >("cloud"))
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
lagrangianReconstructor.H
Foam::particle::tetFace
label tetFace() const
Return current tet face particle is in.
Definition: particleI.H:161
Foam::passiveParticle
Copy of base particle.
Definition: passiveParticle.H:53
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::particle::coordinates
const barycentric & coordinates() const
Return current particle coordinates.
Definition: particleI.H:143
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
Foam::IOPosition
Helper IO class to read and write particle coordinates (positions).
Definition: Cloud.H:56
Foam::passiveParticleCloud
A Cloud of passive particles.
Definition: passiveParticleCloud.H:52
Foam::ILList
Template class for intrusive linked lists.
Definition: ILList.H:52
Foam::particle::procTetPt
label procTetPt(const polyMesh &procMesh, const label procCell, const label procTetFace) const
Return the tet point appropriate for decomposition or reconstruction.
Definition: particle.C:1200
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
passiveParticleCloud.H
Foam::List< label >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
labelIOList.H
Foam::Cloud< passiveParticle >
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::particle::cell
label cell() const
Return current cell particle is in.
Definition: particleI.H:149