LagrangianPatch.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-2026 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 "LagrangianPatch.H"
27 #include "LagrangianMesh.H"
28 #include "LagrangianFields.H"
29 #include "tracking.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
37 
39 
41 }
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
46 (
47  const polyPatch& poly,
48  const LagrangianBoundaryMesh& boundaryMesh
49 )
50 :
51  poly_(poly),
52  boundaryMesh_(boundaryMesh),
53  meshPtr_(nullptr)
54 {}
55 
56 
57 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
58 
60 (
61  const word& type,
62  const polyPatch& poly,
63  const LagrangianBoundaryMesh& boundaryMesh
64 )
65 {
66  polyPatchConstructorTable::iterator cstrIter =
67  polyPatchConstructorTablePtr_->find(type);
68 
69  if (cstrIter == polyPatchConstructorTablePtr_->end())
70  {
72  << "Unknown LagrangianPatch type " << type
73  << nl << nl
74  << "Valid LagrangianPatch types are :" << endl
75  << polyPatchConstructorTablePtr_->sortedToc()
76  << exit(FatalError);
77  }
78 
79  return autoPtr<LagrangianPatch>(cstrIter()(poly, boundaryMesh));
80 }
81 
82 
84 (
85  const polyPatch& poly,
86  const LagrangianBoundaryMesh& boundaryMesh
87 )
88 {
89  return New(poly.type(), poly, boundaryMesh);
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 
96 {}
97 
98 
99 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
100 
102 {
103  if (!meshPtr_.valid())
104  {
106  << "Lagrangian patch mesh requested out of scope of Lagrangian "
107  << "mesh changes" << exit(FatalError);
108  }
109 
110  return meshPtr_;
111 }
112 
113 
115 {
116  return boundaryMesh().mesh();
117 }
118 
119 
121 {
122  return boundaryMesh().mesh().time();
123 }
124 
125 
127 (
131 ) const
132 {}
133 
134 
136 (
140 ) const
141 {
142  this->mesh().sub(mesh.states()) = LagrangianState::toBeRemoved;
143 }
144 
145 
147 {
148  meshPtr_.reset
149  (
150  boundaryMesh_.mesh().changing()
151  ? new LagrangianSubMesh
152  (
153  boundaryMesh_.mesh().sub
154  (
155  static_cast<LagrangianGroup>
156  (
157  static_cast<label>(LagrangianGroup::onPatchZero)
158  + poly_.index()
159  )
160  )
161  )
162  : nullptr
163  );
164 }
165 
166 
167 // ************************************************************************* //
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...
Boundary part of a Lagrangian mesh. Just a list of Lagrangian patches with some added convenience fun...
Class containing Lagrangian geometry and topology.
const List< LagrangianState > & states() const
Return the states.
Base class for Lagrangian patches.
virtual void evaluate(PstreamBuffers &, LagrangianMesh &, const LagrangianInternalScalarDynamicField &fraction) const
Evaluate changes in elements that have tracked to this patch.
const Time & time() const
Return time.
const objectRegistry & db() const
Return the local object registry.
static autoPtr< LagrangianPatch > New(const word &type, const polyPatch &poly, const LagrangianBoundaryMesh &boundaryMesh)
Return a pointer to a new LagrangianPatch of specified type.
virtual ~LagrangianPatch()
Destructor.
virtual void partition() const
Update for mesh changes.
virtual void initEvaluate(PstreamBuffers &, LagrangianMesh &mesh, const LagrangianInternalScalarDynamicField &fraction) const
Initialise evaluation of changes in elements that have tracked to.
LagrangianPatch(const polyPatch &, const LagrangianBoundaryMesh &)
Construct from a patch and a boundary mesh.
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...
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Registry of regIOobjects.
const Time & time() const
Return time.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
A class for handling words, derived from string.
Definition: word.H:63
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const unitSet fraction
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
defineRunTimeSelectionTable(fvConstraint, dictionary)
LagrangianGroup
Lagrangian group enumeration.
error FatalError
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
static const char nl
Definition: Ostream.H:297
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488