patchInjectionBase.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2024 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::PatchInjectionBase
29 
30 Description
31  Base class for patch-based injection models.
32 
33  Class handles injecting at a random point adjacent to the patch faces to
34  provide a more stochastic view of the injection process. Patch faces are
35  triangulated, and area fractions accumulated. The fractional areas are
36  then applied to determine across which face a parcel is to be injected.
37 
38 SourceFiles
39  PatchInjectionBase.C
40 
41 \*---------------------------------------------------------------------------*/
42 
43 #ifndef Foam_patchInjectionBase_H
44 #define Foam_patchInjectionBase_H
45 
46 #include "word.H"
47 #include "labelList.H"
48 #include "scalarList.H"
49 #include "vectorList.H"
50 #include "faceList.H"
51 #include "labelledTri.H"
52 
53 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 
55 namespace Foam
56 {
57 
58 // Forward Declarations
59 class polyMesh;
60 class fvMesh;
61 class Random;
62 
63 /*---------------------------------------------------------------------------*\
64  Class patchInjectionBase Declaration
65 \*---------------------------------------------------------------------------*/
66 
68 {
69 protected:
70 
71  // Protected Data
72 
73  //- Patch name
74  const word patchName_;
75 
76  //- Patch ID
77  const label patchId_;
78 
79  //- Patch area - total across all processors
80  scalar patchArea_;
81 
82  //- Patch face normal directions
84 
85  //- List of cell labels corresponding to injector positions
87 
88  //- The polyPatch faces as triangles, the index of each corresponds
89  //- to the undecomposed patch face index.
91 
92  //- Cumulative triangle area per triangle face (processor-local)
94 
95  //- Cumulative area fractions per processor
97 
98 
99 public:
100 
101  // Constructors
103  //- Construct from mesh and patch name
104  patchInjectionBase(const polyMesh& mesh, const word& patchName);
105 
106  //- Copy constructor
108 
109 
110  //- Destructor
111  virtual ~patchInjectionBase() = default;
112 
113 
114  // Member Functions
115 
116  //- Update patch geometry and derived info for injection locations
117  virtual void updateMesh(const polyMesh& mesh);
118 
119  //- Set the injection position and owner cell, tetFace and tetPt
120  // Supply the fraction used to determine the location on the patch
121  // Returns the seed patch face index
122  label setPositionAndCell
123  (
124  const fvMesh& mesh,
125  const scalar fraction01,
126  Random& rnd,
127  vector& position,
128  label& cellOwner,
129  label& tetFacei,
130  label& tetPti
131  );
132 
133  //- Set the injection position and owner cell, tetFace and tetPt
134  // Returns the seed patch face index
135  virtual label setPositionAndCell
136  (
137  const fvMesh& mesh,
138  Random& rnd,
139  vector& position,
140  label& cellOwner,
141  label& tetFacei,
142  label& tetPti
143  );
144 
145  //- Return the processor that has the location specified by the fraction
146  label whichProc(const scalar fraction01) const;
147 };
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 } // End namespace Foam
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 #endif
156 
157 // ************************************************************************* //
const word patchName_
Patch name.
label whichProc(const scalar fraction01) const
Return the processor that has the location specified by the fraction.
patchInjectionBase(const polyMesh &mesh, const word &patchName)
Construct from mesh and patch name.
virtual void updateMesh(const polyMesh &mesh)
Update patch geometry and derived info for injection locations.
vectorList patchNormal_
Patch face normal directions.
dynamicFvMesh & mesh
List< labelledTri > triFace_
The polyPatch faces as triangles, the index of each corresponds to the undecomposed patch face index...
A class for handling words, derived from Foam::string.
Definition: word.H:63
scalarList sumTriMagSf_
Cumulative area fractions per processor.
const label patchId_
Patch ID.
scalarList triCumulativeMagSf_
Cumulative triangle area per triangle face (processor-local)
Random number generator.
Definition: Random.H:55
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
scalar patchArea_
Patch area - total across all processors.
label setPositionAndCell(const fvMesh &mesh, const scalar fraction01, Random &rnd, vector &position, label &cellOwner, label &tetFacei, label &tetPti)
Set the injection position and owner cell, tetFace and tetPt.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
labelList cellOwners_
List of cell labels corresponding to injector positions.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:75
virtual ~patchInjectionBase()=default
Destructor.
Namespace for OpenFOAM.