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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Description
27  Lagrangian field decomposer.
28 
29 \*---------------------------------------------------------------------------*/
30 
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
36 (
37  const polyMesh& mesh,
38  const polyMesh& procMesh,
39  const labelList& faceProcAddressing,
40  const labelList& cellProcAddressing,
41  const word& cloudName,
42  const Cloud<indexedParticle>& lagrangianPositions,
43  const List<SLList<indexedParticle*>*>& cellParticles
44 )
45 :
46  procMesh_(procMesh),
47  positions_(procMesh, Foam::zero{}, cloudName), // Empty cloud
48  particleIndices_(lagrangianPositions.size())
49 {
50  label pi = 0;
51 
52  labelList decodedProcFaceAddressing(faceProcAddressing.size());
53 
54  forAll(faceProcAddressing, i)
55  {
56  decodedProcFaceAddressing[i] = mag(faceProcAddressing[i]) - 1;
57  }
58 
59  forAll(cellProcAddressing, procCelli)
60  {
61  label celli = cellProcAddressing[procCelli];
62 
63  if (cellParticles[celli])
64  {
65  SLList<indexedParticle*>& particlePtrs = *cellParticles[celli];
66 
67  forAllConstIters(particlePtrs, iter)
68  {
69  const indexedParticle& ppi = *iter();
70  particleIndices_[pi++] = ppi.index();
71 
72  const label mappedTetFace =
73  decodedProcFaceAddressing.find(ppi.tetFace());
74 
75  if (mappedTetFace == -1)
76  {
78  << "Face lookup failure." << nl
79  << abort(FatalError);
80  }
81 
82  positions_.append
83  (
84  new passiveParticle
85  (
86  procMesh,
87  ppi.coordinates(),
88  procCelli,
89  mappedTetFace,
90  ppi.procTetPt(procMesh, procCelli, mappedTetFace)
91  )
92  );
93  }
94  }
95  }
96 
97  particleIndices_.resize(pi);
98 
99  IOPosition<Cloud<passiveParticle>>(positions_).write();
100 }
101 
102 
103 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
Template class for non-intrusive linked lists.
Definition: LList.H:46
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
label size() const noexcept
The number of elements in table.
Definition: HashTable.H:342
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
dynamicFvMesh & mesh
const word cloudName(propsDict.get< word >("cloud"))
A class for handling words, derived from Foam::string.
Definition: word.H:63
constexpr scalar pi(M_PI)
errorManip< error > abort(error &err)
Definition: errorManip.H:139
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28