Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / applications / utilities / parallelProcessing / decomposePar / lagrangianFieldDecomposer.C
blobc9ab1ffbbe3f6091966be5e50543846d38b0abf6
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2011 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 Description
25     Lagrangian field decomposer.
27 \*---------------------------------------------------------------------------*/
29 #include "lagrangianFieldDecomposer.H"
31 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
33 // Construct from components
34 Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
36     const polyMesh& mesh,
37     const polyMesh& procMesh,
38     const labelList& faceProcAddressing,
39     const labelList& cellProcAddressing,
40     const word& cloudName,
41     const Cloud<indexedParticle>& lagrangianPositions,
42     const List<SLList<indexedParticle*>*>& cellParticles
45     procMesh_(procMesh),
46     positions_(procMesh, cloudName, false),
47     particleIndices_(lagrangianPositions.size())
49     label pi = 0;
51     // faceProcAddressing not required currently
52     // labelList decodedProcFaceAddressing(faceProcAddressing.size());
54     // forAll(faceProcAddressing, i)
55     // {
56     //     decodedProcFaceAddressing[i] = mag(faceProcAddressing[i]) - 1;
57     // }
59     forAll(cellProcAddressing, procCelli)
60     {
61         label celli = cellProcAddressing[procCelli];
63         if (cellParticles[celli])
64         {
65             SLList<indexedParticle*>& particlePtrs = *cellParticles[celli];
67             forAllConstIter(SLList<indexedParticle*>, particlePtrs, iter)
68             {
69                 const indexedParticle& ppi = *iter();
70                 particleIndices_[pi++] = ppi.index();
72                 // label mappedTetFace = findIndex
73                 // (
74                 //     decodedProcFaceAddressing,
75                 //     ppi.tetFace()
76                 // );
78                 // if (mappedTetFace == -1)
79                 // {
80                 //     FatalErrorIn
81                 //     (
82                 //         "Foam::lagrangianFieldDecomposer"
83                 //         "::lagrangianFieldDecomposer"
84                 //         "("
85                 //             "const polyMesh& mesh, "
86                 //             "const polyMesh& procMesh, "
87                 //             "const labelList& faceProcAddressing, "
88                 //             "const labelList& cellProcAddressing, "
89                 //             "const word& cloudName, "
90                 //             "const Cloud<indexedParticle>& "
91                 //             "lagrangianPositions, "
92                 //             "const List<SLList<indexedParticle*>*>& "
93                 //             "cellParticles"
94                 //         ")"
95                 //     )   << "Face lookup failure." << nl
96                 //         << abort(FatalError);
97                 // }
99                 positions_.append
100                 (
101                     new passiveParticle
102                     (
103                         procMesh,
104                         ppi.position(),
105                         procCelli,
106                         false
107                     )
108                 );
109             }
110         }
111     }
113     particleIndices_.setSize(pi);
115     IOPosition<Cloud<passiveParticle> >(positions_).write();
119 // ************************************************************************* //