59 on_boundary.insert(on_block_boundary.begin(), on_block_boundary.end());
63 std::vector<Point> new_positions;
65 for (
unsigned int n=0; n<n_iterations; n++)
72 libmesh_error_msg(
"[" <<
_mesh.
processor_id() <<
"]: Node iterator returned nullptr.");
77 if (!on_boundary.count(node->id()) && (
_graph[node->id()].size() > 0))
79 Point avg_position(0.,0.,0.);
81 for (std::size_t j=0; j<
_graph[node->id()].size(); ++j)
90 avg_position.
add( connected_node );
94 new_positions[node->id()] = avg_position /
static_cast<Real>(
_graph[node->id()].size());
101 if (!on_boundary.count(node->id()) && (
_graph[node->id()].size() > 0))
124 const unsigned int son_begin = elem->n_vertices();
125 const unsigned int son_end = elem->n_nodes();
128 for (
unsigned int son=son_begin; son<son_end; son++)
131 if (!on_boundary.count(elem->node_id(son)))
133 const unsigned int n_adjacent_vertices =
134 elem->n_second_order_adjacent_vertices(son);
138 Point avg_position(0,0,0);
139 for (
unsigned int v=0; v<n_adjacent_vertices; v++)
141 _mesh.
point( elem->node_id( elem->second_order_adjacent_vertex(son,v) ) );
143 _mesh.
node_ref(elem->node_id(son)) = avg_position / n_adjacent_vertices;
170 for (
auto s : elem->side_index_range())
176 if ((elem->neighbor_ptr(s) ==
nullptr) ||
177 (elem->id() > elem->neighbor_ptr(s)->id()))
179 std::unique_ptr<const Elem>
side(elem->build_side_ptr(s));
194 for (
auto f : elem->side_index_range())
195 if ((elem->neighbor_ptr(f) ==
nullptr) ||
196 (elem->id() > elem->neighbor_ptr(f)->id()))
200 std::unique_ptr<const Elem> face = elem->build_side_ptr(f,
false);
202 for (
auto s : face->side_index_range())
205 std::unique_ptr<const Elem>
side = face->build_side_ptr(s);
220 libmesh_error_msg(
"At this time it is not possible to smooth a dimension " <<
_mesh.
mesh_dimension() <<
"mesh. Aborting...");
234 for (std::size_t i=0; i<
_graph.size(); ++i)
249 for (std::size_t i=0; i<
_graph.size(); ++i)
251 out_stream << i <<
": ";
252 std::copy(
_graph[i].begin(),
254 std::ostream_iterator<unsigned>(out_stream,
" "));
255 out_stream << std::endl;
269 std::vector<dof_id_type> flat_graph;
272 flat_graph.reserve(
_graph.size());
274 for (std::size_t i=0; i<
_graph.size(); ++i)
277 flat_graph.push_back (cast_int<dof_id_type>(
_graph[i].size()));
280 for (std::size_t j=0; j<
_graph[i].size(); ++j)
281 flat_graph.push_back(
_graph[i][j]);
300 std::size_t cursor=0;
307 std::size_t n_entries = flat_graph[cursor++];
310 _graph[node_ctr].reserve(
_graph[node_ctr].size() + n_entries);
314 for (std::size_t i=0; i<n_entries; ++i)
315 _graph[node_ctr].push_back(flat_graph[cursor++]);
std::vector< std::vector< dof_id_type > > _graph
virtual void smooth() override
virtual SimpleRange< node_iterator > local_node_ptr_range()=0
void allgather(const T &send, std::vector< T, A > &recv) const
uint8_t processor_id_type
const Parallel::Communicator & comm() const
virtual SimpleRange< element_iterator > active_element_ptr_range()=0
void print_graph(std::ostream &out=libMesh::out) const
void add(const TypeVector< T2 > &)
virtual node_iterator nodes_begin()=0
virtual SimpleRange< element_iterator > active_local_element_ptr_range()=0
processor_id_type n_processors() const
Base class for Replicated and Distributed meshes.
void sync_dofobject_data_by_id(const Communicator &comm, const Iterator &range_begin, const Iterator &range_end, SyncFunctor &sync)
LaplaceMeshSmoother(UnstructuredMesh &mesh)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual node_iterator nodes_end()=0
unsigned int mesh_dimension() const
virtual const Node & node_ref(const dof_id_type i) const
virtual const Point & point(const dof_id_type i) const =0
virtual dof_id_type max_node_id() const =0
processor_id_type processor_id() const
A geometric point in (x,y,z) space.