1 #ifndef __HIGHORDERGRID_H__ 2 #define __HIGHORDERGRID_H__ 4 #include <deal.II/base/conditional_ostream.h> 6 #include <deal.II/grid/tria.h> 7 #include <deal.II/distributed/shared_tria.h> 8 #include <deal.II/distributed/tria.h> 10 #include <deal.II/fe/fe_q.h> 11 #include <deal.II/fe/fe_system.h> 12 #include <deal.II/fe/mapping_fe_field.h> 13 #include <deal.II/fe/fe_dgq.h> 15 #include <deal.II/dofs/dof_handler.h> 17 #include <deal.II/numerics/solution_transfer.h> 18 #include <deal.II/distributed/solution_transfer.h> 20 #include <deal.II/lac/vector.h> 21 #include <deal.II/lac/la_parallel_vector.templates.h> 23 #include <deal.II/numerics/data_postprocessor.h> 24 #include <deal.II/numerics/data_out.h> 25 #include <deal.II/numerics/data_out_dof_data.h> 27 #include <deal.II/lac/trilinos_sparse_matrix.h> 28 #include <deal.II/lac/trilinos_vector.h> 30 #include "parameters/all_parameters.h" 35 template <
typename MeshType>
43 using VectorType = dealii::LinearAlgebra::distributed::Vector<double>;
44 using DoFHandlerType = dealii::DoFHandler<PHILIP_DIM>;
46 template <
int dim = PHILIP_DIM,
typename Vector = VectorType,
typename DoFHandler = DoFHandlerType>
47 using SolutionTransfer = dealii::SolutionTransfer<dim, Vector, DoFHandler>;
50 static void reinit_vector(
52 DoFHandlerType
const &,
53 dealii::IndexSet
const &locally_owned_dofs,
54 dealii::IndexSet
const &ghost_dofs,
55 MPI_Comm
const mpi_communicator)
57 vector.reinit(locally_owned_dofs, ghost_dofs, mpi_communicator);
62 class MeshTypeHelper<dealii::parallel::distributed::Triangulation<PHILIP_DIM>>
65 using VectorType = dealii::LinearAlgebra::distributed::Vector<double>;
66 using DoFHandlerType = dealii::DoFHandler<PHILIP_DIM>;
68 template <
int dim = PHILIP_DIM,
typename Vector = VectorType,
typename DoFHandler = DoFHandlerType>
69 using SolutionTransfer = dealii::parallel::distributed::SolutionTransfer<dim, Vector, DoFHandler>;
72 static void reinit_vector(
74 DoFHandlerType
const &,
75 dealii::IndexSet
const &locally_owned_dofs,
76 dealii::IndexSet
const &ghost_dofs,
77 MPI_Comm
const mpi_communicator)
79 vector.reinit(locally_owned_dofs, ghost_dofs, mpi_communicator);
83 #if PHILIP_DIM1!=1 // dealii::parallel::distributed::Triangulation<dim> does not work for 1D 88 using VectorType = dealii::LinearAlgebra::distributed::Vector<double>;
89 using DoFHandlerType = dealii::DoFHandler<PHILIP_DIM>;
91 template <
int dim = PHILIP_DIM,
typename Vector = VectorType,
typename DoFHandler = DoFHandlerType>
92 using SolutionTransfer = dealii::SolutionTransfer<dim, Vector, DoFHandler>;
95 static void reinit_vector(
97 DoFHandlerType
const &,
98 dealii::IndexSet
const &locally_owned_dofs,
99 dealii::IndexSet
const &ghost_dofs,
100 MPI_Comm
const mpi_communicator)
102 vector.reinit(locally_owned_dofs, ghost_dofs, mpi_communicator);
117 #if PHILIP_DIM==1 // dealii::parallel::distributed::Triangulation<dim> does not work for 1D 118 template <
int dim = PHILIP_DIM,
119 typename real = double,
120 typename MeshType = dealii::Triangulation<dim>,
124 template <
int dim = PHILIP_DIM,
125 typename real = double,
126 typename MeshType = dealii::parallel::distributed::Triangulation<dim>,
136 const unsigned int max_degree,
137 const std::shared_ptr<MeshType> triangulation_input,
138 const bool check_valid_metric_Jacobian_input=
true,
139 const bool renumber_dof_handler_Cuthill_Mckee_input=
true,
140 const bool output_high_order_grid=
true);
149 void update_mapping_fe_field();
152 void ensure_conforming_mesh();
155 void initialize_with_triangulation_manifold(
const bool output_mesh =
true);
161 dealii::MappingFEField<dim,dim,VectorType,DoFHandlerType> get_MappingFEField();
201 void reset_initial_nodes();
216 void update_map_nodes_surf_to_vol();
305 void update_surface_nodes();
309 VectorType transform_surface_nodes(std::function<dealii::Point<dim>(dealii::Point<dim>)> transformation)
const;
313 void deform_mesh(std::vector<real> local_surface_displacements);
315 void test_jacobian();
318 std::vector<real> evaluate_jacobian_at_points(
319 const VectorType &solution,
320 const typename DoFHandlerType::cell_iterator &cell,
321 const std::vector<dealii::Point<dim>> &points)
const;
327 template <
typename real2>
328 void evaluate_jacobian_at_points(
329 const std::vector<real2> &dofs,
330 const dealii::FESystem<dim> &fe,
331 const std::vector<dealii::Point<dim>> &points,
332 std::vector<real2> &jacobian_determinants)
const;
336 template <
typename real2>
337 real2 evaluate_jacobian_at_point(
338 const std::vector<real2> &dofs,
339 const dealii::FESystem<dim> &fe,
340 const dealii::Point<dim> &point)
const;
343 bool check_valid_cell(
const typename DoFHandlerType::cell_iterator &cell)
const;
346 bool fix_invalid_cell(
const typename DoFHandlerType::cell_iterator &cell);
354 void evaluate_lagrange_to_bernstein_operator(
const unsigned int order);
356 void output_results_vtk (
const unsigned int cycle)
const;
368 void refine_global();
374 void prepare_for_coarsening_and_refinement();
379 void execute_coarsening_and_refinement(
const bool output_mesh =
false);
408 std::shared_ptr<dealii::MappingFEField<dim,dim,VectorType,DoFHandlerType>>
mapping_fe_field;
426 void update_surface_indices();
443 template <
typename real2>
444 real2 determinant(
const std::array< dealii::Tensor<1,dim,real2>, dim > jacobian)
const;
447 void get_position_vector(
const DoFHandlerType &dh, VectorType &vector,
const dealii::ComponentMask &mask);
451 void get_projected_position_vector(
const DoFHandlerType &dh, VectorType &vector,
const dealii::ComponentMask &mask);
464 virtual void evaluate_vector_field (
const dealii::DataPostprocessorInputs::Vector<dim> &inputs, std::vector<dealii::Vector<double>> &computed_quantities)
const override;
466 virtual std::vector<std::string> get_names ()
const override;
468 virtual std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation> get_data_component_interpretation ()
const override;
470 virtual dealii::UpdateFlags get_needed_update_flags ()
const override;
VectorType initial_volume_nodes
Initial nodal coefficients of the high-order grid.
std::vector< dealii::types::global_dof_index > locally_relevant_surface_nodes_indices
List of surface node indices.
std::vector< real > locally_relevant_surface_nodes
List of surface nodes.
std::shared_ptr< dealii::MappingFEField< dim, dim, VectorType, DoFHandlerType > > mapping_fe_field
MappingFEField that will provide the polynomial-based grid.
const dealii::QGaussLobatto< dim > dim_grid_nodes
Dim-Dimensional grid nodes in reference space.
std::vector< dealii::Point< dim > > initial_locally_relevant_surface_points
Initial locally relevant surface points.
dealii::IndexSet ghost_dofs_grid
Locally relevant ghost degrees of freedom for the grid.
const bool renumber_dof_handler_Cuthill_Mckee
Flag to renumber dof_handler_grid with Cuthill Mckee.
SolutionTransfer solution_transfer
MPI_Comm mpi_communicator
MPI communicator.
dealii::IndexSet ghost_surface_nodes_indexset
Files for the baseline physics.
const dealii::FE_Q< dim > fe_q
Use Lagrange polynomial to represent the spatial location.
VectorType initial_surface_nodes
Distributed ghosted vector of initial surface nodes.
dealii::ConditionalOStream pcout
Parallel std::cout that only outputs on mpi_rank==0.
dealii::TrilinosWrappers::SparseMatrix map_nodes_surf_to_vol
const std::shared_ptr< MeshType > triangulation
Mesh.
std::vector< real > all_surface_nodes
List of all surface nodes.
const bool check_valid_metric_Jacobian
Flag to check validity of Jacobian.
VectorType old_volume_nodes
Used for the SolutionTransfer when performing grid adaptation.
const dealii::FE_DGQ< 1 > oneD_fe_q
Use oneD Lagrange polynomial to represent the spatial location.
dealii::FullMatrix< double > lagrange_to_bernstein_operator
Used to transform coefficients from a Lagrange basis to a Bernstein basis.
std::vector< dealii::types::global_dof_index > locally_owned_surface_nodes_indices
List of surface node indices.
std::map< dealii::types::global_dof_index, std::pair< unsigned int, unsigned int > > global_index_to_point_and_axis
const dealii::QGaussLobatto< 1 > oneD_grid_nodes
One Dimensional grid nodes in reference space.
std::vector< dealii::types::global_dof_index > all_surface_indices
dealii::LinearAlgebra::distributed::Vector< int > surface_to_volume_indices
dealii::IndexSet locally_relevant_dofs_grid
Union of locally owned degrees of freedom and relevant ghost degrees of freedom for the grid...
const unsigned int max_degree
Maximum degree of the geometry polynomial representing the grid.
Postprocessor used to output the grid.
static unsigned int nth_refinement
Used to name the various files outputted.
int n_mpi
Number of MPI processes.
std::vector< unsigned int > n_locally_owned_surface_nodes_per_mpi
std::vector< dealii::Point< dim > > locally_relevant_surface_points
Locally relevant surface points.
std::shared_ptr< dealii::MappingFEField< dim, dim, VectorType, DoFHandlerType > > initial_mapping_fe_field
MappingFEField that will provide the polynomial-based grid for the initial volume_nodes.
std::vector< dealii::types::global_dof_index > locally_relevant_surface_nodes_boundary_id
List of surface node boundary IDs, corresponding to locally_relevant_surface_nodes_indices.
dealii::DoFHandler< dim > dof_handler_grid
Degrees of freedom handler for the high-order grid.
const dealii::FESystem< 1 > oneD_fe_system
One-dimensional fe system for each direction.
std::vector< real > locally_owned_surface_nodes
List of surface nodes.
dealii::IndexSet locally_owned_dofs_grid
Locally own degrees of freedom for the grid.
VectorType volume_nodes
Current nodal coefficients of the high-order grid.
std::map< std::pair< unsigned int, unsigned int >, dealii::types::global_dof_index > point_and_axis_to_global_index
dealii::IndexSet locally_owned_surface_nodes_indexset
const dealii::FESystem< dim > fe_system
Using system of polynomials to represent the x, y, and z directions.