3 #include <deal.II/base/parameter_handler.h> 4 #include <deal.II/base/tensor.h> 6 #include <deal.II/base/qprojector.h> 8 #include <deal.II/grid/tria.h> 9 #include <deal.II/distributed/shared_tria.h> 10 #include <deal.II/distributed/tria.h> 12 #include <deal.II/grid/grid_generator.h> 13 #include <deal.II/grid/grid_refinement.h> 15 #include <deal.II/dofs/dof_handler.h> 16 #include <deal.II/dofs/dof_tools.h> 17 #include <deal.II/dofs/dof_renumbering.h> 19 #include <deal.II/dofs/dof_accessor.h> 21 #include <deal.II/lac/vector.h> 22 #include <deal.II/lac/dynamic_sparsity_pattern.h> 23 #include <deal.II/lac/sparse_matrix.h> 25 #include <deal.II/fe/fe_dgq.h> 28 #include <deal.II/fe/mapping_q.h> 29 #include <deal.II/fe/mapping_q_generic.h> 30 #include <deal.II/fe/mapping_manifold.h> 31 #include <deal.II/fe/mapping_fe_field.h> 35 #include <EpetraExt_Transpose_RowMatrix.h> 36 #include <deal.II/distributed/grid_refinement.h> 37 #include <deal.II/dofs/dof_renumbering.h> 38 #include <deal.II/grid/grid_refinement.h> 39 #include <deal.II/numerics/data_out.h> 40 #include <deal.II/numerics/data_out_dof_data.h> 41 #include <deal.II/numerics/data_out_faces.h> 42 #include <deal.II/numerics/derivative_approximation.h> 43 #include <deal.II/numerics/vector_tools.h> 44 #include <deal.II/numerics/vector_tools.templates.h> 46 #include "dg_base.hpp" 47 #include "global_counter.hpp" 48 #include "post_processor/physics_post_processor.h" 51 unsigned int dRdW_form;
52 unsigned int dRdW_mult;
53 unsigned int dRdX_mult;
54 unsigned int d2R_mult;
59 template <
int dim,
typename real,
typename MeshType>
61 const int nstate_input,
63 const unsigned int degree,
64 const unsigned int max_degree_input,
65 const unsigned int grid_degree_input,
66 const std::shared_ptr<Triangulation> triangulation_input)
67 :
DGBase<dim,real,MeshType>(nstate_input, parameters_input, degree, max_degree_input, grid_degree_input, triangulation_input, this->create_collection_tuple(max_degree_input, nstate_input, parameters_input))
70 template <
int dim,
typename real,
typename MeshType>
72 const int nstate_input,
74 const unsigned int degree,
75 const unsigned int max_degree_input,
76 const unsigned int grid_degree_input,
77 const std::shared_ptr<Triangulation> triangulation_input,
111 template <
int dim,
typename real,
typename MeshType>
120 template <
int dim,
typename real,
typename MeshType>
131 template <
int dim,
typename real,
typename MeshType>
134 dealii::hp::FECollection<dim>,
135 dealii::hp::QCollection<dim>,
136 dealii::hp::QCollection<dim-1>,
137 dealii::hp::FECollection<dim>,
138 dealii::hp::FECollection<1>,
139 dealii::hp::FECollection<1>,
140 dealii::hp::FECollection<1>,
141 dealii::hp::QCollection<1> >
147 dealii::hp::FECollection<dim> fe_coll;
148 dealii::hp::FECollection<1> fe_coll_1D;
149 dealii::hp::FECollection<1> fe_coll_1D_1state;
150 dealii::hp::QCollection<dim> volume_quad_coll;
151 dealii::hp::QCollection<dim-1> face_quad_coll;
152 dealii::hp::QCollection<1> oneD_quad_coll;
154 dealii::hp::FECollection<dim> fe_coll_lagr;
155 dealii::hp::FECollection<1> fe_coll_lagr_1D;
157 const unsigned int overintegration = parameters_input->
overintegration;
162 if (flux_nodes_type==FluxNodes::GLL)
165 const unsigned int integration_strength = degree+1+overintegration;
167 const dealii::FE_DGQ<dim> fe_dg(degree);
168 const dealii::FESystem<dim,dim> fe_system(fe_dg, nstate);
169 fe_coll.push_back (fe_system);
171 const dealii::FE_DGQ<1> fe_dg_1D(degree);
172 const dealii::FESystem<1,1> fe_system_1D(fe_dg_1D, nstate);
173 fe_coll_1D.push_back (fe_system_1D);
174 const dealii::FESystem<1,1> fe_system_1D_1state(fe_dg_1D, 1);
175 fe_coll_1D_1state.push_back (fe_system_1D_1state);
177 dealii::Quadrature<1> oneD_quad(integration_strength);
178 dealii::Quadrature<dim> volume_quad(integration_strength);
179 dealii::Quadrature<dim-1> face_quad(integration_strength);
181 dealii::QGaussLobatto<1> oneD_quad_Gauss_Lobatto (integration_strength);
182 dealii::QGaussLobatto<dim> vol_quad_Gauss_Lobatto (integration_strength);
183 oneD_quad = oneD_quad_Gauss_Lobatto;
184 volume_quad = vol_quad_Gauss_Lobatto;
187 dealii::QGauss<dim-1> face_quad_Gauss_Legendre (integration_strength);
188 face_quad = face_quad_Gauss_Legendre;
190 dealii::QGaussLobatto<dim-1> face_quad_Gauss_Lobatto (integration_strength);
191 face_quad = face_quad_Gauss_Lobatto;
194 volume_quad_coll.push_back (volume_quad);
195 face_quad_coll.push_back (face_quad);
196 oneD_quad_coll.push_back (oneD_quad);
198 dealii::FE_DGQArbitraryNodes<dim,dim> lagrange_poly(oneD_quad);
199 fe_coll_lagr.push_back (lagrange_poly);
201 dealii::FE_DGQArbitraryNodes<1,1> lagrange_poly_1D(oneD_quad);
202 fe_coll_lagr_1D.push_back (lagrange_poly_1D);
205 int minimum_degree = (flux_nodes_type==FluxNodes::GLL) ? 1 : 0;
206 for (
unsigned int degree=minimum_degree; degree<=
max_degree; ++degree) {
209 const dealii::FE_DGQ<dim> fe_dg(degree);
210 const dealii::FESystem<dim,dim> fe_system(fe_dg, nstate);
211 fe_coll.push_back (fe_system);
213 const dealii::FE_DGQ<1> fe_dg_1D(degree);
214 const dealii::FESystem<1,1> fe_system_1D(fe_dg_1D, nstate);
215 fe_coll_1D.push_back (fe_system_1D);
216 const dealii::FESystem<1,1> fe_system_1D_1state(fe_dg_1D, 1);
217 fe_coll_1D_1state.push_back (fe_system_1D_1state);
219 const unsigned int integration_strength = degree+1+overintegration;
221 dealii::Quadrature<1> oneD_quad(integration_strength);
222 dealii::Quadrature<dim> volume_quad(integration_strength);
223 dealii::Quadrature<dim-1> face_quad(integration_strength);
225 if (flux_nodes_type==FluxNodes::GLL) {
226 dealii::QGaussLobatto<1> oneD_quad_Gauss_Lobatto (integration_strength);
227 dealii::QGaussLobatto<dim> vol_quad_Gauss_Lobatto (integration_strength);
228 oneD_quad = oneD_quad_Gauss_Lobatto;
229 volume_quad = vol_quad_Gauss_Lobatto;
233 dealii::QGauss<dim-1> face_quad_Gauss_Legendre (integration_strength);
234 face_quad = face_quad_Gauss_Legendre;
238 dealii::QGaussLobatto<dim-1> face_quad_Gauss_Lobatto (integration_strength);
239 face_quad = face_quad_Gauss_Lobatto;
241 }
else if(flux_nodes_type==FluxNodes::GL) {
242 dealii::QGauss<1> oneD_quad_Gauss_Legendre (integration_strength);
243 dealii::QGauss<dim> vol_quad_Gauss_Legendre (integration_strength);
244 dealii::QGauss<dim-1> face_quad_Gauss_Legendre (integration_strength);
245 oneD_quad = oneD_quad_Gauss_Legendre;
246 volume_quad = vol_quad_Gauss_Legendre;
247 face_quad = face_quad_Gauss_Legendre;
250 volume_quad_coll.push_back (volume_quad);
251 face_quad_coll.push_back (face_quad);
252 oneD_quad_coll.push_back (oneD_quad);
254 dealii::FE_DGQArbitraryNodes<dim,dim> lagrange_poly(oneD_quad);
255 fe_coll_lagr.push_back (lagrange_poly);
257 dealii::FE_DGQArbitraryNodes<1,1> lagrange_poly_1d(oneD_quad);
258 fe_coll_lagr_1D.push_back (lagrange_poly_1d);
260 return std::make_tuple(fe_coll, volume_quad_coll, face_quad_coll, fe_coll_lagr, fe_coll_1D, fe_coll_1D_1state, fe_coll_lagr_1D, oneD_quad_coll);
264 template <
int dim,
typename real,
typename MeshType>
267 std::vector<dealii::types::global_dof_index> dofs_indices;
271 if (!cell->is_locally_owned())
continue;
274 const int i_fele = cell->active_fe_index();
275 const dealii::FESystem<dim,dim> &fe_ref =
fe_collection[i_fele];
276 const unsigned int n_dofs_cell = fe_ref.n_dofs_per_cell();
278 dofs_indices.resize(n_dofs_cell);
279 cell->get_dof_indices (dofs_indices);
281 const dealii::types::global_dof_index cell_index = cell->active_cell_index();
284 for (
unsigned int idof = 0; idof < n_dofs_cell; ++idof) {
285 const dealii::types::global_dof_index dof_index = dofs_indices[idof];
286 solution_update[dof_index] *= dt;
292 template <
int dim,
typename real,
typename MeshType>
298 if (cell->is_locally_owned()) cell->set_future_fe_index (degree);
304 template <
int dim,
typename real,
typename MeshType>
307 unsigned int max_fe_degree = 0;
310 if(cell->is_locally_owned() && cell->active_fe_index() > max_fe_degree)
311 max_fe_degree = cell->active_fe_index();
313 return dealii::Utilities::MPI::max(max_fe_degree, MPI_COMM_WORLD);
316 template <
int dim,
typename real,
typename MeshType>
322 if(cell->is_locally_owned() && cell->active_fe_index() < min_fe_degree)
323 min_fe_degree = cell->active_fe_index();
325 return dealii::Utilities::MPI::min(min_fe_degree, MPI_COMM_WORLD);
328 template <
int dim,
typename real,
typename MeshType>
331 const int iproc = dealii::Utilities::MPI::this_mpi_process(
mpi_communicator);
332 const dealii::Point<dim> unit_vertex = dealii::GeometryInfo<dim>::unit_cell_vertex(0);
333 double current_cell_diameter;
334 double min_diameter_local =
high_order_grid->dof_handler_grid.begin_active()->diameter();
335 int max_cell_polynomial_order = 0;
336 int current_cell_polynomial_order = 0;
337 dealii::Point<dim> refined_cell_coord;
339 if(check_for_p_refined_cell)
341 for (
const auto &cell :
dof_handler.active_cell_iterators())
343 if(!cell->is_locally_owned())
continue;
344 current_cell_polynomial_order = cell->active_fe_index();
345 if ((current_cell_polynomial_order > max_cell_polynomial_order) && (cell->is_locally_owned()))
347 max_cell_polynomial_order = current_cell_polynomial_order;
348 refined_cell_coord = cell->center();
354 for (
const auto &cell :
high_order_grid->dof_handler_grid.active_cell_iterators())
356 if(!cell->is_locally_owned())
continue;
357 current_cell_diameter = cell->diameter();
358 if ((min_diameter_local > current_cell_diameter) && (cell->is_locally_owned()))
360 min_diameter_local = current_cell_diameter;
361 refined_cell_coord =
high_order_grid->mapping_fe_field->transform_unit_to_real_cell(cell, unit_vertex);
366 dealii::Utilities::MPI::MinMaxAvg indexstore;
367 int processor_containing_refined_cell;
369 if(check_for_p_refined_cell)
371 indexstore = dealii::Utilities::MPI::min_max_avg(max_cell_polynomial_order,
mpi_communicator);
372 processor_containing_refined_cell = indexstore.max_index;
376 indexstore = dealii::Utilities::MPI::min_max_avg(min_diameter_local,
mpi_communicator);
377 processor_containing_refined_cell = indexstore.min_index;
380 double global_point[dim];
382 if (iproc == processor_containing_refined_cell)
384 for (
int i=0; i<dim; i++)
385 global_point[i] = refined_cell_coord[i];
388 MPI_Bcast(global_point, dim, MPI_DOUBLE, processor_containing_refined_cell,
mpi_communicator);
390 for (
int i=0; i<dim; i++)
391 refined_cell_coord[i] = global_point[i];
393 return refined_cell_coord;
396 template <
int dim,
typename real,
typename MeshType>
397 template<
typename DoFCellAccessorType>
399 const DoFCellAccessorType &cell,
404 const unsigned int fe_index = cell->active_fe_index();
405 const unsigned int degree = fe_collection[fe_index].tensor_degree();
406 const unsigned int degsq = (degree == 0) ? 1 : degree * (degree+1);
408 const unsigned int normal_direction = dealii::GeometryInfo<dim>::unit_normal_direction[iface];
409 const real vol_div_facearea = cell->extent_in_direction(normal_direction);
416 template <
int dim,
typename real,
typename MeshType>
417 template<
typename DoFCellAccessorType1,
typename DoFCellAccessorType2>
419 const DoFCellAccessorType1 ¤t_cell,
420 const DoFCellAccessorType2 &neighbor_cell)
const 422 if (neighbor_cell->has_children()) {
425 AssertDimension(dim,1);
427 }
else if (neighbor_cell->is_ghost()) {
431 return (current_cell->subdomain_id() < neighbor_cell->subdomain_id());
435 Assert(neighbor_cell->is_locally_owned(), dealii::ExcMessage(
"If not ghost, neighbor should be locally owned."));
437 if (current_cell->index() < neighbor_cell->index()) {
440 }
else if (neighbor_cell->index() == current_cell->index()) {
444 return (current_cell->level() < neighbor_cell->level());
448 Assert(0==1, dealii::ExcMessage(
"Should not have reached here. Somehow another possible case has not been considered when two cells have the same coarseness."));
452 template <
int dim,
typename real,
typename MeshType>
453 template<
typename DoFCellAccessorType1,
typename DoFCellAccessorType2>
455 const DoFCellAccessorType1 ¤t_cell,
456 const DoFCellAccessorType2 ¤t_metric_cell,
457 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
458 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume,
459 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_int,
460 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_ext,
461 dealii::hp::FESubfaceValues<dim,dim> &fe_values_collection_subface,
462 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume_lagrange,
471 const bool compute_auxiliary_right_hand_side,
472 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
473 std::array<dealii::LinearAlgebra::distributed::Vector<double>,dim> &rhs_aux)
475 std::vector<dealii::types::global_dof_index> current_dofs_indices;
476 std::vector<dealii::types::global_dof_index> neighbor_dofs_indices;
479 const int i_fele = current_cell->active_fe_index();
481 const dealii::FESystem<dim,dim> ¤t_fe_ref =
fe_collection[i_fele];
482 const unsigned int n_dofs_curr_cell = current_fe_ref.n_dofs_per_cell();
485 dealii::Vector<real> current_cell_rhs (n_dofs_curr_cell);
487 std::vector<dealii::Tensor<1,dim,double>> current_cell_rhs_aux (n_dofs_curr_cell);
490 current_dofs_indices.resize(n_dofs_curr_cell);
491 current_cell->get_dof_indices (current_dofs_indices);
493 const unsigned int grid_degree = this->
high_order_grid->fe_system.tensor_degree();
494 const unsigned int poly_degree = i_fele;
496 const unsigned int n_metric_dofs_cell =
high_order_grid->fe_system.dofs_per_cell;
497 std::vector<dealii::types::global_dof_index> current_metric_dofs_indices(n_metric_dofs_cell);
498 std::vector<dealii::types::global_dof_index> neighbor_metric_dofs_indices(n_metric_dofs_cell);
499 current_metric_cell->get_dof_indices (current_metric_dofs_indices);
501 const dealii::types::global_dof_index current_cell_index = current_cell->active_cell_index();
503 std::array<std::vector<real>,dim> mapping_support_points;
510 store_vol_flux_nodes,
511 store_surf_flux_nodes);
515 && (this->all_parameters->ode_solver_param.ode_solver_type
516 == Parameters::ODESolverParam::ODESolverEnum::implicit_solver))
518 pcout<<
"ERROR: Implicit does not currently work for strong form. Aborting..."<<std::endl;
526 current_dofs_indices,
527 current_metric_dofs_indices,
532 flux_basis_stiffness,
533 soln_basis_projection_oper_int,
534 soln_basis_projection_oper_ext,
537 mapping_support_points,
538 fe_values_collection_volume,
539 fe_values_collection_volume_lagrange,
542 current_cell_rhs_aux,
543 compute_auxiliary_right_hand_side,
544 compute_dRdW, compute_dRdX, compute_d2R);
546 (void) fe_values_collection_face_int;
547 (void) fe_values_collection_face_ext;
548 (void) fe_values_collection_subface;
549 for (
unsigned int iface=0; iface < dealii::GeometryInfo<dim>::faces_per_cell; ++iface) {
551 auto current_face = current_cell->face(iface);
554 if ((current_face->at_boundary() && !current_cell->has_periodic_neighbor(iface)))
558 const unsigned int boundary_id = current_face->boundary_id();
566 current_dofs_indices,
567 current_metric_dofs_indices,
572 flux_basis_stiffness,
573 soln_basis_projection_oper_int,
574 soln_basis_projection_oper_ext,
577 mapping_support_points,
578 fe_values_collection_face_int,
581 current_cell_rhs_aux,
582 compute_auxiliary_right_hand_side,
583 compute_dRdW, compute_dRdX, compute_d2R);
588 else if (current_face->at_boundary() && current_cell->has_periodic_neighbor(iface))
591 const auto neighbor_cell = current_cell->periodic_neighbor(iface);
595 Assert (current_cell->periodic_neighbor(iface).state() == dealii::IteratorState::valid, dealii::ExcInternalError());
597 const unsigned int n_dofs_neigh_cell =
fe_collection[neighbor_cell->active_fe_index()].n_dofs_per_cell();
598 dealii::Vector<real> neighbor_cell_rhs (n_dofs_neigh_cell);
601 neighbor_dofs_indices.resize(n_dofs_neigh_cell);
602 neighbor_cell->get_dof_indices (neighbor_dofs_indices);
605 const unsigned int neighbor_iface = current_cell->periodic_neighbor_of_periodic_neighbor(iface);
607 const int i_fele_n = neighbor_cell->active_fe_index();
612 const real penalty = 0.5 * (penalty1 + penalty2);
614 const dealii::types::global_dof_index neighbor_cell_index = neighbor_cell->active_cell_index();
615 const auto metric_neighbor_cell = current_metric_cell->periodic_neighbor(iface);
616 metric_neighbor_cell->get_dof_indices(neighbor_metric_dofs_indices);
618 const unsigned int poly_degree_ext = i_fele_n;
619 const unsigned int grid_degree_ext = this->
high_order_grid->fe_system.tensor_degree();
622 store_vol_flux_nodes,
623 store_surf_flux_nodes);
633 current_dofs_indices,
634 neighbor_dofs_indices,
635 current_metric_dofs_indices,
636 neighbor_metric_dofs_indices,
645 flux_basis_stiffness,
646 soln_basis_projection_oper_int,
647 soln_basis_projection_oper_ext,
651 mapping_support_points,
652 fe_values_collection_face_int,
653 fe_values_collection_face_ext,
656 current_cell_rhs_aux,
659 compute_auxiliary_right_hand_side,
660 compute_dRdW, compute_dRdX, compute_d2R);
665 else if (current_cell->face(iface)->has_children())
672 else if (current_cell->neighbor(iface)->face(current_cell->neighbor_face_no(iface))->has_children())
674 Assert (current_cell->neighbor(iface).state() == dealii::IteratorState::valid, dealii::ExcInternalError());
675 Assert (!(current_cell->neighbor(iface)->has_children()), dealii::ExcInternalError());
678 const auto neighbor_cell = current_cell->neighbor(iface);
679 const unsigned int neighbor_iface = current_cell->neighbor_face_no(iface);
682 unsigned int neighbor_i_subface = 0;
683 unsigned int n_subface = dealii::GeometryInfo<dim>::n_subfaces(neighbor_cell->subface_case(neighbor_iface));
685 for (; neighbor_i_subface < n_subface; ++neighbor_i_subface) {
686 if (neighbor_cell->neighbor_child_on_subface (neighbor_iface, neighbor_i_subface) == current_cell) {
690 Assert(neighbor_i_subface != n_subface, dealii::ExcInternalError());
692 const int i_fele_n = neighbor_cell->active_fe_index();
694 const unsigned int n_dofs_neigh_cell =
fe_collection[i_fele_n].n_dofs_per_cell();
695 dealii::Vector<real> neighbor_cell_rhs (n_dofs_neigh_cell);
698 neighbor_dofs_indices.resize(n_dofs_neigh_cell);
699 neighbor_cell->get_dof_indices (neighbor_dofs_indices);
703 const real penalty = 0.5 * (penalty1 + penalty2);
705 const dealii::types::global_dof_index neighbor_cell_index = neighbor_cell->active_cell_index();
706 const auto metric_neighbor_cell = current_metric_cell->neighbor(iface);
707 metric_neighbor_cell->get_dof_indices(neighbor_metric_dofs_indices);
709 const unsigned int poly_degree_ext = i_fele_n;
710 const unsigned int grid_degree_ext = this->
high_order_grid->fe_system.tensor_degree();
713 store_vol_flux_nodes,
714 store_surf_flux_nodes);
725 current_dofs_indices,
726 neighbor_dofs_indices,
727 current_metric_dofs_indices,
728 neighbor_metric_dofs_indices,
737 flux_basis_stiffness,
738 soln_basis_projection_oper_int,
739 soln_basis_projection_oper_ext,
743 mapping_support_points,
744 fe_values_collection_face_int,
745 fe_values_collection_subface,
748 current_cell_rhs_aux,
751 compute_auxiliary_right_hand_side,
752 compute_dRdW, compute_dRdX, compute_d2R);
758 Assert (current_cell->neighbor(iface).state() == dealii::IteratorState::valid, dealii::ExcInternalError());
760 const auto neighbor_cell = current_cell->neighbor_or_periodic_neighbor(iface);
763 const unsigned int neighbor_iface = current_cell->neighbor_of_neighbor(iface);
766 const unsigned int n_dofs_neigh_cell =
fe_collection[neighbor_cell->active_fe_index()].n_dofs_per_cell();
769 dealii::Vector<real> neighbor_cell_rhs (n_dofs_neigh_cell);
772 neighbor_dofs_indices.resize(n_dofs_neigh_cell);
773 neighbor_cell->get_dof_indices (neighbor_dofs_indices);
775 const int i_fele_n = neighbor_cell->active_fe_index();
780 const real penalty = 0.5 * (penalty1 + penalty2);
782 const dealii::types::global_dof_index neighbor_cell_index = neighbor_cell->active_cell_index();
783 const auto metric_neighbor_cell = current_metric_cell->neighbor_or_periodic_neighbor(iface);
784 metric_neighbor_cell->get_dof_indices(neighbor_metric_dofs_indices);
786 const unsigned int poly_degree_ext = i_fele_n;
789 const unsigned int grid_degree_ext = this->
high_order_grid->fe_system.tensor_degree();
792 store_vol_flux_nodes,
793 store_surf_flux_nodes);
803 current_dofs_indices,
804 neighbor_dofs_indices,
805 current_metric_dofs_indices,
806 neighbor_metric_dofs_indices,
815 flux_basis_stiffness,
816 soln_basis_projection_oper_int,
817 soln_basis_projection_oper_ext,
821 mapping_support_points,
822 fe_values_collection_face_int,
823 fe_values_collection_face_ext,
826 current_cell_rhs_aux,
829 compute_auxiliary_right_hand_side,
830 compute_dRdW, compute_dRdX, compute_d2R);
838 if(compute_auxiliary_right_hand_side) {
840 for (
unsigned int i=0; i<n_dofs_curr_cell; ++i) {
841 for(
int idim=0; idim<dim; idim++){
842 rhs_aux[idim][current_dofs_indices[i]] += current_cell_rhs_aux[i][idim];
848 for (
unsigned int i=0; i<n_dofs_curr_cell; ++i) {
849 rhs[current_dofs_indices[i]] += current_cell_rhs[i];
854 template <
int dim,
typename real,
typename MeshType>
860 template <
int dim,
typename real,
typename MeshType>
864 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
865 const dealii::UpdateFlags update_flags = dealii::update_values | dealii::update_JxW_values;
868 std::vector< double > soln_coeff_high;
869 std::vector<dealii::types::global_dof_index> dof_indices;
872 std::vector<dealii::types::global_dof_index> dof_indices_artificial_dissipation(n_dofs_arti_diss);
876 for (
auto cell :
dof_handler.active_cell_iterators()) {
877 if (!(cell->is_locally_owned() || cell->is_ghost()))
continue;
879 dealii::types::global_dof_index cell_index = cell->active_cell_index();
886 const int i_fele = cell->active_fe_index();
887 const int i_quad = i_fele;
888 const int i_mapp = 0;
890 const dealii::FESystem<dim,dim> &fe_high =
fe_collection[i_fele];
891 const unsigned int degree = fe_high.tensor_degree();
893 if (degree == 0)
continue;
895 const unsigned int nstate = fe_high.components;
896 const unsigned int n_dofs_high = fe_high.dofs_per_cell;
898 fe_values_collection_volume.reinit (cell, i_quad, i_mapp, i_fele);
899 const dealii::FEValues<dim,dim> &fe_values_volume = fe_values_collection_volume.get_present_fe_values();
901 dof_indices.resize(n_dofs_high);
902 cell->get_dof_indices (dof_indices);
904 soln_coeff_high.resize(n_dofs_high);
905 for (
unsigned int idof=0; idof<n_dofs_high; ++idof) {
906 soln_coeff_high[idof] =
solution[dof_indices[idof]];
910 const unsigned int lower_degree = degree-1;
911 const dealii::FE_DGQLegendre<dim> fe_dgq_lower(lower_degree);
912 const dealii::FESystem<dim,dim> fe_lower(fe_dgq_lower, nstate);
915 const dealii::QGauss<dim> projection_quadrature(degree+5);
916 std::vector< double > soln_coeff_lower = project_function<dim,double>( soln_coeff_high, fe_high, fe_lower, projection_quadrature);
919 const dealii::Quadrature<dim> &quadrature = fe_values_volume.get_quadrature();
920 const std::vector<dealii::Point<dim,double>> &unit_quad_pts = quadrature.get_points();
922 const unsigned int n_quad_pts = quadrature.size();
923 const unsigned int n_dofs_lower = fe_lower.dofs_per_cell;
925 double element_volume = 0.0;
927 double soln_norm = 0.0;
928 std::vector<double> soln_high(nstate);
929 std::vector<double> soln_lower(nstate);
930 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
931 for (
unsigned int s=0; s<
nstate; ++s) {
936 for (
unsigned int idof=0; idof<n_dofs_high; ++idof) {
937 const unsigned int istate = fe_high.system_to_component_index(idof).first;
938 soln_high[istate] += soln_coeff_high[idof] * fe_high.shape_value_component(idof,unit_quad_pts[iquad],istate);
941 for (
unsigned int idof=0; idof<n_dofs_lower; ++idof) {
942 const unsigned int istate = fe_lower.system_to_component_index(idof).first;
943 soln_lower[istate] += soln_coeff_lower[idof] * fe_lower.shape_value_component(idof,unit_quad_pts[iquad],istate);
946 element_volume += fe_values_volume.JxW(iquad);
948 for (
unsigned int s=0; s<1; ++s)
950 error += (soln_high[s] - soln_lower[s]) * (soln_high[s] - soln_lower[s]) * fe_values_volume.JxW(iquad);
951 soln_norm += soln_high[s] * soln_high[s] * fe_values_volume.JxW(iquad);
958 if (soln_norm < 1e-12)
964 S_e = sqrt(error / soln_norm);
974 const double s_0 = -0.00 - 4.00*log10(degree);
976 const double low = s_0 - kappa;
977 const double upp = s_0 + kappa;
979 const double diameter = std::pow(element_volume, 1.0/dim);
980 const double eps_0 = mu_scale * diameter / (double)degree;
984 if ( s_e < low)
continue;
995 const double PI = 4*atan(1);
996 double eps = 1.0 + sin(PI * (s_e - s_0) * 0.5 / kappa);
1008 typename dealii::DoFHandler<dim>::active_cell_iterator artificial_dissipation_cell(
1011 dof_indices_artificial_dissipation.resize(n_dofs_arti_diss);
1012 artificial_dissipation_cell->get_dof_indices (dof_indices_artificial_dissipation);
1013 for (
unsigned int idof=0; idof<n_dofs_arti_diss; ++idof) {
1014 const unsigned int index = dof_indices_artificial_dissipation[idof];
1032 dealii::ComponentMask(),
1035 if (boundary_dofs.is_element(i)) {
1044 template <
int dim,
typename real,
typename MeshType>
1046 const unsigned int poly_degree_int,
1047 const unsigned int poly_degree_ext,
1048 const unsigned int ,
1090 template <
int dim,
typename real,
typename MeshType>
1093 dealii::deal_II_exceptions::disable_abort_on_exception();
1094 Assert( !(compute_dRdW && compute_dRdX)
1095 && !(compute_dRdW && compute_d2R)
1096 && !(compute_dRdX && compute_d2R)
1097 , dealii::ExcMessage(
"Can only do one at a time compute_dRdW or compute_dRdX or compute_d2R"));
1102 pcout <<
" with dRdW...";
1106 const double l2_norm_sol = diff_sol.l2_norm();
1108 if (l2_norm_sol == 0.0) {
1112 const double l2_norm_node = diff_node.l2_norm();
1114 if (l2_norm_node == 0.0) {
1116 pcout <<
" which is already assembled..." << std::endl;
1122 int n_stencil = 1 + std::pow(2,dim);
1124 n_vmult += n_stencil*n_dofs_cell;
1134 pcout <<
" with dRdX...";
1138 const double l2_norm_sol = diff_sol.l2_norm();
1140 if (l2_norm_sol == 0.0) {
1144 const double l2_norm_node = diff_node.l2_norm();
1146 if (l2_norm_node == 0.0) {
1147 pcout <<
" which is already assembled..." << std::endl;
1161 pcout <<
" with d2RdWdW, d2RdWdX, d2RdXdX...";
1164 const double l2_norm_sol = diff_sol.l2_norm();
1166 if (l2_norm_sol == 0.0) {
1170 const double l2_norm_node = diff_node.l2_norm();
1172 if (l2_norm_node == 0.0) {
1174 auto diff_dual =
dual;
1176 const double l2_norm_dual = diff_dual.l2_norm();
1177 if (l2_norm_dual == 0.0) {
1178 pcout <<
" which is already assembled..." << std::endl;
1207 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
1216 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
1228 soln_basis_int, soln_basis_ext,
1229 flux_basis_int, flux_basis_ext,
1230 flux_basis_stiffness,
1231 soln_basis_projection_oper_int, soln_basis_projection_oper_ext,
1237 int assembly_error = 0;
1249 dealii::Timer timer;
1255 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell) {
1256 if (!soln_cell->is_locally_owned())
continue;
1262 compute_dRdW, compute_dRdX, compute_d2R,
1263 fe_values_collection_volume,
1264 fe_values_collection_face_int,
1265 fe_values_collection_face_ext,
1266 fe_values_collection_subface,
1267 fe_values_collection_volume_lagrange,
1272 flux_basis_stiffness,
1273 soln_basis_projection_oper_int,
1274 soln_basis_projection_oper_ext,
1288 const int mpi_assembly_error = dealii::Utilities::MPI::sum(assembly_error,
mpi_communicator);
1291 if (mpi_assembly_error != 0) {
1292 std::cout <<
"Invalid residual assembly encountered..." 1293 <<
" Filling up RHS with 1s. " << std::endl;
1297 std::cout <<
" Filling up Jacobian with mass matrix. " << std::endl;
1298 const bool do_inverse_mass_matrix =
false;
1314 if ( compute_dRdW ) {
1318 const bool do_inverse_mass_matrix =
false;
1321 if (CFL_mass != 0.0) {
1326 Epetra_CrsMatrix *input_matrix =
const_cast<Epetra_CrsMatrix *
>(&(
system_matrix.trilinos_matrix()));
1327 Epetra_CrsMatrix *output_matrix;
1329 const bool make_data_contiguous =
true;
1331 if (error_transpose) {
1332 std::cout <<
"Failed to create dRdW transpose... Aborting" << std::endl;
1335 bool copy_values =
true;
1337 delete(output_matrix);
1340 if ( compute_dRdX )
dRdXv.compress(dealii::VectorOperation::add);
1341 if ( compute_d2R ) {
1342 d2RdWdW.compress(dealii::VectorOperation::add);
1343 d2RdXdX.compress(dealii::VectorOperation::add);
1344 d2RdWdX.compress(dealii::VectorOperation::add);
1351 template <
int dim,
typename real,
typename MeshType>
1354 pcout <<
"Evaluating residual Linf-norm..." << std::endl;
1356 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
1358 double residual_linf_norm = 0.0;
1359 std::vector<dealii::types::global_dof_index> dofs_indices;
1360 const dealii::UpdateFlags update_flags = dealii::update_values | dealii::update_JxW_values;
1361 dealii::hp::FEValues<dim,dim> fe_values_collection_volume (mapping_collection,
1367 for (
const auto& cell :
dof_handler.active_cell_iterators()) {
1368 if (!cell->is_locally_owned())
continue;
1370 const int i_fele = cell->active_fe_index();
1371 const int i_quad = i_fele;
1372 const int i_mapp = 0;
1374 fe_values_collection_volume.reinit (cell, i_quad, i_mapp, i_fele);
1375 const dealii::FEValues<dim,dim> &fe_values_vol = fe_values_collection_volume.get_present_fe_values();
1377 const dealii::FESystem<dim,dim> &fe_ref =
fe_collection[i_fele];
1378 const unsigned int n_dofs = fe_ref.n_dofs_per_cell();
1379 const unsigned int n_quad = fe_values_vol.n_quadrature_points;
1381 dofs_indices.resize(n_dofs);
1382 cell->get_dof_indices (dofs_indices);
1384 for (
unsigned int iquad = 0; iquad < n_quad; ++iquad) {
1385 double residual_val = 0.0;
1386 for (
unsigned int idof = 0; idof <
n_dofs; ++idof) {
1387 const unsigned int istate = fe_values_vol.get_fe().system_to_component_index(idof).first;
1388 residual_val +=
right_hand_side[dofs_indices[idof]] * fe_values_vol.shape_value_component(idof, iquad, istate);
1390 residual_linf_norm = std::max(std::abs(residual_val), residual_val);
1394 const double mpi_residual_linf_norm = dealii::Utilities::MPI::max(residual_linf_norm,
mpi_communicator);
1395 return mpi_residual_linf_norm;
1399 template <
int dim,
typename real,
typename MeshType>
1412 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
1414 double residual_l2_norm = 0.0;
1415 double domain_volume = 0.0;
1416 std::vector<dealii::types::global_dof_index> dofs_indices;
1417 const dealii::UpdateFlags update_flags = dealii::update_values | dealii::update_JxW_values;
1418 dealii::hp::FEValues<dim,dim> fe_values_collection_volume (mapping_collection,
1424 for (
const auto& cell :
dof_handler.active_cell_iterators()) {
1425 if (!cell->is_locally_owned())
continue;
1427 const int i_fele = cell->active_fe_index();
1428 const int i_quad = i_fele;
1429 const int i_mapp = 0;
1431 fe_values_collection_volume.reinit (cell, i_quad, i_mapp, i_fele);
1432 const dealii::FEValues<dim,dim> &fe_values_vol = fe_values_collection_volume.get_present_fe_values();
1434 const dealii::FESystem<dim,dim> &fe_ref =
fe_collection[i_fele];
1435 const unsigned int n_dofs = fe_ref.n_dofs_per_cell();
1436 const unsigned int n_quad = fe_values_vol.n_quadrature_points;
1438 dofs_indices.resize(n_dofs);
1439 cell->get_dof_indices (dofs_indices);
1441 for (
unsigned int iquad = 0; iquad < n_quad; ++iquad) {
1442 double residual_val = 0.0;
1443 for (
unsigned int idof = 0; idof <
n_dofs; ++idof) {
1444 const unsigned int istate = fe_values_vol.get_fe().system_to_component_index(idof).first;
1445 residual_val +=
right_hand_side[dofs_indices[idof]] * fe_values_vol.shape_value_component(idof, iquad, istate);
1447 residual_l2_norm += residual_val*residual_val * fe_values_vol.JxW(iquad);
1448 domain_volume += fe_values_vol.JxW(iquad);
1452 const double mpi_residual_l2_norm = dealii::Utilities::MPI::sum(residual_l2_norm,
mpi_communicator);
1453 const double mpi_domain_volume = dealii::Utilities::MPI::sum(domain_volume,
mpi_communicator);
1454 return std::sqrt(mpi_residual_l2_norm) / mpi_domain_volume;
1457 template <
int dim,
typename real,
typename MeshType>
1465 template <
int dim,
typename DoFHandlerType = dealii::DoFHandler<dim>>
1466 class DataOutEulerFaces :
public dealii::DataOutFaces<dim, DoFHandlerType>
1468 static const unsigned int dimension = DoFHandlerType::dimension;
1469 static const unsigned int space_dimension = DoFHandlerType::space_dimension;
1470 using cell_iterator =
typename dealii::DataOut_DoFData<DoFHandlerType, dimension - 1, dimension>::cell_iterator;
1472 using FaceDescriptor =
typename std::pair<cell_iterator, unsigned int>;
1483 virtual FaceDescriptor first_face()
override;
1506 virtual FaceDescriptor next_face(
const FaceDescriptor &face)
override;
1510 template <
int dim,
typename DoFHandlerType>
1511 typename DataOutEulerFaces<dim, DoFHandlerType>::FaceDescriptor
1512 DataOutEulerFaces<dim, DoFHandlerType>::first_face()
1515 typename dealii::Triangulation<dimension, space_dimension>::active_cell_iterator
1518 if (cell->is_locally_owned())
1519 for (
const unsigned int f : dealii::GeometryInfo<dimension>::face_indices())
1520 if (cell->face(f)->at_boundary())
1521 if (cell->face(f)->boundary_id() == 1001)
1522 return FaceDescriptor(cell, f);
1527 return FaceDescriptor();
1530 template <
int dim,
typename DoFHandlerType>
1531 typename DataOutEulerFaces<dim, DoFHandlerType>::FaceDescriptor
1532 DataOutEulerFaces<dim, DoFHandlerType>::next_face(
const FaceDescriptor &old_face)
1534 FaceDescriptor face = old_face;
1538 Assert(face.first->is_locally_owned(), dealii::ExcInternalError());
1539 for (
unsigned int f = face.second + 1; f < dealii::GeometryInfo<dimension>::faces_per_cell; ++f)
1540 if (face.first->face(f)->at_boundary())
1541 if (face.first->face(f)->boundary_id() == 1001) {
1551 typename dealii::Triangulation<dimension, space_dimension>::active_cell_iterator
1552 active_cell = face.first;
1561 if (active_cell->is_locally_owned())
1562 for (
const unsigned int f : dealii::GeometryInfo<dimension>::face_indices())
1563 if (active_cell->face(f)->at_boundary())
1564 if (active_cell->face(f)->boundary_id() == 1001) {
1565 face.first = active_cell;
1582 class NormalPostprocessor :
public dealii::DataPostprocessorVector<dim>
1585 NormalPostprocessor ()
1586 : dealii::DataPostprocessorVector<dim> (
"normal", dealii::update_normal_vectors)
1589 evaluate_vector_field (
const dealii::DataPostprocessorInputs::Vector<dim> &input_data, std::vector<dealii::Vector<double>> &computed_quantities)
const override 1594 AssertDimension (input_data.normals.size(), computed_quantities.size());
1596 for (
unsigned int p=0; p<input_data.solution_gradients.size(); ++p) {
1602 AssertDimension (computed_quantities[p].size(), dim);
1603 for (
unsigned int d=0; d<dim; ++d)
1604 computed_quantities[p][d] = input_data.normals[p][d];
1608 evaluate_scalar_field (
const dealii::DataPostprocessorInputs::Scalar<dim> &input_data, std::vector<dealii::Vector<double> > &computed_quantities)
const override 1613 AssertDimension (input_data.normals.size(), computed_quantities.size());
1615 for (
unsigned int p=0; p<input_data.solution_gradients.size(); ++p) {
1621 AssertDimension (computed_quantities[p].size(), dim);
1622 for (
unsigned int d=0; d<dim; ++d)
1623 computed_quantities[p][d] = input_data.normals[p][d];
1630 template <
int dim,
typename real,
typename MeshType>
1634 DataOutEulerFaces<dim, dealii::DoFHandler<dim>> data_out;
1638 std::vector<std::string> position_names;
1639 for(
int d=0;d<dim;++d) {
1640 if (d==0) position_names.push_back(
"x");
1641 if (d==1) position_names.push_back(
"y");
1642 if (d==2) position_names.push_back(
"z");
1644 std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation> data_component_interpretation(dim, dealii::DataComponentInterpretation::component_is_scalar);
1647 dealii::Vector<float> subdomain(
triangulation->n_active_cells());
1648 for (
unsigned int i = 0; i < subdomain.size(); ++i) {
1651 const std::string name =
"subdomain";
1652 data_out.add_data_vector(subdomain, name, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
1655 data_out.add_data_vector(
artificial_dissipation_coeffs, std::string(
"artificial_dissipation_coeffs"), dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
1656 data_out.add_data_vector(
artificial_dissipation_se, std::string(
"artificial_dissipation_se"), dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
1660 data_out.add_data_vector(
max_dt_cell, std::string(
"max_dt_cell"), dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
1662 data_out.add_data_vector(
cell_volume, std::string(
"cell_volume"), dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
1667 data_out.add_data_vector (
solution, *post_processor);
1669 NormalPostprocessor<dim> normals_post_processor;
1670 data_out.add_data_vector (
solution, normals_post_processor);
1673 std::vector<unsigned int> active_fe_indices;
1674 dof_handler.get_active_fe_indices(active_fe_indices);
1675 dealii::Vector<double> active_fe_indices_dealiivector(active_fe_indices.begin(), active_fe_indices.end());
1676 dealii::Vector<double> cell_poly_degree = active_fe_indices_dealiivector;
1678 data_out.add_data_vector (active_fe_indices_dealiivector,
"PolynomialDegree", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
1681 std::vector<std::string> residual_names;
1682 for(
int s=0;s<
nstate;++s) {
1683 std::string varname =
"residual" + dealii::Utilities::int_to_string(s,1);
1684 residual_names.push_back(varname);
1687 for (
auto &&rhs_value : residual) {
1688 if (std::signbit(rhs_value)) rhs_value = -rhs_value;
1689 if (rhs_value == 0.0) rhs_value = std::numeric_limits<double>::min();
1691 residual.update_ghost_values();
1692 data_out.add_data_vector (residual, residual_names, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_dof_data);
1710 const dealii::Mapping<dim> &mapping = (*(
high_order_grid->mapping_fe_field));
1714 const int n_subdivisions = grid_degree;
1715 data_out.build_patches(mapping, n_subdivisions);
1717 const bool write_higher_order_cells =
false;
1718 dealii::DataOutBase::VtkFlags vtkflags(current_time,cycle,
true,dealii::DataOutBase::VtkFlags::ZlibCompressionLevel::best_compression,write_higher_order_cells);
1719 data_out.set_flags(vtkflags);
1721 const int iproc = dealii::Utilities::MPI::this_mpi_process(
mpi_communicator);
1723 filename += dealii::Utilities::int_to_string(cycle, 4) +
".";
1724 filename += dealii::Utilities::int_to_string(iproc, 4);
1726 std::ofstream output(filename);
1727 data_out.write_vtu(output);
1731 std::vector<std::string> filenames;
1732 for (
unsigned int iproc = 0; iproc < dealii::Utilities::MPI::n_mpi_processes(
mpi_communicator); ++iproc) {
1733 std::string fn =
"surface_solution-" + dealii::Utilities::int_to_string(dim, 1) +
"D_maxpoly"+dealii::Utilities::int_to_string(
max_degree, 2)+
"-";
1734 fn += dealii::Utilities::int_to_string(cycle, 4) +
".";
1735 fn += dealii::Utilities::int_to_string(iproc, 4);
1737 filenames.push_back(fn);
1740 master_fn += dealii::Utilities::int_to_string(cycle, 4) +
".pvtu";
1741 std::ofstream master_output(master_fn);
1742 data_out.write_pvtu_record(master_output, filenames);
1748 template <
int dim,
typename real,
typename MeshType>
1756 dealii::DataOut<dim, dealii::DoFHandler<dim>> data_out;
1760 std::vector<std::string> position_names;
1761 for(
int d=0;d<dim;++d) {
1762 if (d==0) position_names.push_back(
"x");
1763 if (d==1) position_names.push_back(
"y");
1764 if (d==2) position_names.push_back(
"z");
1766 std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation> data_component_interpretation(dim, dealii::DataComponentInterpretation::component_is_scalar);
1769 dealii::Vector<float> subdomain(
triangulation->n_active_cells());
1770 for (
unsigned int i = 0; i < subdomain.size(); ++i) {
1773 data_out.add_data_vector(subdomain,
"subdomain", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
1776 data_out.add_data_vector(
artificial_dissipation_coeffs,
"artificial_dissipation_coeffs", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
1777 data_out.add_data_vector(
artificial_dissipation_se,
"artificial_dissipation_se", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
1781 data_out.add_data_vector(
max_dt_cell,
"max_dt_cell", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
1783 data_out.add_data_vector(reduced_mesh_weights,
"reduced_mesh_weights", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
1785 data_out.add_data_vector(
cell_volume,
"cell_volume", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
1790 data_out.add_data_vector (
solution, *post_processor);
1793 std::vector<unsigned int> active_fe_indices;
1794 dof_handler.get_active_fe_indices(active_fe_indices);
1795 dealii::Vector<double> active_fe_indices_dealiivector(active_fe_indices.begin(), active_fe_indices.end());
1796 dealii::Vector<double> cell_poly_degree = active_fe_indices_dealiivector;
1798 data_out.add_data_vector (active_fe_indices_dealiivector,
"PolynomialDegree", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
1801 std::vector<std::string> residual_names;
1802 for(
int s=0;s<
nstate;++s) {
1803 std::string varname =
"residual" + dealii::Utilities::int_to_string(s,1);
1804 residual_names.push_back(varname);
1807 for (
auto &&rhs_value : residual) {
1808 if (std::signbit(rhs_value)) rhs_value = -rhs_value;
1809 if (rhs_value == 0.0) rhs_value = std::numeric_limits<double>::min();
1811 residual.update_ghost_values();
1812 data_out.add_data_vector (residual, residual_names, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_dof_data);
1814 typename dealii::DataOut<dim,dealii::DoFHandler<dim>>::CurvedCellRegion curved = dealii::DataOut<dim,dealii::DoFHandler<dim>>::CurvedCellRegion::curved_inner_cells;
1818 const dealii::Mapping<dim> &mapping = (*(
high_order_grid->mapping_fe_field));
1821 const int n_subdivisions = (enable_higher_order_vtk_output) ? std::max(grid_degree,
get_max_fe_degree()) : 0;
1822 data_out.build_patches(mapping, n_subdivisions, curved);
1823 const bool write_higher_order_cells = (n_subdivisions>1 && dim>1) ?
true :
false;
1824 dealii::DataOutBase::VtkFlags vtkflags(current_time,cycle,
true,dealii::DataOutBase::VtkFlags::ZlibCompressionLevel::best_compression,write_higher_order_cells);
1825 data_out.set_flags(vtkflags);
1827 const int iproc = dealii::Utilities::MPI::this_mpi_process(
mpi_communicator);
1829 filename += dealii::Utilities::int_to_string(cycle, 4) +
".";
1830 filename += dealii::Utilities::int_to_string(iproc, 4);
1832 std::ofstream output(filename);
1833 data_out.write_vtu(output);
1837 std::vector<std::string> filenames;
1838 for (
unsigned int iproc = 0; iproc < dealii::Utilities::MPI::n_mpi_processes(
mpi_communicator); ++iproc) {
1839 std::string fn =
"solution-" + dealii::Utilities::int_to_string(dim, 1) +
"D_maxpoly"+dealii::Utilities::int_to_string(
max_degree, 2)+
"-";
1840 fn += dealii::Utilities::int_to_string(cycle, 4) +
".";
1841 fn += dealii::Utilities::int_to_string(iproc, 4);
1843 filenames.push_back(fn);
1846 master_fn += dealii::Utilities::int_to_string(cycle, 4) +
".pvtu";
1847 std::ofstream master_output(master_fn);
1848 data_out.write_pvtu_record(master_output, filenames);
1853 template <
int dim,
typename real,
typename MeshType>
1856 for (
int idim=0; idim<dim; idim++) {
1865 template <
int dim,
typename real,
typename MeshType>
1867 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R)
1869 pcout <<
"Allocating DG system and initializing FEValues" << std::endl;
1877 dealii::DoFRenumbering::Cuthill_McKee(
dof_handler,
true);
1901 reduced_mesh_weights.reinit(
triangulation->n_active_cells());
1908 solution.add(std::numeric_limits<real>::lowest());
1925 if (compute_dRdW || compute_dRdX || compute_d2R) {
1927 dealii::DoFTools::make_flux_sparsity_pattern(
dof_handler, dsp);
1970 template <
int dim,
typename real,
typename MeshType>
1975 dealii::IndexSet ghost_dofs_artificial_dissipation;
1976 dealii::IndexSet locally_relevant_dofs_artificial_dissipation;
1978 locally_relevant_dofs_artificial_dissipation = ghost_dofs_artificial_dissipation;
1979 ghost_dofs_artificial_dissipation.subtract_set(locally_owned_dofs_artificial_dissipation);
1989 template <
int dim,
typename real,
typename MeshType>
1996 const dealii::IndexSet &col_parallel_partitioning_d2RdWdX =
high_order_grid->locally_owned_dofs_grid;
1997 d2RdWdX.reinit(row_parallel_partitioning_d2RdWdX, col_parallel_partitioning_d2RdWdX, sparsity_pattern_d2RdWdX,
mpi_communicator);
2004 d2RdWdW.reinit(row_parallel_partitioning_d2RdWdW, col_parallel_partitioning_d2RdWdW, sparsity_pattern_d2RdWdW,
mpi_communicator);
2009 const dealii::IndexSet &row_parallel_partitioning_d2RdXdX =
high_order_grid->locally_owned_dofs_grid;
2010 const dealii::IndexSet &col_parallel_partitioning_d2RdXdX =
high_order_grid->locally_owned_dofs_grid;
2011 d2RdXdX.reinit(row_parallel_partitioning_d2RdXdX, col_parallel_partitioning_d2RdXdX, sparsity_pattern_d2RdXdX,
mpi_communicator);
2015 template <
int dim,
typename real,
typename MeshType>
2021 const dealii::IndexSet &col_parallel_partitioning =
high_order_grid->locally_owned_dofs_grid;
2022 dRdXv.reinit(row_parallel_partitioning, col_parallel_partitioning, dRdXv_sparsity_pattern, MPI_COMM_WORLD);
2025 template <
int dim,
typename real,
typename MeshType>
2027 const bool Cartesian_element,
2028 const unsigned int poly_degree,
const unsigned int grid_degree,
2048 if(grid_degree > 1 || !Cartesian_element){
2057 if(((FR_Type != FR_enum::cDG) ||
2058 (
use_auxiliary_eq && FR_Type_Aux != FR_Aux_enum::kDG) ) && (grid_degree > 1 || !Cartesian_element)){
2063 template <
int dim,
typename real,
typename MeshType>
2076 dealii::DynamicSparsityPattern dsp(
dof_handler.n_dofs());
2077 std::vector<dealii::types::global_dof_index> dofs_indices;
2080 if (!cell->is_locally_owned())
continue;
2082 const unsigned int fe_index_curr_cell = cell->active_fe_index();
2085 const dealii::FESystem<dim,dim> ¤t_fe_ref =
fe_collection[fe_index_curr_cell];
2086 const unsigned int n_dofs_cell = current_fe_ref.n_dofs_per_cell();
2088 dofs_indices.resize(n_dofs_cell);
2089 cell->get_dof_indices (dofs_indices);
2090 for (
unsigned int itest=0; itest<n_dofs_cell; ++itest) {
2091 for (
unsigned int itrial=0; itrial<n_dofs_cell; ++itrial) {
2092 dsp.add(dofs_indices[itest], dofs_indices[itrial]);
2099 if (do_inverse_mass_matrix) {
2118 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
2127 const bool Cartesian_first_element = (first_cell->manifold_id() == dealii::numbers::flat_manifold_id);
2135 if (!cell->is_locally_owned())
continue;
2137 const bool Cartesian_element = (cell->manifold_id() == dealii::numbers::flat_manifold_id);
2139 const unsigned int fe_index_curr_cell = cell->active_fe_index();
2140 const unsigned int curr_grid_degree =
high_order_grid->fe_system.tensor_degree();
2147 reinit_operators_for_mass_matrix(Cartesian_element, fe_index_curr_cell, curr_grid_degree, mapping_basis, basis, reference_mass_matrix, reference_FR, reference_FR_aux, deriv_p);
2158 const unsigned int n_dofs_cell =
fe_collection[fe_index_curr_cell].n_dofs_per_cell();
2163 const unsigned int n_metric_dofs =
high_order_grid->fe_system.dofs_per_cell;
2164 const unsigned int n_grid_nodes = n_metric_dofs/dim;
2165 std::vector<dealii::types::global_dof_index> metric_dof_indices(n_metric_dofs);
2166 metric_cell->get_dof_indices (metric_dof_indices);
2168 std::array<std::vector<real>,dim> mapping_support_points;
2169 for(
int idim=0; idim<dim; idim++){
2170 mapping_support_points[idim].resize(n_metric_dofs/dim);
2172 const std::vector<unsigned int > &index_renumbering = dealii::FETools::hierarchic_to_lexicographic_numbering<dim>(curr_grid_degree);
2173 for (
unsigned int idof = 0; idof< n_metric_dofs; ++idof) {
2174 const real val = (
high_order_grid->volume_nodes[metric_dof_indices[idof]]);
2175 const unsigned int istate = fe_metric.system_to_component_index(idof).first;
2176 const unsigned int ishape = fe_metric.system_to_component_index(idof).second;
2177 const unsigned int igrid_node = index_renumbering[ishape];
2178 mapping_support_points[istate][igrid_node] = val;
2184 n_quad_pts, n_grid_nodes,
2185 mapping_support_points,
2189 dofs_indices.resize(n_dofs_cell);
2190 cell->get_dof_indices (dofs_indices);
2194 do_inverse_mass_matrix,
2202 reference_mass_matrix,
2209 if (do_inverse_mass_matrix) {
2228 template<
int dim,
typename real,
typename MeshType>
2230 const bool Cartesian_element,
2231 const bool do_inverse_mass_matrix,
2232 const unsigned int poly_degree,
2233 const unsigned int ,
2234 const unsigned int n_quad_pts,
2235 const unsigned int n_dofs_cell,
2236 const std::vector<dealii::types::global_dof_index> dofs_indices,
2250 dealii::FullMatrix<real> local_mass_matrix(n_dofs_cell);
2251 dealii::FullMatrix<real> local_mass_matrix_inv(n_dofs_cell);
2252 dealii::FullMatrix<real> local_mass_matrix_aux(n_dofs_cell);
2253 dealii::FullMatrix<real> local_mass_matrix_aux_inv(n_dofs_cell);
2255 for(
int istate=0; istate<
nstate; istate++){
2256 const unsigned int n_shape_fns = n_dofs_cell /
nstate;
2257 dealii::FullMatrix<real> local_mass_matrix_state(n_shape_fns);
2258 dealii::FullMatrix<real> local_mass_matrix_inv_state(n_shape_fns);
2259 dealii::FullMatrix<real> local_mass_matrix_aux_state(n_shape_fns);
2260 dealii::FullMatrix<real> local_mass_matrix_aux_inv_state(n_shape_fns);
2264 if(Cartesian_element){
2265 local_mass_matrix_state.add(metric_oper.
det_Jac_vol[0],
2272 local_mass_matrix_aux_state.add(1.0, local_mass_matrix_state);
2274 if(FR_Type != FR_enum::cDG){
2275 local_mass_matrix_state.add(metric_oper.
det_Jac_vol[0],
2282 if(FR_Type_Aux != FR_Aux_enum::kDG){
2283 local_mass_matrix_aux_state.add(metric_oper.
det_Jac_vol[0],
2290 if(do_inverse_mass_matrix){
2291 local_mass_matrix_inv_state.invert(local_mass_matrix_state);
2293 local_mass_matrix_aux_inv_state.invert(local_mass_matrix_aux_state);
2302 n_shape_fns, n_quad_pts,
2307 if(
use_auxiliary_eq) local_mass_matrix_aux_state.add(1.0, local_mass_matrix_state);
2309 if(FR_Type != FR_enum::cDG){
2310 dealii::FullMatrix<real> local_FR(n_shape_fns);
2315 local_mass_matrix_state);
2316 local_mass_matrix_state.add(1.0, local_FR);
2319 if(FR_Type_Aux != FR_Aux_enum::kDG){
2320 dealii::FullMatrix<real> local_FR_aux(n_shape_fns);
2325 local_mass_matrix_aux_state);
2326 local_mass_matrix_aux_state.add(1.0, local_FR_aux);
2330 if(do_inverse_mass_matrix){
2331 local_mass_matrix_inv_state.invert(local_mass_matrix_state);
2333 local_mass_matrix_aux_inv_state.invert(local_mass_matrix_aux_state);
2340 std::vector<real> J_inv(n_quad_pts);
2341 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
2342 J_inv[iquad] = 1.0 / metric_oper.
det_Jac_vol[iquad];
2344 dealii::FullMatrix<real> local_weighted_mass_matrix(n_shape_fns);
2345 dealii::FullMatrix<real> local_weighted_mass_matrix_aux(n_shape_fns);
2348 n_shape_fns, n_quad_pts,
2353 local_weighted_mass_matrix_aux.add(1.0, local_weighted_mass_matrix);
2355 if(FR_Type != FR_enum::cDG){
2356 dealii::FullMatrix<real> local_FR(n_shape_fns);
2361 local_weighted_mass_matrix);
2362 local_weighted_mass_matrix.add(1.0, local_FR);
2366 if(FR_Type_Aux != FR_Aux_enum::kDG){
2367 dealii::FullMatrix<real> local_FR_aux(n_shape_fns);
2373 local_weighted_mass_matrix_aux.add(1.0, local_FR_aux);
2376 dealii::FullMatrix<real> ref_mass_dim(n_shape_fns);
2382 if(FR_Type != FR_enum::cDG){
2383 dealii::FullMatrix<real> local_FR(n_shape_fns);
2388 ref_mass_dim.add(1.0, local_FR);
2390 dealii::FullMatrix<real> ref_mass_dim_inv(n_shape_fns);
2391 ref_mass_dim_inv.invert(ref_mass_dim);
2392 dealii::FullMatrix<real> temp(n_shape_fns);
2393 ref_mass_dim_inv.mmult(temp, local_weighted_mass_matrix);
2394 temp.mmult(local_mass_matrix_inv_state, ref_mass_dim_inv);
2395 local_mass_matrix_state.invert(local_mass_matrix_inv_state);
2397 dealii::FullMatrix<real> temp2(n_shape_fns);
2398 ref_mass_dim_inv.mmult(temp2, local_weighted_mass_matrix_aux);
2399 temp2.mmult(local_mass_matrix_aux_inv_state, ref_mass_dim_inv);
2400 local_mass_matrix_aux_state.invert(local_mass_matrix_aux_inv_state);
2404 for(
unsigned int test_shape=0; test_shape<n_shape_fns; test_shape++){
2406 const unsigned int test_index = istate * n_shape_fns + test_shape;
2408 for(
unsigned int trial_shape=test_shape; trial_shape<n_shape_fns; trial_shape++){
2409 const unsigned int trial_index = istate * n_shape_fns + trial_shape;
2410 local_mass_matrix[test_index][trial_index] = local_mass_matrix_state[test_shape][trial_shape];
2411 local_mass_matrix[trial_index][test_index] = local_mass_matrix_state[test_shape][trial_shape];
2413 local_mass_matrix_inv[test_index][trial_index] = local_mass_matrix_inv_state[test_shape][trial_shape];
2414 local_mass_matrix_inv[trial_index][test_index] = local_mass_matrix_inv_state[test_shape][trial_shape];
2417 local_mass_matrix_aux[test_index][trial_index] = local_mass_matrix_aux_state[test_shape][trial_shape];
2418 local_mass_matrix_aux[trial_index][test_index] = local_mass_matrix_aux_state[test_shape][trial_shape];
2420 local_mass_matrix_aux_inv[test_index][trial_index] = local_mass_matrix_aux_inv_state[test_shape][trial_shape];
2421 local_mass_matrix_aux_inv[trial_index][test_index] = local_mass_matrix_aux_inv_state[test_shape][trial_shape];
2428 if (do_inverse_mass_matrix) {
2451 template<
int dim,
typename real,
typename MeshType>
2453 const dealii::LinearAlgebra::distributed::Vector<double> &input_vector,
2454 dealii::LinearAlgebra::distributed::Vector<double> &output_vector,
2462 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
2473 const unsigned int grid_degree = this->
high_order_grid->fe_system.tensor_degree();
2475 const unsigned int n_metric_dofs =
high_order_grid->fe_system.dofs_per_cell;
2479 const bool Cartesian_first_element = (first_cell->manifold_id() == dealii::numbers::flat_manifold_id) ?
true :
false;
2481 if(Cartesian_first_element){
2482 if(use_auxiliary_eq){
2490 if(use_auxiliary_eq){
2498 dealii::Timer timer;
2503 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell) {
2504 if (!soln_cell->is_locally_owned())
continue;
2506 const unsigned int poly_degree = soln_cell->active_fe_index();
2507 const unsigned int n_dofs_cell =
fe_collection[poly_degree].n_dofs_per_cell();
2508 std::vector<dealii::types::global_dof_index> current_dofs_indices;
2509 current_dofs_indices.resize(n_dofs_cell);
2510 soln_cell->get_dof_indices (current_dofs_indices);
2512 const bool Cartesian_element = (soln_cell->manifold_id() == dealii::numbers::flat_manifold_id);
2515 if((poly_degree != mass_inv.
current_degree && Cartesian_element && !use_auxiliary_eq) ||
2516 (poly_degree != projection_oper.
current_degree && (grid_degree > 1 || Cartesian_element) && !use_auxiliary_eq))
2519 if(Cartesian_element){
2521 if(use_auxiliary_eq){
2527 if(use_auxiliary_eq){
2535 std::vector<dealii::types::global_dof_index> metric_dof_indices(n_metric_dofs);
2536 metric_cell->get_dof_indices (metric_dof_indices);
2538 std::array<std::vector<real>,dim> mapping_support_points;
2539 for(
int idim=0; idim<dim; idim++){
2540 mapping_support_points[idim].resize(n_metric_dofs/dim);
2542 const std::vector<unsigned int > &index_renumbering = dealii::FETools::hierarchic_to_lexicographic_numbering<dim>(grid_degree);
2543 for (
unsigned int idof = 0; idof< n_metric_dofs; ++idof) {
2544 const real val = (
high_order_grid->volume_nodes[metric_dof_indices[idof]]);
2545 const unsigned int istate = fe_metric.system_to_component_index(idof).first;
2546 const unsigned int ishape = fe_metric.system_to_component_index(idof).second;
2547 const unsigned int igrid_node = index_renumbering[ishape];
2548 mapping_support_points[istate][igrid_node] = val;
2552 const unsigned int n_grid_nodes = n_metric_dofs / dim;
2556 n_quad_pts, n_grid_nodes,
2557 mapping_support_points,
2560 for(
int istate=0; istate<
nstate; istate++){
2561 const unsigned int n_shape_fns = n_dofs_cell /
nstate;
2562 std::vector<real> local_input_vector(n_shape_fns);
2563 std::vector<real> local_output_vector(n_shape_fns);
2565 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
2566 const unsigned int idof = istate * n_shape_fns + ishape;
2567 local_input_vector[ishape] = input_vector[current_dofs_indices[idof]];
2570 if(Cartesian_element){
2571 if(use_auxiliary_eq){
2583 if(use_auxiliary_eq){
2584 std::vector<real> projection_of_input(n_quad_pts);
2588 std::vector<real> JxW_inv(n_quad_pts);
2589 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
2590 JxW_inv[iquad] = 1.0 / (quad_weights[iquad] * metric_oper.
det_Jac_vol[iquad]);
2593 local_output_vector,
2597 std::vector<real> projection_of_input(n_quad_pts);
2601 std::vector<real> JxW_inv(n_quad_pts);
2602 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
2603 JxW_inv[iquad] = 1.0 / (quad_weights[iquad] * metric_oper.
det_Jac_vol[iquad]);
2606 local_output_vector,
2611 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
2612 const unsigned int idof = istate * n_shape_fns + ishape;
2613 output_vector[current_dofs_indices[idof]] = local_output_vector[ishape];
2624 template<
int dim,
typename real,
typename MeshType>
2626 const dealii::LinearAlgebra::distributed::Vector<double> &input_vector,
2627 dealii::LinearAlgebra::distributed::Vector<double> &output_vector,
2629 const bool use_unmodified_mass_matrix)
2633 const FR_enum FR_cDG = FR_enum::cDG;
2637 const FR_Aux_enum FR_Type_Aux = this->all_parameters->flux_reconstruction_aux_type;
2639 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
2649 const unsigned int grid_degree = this->
high_order_grid->fe_system.tensor_degree();
2651 const unsigned int n_metric_dofs =
high_order_grid->fe_system.dofs_per_cell;
2655 const bool Cartesian_first_element = (first_cell->manifold_id() == dealii::numbers::flat_manifold_id);
2657 if(use_auxiliary_eq){
2659 if(grid_degree>1 || !Cartesian_first_element){
2665 if(grid_degree>1 || !Cartesian_first_element){
2670 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell) {
2671 if (!soln_cell->is_locally_owned())
continue;
2673 const unsigned int poly_degree = soln_cell->active_fe_index();
2674 const unsigned int n_dofs_cell =
fe_collection[poly_degree].n_dofs_per_cell();
2675 std::vector<dealii::types::global_dof_index> current_dofs_indices;
2676 current_dofs_indices.resize(n_dofs_cell);
2677 soln_cell->get_dof_indices (current_dofs_indices);
2679 const bool Cartesian_element = (soln_cell->manifold_id() == dealii::numbers::flat_manifold_id) ?
true :
false;
2682 if((poly_degree != mass.
current_degree && (grid_degree == 1 || Cartesian_element) && !use_auxiliary_eq) ||
2683 (poly_degree != projection_oper.
current_degree && (grid_degree > 1 || !Cartesian_element) && !use_auxiliary_eq)){
2685 if(use_auxiliary_eq){
2687 if(grid_degree>1 || !Cartesian_element){
2693 if(grid_degree>1 || !Cartesian_element){
2701 std::vector<dealii::types::global_dof_index> metric_dof_indices(n_metric_dofs);
2702 metric_cell->get_dof_indices (metric_dof_indices);
2704 std::array<std::vector<real>,dim> mapping_support_points;
2705 for(
int idim=0; idim<dim; idim++){
2706 mapping_support_points[idim].resize(n_metric_dofs/dim);
2708 const std::vector<unsigned int > &index_renumbering = dealii::FETools::hierarchic_to_lexicographic_numbering<dim>(grid_degree);
2709 for (
unsigned int idof = 0; idof< n_metric_dofs; ++idof) {
2710 const real val = (
high_order_grid->volume_nodes[metric_dof_indices[idof]]);
2711 const unsigned int istate = fe_metric.system_to_component_index(idof).first;
2712 const unsigned int ishape = fe_metric.system_to_component_index(idof).second;
2713 const unsigned int igrid_node = index_renumbering[ishape];
2714 mapping_support_points[istate][igrid_node] = val;
2718 const unsigned int n_grid_nodes = n_metric_dofs / dim;
2722 n_quad_pts, n_grid_nodes,
2723 mapping_support_points,
2727 for(
int istate=0; istate<
nstate; istate++){
2728 const unsigned int n_shape_fns = n_dofs_cell /
nstate;
2729 std::vector<real> local_input_vector(n_shape_fns);
2730 std::vector<real> local_output_vector(n_shape_fns);
2732 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
2733 const unsigned int idof = istate * n_shape_fns + ishape;
2734 local_input_vector[ishape] = input_vector[current_dofs_indices[idof]];
2736 if(Cartesian_element){
2737 if(use_auxiliary_eq){
2751 if(use_auxiliary_eq){
2753 dealii::FullMatrix<double> proj_mass(n_quad_pts_1D, n_dofs_1D);
2756 std::vector<real> projection_of_input(n_quad_pts);
2759 std::vector<real> JxW(n_quad_pts);
2760 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
2761 JxW[iquad] = (metric_oper.
det_Jac_vol[iquad] / quad_weights[iquad]);
2764 local_output_vector,
2770 std::vector<real> proj_mass(n_shape_fns);
2773 std::vector<real> projection_of_input(n_quad_pts);
2774 std::vector<real> ones(n_shape_fns, 1.0);
2777 std::vector<real> JxW(n_quad_pts);
2778 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
2779 JxW[iquad] = (metric_oper.
det_Jac_vol[iquad] / quad_weights[iquad])
2780 * projection_of_input[iquad];
2782 std::vector<real> temp(n_shape_fns);
2787 local_output_vector,
2793 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
2794 const unsigned int idof = istate * n_shape_fns + ishape;
2795 output_vector[current_dofs_indices[idof]] = local_output_vector[ishape];
2801 template<
int dim,
typename real,
typename MeshType>
2806 template<
int dim,
typename real,
typename MeshType>
2811 template<
int dim,
typename real,
typename MeshType>
2816 std::vector<dealii::types::global_dof_index> dofs_indices;
2819 if (!cell->is_locally_owned())
continue;
2821 const unsigned int fe_index_curr_cell = cell->active_fe_index();
2824 const dealii::FESystem<dim,dim> ¤t_fe_ref =
fe_collection[fe_index_curr_cell];
2825 const unsigned int n_dofs_cell = current_fe_ref.n_dofs_per_cell();
2827 dofs_indices.resize(n_dofs_cell);
2828 cell->get_dof_indices (dofs_indices);
2830 const double max_dt =
max_dt_cell[cell->active_cell_index()];
2832 for (
unsigned int itest=0; itest<n_dofs_cell; ++itest) {
2833 const unsigned int istate_test = current_fe_ref.system_to_component_index(itest).first;
2834 for (
unsigned int itrial=itest; itrial<n_dofs_cell; ++itrial) {
2835 const unsigned int istate_trial = current_fe_ref.system_to_component_index(itrial).first;
2837 if(istate_test==istate_trial) {
2838 const unsigned int row = dofs_indices[itest];
2839 const unsigned int col = dofs_indices[itrial];
2841 const double new_val = value / (dt_scale * max_dt);
2842 AssertIsFinite(new_val);
2852 template<
int dim,
typename real>
2854 const std::vector< real > &function_coeff,
2855 const dealii::FESystem<dim,dim> &fe_input,
2856 const dealii::FESystem<dim,dim> &fe_output,
2857 const dealii::QGauss<dim> &projection_quadrature)
2859 const unsigned int nstate = fe_input.n_components();
2860 const unsigned int n_vector_dofs_in = fe_input.dofs_per_cell;
2861 const unsigned int n_vector_dofs_out = fe_output.dofs_per_cell;
2862 const unsigned int n_dofs_in = n_vector_dofs_in /
nstate;
2863 const unsigned int n_dofs_out = n_vector_dofs_out /
nstate;
2865 assert(n_vector_dofs_in == function_coeff.size());
2866 assert(nstate == fe_output.n_components());
2868 const unsigned int n_quad_pts = projection_quadrature.size();
2869 const std::vector<dealii::Point<dim,double>> &unit_quad_pts = projection_quadrature.get_points();
2871 std::vector< real > function_coeff_out(n_vector_dofs_out);
2872 for (
unsigned istate = 0; istate <
nstate; ++istate) {
2874 std::vector< real > function_at_quad(n_quad_pts);
2877 dealii::FullMatrix<double> interpolation_operator(n_dofs_out,n_quad_pts);
2879 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
2880 function_at_quad[iquad] = 0.0;
2881 for (
unsigned int idof=0; idof<n_dofs_in; ++idof) {
2882 const unsigned int idof_vector = fe_input.component_to_system_index(istate,idof);
2883 function_at_quad[iquad] += function_coeff[idof_vector] * fe_input.shape_value_component(idof_vector,unit_quad_pts[iquad],istate);
2885 function_at_quad[iquad] *= projection_quadrature.weight(iquad);
2887 for (
unsigned int idof=0; idof<n_dofs_out; ++idof) {
2888 const unsigned int idof_vector = fe_output.component_to_system_index(istate,idof);
2889 interpolation_operator[idof][iquad] = fe_output.shape_value_component(idof_vector,unit_quad_pts[iquad],istate);
2893 std::vector< real > rhs(n_dofs_out);
2894 for (
unsigned int idof=0; idof<n_dofs_out; ++idof) {
2896 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
2897 rhs[idof] += interpolation_operator[idof][iquad] * function_at_quad[iquad];
2901 dealii::FullMatrix<double> mass(n_dofs_out, n_dofs_out);
2902 for(
unsigned int row=0; row<n_dofs_out; ++row) {
2903 for(
unsigned int col=0; col<n_dofs_out; ++col) {
2907 for(
unsigned int row=0; row<n_dofs_out; ++row) {
2908 for(
unsigned int col=0; col<n_dofs_out; ++col) {
2909 for(
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
2910 mass[row][col] += interpolation_operator[row][iquad] * interpolation_operator[col][iquad] * projection_quadrature.weight(iquad);
2914 dealii::FullMatrix<double> inverse_mass(n_dofs_out, n_dofs_out);
2915 inverse_mass.invert(mass);
2917 for(
unsigned int row=0; row<n_dofs_out; ++row) {
2918 const unsigned int idof_vector = fe_output.component_to_system_index(istate,row);
2919 function_coeff_out[idof_vector] = 0.0;
2920 for(
unsigned int col=0; col<n_dofs_out; ++col) {
2921 function_coeff_out[idof_vector] += inverse_mass[row][col] * rhs[col];
2926 return function_coeff_out;
2930 template <
int dim,
typename real,
typename MeshType>
2931 template <
typename real2>
2933 const dealii::Quadrature<dim> &volume_quadrature,
2934 const std::vector< real2 > &soln_coeff_high,
2935 const dealii::FiniteElement<dim,dim> &fe_high,
2936 const std::vector<real2> &jac_det)
2938 const unsigned int degree = fe_high.tensor_degree();
2940 if (degree == 0)
return 0;
2942 const unsigned int nstate = fe_high.components;
2943 const unsigned int n_dofs_high = fe_high.dofs_per_cell;
2946 const unsigned int lower_degree = degree-1;
2947 const dealii::FE_DGQLegendre<dim> fe_dgq_lower(lower_degree);
2948 const dealii::FESystem<dim,dim> fe_lower(fe_dgq_lower, nstate);
2951 const dealii::QGauss<dim> projection_quadrature(degree+5);
2952 std::vector< real2 > soln_coeff_lower = project_function<dim,real2>( soln_coeff_high, fe_high, fe_lower, projection_quadrature);
2955 const std::vector<dealii::Point<dim,double>> &unit_quad_pts = volume_quadrature.get_points();
2957 const unsigned int n_quad_pts = volume_quadrature.size();
2958 const unsigned int n_dofs_lower = fe_lower.dofs_per_cell;
2960 real2 element_volume = 0.0;
2962 real2 soln_norm = 0.0;
2963 std::vector<real2> soln_high(nstate);
2964 std::vector<real2> soln_lower(nstate);
2965 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
2966 for (
unsigned int s=0; s<
nstate; ++s) {
2968 soln_lower[s] = 0.0;
2971 for (
unsigned int idof=0; idof<n_dofs_high; ++idof) {
2972 const unsigned int istate = fe_high.system_to_component_index(idof).first;
2973 soln_high[istate] += soln_coeff_high[idof] * fe_high.shape_value_component(idof,unit_quad_pts[iquad],istate);
2976 for (
unsigned int idof=0; idof<n_dofs_lower; ++idof) {
2977 const unsigned int istate = fe_lower.system_to_component_index(idof).first;
2978 soln_lower[istate] += soln_coeff_lower[idof] * fe_lower.shape_value_component(idof,unit_quad_pts[iquad],istate);
2981 const real2 JxW = jac_det[iquad] * volume_quadrature.weight(iquad);
2982 element_volume += JxW;
2985 for (
unsigned int s=0; s<1; ++s)
2987 error += (soln_high[s] - soln_lower[s]) * (soln_high[s] - soln_lower[s]) * JxW;
2988 soln_norm += soln_high[s] * soln_high[s] * JxW;
2992 if (soln_norm < 1e-15)
return 0;
2994 const real2 S_e = sqrt(error / soln_norm);
2995 const real2 s_e = log10(S_e);
2998 const double s_0 = -0.00 - 4.00*log10(degree);
3000 const double low = s_0 - kappa;
3001 const double upp = s_0 + kappa;
3003 const real2 diameter = pow(element_volume, 1.0/dim);
3004 const real2 eps_0 = mu_scale * diameter / (double)degree;
3006 if ( s_e < low)
return 0.0;
3013 const double PI = 4*atan(1);
3014 real2 eps = 1.0 + sin(PI * (s_e - s_0) * 0.5 / kappa);
3019 template <
int dim,
typename real,
typename MeshType>
3022 this->current_time = current_time_input;
3032 template double DGBase<PHILIP_DIM,double,dealii::Triangulation<PHILIP_DIM>>::discontinuity_sensor<double>(
const dealii::Quadrature<PHILIP_DIM> &volume_quadrature,
const std::vector< double > &soln_coeff_high,
const dealii::FiniteElement<PHILIP_DIM,PHILIP_DIM> &fe_high,
const std::vector<double> &jac_det);
3055 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
3056 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
3057 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
3058 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
3059 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
3060 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
3061 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
3062 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
3071 const bool compute_auxiliary_right_hand_side,
3072 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
3073 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
3077 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
3078 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
3079 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
3080 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
3081 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
3082 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
3083 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
3084 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
3093 const bool compute_auxiliary_right_hand_side,
3094 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
3095 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
3099 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
3100 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
3101 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
3102 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
3103 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
3104 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
3105 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
3106 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
3115 const bool compute_auxiliary_right_hand_side,
3116 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
3117 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
void output_face_results_vtk(const unsigned int cycle, const double current_time=0.0)
Output Euler face solution.
unsigned int current_degree
Stores the degree of the current poly degree.
real2 discontinuity_sensor(const dealii::Quadrature< dim > &volume_quadrature, const std::vector< real2 > &soln_coeff_high, const dealii::FiniteElement< dim, dim > &fe_high, const std::vector< real2 > &jac_det)
dealii::SparsityPattern get_d2RdWdX_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXdW.
double CFL_mass_dRdW
CFL used to add mass matrix in the optimization FlowConstraints class.
dealii::FullMatrix< double > build_dim_mass_matrix(const int nstate, const unsigned int n_dofs, const unsigned int n_quad_pts, basis_functions< dim, n_faces, real > &basis, const std::vector< double > &det_Jac, const std::vector< double > &quad_weights)
Assemble the dim mass matrix on the fly with metric Jacobian dependence.
void build_determinant_volume_metric_Jacobian(const unsigned int n_quad_pts, const unsigned int n_metric_dofs, const std::array< std::vector< real >, dim > &mapping_support_points, mapping_shape_functions< dim, n_faces, real > &mapping_basis)
Builds just the determinant of the volume metric determinant.
PartialDifferentialEquation pde_type
Store the PDE type to be solved.
dealii::Vector< double > artificial_dissipation_coeffs
Artificial dissipation in each cell.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
The metric independent inverse of the FR mass matrix .
bool use_auxiliary_eq
Flag for using the auxiliary equation.
const dealii::UpdateFlags neighbor_face_update_flags
Update flags needed at neighbor' face points.
Sacado::Fad::DFad< FadType > FadFadType
Sacado AD type that allows 2nd derivatives.
void time_scaled_mass_matrices(const real scale)
virtual void allocate_second_derivatives()
Allocates the second derivatives.
dealii::LinearAlgebra::distributed::Vector< double > artificial_dissipation_c0
Artificial dissipation coefficients.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
unsigned int current_degree
Stores the degree of the current poly degree.
const dealii::hp::FECollection< 1 > oneD_fe_collection
1D Finite Element Collection for p-finite-element to represent the solution
const unsigned int initial_degree
Initial polynomial degree assigned during constructor.
dealii::LinearAlgebra::distributed::Vector< double > solution_d2R
Sacado::Fad::DFad< double > FadType
Sacado AD type for first derivatives.
dealii::TrilinosWrappers::SparseMatrix dRdXv
unsigned int current_grid_degree
Stores the degree of the current grid degree.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
void add_time_scaled_mass_matrices()
Add time scaled mass matrices to the system.
double assemble_residual_time
Computational time for assembling residual.
bool output_face_results_vtk
Flag for outputting the surface solution vtk files.
dealii::LinearAlgebra::distributed::Vector< real > dual
Current optimization dual variables corresponding to the residual constraints also known as the adjoi...
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
codi_JacobianComputationType RadType
CoDiPaco reverse-AD type for first derivatives.
dealii::LinearAlgebra::distributed::Vector< double > volume_nodes_dRdX
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
The metric independent FR mass matrix for auxiliary equation .
std::array< dealii::LinearAlgebra::distributed::Vector< double >, dim > auxiliary_right_hand_side
The auxiliary equations' right hand sides.
dealii::FullMatrix< double > tensor_product_state(const int nstate, const dealii::FullMatrix< double > &basis_x, const dealii::FullMatrix< double > &basis_y, const dealii::FullMatrix< double > &basis_z)
Returns the tensor product of matrices passed, but makes it sparse diagonal by state.
void add_mass_matrices(const real scale)
Add mass matrices to the system scaled by a factor (likely time-step)
dealii::TrilinosWrappers::SparseMatrix global_mass_matrix_auxiliary
Global auxiliary mass matrix.
std::shared_ptr< Triangulation > triangulation
Mesh.
void output_results_vtk(const unsigned int cycle, const double current_time=0.0)
Output solution.
bool use_energy
Flag to use an energy monotonicity test.
Projection operator corresponding to basis functions onto -norm for auxiliary equation.
void inner_product_1D(const std::vector< real > &input_vect, const std::vector< real > &weight_vect, std::vector< real > &output_vect, const dealii::FullMatrix< double > &basis_x, const bool adding=false, const double factor=1.0)
Apply the inner product operation using the 1D operator in each direction.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
dealii::QGauss< 0 > oneD_face_quadrature
1D surface quadrature is always one single point for all poly degrees.
void update_artificial_dissipation_discontinuity_sensor()
Update discontinuity sensor.
dealii::Point< dim > coordinates_of_highest_refined_cell(bool check_for_p_refined_cell=false)
Returns the coordinates of the most refined cell.
Files for the baseline physics.
void allocate_auxiliary_equation()
Allocates the auxiliary equations' variables and right hand side (primarily for Strong form diffusive...
const dealii::hp::FECollection< 1 > oneD_fe_collection_flux
1D collocated flux basis used in strong form
bool use_weak_form
Flag to use weak or strong form of DG.
ManufacturedSolutionParam manufactured_solution_param
Associated manufactured solution parameters.
unsigned int current_degree
Stores the degree of the current poly degree.
dealii::SparsityPattern get_d2RdXdX_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXdX.
double get_residual_linfnorm() const
Returns the Linf-norm of the right_hand_side vector.
dealii::TrilinosWrappers::SparseMatrix system_matrix_transpose
DGBase(const int nstate_input, const Parameters::AllParameters *const parameters_input, const unsigned int degree, const unsigned int max_degree_input, const unsigned int grid_degree_input, const std::shared_ptr< Triangulation > triangulation_input)
Principal constructor that will call delegated constructor.
dealii::FullMatrix< double > oneD_transpose_vol_operator
Stores the transpose of the operator for fast weight-adjusted solves.
virtual void allocate_model_variables()=0
Allocate the necessary variables declared in src/physics/model.h.
std::unique_ptr< Epetra_RowMatrixTransposer > epetra_rowmatrixtransposer_dRdW
Epetra_RowMatrixTransposer used to transpose the system_matrix.
Flux_Reconstruction
Type of correction in Flux Reconstruction.
dealii::TrilinosWrappers::SparseMatrix d2RdWdW
Flux_Reconstruction_Aux flux_reconstruction_aux_type
Store flux reconstruction type for the auxiliary variables.
double get_residual_l2norm() const
Returns the L2-norm of the right_hand_side vector.
-th order modal derivative of basis fuctions, ie/
virtual void assemble_boundary_term_and_build_operators(typename dealii::DoFHandler< dim >::active_cell_iterator cell, const dealii::types::global_dof_index current_cell_index, const unsigned int iface, const unsigned int boundary_id, const real penalty, const std::vector< dealii::types::global_dof_index > &cell_dofs_indices, const std::vector< dealii::types::global_dof_index > &metric_dof_indices, const unsigned int poly_degree, const unsigned int grid_degree, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis, OPERATOR::local_basis_stiffness< dim, 2 *dim, real > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< real, dim, 2 *dim > &metric_oper, OPERATOR::mapping_shape_functions< dim, 2 *dim, real > &mapping_basis, std::array< std::vector< real >, dim > &mapping_support_points, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_int, const dealii::FESystem< dim, dim > ¤t_fe_ref, dealii::Vector< real > &local_rhs_int_cell, std::vector< dealii::Tensor< 1, dim, real >> &local_auxiliary_RHS, const bool compute_auxiliary_right_hand_side, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R)=0
Builds the necessary operators/fe values and assembles boundary residual.
void build_1D_shape_functions_at_grid_nodes(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Constructs the volume operator and gradient operator.
dealii::TrilinosWrappers::SparseMatrix global_mass_matrix
Global mass matrix.
void reinit_operators_for_cell_residual_loop(const unsigned int poly_degree_int, const unsigned int poly_degree_ext, const unsigned int grid_degree, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim, real > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim, real > &mapping_basis)
Builds needed operators for cell residual loop.
MPI_Comm mpi_communicator
MPI communicator.
dealii::Vector< double > max_dt_cell
Time it takes for the maximum wavespeed to cross the cell domain.
Main parameter class that contains the various other sub-parameter classes.
const dealii::hp::FECollection< 1 > oneD_fe_collection_1state
1D Finite Element Collection for p-finite-element to represent the solution for a single state...
void reinit_operators_for_mass_matrix(const bool Cartesian_element, const unsigned int poly_degree, const unsigned int grid_degree, OPERATOR::mapping_shape_functions< dim, 2 *dim, real > &mapping_basis, OPERATOR::basis_functions< dim, 2 *dim, real > &basis, OPERATOR::local_mass< dim, 2 *dim, real > &reference_mass_matrix, OPERATOR::local_Flux_Reconstruction_operator< dim, 2 *dim, real > &reference_FR, OPERATOR::local_Flux_Reconstruction_operator_aux< dim, 2 *dim, real > &reference_FR_aux, OPERATOR::derivative_p< dim, 2 *dim, real > &deriv_p)
Builds needed operators to compute mass matrices/inverses efficiently.
dealii::LinearAlgebra::distributed::Vector< double > solution
Current modal coefficients of the solution.
ESFR correction matrix without jac dependence.
std::vector< real > det_Jac_vol
The determinant of the metric Jacobian at volume cubature nodes.
Local mass matrix without jacobian dependence.
virtual void update_model_variables()=0
Update the necessary variables declared in src/physics/model.h.
ManufacturedConvergenceStudyParam manufactured_convergence_study_param
Contains parameters for manufactured convergence study.
bool enable_higher_order_vtk_output
Enable writing of higher-order vtk results.
Flux_Reconstruction flux_reconstruction_type
Store flux reconstruction type.
const int nstate
Number of state variables.
dealii::DoFHandler< dim > dof_handler_artificial_dissipation
Degrees of freedom handler for C0 artificial dissipation.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
dealii::IndexSet locally_owned_dofs
Locally own degrees of freedom.
dealii::LinearAlgebra::distributed::Vector< double > solution_dRdW
dealii::LinearAlgebra::distributed::Vector< double > volume_nodes_dRdW
dealii::SparsityPattern mass_sparsity_pattern
Sparsity pattern used on the system_matrix.
unsigned int current_degree
Stores the degree of the current poly degree.
dealii::TrilinosWrappers::SparseMatrix global_inverse_mass_matrix_auxiliary
Global inverse of the auxiliary mass matrix.
dealii::FullMatrix< double > oneD_transpose_vol_operator
Stores the transpose of the operator for fast weight-adjusted solves.
void build_1D_gradient_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
void reinit()
Reinitializes the DG object after a change of triangulation.
dealii::TrilinosWrappers::SparseMatrix time_scaled_global_mass_matrix
Global mass matrix divided by the time scales.
dealii::hp::QCollection< dim-1 > face_quadrature_collection
Quadrature used to evaluate face integrals.
unsigned int current_degree
Stores the degree of the current poly degree.
real evaluate_penalty_scaling(const DoFCellAccessorType &cell, const int iface, const dealii::hp::FECollection< dim > fe_collection) const
bool do_renumber_dofs
Flag for renumbering DOFs.
const unsigned int max_degree
Maximum degree used for p-refi1nement.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
Base metric operators class that stores functions used in both the volume and on surface.
real current_time
The current time set in set_current_time()
ESFR correction matrix for AUX EQUATION without jac dependence.
dealii::ConditionalOStream pcout
Parallel std::cout that only outputs on mpi_rank==0.
unsigned int get_max_fe_degree()
Gets the maximum value of currently active FE degree.
dealii::IndexSet ghost_dofs
Locally relevant ghost degrees of freedom.
The mapping shape functions evaluated at the desired nodes (facet set included in volume grid nodes f...
virtual void allocate_system(const bool compute_dRdW=true, const bool compute_dRdX=true, const bool compute_d2R=true)
Allocates the system.
bool use_manufactured_source_term
Uses non-zero source term based on the manufactured solution and the PDE.
virtual void allocate_dRdX()
Allocates the residual derivatives w.r.t the volume nodes.
const dealii::UpdateFlags face_update_flags
Update flags needed at face points.
std::shared_ptr< HighOrderGrid< dim, real, MeshType > > high_order_grid
High order grid that will provide the MappingFEField.
void build_1D_shape_functions_at_volume_flux_nodes(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Constructs the volume and volume gradient operator.
std::vector< real > project_function(const std::vector< real > &function_coeff, const dealii::FESystem< dim, dim > &fe_input, const dealii::FESystem< dim, dim > &fe_output, const dealii::QGauss< dim > &projection_quadrature)
Get the coefficients of a function projected onto a set of basis (to be replaced with operators->proj...
The metric independent FR mass matrix .
dealii::LinearAlgebra::distributed::Vector< double > solution_dRdX
dealii::TrilinosWrappers::SparseMatrix d2RdWdX
const unsigned int max_grid_degree
Maximum grid degree used for hp-refi1nement.
virtual void assemble_face_term_and_build_operators(typename dealii::DoFHandler< dim >::active_cell_iterator cell, typename dealii::DoFHandler< dim >::active_cell_iterator neighbor_cell, const dealii::types::global_dof_index current_cell_index, const dealii::types::global_dof_index neighbor_cell_index, const unsigned int iface, const unsigned int neighbor_iface, const real penalty, const std::vector< dealii::types::global_dof_index > ¤t_dofs_indices, const std::vector< dealii::types::global_dof_index > &neighbor_dofs_indices, const std::vector< dealii::types::global_dof_index > ¤t_metric_dofs_indices, const std::vector< dealii::types::global_dof_index > &neighbor_metric_dofs_indices, const unsigned int poly_degree_int, const unsigned int poly_degree_ext, const unsigned int grid_degree_int, const unsigned int grid_degree_ext, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim, real > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< real, dim, 2 *dim > &metric_oper_int, OPERATOR::metric_operators< real, dim, 2 *dim > &metric_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim, real > &mapping_basis, std::array< std::vector< real >, dim > &mapping_support_points, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_int, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_ext, dealii::Vector< real > ¤t_cell_rhs, dealii::Vector< real > &neighbor_cell_rhs, std::vector< dealii::Tensor< 1, dim, real >> ¤t_cell_rhs_aux, dealii::LinearAlgebra::distributed::Vector< double > &rhs, std::array< dealii::LinearAlgebra::distributed::Vector< double >, dim > &rhs_aux, const bool compute_auxiliary_right_hand_side, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R)=0
Builds the necessary operators/fe values and assembles face residual.
dealii::LinearAlgebra::distributed::Vector< double > dual_d2R
const dealii::UpdateFlags volume_update_flags
Update flags needed at volume points.
dealii::IndexSet locally_relevant_dofs
Union of locally owned degrees of freedom and relevant ghost degrees of freedom.
virtual void assemble_subface_term_and_build_operators(typename dealii::DoFHandler< dim >::active_cell_iterator cell, typename dealii::DoFHandler< dim >::active_cell_iterator neighbor_cell, const dealii::types::global_dof_index current_cell_index, const dealii::types::global_dof_index neighbor_cell_index, const unsigned int iface, const unsigned int neighbor_iface, const unsigned int neighbor_i_subface, const real penalty, const std::vector< dealii::types::global_dof_index > ¤t_dofs_indices, const std::vector< dealii::types::global_dof_index > &neighbor_dofs_indices, const std::vector< dealii::types::global_dof_index > ¤t_metric_dofs_indices, const std::vector< dealii::types::global_dof_index > &neighbor_metric_dofs_indices, const unsigned int poly_degree_int, const unsigned int poly_degree_ext, const unsigned int grid_degree_int, const unsigned int grid_degree_ext, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim, real > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< real, dim, 2 *dim > &metric_oper_int, OPERATOR::metric_operators< real, dim, 2 *dim > &metric_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim, real > &mapping_basis, std::array< std::vector< real >, dim > &mapping_support_points, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_int, dealii::hp::FESubfaceValues< dim, dim > &fe_values_collection_subface, dealii::Vector< real > ¤t_cell_rhs, dealii::Vector< real > &neighbor_cell_rhs, std::vector< dealii::Tensor< 1, dim, real >> ¤t_cell_rhs_aux, dealii::LinearAlgebra::distributed::Vector< double > &rhs, std::array< dealii::LinearAlgebra::distributed::Vector< double >, dim > &rhs_aux, const bool compute_auxiliary_right_hand_side, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R)=0
Builds the necessary operators/fe values and assembles subface residual.
dealii::SparsityPattern get_dRdX_sparsity_pattern()
Evaluate SparsityPattern of dRdX.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
dealii::FullMatrix< double > oneD_vol_operator
Stores the one dimensional volume operator.
static std::unique_ptr< dealii::DataPostprocessor< dim > > create_Postprocessor(const Parameters::AllParameters *const parameters_input)
Create the post-processor with the correct template parameters.
double kappa_artificial_dissipation
Parameter kappa from Persson and Peraire, 2008.
Flux_Reconstruction_Aux
Type of correction in Flux Reconstruction for the auxiliary variables.
void evaluate_local_metric_dependent_mass_matrix_and_set_in_global_mass_matrix(const bool Cartesian_element, const bool do_inverse_mass_matrix, const unsigned int poly_degree, const unsigned int curr_grid_degree, const unsigned int n_quad_pts, const unsigned int n_dofs_cell, const std::vector< dealii::types::global_dof_index > dofs_indices, OPERATOR::metric_operators< real, dim, 2 *dim > &metric_oper, OPERATOR::basis_functions< dim, 2 *dim, real > &basis, OPERATOR::local_mass< dim, 2 *dim, real > &reference_mass_matrix, OPERATOR::local_Flux_Reconstruction_operator< dim, 2 *dim, real > &reference_FR, OPERATOR::local_Flux_Reconstruction_operator_aux< dim, 2 *dim, real > &reference_FR_aux, OPERATOR::derivative_p< dim, 2 *dim, real > &deriv_p)
Evaluates the metric dependent local mass matrices and inverses, then sets them in the global matrice...
unsigned int current_degree
Stores the degree of the current poly degree.
void build_1D_surface_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 0 > &quadrature)
Assembles the one dimensional operator.
dealii::LinearAlgebra::distributed::Vector< double > volume_nodes_d2R
virtual void allocate_dual_vector()=0
Allocate the dual vector for optimization.
double mu_artificial_dissipation
Parameter mu from Persson & Peraire, 2008.
dealii::Vector< double > artificial_dissipation_se
Artificial dissipation error ratio sensor in each cell.
unsigned int current_degree
Stores the degree of the current poly degree.
unsigned int get_min_fe_degree()
Gets the minimum value of currently active FE degree.
RenumberDofsType
Renumber dofs type.
void set_high_order_grid(std::shared_ptr< HighOrderGrid< dim, real, MeshType >> new_high_order_grid)
Sets the associated high order grid with the provided one.
std::string solution_vtk_files_directory_name
Name of directory for writing solution vtk files.
The metric independent inverse of the FR mass matrix for auxiliary equation .
MassiveCollectionTuple create_collection_tuple(const unsigned int max_degree, const int nstate, const Parameters::AllParameters *const parameters_input) const
Used in the delegated constructor.
virtual void assemble_volume_term_and_build_operators(typename dealii::DoFHandler< dim >::active_cell_iterator cell, const dealii::types::global_dof_index current_cell_index, const std::vector< dealii::types::global_dof_index > &cell_dofs_indices, const std::vector< dealii::types::global_dof_index > &metric_dof_indices, const unsigned int poly_degree, const unsigned int grid_degree, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis, OPERATOR::local_basis_stiffness< dim, 2 *dim, real > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< real, dim, 2 *dim > &metric_oper, OPERATOR::mapping_shape_functions< dim, 2 *dim, real > &mapping_basis, std::array< std::vector< real >, dim > &mapping_support_points, dealii::hp::FEValues< dim, dim > &fe_values_collection_volume, dealii::hp::FEValues< dim, dim > &fe_values_collection_volume_lagrange, const dealii::FESystem< dim, dim > ¤t_fe_ref, dealii::Vector< real > &local_rhs_int_cell, std::vector< dealii::Tensor< 1, dim, real >> &local_auxiliary_RHS, const bool compute_auxiliary_right_hand_side, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R)=0
Builds the necessary operators/fe values and assembles volume residual.
virtual void set_use_auxiliary_eq()=0
Set use_auxiliary_eq flag.
Projection operator corresponding to basis functions onto -norm.
dealii::DoFHandler< dim > dof_handler
Finite Element Collection to represent the high-order grid.
FluxNodes flux_nodes_type
Store selected FluxNodes from the input file.
unsigned int current_degree
Stores the degree of the current poly degree.
dealii::FullMatrix< double > build_dim_Flux_Reconstruction_operator_directly(const int nstate, const unsigned int n_dofs, dealii::FullMatrix< double > &pth_deriv, dealii::FullMatrix< double > &mass_matrix)
Computes the dim sized flux reconstruction operator for general Mass Matrix (needed for curvilinear)...
dealii::SparsityPattern sparsity_pattern
Sparsity pattern used on the system_matrix.
void apply_global_mass_matrix(const dealii::LinearAlgebra::distributed::Vector< double > &input_vector, dealii::LinearAlgebra::distributed::Vector< double > &output_vector, const bool use_auxiliary_eq=false, const bool use_unmodified_mass_matrix=false)
Applies the local metric dependent mass matrices when the global is not stored.
dealii::SparsityPattern get_d2RdWdW_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdWdW.
void time_scale_solution_update(dealii::LinearAlgebra::distributed::Vector< double > &solution_update, const real CFL) const
Scales a solution update with the appropriate maximum time step.
bool add_artificial_dissipation
Flag to add artificial dissipation from Persson's shock capturing paper.
unsigned int current_degree
Stores the degree of the current poly degree.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
dealii::TrilinosWrappers::SparseMatrix system_matrix
void evaluate_mass_matrices(bool do_inverse_mass_matrix=false)
Allocates and evaluates the mass matrices for the entire grid.
const dealii::hp::FECollection< dim > fe_collection_lagrange
Lagrange basis used in strong form.
dealii::Vector< double > cell_volume
Time it takes for the maximum wavespeed to cross the cell domain.
bool current_cell_should_do_the_work(const DoFCellAccessorType1 ¤t_cell, const DoFCellAccessorType2 &neighbor_cell) const
In the case that two cells have the same coarseness, this function decides if the current cell should...
virtual void assemble_auxiliary_residual()=0
Asembles the auxiliary equations' residuals and solves.
double sipg_penalty_factor
Scaling of Symmetric Interior Penalty term to ensure coercivity.
void set_current_time(const real current_time_input)
Sets the current time within DG to be used for unsteady source terms.
dealii::FullMatrix< double > build_dim_Flux_Reconstruction_operator(const dealii::FullMatrix< double > &local_Mass_Matrix, const int nstate, const unsigned int n_dofs)
Computes the dim sized flux reconstruction operator with simplified tensor product form...
bool use_weight_adjusted_mass
Flag to use weight-adjusted Mass Matrix for curvilinear elements.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
bool use_periodic_bc
Flag to use periodic BC.
dealii::hp::QCollection< 1 > oneD_quadrature_collection
1D quadrature to generate Lagrange polynomials for the sake of flux interpolation.
std::array< dealii::LinearAlgebra::distributed::Vector< double >, dim > auxiliary_solution
The auxiliary equations' solution.
bool freeze_artificial_dissipation
Flag to freeze artificial dissipation.
dealii::TrilinosWrappers::SparseMatrix d2RdXdX
DGBase is independent of the number of state variables.
void allocate_artificial_dissipation()
Allocates variables of artificial dissipation.
void assemble_cell_residual(const DoFCellAccessorType1 ¤t_cell, const DoFCellAccessorType2 ¤t_metric_cell, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R, dealii::hp::FEValues< dim, dim > &fe_values_collection_volume, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_int, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_ext, dealii::hp::FESubfaceValues< dim, dim > &fe_values_collection_subface, dealii::hp::FEValues< dim, dim > &fe_values_collection_volume_lagrange, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim, real > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim, real > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim, real > &soln_basis_projection_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim, real > &mapping_basis, const bool compute_auxiliary_right_hand_side, dealii::LinearAlgebra::distributed::Vector< double > &rhs, std::array< dealii::LinearAlgebra::distributed::Vector< double >, dim > &rhs_aux)
Used in assemble_residual().
dealii::hp::QCollection< dim > volume_quadrature_collection
Finite Element Collection to represent the high-order grid.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
void set_all_cells_fe_degree(const unsigned int degree)
Refers to a collection Mappings, which represents the high-order grid.
unsigned int n_dofs() const
Number of degrees of freedom.
void build_1D_shape_functions_at_flux_nodes(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature, const dealii::Quadrature< 0 > &face_quadrature)
Constructs the volume, gradient, surface, and surface gradient operator.
ArtificialDissipationParam artificial_dissipation_param
Contains parameters for artificial dissipation.
codi_HessianComputationType RadFadType
Nested reverse-forward mode type for Jacobian and Hessian computation using TapeHelper.
void matrix_vector_mult_1D(const std::vector< real > &input_vect, std::vector< real > &output_vect, const dealii::FullMatrix< double > &basis_x, const bool adding=false, const double factor=1.0)
Apply the matrix vector operation using the 1D operator in each direction.
RenumberDofsType renumber_dofs_type
Store selected RenumberDofsType from the input file.
void build_1D_surface_gradient_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 0 > &quadrature)
Assembles the one dimensional operator.
const dealii::hp::FECollection< dim > fe_collection
Finite Element Collection for p-finite-element to represent the solution.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
std::tuple< dealii::hp::FECollection< dim >, dealii::hp::QCollection< dim >, dealii::hp::QCollection< dim-1 >, dealii::hp::FECollection< dim >, dealii::hp::FECollection< 1 >, dealii::hp::FECollection< 1 >, dealii::hp::FECollection< 1 >, dealii::hp::QCollection< 1 > > MassiveCollectionTuple
Makes for cleaner doxygen documentation.
unsigned int current_degree
Stores the degree of the current poly degree.
double max_artificial_dissipation_coeff
Stores maximum artificial dissipation while assembling the residual.
Projection operator corresponding to basis functions onto M-norm (L2).
dealii::LinearAlgebra::distributed::Vector< double > right_hand_side
Residual of the current solution.
void assemble_residual(const bool compute_dRdW=false, const bool compute_dRdX=false, const bool compute_d2R=false, const double CFL_mass=0.0)
Main loop of the DG class.
Local stiffness matrix without jacobian dependence.
dealii::TrilinosWrappers::SparseMatrix global_inverse_mass_matrix
Global inverser mass matrix.
FluxNodes
Flux nodes type.
void set_dual(const dealii::LinearAlgebra::distributed::Vector< real > &dual_input)
Sets the stored dual variables used to compute the dual dotted with the residual Hessians.
int overintegration
Number of additional quadrature points to use.
bool store_residual_cpu_time
Flag to store the residual local processor cput time.
const dealii::FE_Q< dim > fe_q_artificial_dissipation
Continuous distribution of artificial dissipation.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
void apply_inverse_global_mass_matrix(const dealii::LinearAlgebra::distributed::Vector< double > &input_vector, dealii::LinearAlgebra::distributed::Vector< double > &output_vector, const bool use_auxiliary_eq=false)
Applies the inverse of the local metric dependent mass matrices when the global is not stored...