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-------------------------------------------------------------------------------
10License
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
26Description
27 Lagrangian field decomposer.
28
29\*---------------------------------------------------------------------------*/
30
32
33// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34
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, cloudName, IDLList<passiveParticle>()),
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 (
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
100}
101
102
103// ************************************************************************* //
Base cloud calls templated on particle type.
Definition: Cloud.H:68
Template class for intrusive linked lists.
Definition: ILList.H:69
Helper IO class to read and write particle coordinates (positions).
Definition: IOPosition.H:56
Template class for non-intrusive linked lists.
Definition: LList.H:79
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
Definition: UList.C:212
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Adds label index to base particle.
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
label tetFace() const noexcept
Return current tet face particle is in.
Definition: particleI.H:161
const barycentric & coordinates() const noexcept
Return current particle coordinates.
Definition: particleI.H:143
Copy of base particle.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
runTime write()
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Definition: stdFoam.H:278
const word cloudName(propsDict.get< word >("cloud"))