meshedSurfRef.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) 2016-2020 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::meshedSurfRef
28 
29 Description
30  Implements a meshed surface by referencing existing faces and points.
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef meshedSurfRef_H
35 #define meshedSurfRef_H
36 
37 #include "meshedSurf.H"
38 #include <functional>
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 /*---------------------------------------------------------------------------*\
46  Class meshedSurfRef Declaration
47 \*---------------------------------------------------------------------------*/
48 
49 class meshedSurfRef
50 :
51  public meshedSurf
52 {
53  std::reference_wrapper<const pointField> points_;
54  std::reference_wrapper<const faceList> faces_;
55  std::reference_wrapper<const labelList> zoneIds_;
56  std::reference_wrapper<const labelList> faceIds_;
57 
58 
59 public:
60 
61  // Constructors
62 
63  //- Default construct
65  :
66  points_(std::cref<pointField>(pointField::null())),
67  faces_(std::cref<faceList>(faceList::null())),
68  zoneIds_(std::cref<labelList>(labelList::null())),
69  faceIds_(std::cref<labelList>(labelList::null()))
70  {}
71 
72 
73  //- Construct from components
75  (
76  const pointField& pointLst,
77  const faceList& faceLst,
78  const labelList& zoneIdLst = labelList::null(),
79  const labelList& faceIdLst = labelList::null()
80  )
81  :
82  points_(std::cref<pointField>(pointLst)),
83  faces_(std::cref<faceList>(faceLst)),
84  zoneIds_(std::cref<labelList>(zoneIdLst)),
85  faceIds_(std::cref<labelList>(faceIdLst))
86  {}
87 
88 
89  //- Destructor
90  virtual ~meshedSurfRef() = default;
91 
92 
93  // Member Functions
94 
95  //- The points used for the surface
96  virtual const pointField& points() const
97  {
98  return points_.get();
99  }
100 
101  //- The faces used for the surface
102  virtual const faceList& faces() const
103  {
104  return faces_.get();
105  }
106 
107  //- Per-face zone/region information.
108  virtual const labelList& zoneIds() const
109  {
110  return zoneIds_.get();
111  }
112 
113  //- Per-face identifier (eg, element Id)
114  virtual const labelList& faceIds() const
115  {
116  return faceIds_.get();
117  }
118 
119  //- Remove all references by redirecting to null objects
120  void clear()
121  {
122  points_ = std::cref<pointField>(pointField::null());
123  faces_ = std::cref<faceList>(faceList::null());
124  zoneIds_ = std::cref<labelList>(labelList::null());
125  faceIds_ = std::cref<labelList>(labelList::null());
126  }
127 
128  //- Reset components
129  void reset
130  (
131  const pointField& pointLst,
132  const faceList& faceLst,
133  const labelList& zoneIdLst = labelList::null(),
134  const labelList& faceIdLst = labelList::null()
135  )
136  {
137  points_ = std::cref<pointField>(pointLst);
138  faces_ = std::cref<faceList>(faceLst);
139  zoneIds_ = std::cref<labelList>(zoneIdLst);
140  faceIds_ = std::cref<labelList>(faceIdLst);
141  }
142 };
143 
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 } // End namespace Foam
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 #endif
152 
153 // ************************************************************************* //
Foam::meshedSurfRef::meshedSurfRef
meshedSurfRef()
Default construct.
Definition: meshedSurfRef.H:63
Foam::meshedSurfRef::faces
virtual const faceList & faces() const
The faces used for the surface.
Definition: meshedSurfRef.H:101
Foam::List::null
static const List< T > & null()
Return a null List.
Definition: ListI.H:109
Foam::meshedSurfRef::reset
void reset(const pointField &pointLst, const faceList &faceLst, const labelList &zoneIdLst=labelList::null(), const labelList &faceIdLst=labelList::null())
Reset components.
Definition: meshedSurfRef.H:129
Foam::meshedSurfRef::points
virtual const pointField & points() const
The points used for the surface.
Definition: meshedSurfRef.H:95
Foam::meshedSurf
Abstract definition of a meshed surface defined by faces and points.
Definition: meshedSurf.H:49
Foam::meshedSurfRef
Implements a meshed surface by referencing existing faces and points.
Definition: meshedSurfRef.H:48
Foam::Field< vector >
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::meshedSurfRef::faceIds
virtual const labelList & faceIds() const
Per-face identifier (eg, element Id)
Definition: meshedSurfRef.H:113
Foam::List< face >
Foam::meshedSurfRef::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: meshedSurfRef.H:107
meshedSurf.H
Foam::meshedSurfRef::clear
void clear()
Remove all references by redirecting to null objects.
Definition: meshedSurfRef.H:119
Foam::Field::null
static const Field< Type > & null()
Return nullObject reference Field.
Definition: FieldI.H:31
Foam::meshedSurfRef::~meshedSurfRef
virtual ~meshedSurfRef()=default
Destructor.