All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lagrangianFieldDecomposer.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-2018 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 
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, IDLList<passiveParticle>()),
46  particleIndices_(lagrangianPositions.size())
47 {
48  label pi = 0;
49 
50  labelList decodedProcFaceAddressing(faceProcAddressing.size());
51 
52  forAll(faceProcAddressing, i)
53  {
54  decodedProcFaceAddressing[i] = mag(faceProcAddressing[i]) - 1;
55  }
56 
57  forAll(cellProcAddressing, procCelli)
58  {
59  label celli = cellProcAddressing[procCelli];
60 
61  if (cellParticles[celli])
62  {
63  SLList<indexedParticle*>& particlePtrs = *cellParticles[celli];
64 
65  forAllConstIter(SLList<indexedParticle*>, particlePtrs, iter)
66  {
67  const indexedParticle& ppi = *iter();
68  particleIndices_[pi++] = ppi.index();
69 
70  label mappedTetFace = findIndex
71  (
72  decodedProcFaceAddressing,
73  ppi.tetFace()
74  );
75 
76  if (mappedTetFace == -1)
77  {
79  << "Face lookup failure." << nl
80  << abort(FatalError);
81  }
82 
83  positions_.append
84  (
85  new passiveParticle
86  (
87  procMesh,
88  ppi.coordinates(),
89  procCelli,
90  mappedTetFace,
91  ppi.procTetPt(procMesh, procCelli, mappedTetFace)
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:434
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
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
Definition: fvMesh.C:1035
lagrangianFieldDecomposer(const polyMesh &mesh, const polyMesh &procMesh, const labelList &faceProcAddressing, const labelList &cellProcAddressing, const word &cloudName, const Cloud< indexedParticle > &lagrangianPositions, const List< SLList< indexedParticle *> *> &cellParticles)
Construct from components.
List< label > labelList
A List of labels.
Definition: labelList.H:56
ILList< DLListBase, T > IDLList
Definition: IDLList.H:43
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
errorManip< error > abort(error &err)
Definition: errorManip.H:131
static const char nl
Definition: Ostream.H:260
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
dimensioned< scalar > mag(const dimensioned< Type > &)