processorLagrangianPatch.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 "LagrangianFields.H"
28 #include "tracking.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
36 
38  (
41  polyPatch
42  );
43 }
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
48 (
49  const polyPatch& patch,
50  const LagrangianBoundaryMesh& boundaryMesh
51 )
52 :
53  LagrangianPatch(patch, boundaryMesh),
54  processorPatch_(refCast<const processorPolyPatch>(patch))
55 {}
56 
57 
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
59 
61 {}
62 
63 
64 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
65 
67 {
68  return
69  receiveMeshPtr_.valid()
70  ? receiveMeshPtr_()
72 }
73 
74 
76 (
77  PstreamBuffers& pBufs,
80 ) const
81 {
82  const LagrangianSubMesh& patchMesh = this->mesh();
83 
84  // Sub-set the geometry and topology of the elements
85  SubField<barycentric> sendCoordinates = patchMesh.sub(mesh.coordinates());
86  labelField sendCelli(patchMesh.sub(mesh.celli()));
87  labelField sendFacei(patchMesh.sub(mesh.facei()));
88  SubField<label> sendFaceTrii = patchMesh.sub(mesh.faceTrii());
89  SubField<scalar> sendFraction = patchMesh.sub(fraction.primitiveField());
90 
91  // Pre-communication steps
92  forAll(patchMesh, i)
93  {
95  (
96  processorPatch_,
97  sendCelli[i],
98  sendFacei[i]
99  );
100  }
101 
102  // Send
103  UOPstream(processorPatch_.neighbProcNo(), pBufs)()
104  << sendCoordinates
105  << sendCelli
106  << sendFacei
107  << sendFaceTrii
108  << sendFraction;
109 
110  // Remove the sent elements
111  patchMesh.sub(mesh.states()) = LagrangianState::toBeRemoved;
112 }
113 
114 
116 (
117  PstreamBuffers& pBufs,
120 ) const
121 {
122  // Receive
123  UIPstream uips(processorPatch_.neighbProcNo(), pBufs);
124  barycentricField receiveCoordinates(uips);
125  labelField receiveCelli(uips);
126  labelField receiveFacei(uips);
127  labelField receiveFaceTrii(uips);
128  scalarField receiveFraction(uips);
129 
130  // Post-communication steps
131  forAll(receiveCoordinates, i)
132  {
134  (
135  processorPatch_,
136  receiveCoordinates[i],
137  receiveCelli[i],
138  receiveFacei[i],
139  receiveFaceTrii[i]
140  );
141  }
142 
143  // Insert the received elements and store the sub-mesh in which they reside
144  receiveMeshPtr_.set
145  (
147  (
148  mesh.append
149  (
150  receiveCoordinates,
151  receiveCelli,
152  receiveFacei,
153  receiveFaceTrii
154  )
155  )
156  );
157 
158  // Set the step fractions of the elements
159  mesh.appendSpecifiedField<scalar, LagrangianInternalDynamicField>
160  (
161  receiveMeshPtr_(),
162  const_cast<LagrangianScalarInternalDynamicField&>(fraction),
163  receiveFraction
164  );
165 
166  // Set the elements to be in the adjacent cell
167  receiveMeshPtr_().sub(mesh.states()) = LagrangianState::inCell;
168 }
169 
170 
172 {
174 
175  // The elements are back on this patch, and the receive mesh is now out of
176  // date and no longer needed
177  receiveMeshPtr_.clear();
178 }
179 
180 
181 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:433
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const PrimitiveField< Type > & primitiveField() const
Return a const-reference to the primitive field.
Boundary part of a Lagrangian mesh. Just a list of Lagrangian patches with some added convenience fun...
Class containing Lagrangian geometry and topology.
Base class for Lagrangian patches.
virtual void partition() const
Update for mesh changes.
virtual const LagrangianSubMesh & mesh() const
Return the sub-mesh associated with this patch.
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
SubList< Type > sub(const List< Type > &list) const
Return a sub-list corresponding to this sub-mesh.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Pre-declare related SubField type.
Definition: SubField.H:63
Input inter-processor communications stream operating on external buffer.
Definition: UIPstream.H:57
Output inter-processor communications stream operating on external buffer.
Definition: UOPstream.H:58
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
Processor Lagrangian patch. This is used for the patches that interface between processors across fac...
processorLagrangianPatch(const polyPatch &, const LagrangianBoundaryMesh &)
Construct from a patch and a boundary mesh.
virtual void initEvaluate(PstreamBuffers &, LagrangianMesh &, const LagrangianScalarInternalDynamicField &fraction) const
Initialise evaluation of changes in elements that have tracked to.
virtual void partition() const
Update following partitioning of the mesh.
virtual void evaluate(PstreamBuffers &, LagrangianMesh &, const LagrangianScalarInternalDynamicField &fraction) const
Evaluate changes in elements that have tracked to this patch.
virtual const LagrangianSubMesh & mesh() const
Return the sub-mesh associated with this patch.
virtual ~processorLagrangianPatch()
Destructor.
Neighbour processor patch.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
void outProcessor(const processorPolyPatch &outPatch, barycentric &coordinates, label &celli, label &facei, label &faceTrii)
Complete crossing of a processor patch. Restore the topology.
Definition: tracking.C:1777
void inProcessor(const processorPolyPatch &inPatch, label &celli, label &facei)
Initialise crossing of a processor patch. Breaks the topology in order.
Definition: tracking.C:1762
Namespace for OpenFOAM.
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:134
defineTypeNameAndDebug(combustionModel, 0)