Loading...
Searching...
No Matches
ParallelRefinement.h
// Copyright (C) 2012-2014 Chris Richardson
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
//
// First Added: 2013-01-02
#ifndef __PARALLEL_REFINEMENT_H
#define __PARALLEL_REFINEMENT_H
#include <unordered_map>
#include <vector>
namespace dolfin
{
// Forward declarations
class Mesh;
template<typename T> class MeshFunction;
class ParallelRefinement
{
public:
ParallelRefinement(const Mesh& mesh);
~ParallelRefinement();
const Mesh& mesh() const
{ return _mesh; }
bool is_marked(std::size_t edge_index) const;
void mark(std::size_t edge_index);
void mark_all();
void mark(const MeshFunction<bool>& refinement_marker);
void mark(const MeshEntity& cell);
std::vector<std::size_t> marked_edge_list(const MeshEntity& cell) const;
void update_logical_edgefunction();
void create_new_vertices();
std::shared_ptr<const std::map<std::size_t, std::size_t> > edge_to_new_vertex() const;
void new_cell(const Cell& cell);
void new_cell(std::size_t i0, std::size_t i1, std::size_t i2,
std::size_t i3);
void new_cell(std::size_t i0, std::size_t i1, std::size_t i2);
void new_cells(const std::vector<std::size_t>& idx);
void partition(Mesh& new_mesh, bool redistribute) const;
void build_local(Mesh& new_mesh) const;
private:
// Mesh reference
const Mesh& _mesh;
// Shared edges between processes. In R^2, vector size is 1
std::unordered_map<unsigned int, std::vector<std::pair<unsigned int,
unsigned int> > > shared_edges;
// Mapping from old local edge index to new global vertex, needed
// to create new topology
std::shared_ptr<std::map<std::size_t, std::size_t> > local_edge_to_new_vertex;
// New storage for all coordinates when creating new vertices
std::vector<double> new_vertex_coordinates;
// New storage for all cells when creating new topology
std::vector<std::size_t> new_cell_topology;
// Management of marked edges
std::vector<bool> marked_edges;
// Temporary storage for edges that have been recently marked
std::vector<std::vector<std::size_t> > marked_for_update;
};
}
#endif
dolfin::Cell
A Cell is a MeshEntity of topological codimension 0.
Definition Cell.h:43
dolfin::MeshEntity
Definition MeshEntity.h:43
dolfin::MeshFunction
Definition MeshFunction.h:58
dolfin::Mesh
Definition Mesh.h:84
dolfin::ParallelRefinement::is_marked
bool is_marked(std::size_t edge_index) const
Definition ParallelRefinement.cpp:58
dolfin::ParallelRefinement::partition
void partition(Mesh &new_mesh, bool redistribute) const
Definition ParallelRefinement.cpp:290
dolfin::ParallelRefinement::build_local
void build_local(Mesh &new_mesh) const
Definition ParallelRefinement.cpp:245
dolfin::ParallelRefinement::~ParallelRefinement
~ParallelRefinement()
Destructor.
Definition ParallelRefinement.cpp:53
dolfin::ParallelRefinement::ParallelRefinement
ParallelRefinement(const Mesh &mesh)
Constructor.
Definition ParallelRefinement.cpp:44
dolfin::ParallelRefinement::edge_to_new_vertex
std::shared_ptr< const std::map< std::size_t, std::size_t > > edge_to_new_vertex() const
Definition ParallelRefinement.cpp:90
dolfin::ParallelRefinement::mesh
const Mesh & mesh() const
Original mesh associated with this refinement.
Definition ParallelRefinement.h:53
dolfin::ParallelRefinement::mark_all
void mark_all()
Mark all edges in mesh.
Definition ParallelRefinement.cpp:84
dolfin::ParallelRefinement::mark
void mark(std::size_t edge_index)
Definition ParallelRefinement.cpp:64
dolfin::ParallelRefinement::new_cell
void new_cell(const Cell &cell)
Definition ParallelRefinement.cpp:340
dolfin::ParallelRefinement::create_new_vertices
void create_new_vertices()
Definition ParallelRefinement.cpp:148
dolfin::ParallelRefinement::update_logical_edgefunction
void update_logical_edgefunction()
Transfer marked edges between processes.
Definition ParallelRefinement.cpp:130
dolfin::ParallelRefinement::new_cells
void new_cells(const std::vector< std::size_t > &idx)
Definition ParallelRefinement.cpp:363
dolfin::ParallelRefinement::marked_edge_list
std::vector< std::size_t > marked_edge_list(const MeshEntity &cell) const
Definition ParallelRefinement.cpp:116
dolfin
Definition adapt.h:30