lagrangianFieldDecomposer.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 | Copyright (C) 2011-2016 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 Description
25  Lagrangian field decomposer.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
34 (
35  const polyMesh& mesh,
36  const polyMesh& procMesh,
37  const labelList& faceProcAddressing,
38  const labelList& cellProcAddressing,
39  const word& cloudName,
40  const Cloud<indexedParticle>& lagrangianPositions,
41  const List<SLList<indexedParticle*>*>& cellParticles
42 )
43 :
44  procMesh_(procMesh),
45  positions_(procMesh, cloudName, false),
46  particleIndices_(lagrangianPositions.size())
47 {
48  label pi = 0;
49 
50  // faceProcAddressing not required currently
51  // labelList decodedProcFaceAddressing(faceProcAddressing.size());
52 
53  // forAll(faceProcAddressing, i)
54  // {
55  // decodedProcFaceAddressing[i] = mag(faceProcAddressing[i]) - 1;
56  // }
57 
58  forAll(cellProcAddressing, procCelli)
59  {
60  label celli = cellProcAddressing[procCelli];
61 
62  if (cellParticles[celli])
63  {
64  SLList<indexedParticle*>& particlePtrs = *cellParticles[celli];
65 
66  forAllConstIter(SLList<indexedParticle*>, particlePtrs, iter)
67  {
68  const indexedParticle& ppi = *iter();
69  particleIndices_[pi++] = ppi.index();
70 
71  // label mappedTetFace = findIndex
72  // (
73  // decodedProcFaceAddressing,
74  // ppi.tetFace()
75  // );
76 
77  // if (mappedTetFace == -1)
78  // {
79  // FatalErrorInFunction
80  // << "Face lookup failure." << nl
81  // << abort(FatalError);
82  // }
83 
84  positions_.append
85  (
86  new passiveParticle
87  (
88  procMesh,
89  ppi.position(),
90  procCelli,
91  false
92  )
93  );
94  }
95  }
96  }
97 
98  particleIndices_.setSize(pi);
99 
100  IOPosition<Cloud<passiveParticle>>(positions_).write();
101 }
102 
103 
104 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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< label > labelList
A List of labels.
Definition: labelList.H:56
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
virtual bool write() const
Write mesh using IO settings from time.
Definition: fvMesh.C:870