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 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& patch,
48  const LagrangianBoundaryMesh& boundaryMesh
49 )
50 :
51  patch_(patch),
52  boundaryMesh_(boundaryMesh),
53  meshPtr_(nullptr)
54 {}
55 
56 
57 // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
58 
60 (
61  const word& type,
62  const polyPatch& patch,
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()(patch, boundaryMesh));
80 }
81 
82 
84 (
85  const polyPatch& patch,
86  const LagrangianBoundaryMesh& boundaryMesh
87 )
88 {
89  return New(patch.type(), patch, 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 (
125 ) const
126 {}
127 
128 
130 (
134 ) const
135 {
136  this->mesh().sub(mesh.states()) = LagrangianState::toBeRemoved;
137 }
138 
139 
141 {
142  meshPtr_.reset
143  (
144  boundaryMesh_.mesh().changing()
145  ? new LagrangianSubMesh
146  (
147  boundaryMesh_.mesh().sub
148  (
149  static_cast<LagrangianGroup>
150  (
151  static_cast<label>(LagrangianGroup::onPatchZero)
152  + patch_.index()
153  )
154  )
155  )
156  : nullptr
157  );
158 }
159 
160 
161 // ************************************************************************* //
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 initEvaluate(PstreamBuffers &, LagrangianMesh &mesh, const LagrangianScalarInternalDynamicField &fraction) const
Initialise evaluation of changes in elements that have tracked to.
const objectRegistry & db() const
Return the local object registry.
static autoPtr< LagrangianPatch > New(const word &type, const polyPatch &patch, 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 evaluate(PstreamBuffers &, LagrangianMesh &, const LagrangianScalarInternalDynamicField &fraction) const
Evaluate changes in elements that have tracked to this patch.
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).
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.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
A class for handling words, derived from string.
Definition: word.H:62
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
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
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:258
defineTypeNameAndDebug(combustionModel, 0)
LagrangianGroup
Lagrangian group enumeration.
error FatalError
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:267
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488