libMesh
Loading...
Searching...
No Matches
parallel_ghost_sync.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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#include "libmesh/parallel_ghost_sync.h"
21#include "libmesh/int_range.h"
22
23namespace libMesh
24{
25
29
30
31
32void SyncNodalPositions::gather_data (const std::vector<dof_id_type> & ids,
33 std::vector<datum> & data) const
34{
35 data.resize(ids.size());
36
37 // Gather (x,y,z) data for all node IDs in the ids vector
38 for (auto i : index_range(ids))
39 {
40 // Look for this node in the mesh
41 const Point & pt = mesh.point(ids[i]);
42
43 // Store this node's position in the data array.
44 // This should call Point::op=
45 data[i] = pt;
46 } // end for
47} // gather_data()
48
49
50
51void SyncNodalPositions::act_on_data (const std::vector<dof_id_type> & ids,
52 const std::vector<datum> & data) const
53{
54 for (auto i : index_range(ids))
55 {
56 // Get a pointer to the node whose position is to be updated.
57 Node & node = mesh.node_ref(ids[i]);
58
59 // Update this node's position. Should call Point::op=
60 node = data[i];
61 } // end for
62} // act_on_data()
63
64
68
69void SyncSubdomainIds::gather_data (const std::vector<dof_id_type> & ids,
70 std::vector<datum> & ids_out) const
71{
72 ids_out.reserve(ids.size());
73
74 for (const auto & id : ids)
75 {
76 Elem & elem = mesh.elem_ref(id);
77 ids_out.push_back(elem.subdomain_id());
78 }
79}
80
81void SyncSubdomainIds::act_on_data (const std::vector<dof_id_type> & ids,
82 const std::vector<datum> & subdomain_ids) const
83{
84 for (auto i : index_range(ids))
85 {
86 Elem & elem = mesh.elem_ref(ids[i]);
87 elem.subdomain_id()=subdomain_ids[i];
88 }
89}
90
91SyncElementIntegers::SyncElementIntegers(MeshBase & m, const std::string & integer_name)
92 : mesh(m), ind(m.get_elem_integer_index(integer_name))
93{}
94
95void SyncElementIntegers::gather_data(const std::vector<dof_id_type> & ids,
96 std::vector<dof_id_type> & ids_out) const
97{
98 ids_out.reserve(ids.size());
99
100 for (const auto & id : ids)
101 {
102 Elem & elem = mesh.elem_ref(id);
103 ids_out.push_back(elem.get_extra_integer(ind));
104 }
105}
106
107void SyncElementIntegers::act_on_data(const std::vector<dof_id_type> & ids,
108 const std::vector<dof_id_type> & integer_ids) const
109{
110 for (auto i : index_range(ids))
111 {
112 Elem & elem = mesh.elem_ref(ids[i]);
113 elem.set_extra_integer(ind, integer_ids[i]);
114 }
115}
116
117} // namespace
dof_id_type get_extra_integer(const unsigned int index) const
Gets the value on this object of the extra integer associated with index, which should have been obta...
void set_extra_integer(const unsigned int index, const dof_id_type value)
Sets the value on this object of the extra integer associated with index, which should have been obta...
This is the base class from which all geometric element types are derived.
Definition elem.h:96
subdomain_id_type subdomain_id() const
Definition elem.h:2591
This is the MeshBase class.
Definition mesh_base.h:81
virtual const Node & node_ref(const dof_id_type i) const
Definition mesh_base.h:745
virtual const Point & point(const dof_id_type i) const =0
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:788
A Node is like a Point, but with more information.
Definition node.h:55
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:40
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...
Definition int_range.h:153
SyncElementIntegers(MeshBase &m, const std::string &integer_name)
void act_on_data(const std::vector< dof_id_type > &ids, const std::vector< datum > &data) const
void gather_data(const std::vector< dof_id_type > &ids, std::vector< datum > &data) const
void act_on_data(const std::vector< dof_id_type > &ids, const std::vector< datum > &data) const
void gather_data(const std::vector< dof_id_type > &ids, std::vector< datum > &data) const
void act_on_data(const std::vector< dof_id_type > &ids, const std::vector< datum > &data) const
void gather_data(const std::vector< dof_id_type > &ids, std::vector< datum > &data) const