[P]arallel [Hi]gh-order [Li]brary for [P]DEs  Latest
Parallel High-Order Library for PDEs through hp-adaptive Discontinuous Galerkin methods
metric_to_mesh_generator.h
1 #ifndef __METRIC_TO_MESH_GENERATOR_H__
2 #define __METRIC_TO_MESH_GENERATOR_H__
3 
4 #include <deal.II/fe/fe_q.h>
5 #include <deal.II/fe/fe_system.h>
6 #include <deal.II/fe/mapping_fe_field.h>
7 
8 #include <deal.II/distributed/tria.h>
9 #include <deal.II/grid/tria.h>
10 
11 #include <deal.II/base/conditional_ostream.h>
12 
13 #include <deal.II/lac/vector.h>
14 #include <deal.II/lac/la_parallel_vector.templates.h>
15 
16 #include <deal.II/dofs/dof_handler.h>
17 
18 namespace PHiLiP {
20 #if PHILIP_DIM==1 // dealii::parallel::distributed::Triangulation<dim> does not work for 1D
21 template <int dim, int nstate, typename real, typename MeshType = dealii::Triangulation<dim>>
22 #else
23 template <int dim, int nstate, typename real, typename MeshType = dealii::parallel::distributed::Triangulation<dim>>
24 #endif
26 
27  using VectorType = dealii::LinearAlgebra::distributed::Vector<double>;
28  using DoFHandlerType = dealii::DoFHandler<dim>;
29 
30 public:
33  std::shared_ptr<dealii::MappingFEField<dim,dim,VectorType,DoFHandlerType>> _volume_nodes_mapping,
34  std::shared_ptr<MeshType> _triangulation);
35 
37  ~MetricToMeshGenerator() = default;
38 
40  void generate_mesh_from_cellwise_metric(const std::vector<dealii::Tensor<2, dim, real>> &cellwise_optimal_metric);
41 
43  std::string get_generated_mesh_filename() const;
44 
45 private:
47  void reinit();
48 
50  void interpolate_metric_to_vertices(const std::vector<dealii::Tensor<2, dim, real>> &cellwise_optimal_metric);
51 
53  void write_geo_file() const;
54 
56  void write_pos_file() const;
57 
58 
60  std::shared_ptr<dealii::MappingFEField<dim,dim,VectorType,DoFHandlerType>> volume_nodes_mapping;
61 
63  std::shared_ptr<MeshType> triangulation;
64 
66  dealii::DoFHandler<dim> dof_handler_vertices;
67 
69  const dealii::FE_Q<dim> fe_q;
70 
72  const dealii::FESystem<dim> fe_system;
73 
75  std::array<VectorType, dim*dim> optimal_metric_at_vertices;
76 
78  std::vector<dealii::Point<dim>> all_vertices;
79 
81  MPI_Comm mpi_communicator;
82 
84  dealii::ConditionalOStream pcout;
85 
87  int mpi_rank;
88 
90  int n_mpi;
91 
93  const std::string filename;
95  const std::string filename_pos;
97  const std::string filename_geo;
99  const std::string filename_msh;
100 
101  dealii::IndexSet locally_owned_vertex_dofs;
102  dealii::IndexSet ghost_vertex_dofs;
103  dealii::IndexSet locally_relevant_vertex_dofs;
104 
105 }; // class ends
106 
107 } // PHiLiP namespace
108 #endif
const std::string filename_msh
.geo file
dealii::DoFHandler< dim > dof_handler_vertices
DoFHandler to get global index of vertices.
MetricToMeshGenerator(std::shared_ptr< dealii::MappingFEField< dim, dim, VectorType, DoFHandlerType >> _volume_nodes_mapping, std::shared_ptr< MeshType > _triangulation)
Constructor.
dealii::IndexSet ghost_vertex_dofs
Dofs not owned by current processor (but it can still access them).
std::shared_ptr< MeshType > triangulation
Stores triangulation currently in use.
dealii::DoFHandler< dim > DoFHandlerType
Alias for declaring DofHandler.
const dealii::FESystem< dim > fe_system
FESystem for vertices, created with nstate = 1 to relate an entire vertex of size dim by a single dof...
Files for the baseline physics.
Definition: ADTypes.hpp:10
dealii::IndexSet locally_owned_vertex_dofs
Dofs owned by current processor.
int mpi_rank
Processor# of current processor.
void generate_mesh_from_cellwise_metric(const std::vector< dealii::Tensor< 2, dim, real >> &cellwise_optimal_metric)
Generates mesh from the input cellwise metric.
std::shared_ptr< dealii::MappingFEField< dim, dim, VectorType, DoFHandlerType > > volume_nodes_mapping
Mapping field to update physical quadrature points, jacobians etc with the movement of volume nodes...
void write_pos_file() const
Writes .pos file.
void reinit()
Reinitialize dof handler vertices after updating triangulation.
dealii::IndexSet locally_relevant_vertex_dofs
Union of locally owned degrees of freedom and ghost degrees of freedom.
std::vector< dealii::Point< dim > > all_vertices
Stores all vertices.
void interpolate_metric_to_vertices(const std::vector< dealii::Tensor< 2, dim, real >> &cellwise_optimal_metric)
Interpolates cellwise metric field to vertices.
void write_geo_file() const
Writes .geo file.
const dealii::FE_Q< dim > fe_q
Continuous FE of degree 1.
std::string get_generated_mesh_filename() const
Returns name of the .msh file.
int n_mpi
Total no. of processors.
~MetricToMeshGenerator()=default
Destructor.
std::array< VectorType, dim *dim > optimal_metric_at_vertices
Stores optimal metric at vertices. Accessed by optimal_metric_at_vertices[position_in_metric_tensor][...
const std::string filename_pos
.pos file.
dealii::ConditionalOStream pcout
std::cout only on processor #0.
MPI_Comm mpi_communicator
Alias for MPI_COMM_WORLD.
dealii::LinearAlgebra::distributed::Vector< double > VectorType
Alias for dealii&#39;s parallel distributed vector.
Class to convert metric field to mesh using BAMG.
const std::string filename_geo
.geo file
const std::string filename
Name of the file.