libMesh
system_subset_by_subdomain.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_SYSTEM_SUBSET_BY_SUBDOMAIN_H
21 #define LIBMESH_SYSTEM_SUBSET_BY_SUBDOMAIN_H
22 
23 // Local Includes
24 #include "libmesh/system_subset.h"
25 #include "libmesh/id_types.h"
26 #include "libmesh/parallel_object.h"
27 
28 // C++ includes
29 #include <cstddef>
30 #include <set>
31 
32 namespace libMesh
33 {
34 
35 // Forward Declarations
36 
46  public ParallelObject
47 {
48 public:
49 
54  class SubdomainSelection : public ReferenceCountedObject<SubdomainSelection>
55  {
56  public:
57 
62 
66  virtual ~SubdomainSelection ();
67 
72  virtual bool operator() (const subdomain_id_type & subdomain_id) const = 0;
73 
74  private:
82 
90  }; // subclass \p SubdomainSelection
91 
92 
93 
98  {
99  public:
104  explicit
105  SubdomainSelectionByList (const std::set<subdomain_id_type> & list);
106 
111  virtual bool operator() (const subdomain_id_type & subdomain_id) const override;
112 
113  protected:
117  const std::set<subdomain_id_type> & _list;
118  };
119 
128  SystemSubsetBySubdomain (const System & system,
129  const SubdomainSelection & subdomain_selection,
130  const std::set<unsigned int> * const var_nums = nullptr);
131 
140  SystemSubsetBySubdomain (const System & system,
141  const std::set<subdomain_id_type> & subdomain_ids,
142  const std::set<unsigned int> * const var_nums = nullptr);
143 
147  virtual ~SystemSubsetBySubdomain ();
148 
155  virtual const std::vector<unsigned int> & dof_ids () const override;
156 
164  void init (const SubdomainSelection & subdomain_selection);
165 
173  void init (const std::set<subdomain_id_type> & subdomain_ids);
174 
175 protected:
176 
181  void set_var_nums (const std::set<unsigned int> * const var_nums);
182 
189  std::set<unsigned int> _var_nums;
190 
194  std::vector<unsigned int> _dof_ids;
195 
196 }; // class SystemSubset
197 
198 } // namespace libMesh
199 
200 #endif // LIBMESH_SYSTEM_SUBSET_BY_SUBDOMAIN_H
SubdomainSelection & operator=(const SubdomainSelection &)
This isn&#39;t a copyable object, so let&#39;s make sure nobody tries.
void init(const SubdomainSelection &subdomain_selection)
Initializes the class.
virtual bool operator()(const subdomain_id_type &subdomain_id) const =0
Method that decides whether a given subdomain id is included in the subset or nor.
virtual ~SystemSubsetBySubdomain()
Destructor.
void set_var_nums(const std::set< unsigned int > *const var_nums)
Sets _var_nums to either a copy of var_nums or, if that is nullptr, a set of all variable numbers tha...
virtual bool operator()(const subdomain_id_type &subdomain_id) const override
Method that decides whether a given subdomain id is included in the subset or nor.
The libMesh namespace provides an interface to certain functionality in the library.
This class represents a subset of the dofs of a System, selected by the subdomain_id and possible the...
This is a base class for classes which represent subsets of the dofs of a System. ...
Definition: system_subset.h:42
Manages consistently variables, degrees of freedom, and coefficient vectors.
Definition: system.h:96
virtual const std::vector< unsigned int > & dof_ids() const override
Subclass for user-specified selection of subdomain ids to be included in a SystemSubset.
This class implements reference counting.
An object whose state is distributed along a set of processors.
std::set< unsigned int > _var_nums
The set of all variable numbers that are contained in the subset.
const std::set< subdomain_id_type > & _list
The actual list.
SystemSubsetBySubdomain(const System &system, const SubdomainSelection &subdomain_selection, const std::set< unsigned int > *const var_nums=nullptr)
Constructor.
SubdomainSelectionByList(const std::set< subdomain_id_type > &list)
Constructor.
std::vector< unsigned int > _dof_ids
The actual set of the dof ids.