MPLICcellStorage.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) 2020-2021 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 \*---------------------------------------------------------------------------*/
25 
26 #include "MPLICcellStorage.H"
27 
28 
29 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
30 
31 Foam::boolList Foam::MPLICcellStorage::calcIsOwner
32 (
33  const primitiveMesh& mesh,
34  const label celli
35 ) const
36 {
37  const cell& c = mesh.cells()[celli];
38  boolList cOwns(c.size(), false);
39  forAll(c, i)
40  {
41  const label ow = mesh.faceOwner()[c[i]];
42  if (ow == celli)
43  {
44  cOwns[i] = true;
45  }
46  }
47  return cOwns;
48 }
49 
50 
51 Foam::scalar Foam::MPLICcellStorage::calcAlphaMin() const
52 {
53  // Initialise with the first value in the list
54  scalar cellAlphaMin(pointsAlpha_.first());
55 
56  // Loop through the rest and compare element-wise
57  for (label i = 1; i < cPoints_.size(); ++i)
58  {
59  const label pI = cPoints_[i];
60  cellAlphaMin = min(cellAlphaMin, pointsAlpha_[pI]);
61  }
62 
63  // Return minimum value
64  return cellAlphaMin;
65 }
66 
67 
68 Foam::scalar Foam::MPLICcellStorage::calcAlphaMax() const
69 {
70  // Initialise with the first value in the list
71  scalar cellAlphaMax(pointsAlpha_.first());
72 
73  // Loop through the rest and compare element-wise
74  for (label i = 1; i < cPoints_.size(); ++i)
75  {
76  const label pI = cPoints_[i];
77  cellAlphaMax = max(cellAlphaMax, pointsAlpha_[pI]);
78  }
79 
80  // Return maximum value
81  return cellAlphaMax;
82 }
83 
84 
85 Foam::scalarField Foam::MPLICcellStorage::calcFacesAlphaMin() const
86 {
87  scalarField facesAlphaMin(cFaces_.size());
88 
89  forAll(cFaces_, facei)
90  {
91  // Face
92  const face& f = faces_[cFaces_[facei]];
93 
94  // Initialise with the first value in the list
95  scalar fAlphaMin(pointsAlpha_[f.first()]);
96 
97  // Loop through the rest and compare element-wise
98  for (label i = 1; i < f.size(); ++i)
99  {
100  fAlphaMin = min(fAlphaMin, pointsAlpha_[f[i]]);
101  }
102 
103  facesAlphaMin[facei] = fAlphaMin;
104  }
105 
106  // Return minimum value
107  return facesAlphaMin;
108 }
109 
110 
111 Foam::scalarField Foam::MPLICcellStorage::calcFacesAlphaMax() const
112 {
113  scalarField facesAlphaMax(cFaces_.size());
114 
115  forAll(cFaces_, facei)
116  {
117  // Face
118  const face& f = faces_[cFaces_[facei]];
119 
120  // Initialise with the first value in the list
121  scalar fAlphaMax(pointsAlpha_[f.first()]);
122 
123  // Loop through the rest and compare element-wise
124  for (label i = 1; i < f.size(); ++i)
125  {
126  fAlphaMax = max(fAlphaMax, pointsAlpha_[f[i]]);
127  }
128 
129  facesAlphaMax[facei] = fAlphaMax;
130  }
131 
132  // Return maximum
133  return facesAlphaMax;
134 }
135 
136 
137 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
138 
140 (
141  const primitiveMesh& mesh,
142  const scalarField& pointsAlpha,
143  const vectorField& pointsU,
144  const scalar cellAlpha,
145  const vector& cellU,
146  const label celli
147 )
148 :
149  points_(mesh.points()),
150  faces_(mesh.faces()),
151  edges_(mesh.edges()),
152  edgeFaces_(mesh.faceEdges()),
153  cPoints_(mesh.cellPoints()[celli]),
154  cFaces_(mesh.cells()[celli]),
155  cEdges_(mesh.cellEdges()[celli]),
156  pointsAlpha_(pointsAlpha),
157  pointsU_(pointsU),
158  cellAlpha_(cellAlpha),
159  celllU_(cellU),
160  owns_(calcIsOwner(mesh, celli)),
161  volume_(mesh.cellVolumes()[celli]),
162  centre_(mesh.cellCentres()[celli]),
163  Sf_(mesh.faceAreas(), cFaces_),
164  Cf_(mesh.faceCentres(), cFaces_),
165  magSf_(mesh.magFaceAreas(), cFaces_),
166  cellAlphaMin_(calcAlphaMin()),
167  cellAlphaMax_(calcAlphaMax()),
168  facesAlphaMin_(calcFacesAlphaMin()),
169  facesAlphaMax_(calcFacesAlphaMax()),
170  faceEdges_(mesh.faceEdges())
171 {}
172 
173 
174 // ************************************************************************* //
const labelListList & cellEdges() const
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
scalar cellAlphaMin() const
Return minimum point alpha value in the cell.
const labelListList & faceEdges() const
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual const pointField & points() const =0
Return mesh points.
const cellList & cells() const
T & first()
Return the first element of the list.
Definition: UListI.H:114
MPLICcellStorage(const primitiveMesh &mesh, const scalarField &pointsAlpha, const vectorField &pointsU, const scalar cellAlpha, const vector &cellU, const label celli)
Construct from components.
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
const scalarField & magFaceAreas() const
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
const vectorField & cellCentres() const
const scalarField & facesAlphaMax() const
Return maximum point alpha value on the cell faces.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const vectorField & faceCentres() const
const vectorField & faceAreas() const
virtual const faceList & faces() const =0
Return faces.
scalar cellAlphaMax() const
Return maximum point alpha value in the cell.
const scalarField & facesAlphaMin() const
Return minimum point alpha value on the cell faces.
const labelListList & cellPoints() const
const scalarField & cellVolumes() const