24 #include "libmesh/system_subset_by_subdomain.h" 25 #include "libmesh/system.h" 26 #include "libmesh/dof_map.h" 27 #include "libmesh/parallel.h" 28 #include "libmesh/elem.h" 47 return _list.count(subdomain_id);
56 const std::set<unsigned int> *
const var_nums):
63 this->
init(subdomain_selection);
68 const std::set<subdomain_id_type> & subdomain_ids,
69 const std::set<unsigned int> *
const var_nums):
76 this->
init(subdomain_ids);
81 const std::vector<unsigned int> &
93 if (var_nums !=
nullptr)
107 std::vector<std::vector<dof_id_type>> dof_ids_per_processor(this->
n_processors());
110 std::vector<dof_id_type> dof_indices;
113 for (
const auto & elem :
mesh.active_local_element_ptr_range())
114 if (subdomain_selection(elem->subdomain_id()))
119 for (
const auto & dof : dof_indices)
122 dof_ids_per_processor[proc].push_back(dof);
127 std::vector<Parallel::Request> request_per_processor(this->
n_processors());
130 this->
comm().
send(proc,dof_ids_per_processor[proc],request_per_processor[proc]);
133 std::vector<dof_id_type> received_dofs;
135 received_dofs = dof_ids_per_processor[proc];
138 _dof_ids.insert(
_dof_ids.end(), received_dofs.begin(), received_dofs.end());
144 std::vector<unsigned int>::iterator new_end = std::unique (
_dof_ids.begin(),
_dof_ids.end());
152 request_per_processor[proc].wait();
159 init (
const std::set<subdomain_id_type> & subdomain_ids)
162 this->
init(selection);
dof_id_type end_dof(const processor_id_type proc) const
void init(const SubdomainSelection &subdomain_selection)
Initializes the class.
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...
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
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.
const Parallel::Communicator & comm() const
const System & _system
A reference to the System we belong to.
virtual ~SubdomainSelection()
Destructor.
The libMesh namespace provides an interface to certain functionality in the library.
const MeshBase & get_mesh() const
This is the MeshBase class.
This class handles the numbering of degrees of freedom on a mesh.
processor_id_type n_processors() const
Status receive(const unsigned int dest_processor_id, T &buf, const MessageTag &tag=any_tag) const
This is a base class for classes which represent subsets of the dofs of a System. ...
Manages consistently variables, degrees of freedom, and coefficient vectors.
virtual const std::vector< unsigned int > & dof_ids() const override
SubdomainSelection()
Constructor.
Selection of subdomain ids by a list.
Subclass for user-specified selection of subdomain ids to be included in a SystemSubset.
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.
void send(const unsigned int dest_processor_id, const T &buf, const MessageTag &tag=no_tag) const
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
SystemSubsetBySubdomain(const System &system, const SubdomainSelection &subdomain_selection, const std::set< unsigned int > *const var_nums=nullptr)
Constructor.
dof_id_type first_dof(const processor_id_type proc) const
SubdomainSelectionByList(const std::set< subdomain_id_type > &list)
Constructor.
unsigned int n_vars() const
processor_id_type processor_id() const
const DofMap & get_dof_map() const
std::vector< unsigned int > _dof_ids
The actual set of the dof ids.