cellPointLagrangianAccumulator.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) 2025 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 
27 #include "syncTools.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
34 }
35 
36 
37 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
38 
39 void Foam::cellPointLagrangianAccumulator::calcPointCellWeights()
40 {
41  const labelListList& pointCells = mesh().pointCells();
42 
43  List<scalar> pointWeights(mesh().nPoints(), scalar(0));
44 
45  pointCellWeights_.setSize(pointCells);
46 
47  forAll(pointCells, pointi)
48  {
49  forAll(pointCells[pointi], pointCelli)
50  {
51  const label celli = pointCells[pointi][pointCelli];
52 
53  const scalar w =
54  1/mag(mesh().points()[pointi] - mesh().cellCentres()[celli]);
55 
56  pointWeights[pointi] += w;
57 
58  pointCellWeights_[pointi][pointCelli] = w;
59  }
60  }
61 
63  (
64  mesh(),
65  pointWeights,
66  plusEqOp<scalar>(),
67  scalar(0)
68  );
69 
70  forAll(pointCells, pointi)
71  {
72  forAll(pointCells[pointi], pointCelli)
73  {
74  pointCellWeights_[pointi][pointCelli] /= pointWeights[pointi];
75  }
76  }
77 }
78 
79 
80 #define ACCESS_ACCUMULATING_POINT_TYPES(Type, nullArg) \
81 namespace Foam \
82 { \
83  template<> \
84  DynamicList<Type>& \
85  cellPointLagrangianAccumulator::accumulatingPointValues() const \
86  { \
87  autoPtr<DynamicList<Type>>& ptr = \
88  CAT3(accumulatingPoint, CAPITALIZE(Type), ValuesPtr_); \
89  \
90  if (!ptr.valid()) \
91  { \
92  ptr.set(new DynamicList<Type>()); \
93  } \
94  \
95  return ptr(); \
96  } \
97 }
99 #undef ACCESS_ACCUMULATING_POINT_TYPES
100 
101 
102 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
103 
105 (
106  const polyMesh& mesh
107 )
108 :
110  <
111  polyMesh,
114  >(mesh),
115  pointCellWeights_(),
116  pointAccumulatingPoint_(mesh.nPoints(), -1),
117  accumulatingPointPoint_()
118 {
119  calcPointCellWeights();
120 }
121 
122 
123 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
124 
126 {}
127 
128 
129 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
130 
132 {
133  calcPointCellWeights();
134  return true;
135 }
136 
137 
138 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
#define ACCESS_ACCUMULATING_POINT_TYPES(Type, nullArg)
void setSize(const label mRows)
Reset size of CompactListList.
Templated abstract base-class for demand-driven mesh objects used to automate their allocation to the...
Helper class for the cell-point Lagrangian accumulation scheme. This is a mesh object in order to pro...
virtual bool movePoints()
Update for mesh motion.
cellPointLagrangianAccumulator(const polyMesh &mesh)
Construct from mesh.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const labelListList & pointCells() const
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronise values on all mesh points.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
const pointField & points
label nPoints
Namespace for OpenFOAM.
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
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
List< labelList > labelListList
A List of labelList.
Definition: labelList.H:57
defineTypeNameAndDebug(combustionModel, 0)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)