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-2019 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> ids_;
56 
57 
58 public:
59 
60  // Constructors
61 
62  //- Construct null
64  :
65  points_(std::cref<pointField>(pointField::null())),
66  faces_(std::cref<faceList>(faceList::null())),
67  ids_(std::cref<labelList>(labelList::null()))
68  {}
69 
70 
71  //- Construct from components
73  (
74  const pointField& pts,
75  const faceList& fcs,
76  const labelList& ids = labelList::null()
77  )
78  :
79  points_(std::cref<pointField>(pts)),
80  faces_(std::cref<faceList>(fcs)),
81  ids_(std::cref<labelList>(ids))
82  {}
83 
84 
85  //- Destructor
86  virtual ~meshedSurfRef() = default;
87 
88 
89  // Member Functions
90 
91  //- The points used for the surface
92  virtual const pointField& points() const
93  {
94  return points_.get();
95  }
96 
97  //- The faces used for the surface
98  virtual const faceList& faces() const
99  {
100  return faces_.get();
101  }
102 
103  //- Per-face zone/region information.
104  virtual const labelList& zoneIds() const
105  {
106  return ids_.get();
107  }
108 
109  //- Remove all references by redirecting to null objects
110  void clear()
111  {
112  points_ = std::cref<pointField>(pointField::null());
113  faces_ = std::cref<faceList>(faceList::null());
114  ids_ = std::cref<labelList>(labelList::null());
115  }
116 
117  //- Reset components
118  void reset
119  (
120  const pointField& pts,
121  const faceList& fcs,
122  const labelList& ids = labelList::null()
123  )
124  {
125  points_ = std::cref<pointField>(pts);
126  faces_ = std::cref<faceList>(fcs);
127  ids_ = std::cref<labelList>(ids);
128  }
129 };
130 
131 
132 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
133 
134 } // End namespace Foam
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 #endif
139 
140 // ************************************************************************* //
Foam::meshedSurfRef::meshedSurfRef
meshedSurfRef()
Construct null.
Definition: meshedSurfRef.H:62
Foam::meshedSurfRef::faces
virtual const faceList & faces() const
The faces used for the surface.
Definition: meshedSurfRef.H:97
Foam::List< label >::null
static const List< label > & null()
Return a null List.
Definition: ListI.H:108
Foam::meshedSurfRef::points
virtual const pointField & points() const
The points used for the surface.
Definition: meshedSurfRef.H:91
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::meshedSurfRef::reset
void reset(const pointField &pts, const faceList &fcs, const labelList &ids=labelList::null())
Reset components.
Definition: meshedSurfRef.H:118
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::List< face >
Foam::meshedSurfRef::zoneIds
virtual const labelList & zoneIds() const
Per-face zone/region information.
Definition: meshedSurfRef.H:103
Foam::Field::null
static const Field< Type > & null()
Return nullObject reference field.
Definition: Field.H:96
meshedSurf.H
Foam::meshedSurfRef::clear
void clear()
Remove all references by redirecting to null objects.
Definition: meshedSurfRef.H:109
Foam::meshedSurfRef::~meshedSurfRef
virtual ~meshedSurfRef()=default
Destructor.