libMesh
parallel_ghost_sync.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 
22 namespace libMesh
23 {
24 
26  : mesh(m)
27 {}
28 
29 
30 
31 void SyncNodalPositions::gather_data (const std::vector<dof_id_type> & ids,
32  std::vector<datum> & data) const
33 {
34  data.resize(ids.size());
35 
36  // Gather (x,y,z) data for all node IDs in the ids vector
37  for (std::size_t i=0; i<ids.size(); ++i)
38  {
39  // Look for this node in the mesh
40  const Point & pt = mesh.point(ids[i]);
41 
42  // Store this node's position in the data array.
43  // This should call Point::op=
44  data[i] = pt;
45  } // end for
46 } // gather_data()
47 
48 
49 
50 void SyncNodalPositions::act_on_data (const std::vector<dof_id_type> & ids,
51  std::vector<datum> & data) const
52 {
53  for (std::size_t i=0; i<ids.size(); ++i)
54  {
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 } // namespace
void act_on_data(const std::vector< dof_id_type > &ids, std::vector< datum > &data) const
A Node is like a Point, but with more information.
Definition: node.h:52
virtual const Point & point(const dof_id_type i) const =0
virtual const Node & node_ref(const dof_id_type i) const
Definition: mesh_base.h:420
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
This is the MeshBase class.
Definition: mesh_base.h:68
void gather_data(const std::vector< dof_id_type > &ids, std::vector< datum > &data) const
IterBase * data
Ideally this private member data should have protected access.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38