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,
int nspecies,
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,nspecies,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,
int nspecies,
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,
int nspecies,
typename real,
typename MeshType>
120 template <
int dim,
int nspecies,
typename real,
typename MeshType>
131 template <
int dim,
int nspecies,
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);
263 template <
int dim,
int nspecies,
typename real,
typename MeshType>
266 std::vector<dealii::types::global_dof_index> dofs_indices;
270 if (!cell->is_locally_owned())
continue;
273 const int i_fele = cell->active_fe_index();
274 const dealii::FESystem<dim,dim> &fe_ref =
fe_collection[i_fele];
275 const unsigned int n_dofs_cell = fe_ref.n_dofs_per_cell();
277 dofs_indices.resize(n_dofs_cell);
278 cell->get_dof_indices (dofs_indices);
280 const dealii::types::global_dof_index cell_index = cell->active_cell_index();
283 for (
unsigned int idof = 0; idof < n_dofs_cell; ++idof) {
284 const dealii::types::global_dof_index dof_index = dofs_indices[idof];
285 solution_update[dof_index] *= dt;
291 template <
int dim,
int nspecies,
typename real,
typename MeshType>
297 if (cell->is_locally_owned()) cell->set_future_fe_index (degree);
303 template <
int dim,
int nspecies,
typename real,
typename MeshType>
306 unsigned int max_fe_degree = 0;
309 if(cell->is_locally_owned() && cell->active_fe_index() > max_fe_degree)
310 max_fe_degree = cell->active_fe_index();
312 return dealii::Utilities::MPI::max(max_fe_degree, MPI_COMM_WORLD);
315 template <
int dim,
int nspecies,
typename real,
typename MeshType>
321 if(cell->is_locally_owned() && cell->active_fe_index() < min_fe_degree)
322 min_fe_degree = cell->active_fe_index();
324 return dealii::Utilities::MPI::min(min_fe_degree, MPI_COMM_WORLD);
327 template <
int dim,
int nspecies,
typename real,
typename MeshType>
330 const int iproc = dealii::Utilities::MPI::this_mpi_process(
mpi_communicator);
331 const dealii::Point<dim> unit_vertex = dealii::GeometryInfo<dim>::unit_cell_vertex(0);
332 double current_cell_diameter;
333 double min_diameter_local =
high_order_grid->dof_handler_grid.begin_active()->diameter();
334 int max_cell_polynomial_order = 0;
335 int current_cell_polynomial_order = 0;
336 dealii::Point<dim> refined_cell_coord;
338 if(check_for_p_refined_cell)
340 for (
const auto &cell :
dof_handler.active_cell_iterators())
342 if(!cell->is_locally_owned())
continue;
343 current_cell_polynomial_order = cell->active_fe_index();
344 if ((current_cell_polynomial_order > max_cell_polynomial_order) && (cell->is_locally_owned()))
346 max_cell_polynomial_order = current_cell_polynomial_order;
347 refined_cell_coord = cell->center();
353 for (
const auto &cell :
high_order_grid->dof_handler_grid.active_cell_iterators())
355 if(!cell->is_locally_owned())
continue;
356 current_cell_diameter = cell->diameter();
357 if ((min_diameter_local > current_cell_diameter) && (cell->is_locally_owned()))
359 min_diameter_local = current_cell_diameter;
360 refined_cell_coord =
high_order_grid->mapping_fe_field->transform_unit_to_real_cell(cell, unit_vertex);
365 dealii::Utilities::MPI::MinMaxAvg indexstore;
366 int processor_containing_refined_cell;
368 if(check_for_p_refined_cell)
370 indexstore = dealii::Utilities::MPI::min_max_avg(max_cell_polynomial_order,
mpi_communicator);
371 processor_containing_refined_cell = indexstore.max_index;
375 indexstore = dealii::Utilities::MPI::min_max_avg(min_diameter_local,
mpi_communicator);
376 processor_containing_refined_cell = indexstore.min_index;
379 double global_point[dim];
381 if (iproc == processor_containing_refined_cell)
383 for (
int i=0; i<dim; i++)
384 global_point[i] = refined_cell_coord[i];
387 MPI_Bcast(global_point, dim, MPI_DOUBLE, processor_containing_refined_cell,
mpi_communicator);
389 for (
int i=0; i<dim; i++)
390 refined_cell_coord[i] = global_point[i];
392 return refined_cell_coord;
395 template <
int dim,
int nspecies,
typename real,
typename MeshType>
396 template<
typename DoFCellAccessorType>
398 const DoFCellAccessorType &cell,
403 const unsigned int fe_index = cell->active_fe_index();
404 const unsigned int degree = fe_collection[fe_index].tensor_degree();
405 const unsigned int degsq = (degree == 0) ? 1 : degree * (degree+1);
407 const unsigned int normal_direction = dealii::GeometryInfo<dim>::unit_normal_direction[iface];
408 const real vol_div_facearea = cell->extent_in_direction(normal_direction);
415 template <
int dim,
int nspecies,
typename real,
typename MeshType>
416 template<
typename DoFCellAccessorType1,
typename DoFCellAccessorType2>
418 const DoFCellAccessorType1 ¤t_cell,
419 const DoFCellAccessorType2 &neighbor_cell)
const 421 if (neighbor_cell->has_children()) {
424 AssertDimension(dim,1);
426 }
else if (neighbor_cell->is_ghost()) {
430 return (current_cell->subdomain_id() < neighbor_cell->subdomain_id());
434 Assert(neighbor_cell->is_locally_owned(), dealii::ExcMessage(
"If not ghost, neighbor should be locally owned."));
436 if (current_cell->index() < neighbor_cell->index()) {
439 }
else if (neighbor_cell->index() == current_cell->index()) {
443 return (current_cell->level() < neighbor_cell->level());
447 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."));
451 template <
int dim,
int nspecies,
typename real,
typename MeshType>
452 template<
typename adtype>
454 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<dim, dim, false>> ¤t_cell,
455 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<dim, dim, false>> ¤t_metric_cell,
456 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
457 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume,
458 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_int,
459 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_ext,
460 dealii::hp::FESubfaceValues<dim,dim> &fe_values_collection_subface,
461 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume_lagrange,
470 const bool compute_auxiliary_right_hand_side,
471 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
472 std::array<dealii::LinearAlgebra::distributed::Vector<double>,dim> &rhs_aux)
474 std::vector<dealii::types::global_dof_index> current_dofs_indices;
475 std::vector<dealii::types::global_dof_index> neighbor_dofs_indices;
478 const int i_fele = current_cell->active_fe_index();
480 const dealii::FESystem<dim,dim> ¤t_fe_ref =
fe_collection[i_fele];
481 const unsigned int n_dofs_curr_cell = current_fe_ref.n_dofs_per_cell();
484 std::vector<real> current_cell_rhs (n_dofs_curr_cell);
486 dealii::Tensor<1,dim,std::vector<real>> current_cell_rhs_aux;
487 if(compute_auxiliary_right_hand_side){
488 for(
int idim=0; idim<dim; idim++){
489 current_cell_rhs_aux[idim].resize(n_dofs_curr_cell);
494 current_dofs_indices.resize(n_dofs_curr_cell);
495 current_cell->get_dof_indices (current_dofs_indices);
497 const unsigned int grid_degree = this->
high_order_grid->fe_system.tensor_degree();
498 const unsigned int poly_degree = i_fele;
500 const unsigned int n_metric_dofs_cell =
high_order_grid->fe_system.dofs_per_cell;
501 std::vector<dealii::types::global_dof_index> current_metric_dofs_indices(n_metric_dofs_cell);
502 std::vector<dealii::types::global_dof_index> neighbor_metric_dofs_indices(n_metric_dofs_cell);
503 current_metric_cell->get_dof_indices (current_metric_dofs_indices);
505 const dealii::types::global_dof_index current_cell_index = current_cell->active_cell_index();
513 && (this->all_parameters->ode_solver_param.ode_solver_type
514 == Parameters::ODESolverParam::ODESolverEnum::implicit_solver)
515 && (this->use_auxiliary_eq || this->all_parameters->using_wall_model))
519 pcout<<
"ERROR: Implicit does not currently work for strong form with Auxiliary Equation. The added terms dR/dq * dq/du needs to be added. Aborting..."<<std::endl;
523 pcout<<
"ERROR: Implicit does not currently work for strong form with wall model. The Jacobian dR/du does not account for the neighboring solution at the wall. Aborting..."<<std::endl;
528 std::array<std::vector<adtype>,dim> mapping_support_points;
533 current_dofs_indices,
534 current_metric_dofs_indices,
539 flux_basis_stiffness,
540 soln_basis_projection_oper_int,
541 soln_basis_projection_oper_ext,
544 mapping_support_points,
545 fe_values_collection_volume,
546 fe_values_collection_volume_lagrange,
549 current_cell_rhs_aux,
550 compute_auxiliary_right_hand_side,
551 compute_dRdW, compute_dRdX, compute_d2R);
553 (void) fe_values_collection_face_int;
554 (void) fe_values_collection_face_ext;
555 (void) fe_values_collection_subface;
556 for (
unsigned int iface=0; iface < dealii::GeometryInfo<dim>::faces_per_cell; ++iface) {
558 auto current_face = current_cell->face(iface);
561 if ((current_face->at_boundary() && !current_cell->has_periodic_neighbor(iface)))
565 const unsigned int boundary_id = current_face->boundary_id();
573 current_dofs_indices,
574 current_metric_dofs_indices,
579 soln_basis_projection_oper_int,
582 mapping_support_points,
583 fe_values_collection_face_int,
586 current_cell_rhs_aux,
587 compute_auxiliary_right_hand_side,
588 compute_dRdW, compute_dRdX, compute_d2R);
593 else if (current_face->at_boundary() && current_cell->has_periodic_neighbor(iface))
596 const auto neighbor_cell = current_cell->periodic_neighbor(iface);
600 Assert (current_cell->periodic_neighbor(iface).state() == dealii::IteratorState::valid, dealii::ExcInternalError());
602 const unsigned int n_dofs_neigh_cell =
fe_collection[neighbor_cell->active_fe_index()].n_dofs_per_cell();
603 std::vector<real> neighbor_cell_rhs (n_dofs_neigh_cell);
606 neighbor_dofs_indices.resize(n_dofs_neigh_cell);
607 neighbor_cell->get_dof_indices (neighbor_dofs_indices);
610 const unsigned int neighbor_iface = current_cell->periodic_neighbor_of_periodic_neighbor(iface);
612 const int i_fele_n = neighbor_cell->active_fe_index();
617 const real penalty = 0.5 * (penalty1 + penalty2);
619 const dealii::types::global_dof_index neighbor_cell_index = neighbor_cell->active_cell_index();
620 const auto metric_neighbor_cell = current_metric_cell->periodic_neighbor(iface);
621 metric_neighbor_cell->get_dof_indices(neighbor_metric_dofs_indices);
623 const unsigned int poly_degree_ext = i_fele_n;
624 const unsigned int grid_degree_ext = this->
high_order_grid->fe_system.tensor_degree();
630 const dealii::FESystem<dim,dim> &neighbor_fe_ref =
fe_collection[i_fele_n];
639 fe_values_collection_face_int,
640 fe_values_collection_face_ext,
641 fe_values_collection_subface,
644 current_dofs_indices,
645 neighbor_dofs_indices,
646 current_metric_dofs_indices,
647 neighbor_metric_dofs_indices,
656 flux_basis_stiffness,
657 soln_basis_projection_oper_int,
658 soln_basis_projection_oper_ext,
662 mapping_support_points,
665 current_cell_rhs_aux,
668 compute_auxiliary_right_hand_side,
669 compute_dRdW, compute_dRdX, compute_d2R);
674 else if (current_cell->face(iface)->has_children())
681 else if (current_cell->neighbor(iface)->face(current_cell->neighbor_face_no(iface))->has_children())
683 Assert (current_cell->neighbor(iface).state() == dealii::IteratorState::valid, dealii::ExcInternalError());
684 Assert (!(current_cell->neighbor(iface)->has_children()), dealii::ExcInternalError());
687 const auto neighbor_cell = current_cell->neighbor(iface);
688 const unsigned int neighbor_iface = current_cell->neighbor_face_no(iface);
691 unsigned int neighbor_i_subface = 0;
692 unsigned int n_subface = dealii::GeometryInfo<dim>::n_subfaces(neighbor_cell->subface_case(neighbor_iface));
694 for (; neighbor_i_subface < n_subface; ++neighbor_i_subface) {
695 if (neighbor_cell->neighbor_child_on_subface (neighbor_iface, neighbor_i_subface) == current_cell) {
699 Assert(neighbor_i_subface != n_subface, dealii::ExcInternalError());
701 const int i_fele_n = neighbor_cell->active_fe_index();
703 const unsigned int n_dofs_neigh_cell =
fe_collection[i_fele_n].n_dofs_per_cell();
704 std::vector<real> neighbor_cell_rhs (n_dofs_neigh_cell);
707 neighbor_dofs_indices.resize(n_dofs_neigh_cell);
708 neighbor_cell->get_dof_indices (neighbor_dofs_indices);
712 const real penalty = 0.5 * (penalty1 + penalty2);
714 const dealii::types::global_dof_index neighbor_cell_index = neighbor_cell->active_cell_index();
715 const auto metric_neighbor_cell = current_metric_cell->neighbor(iface);
716 metric_neighbor_cell->get_dof_indices(neighbor_metric_dofs_indices);
718 const unsigned int poly_degree_ext = i_fele_n;
719 const unsigned int grid_degree_ext = this->
high_order_grid->fe_system.tensor_degree();
725 const dealii::FESystem<dim,dim> &neighbor_fe_ref =
fe_collection[i_fele_n];
734 fe_values_collection_face_int,
735 fe_values_collection_face_ext,
736 fe_values_collection_subface,
739 current_dofs_indices,
740 neighbor_dofs_indices,
741 current_metric_dofs_indices,
742 neighbor_metric_dofs_indices,
751 flux_basis_stiffness,
752 soln_basis_projection_oper_int,
753 soln_basis_projection_oper_ext,
757 mapping_support_points,
760 current_cell_rhs_aux,
763 compute_auxiliary_right_hand_side,
764 compute_dRdW, compute_dRdX, compute_d2R,
772 Assert (current_cell->neighbor(iface).state() == dealii::IteratorState::valid, dealii::ExcInternalError());
774 const auto neighbor_cell = current_cell->neighbor_or_periodic_neighbor(iface);
777 const unsigned int neighbor_iface = current_cell->neighbor_of_neighbor(iface);
780 const unsigned int n_dofs_neigh_cell =
fe_collection[neighbor_cell->active_fe_index()].n_dofs_per_cell();
783 std::vector<real> neighbor_cell_rhs (n_dofs_neigh_cell);
786 neighbor_dofs_indices.resize(n_dofs_neigh_cell);
787 neighbor_cell->get_dof_indices (neighbor_dofs_indices);
789 const int i_fele_n = neighbor_cell->active_fe_index();
794 const real penalty = 0.5 * (penalty1 + penalty2);
796 const dealii::types::global_dof_index neighbor_cell_index = neighbor_cell->active_cell_index();
797 const auto metric_neighbor_cell = current_metric_cell->neighbor_or_periodic_neighbor(iface);
798 metric_neighbor_cell->get_dof_indices(neighbor_metric_dofs_indices);
800 const unsigned int poly_degree_ext = i_fele_n;
803 const unsigned int grid_degree_ext = this->
high_order_grid->fe_system.tensor_degree();
809 const dealii::FESystem<dim,dim> &neighbor_fe_ref =
fe_collection[i_fele_n];
818 fe_values_collection_face_int,
819 fe_values_collection_face_ext,
820 fe_values_collection_subface,
823 current_dofs_indices,
824 neighbor_dofs_indices,
825 current_metric_dofs_indices,
826 neighbor_metric_dofs_indices,
835 flux_basis_stiffness,
836 soln_basis_projection_oper_int,
837 soln_basis_projection_oper_ext,
841 mapping_support_points,
844 current_cell_rhs_aux,
847 compute_auxiliary_right_hand_side,
848 compute_dRdW, compute_dRdX, compute_d2R);
856 if(compute_auxiliary_right_hand_side) {
858 for(
int idim=0; idim<dim; idim++){
859 for (
unsigned int idof=0; idof<n_dofs_curr_cell; ++idof) {
860 rhs_aux[idim][current_dofs_indices[idof]] += current_cell_rhs_aux[idim][idof];
866 for (
unsigned int idof=0; idof<n_dofs_curr_cell; ++idof) {
867 rhs[current_dofs_indices[idof]] += current_cell_rhs[idof];
873 template <
int dim,
int nspecies,
typename real,
typename MeshType>
875 typename dealii::DoFHandler<dim>::active_cell_iterator cell,
876 const dealii::types::global_dof_index current_cell_index,
877 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices,
878 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices,
879 const unsigned int poly_degree,
880 const unsigned int grid_degree,
888 std::array<std::vector<double>,dim> &mapping_support_points,
889 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume,
890 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume_lagrange,
891 const dealii::FESystem<dim,dim> &fe_soln,
892 std::vector<real> &local_rhs_cell,
893 dealii::Tensor<1,dim,std::vector<real>> &local_auxiliary_RHS,
894 const bool compute_auxiliary_right_hand_side,
895 const bool ,
const bool ,
const bool )
897 const unsigned int n_soln_dofs = fe_soln.dofs_per_cell;
899 AssertDimension (n_soln_dofs, soln_dofs_indices.size());
901 const unsigned int n_metric_dofs = this->
high_order_grid->fe_system.dofs_per_cell;
903 std::vector<real> local_dual(n_soln_dofs);
904 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
905 local_dual[itest] = 0.0;
908 std::vector<double> local_solution(n_soln_dofs);
909 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
910 local_solution[idof] = this->
solution(soln_dofs_indices[idof]);
913 std::vector<double> local_metric_coeff_int(n_metric_dofs);
914 for(
unsigned int idof=0; idof<n_metric_dofs; ++idof)
916 local_metric_coeff_int[idof] = this->
high_order_grid->volume_nodes[metric_dofs_indices[idof]];
921 dealii::Tensor<1,dim,std::vector<double>> local_aux_solution;
922 for(
unsigned int idim=0; idim<dim; idim++){
923 local_aux_solution[idim].resize(n_soln_dofs);
924 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
926 local_aux_solution[idim][idof] = this->
auxiliary_solution[idim](soln_dofs_indices[idof]);
931 double dual_dot_residual = 0.0;
932 std::vector<double> rhs(n_soln_dofs);
933 dealii::Tensor<1,dim,std::vector<double>> rhs_aux;
934 if(compute_auxiliary_right_hand_side){
935 for(
int idim=0; idim<dim; idim++){
936 rhs_aux[idim].resize(n_soln_dofs);
944 local_metric_coeff_int,
952 flux_basis_stiffness,
953 soln_basis_projection_oper_int,
954 soln_basis_projection_oper_ext,
957 mapping_support_points,
958 fe_values_collection_volume,
959 fe_values_collection_volume_lagrange,
963 compute_auxiliary_right_hand_side,
967 if(compute_auxiliary_right_hand_side){
968 for(
int idim=0; idim<dim; idim++){
969 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
970 local_auxiliary_RHS[idim][itest] += rhs_aux[idim][itest];
975 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
976 local_rhs_cell[itest] += rhs[itest];
982 template <
int dim,
int nspecies,
typename real,
typename MeshType>
983 template <
typename adtype>
984 typename std::enable_if<!std::is_same<adtype, double>::value,
void>::type
986 typename dealii::DoFHandler<dim>::active_cell_iterator cell,
987 const dealii::types::global_dof_index current_cell_index,
988 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices,
989 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices,
990 const unsigned int poly_degree,
991 const unsigned int grid_degree,
999 std::array<std::vector<adtype>,dim> &mapping_support_points,
1000 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume,
1001 dealii::hp::FEValues<dim,dim> &fe_values_collection_volume_lagrange,
1002 const dealii::FESystem<dim,dim> &fe_soln,
1003 std::vector<real> &local_rhs_cell,
1004 dealii::Tensor<1,dim,std::vector<real>> &local_auxiliary_RHS,
1005 const bool compute_auxiliary_right_hand_side,
1006 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R)
1008 const unsigned int n_soln_dofs = fe_soln.dofs_per_cell;
1010 AssertDimension (n_soln_dofs, soln_dofs_indices.size());
1012 const unsigned int n_metric_dofs = this->
high_order_grid->fe_system.dofs_per_cell;
1014 std::vector<real> local_dual(n_soln_dofs);
1015 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1016 const unsigned int global_residual_row = soln_dofs_indices[itest];
1018 local_dual[itest] = this->
dual[global_residual_row];
1022 unsigned int w_start=0, w_end=0, x_start=0, x_end=0;
1023 if(compute_dRdW || compute_dRdX || compute_d2R)
1026 n_soln_dofs, n_metric_dofs,
1027 w_start, w_end, x_start, x_end );
1030 using TH = codi::TapeHelper<adtype>;
1032 typename adtype::TapeType &tape = adtype::getGlobalTape();
1033 if (compute_dRdW || compute_dRdX || compute_d2R) {
1034 th.startRecording();
1037 std::vector<adtype> local_solution(n_soln_dofs);
1038 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1039 const real val = this->
solution(soln_dofs_indices[idof]);
1040 local_solution[idof] = val;
1042 if (compute_dRdW || compute_d2R) {
1043 th.registerInput(local_solution[idof]);
1045 tape.deactivateValue(local_solution[idof]);
1049 std::vector<adtype> local_metric_coeff_int(n_metric_dofs);
1050 for(
unsigned int idof=0; idof<n_metric_dofs; ++idof)
1052 const real val = this->
high_order_grid->volume_nodes[metric_dofs_indices[idof]];
1053 local_metric_coeff_int[idof] = val;
1054 if (compute_dRdX || compute_d2R) {
1055 th.registerInput(local_metric_coeff_int[idof]);
1057 tape.deactivateValue(local_metric_coeff_int[idof]);
1063 dealii::Tensor<1,dim,std::vector<adtype>> local_aux_solution;
1064 for(
unsigned int idim=0; idim<dim; idim++){
1065 local_aux_solution[idim].resize(n_soln_dofs);
1066 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1069 local_aux_solution[idim][idof] = val;
1071 tape.deactivateValue(local_aux_solution[idim][idof]);
1082 adtype dual_dot_residual = 0.0;
1083 std::vector<adtype> rhs(n_soln_dofs);
1084 dealii::Tensor<1,dim,std::vector<adtype>> rhs_aux;
1085 if(compute_auxiliary_right_hand_side){
1086 for(
int idim=0; idim<dim; idim++){
1087 rhs_aux[idim].resize(n_soln_dofs);
1095 local_metric_coeff_int,
1098 metric_dofs_indices,
1103 flux_basis_stiffness,
1104 soln_basis_projection_oper_int,
1105 soln_basis_projection_oper_ext,
1108 mapping_support_points,
1109 fe_values_collection_volume,
1110 fe_values_collection_volume_lagrange,
1114 compute_auxiliary_right_hand_side,
1117 if (compute_dRdW || compute_dRdX) {
1128 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1129 th.registerOutput(rhs[itest]);
1132 }
else if (compute_d2R) {
1133 th.registerOutput(dual_dot_residual);
1136 if (compute_dRdW || compute_dRdX || compute_d2R) {
1140 if(compute_auxiliary_right_hand_side){
1141 for(
int idim=0; idim<dim; idim++){
1142 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1143 local_auxiliary_RHS[idim][itest] += getValue<adtype>(rhs_aux[idim][itest]);
1144 AssertIsFinite(local_auxiliary_RHS[idim][itest]);
1149 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1150 local_rhs_cell[itest] += getValue<adtype>(rhs[itest]);
1151 AssertIsFinite(local_rhs_cell[itest]);
1156 typename TH::JacobianType& jac = th.createJacobian();
1157 th.evalJacobian(jac);
1158 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1160 std::vector<real> residual_derivatives(n_soln_dofs);
1161 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1162 const unsigned int i_dx = idof+w_start;
1163 residual_derivatives[idof] = jac(itest,i_dx);
1164 AssertIsFinite(residual_derivatives[idof]);
1166 const bool elide_zero_values =
false;
1167 this->
system_matrix.add(soln_dofs_indices[itest], soln_dofs_indices, residual_derivatives, elide_zero_values);
1169 th.deleteJacobian(jac);
1173 typename TH::JacobianType& jac = th.createJacobian();
1174 th.evalJacobian(jac);
1175 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1176 std::vector<real> residual_derivatives(n_metric_dofs);
1177 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1178 const unsigned int i_dx = idof+x_start;
1179 residual_derivatives[idof] = jac(itest,i_dx);
1181 this->
dRdXv.add(soln_dofs_indices[itest], metric_dofs_indices, residual_derivatives);
1183 th.deleteJacobian(jac);
1187 typename TH::HessianType& hes = th.createHessian();
1188 th.evalHessian(hes);
1190 int i_dependent = (compute_dRdW || compute_dRdX) ? n_soln_dofs : 0;
1192 std::vector<real> dWidW(n_soln_dofs);
1193 std::vector<real> dWidX(n_metric_dofs);
1194 std::vector<real> dXidX(n_metric_dofs);
1196 for (
unsigned int idof=0; idof<n_soln_dofs; ++idof) {
1198 const unsigned int i_dx = idof+w_start;
1200 for (
unsigned int jdof=0; jdof<n_soln_dofs; ++jdof) {
1201 const unsigned int j_dx = jdof+w_start;
1202 dWidW[jdof] = hes(i_dependent,i_dx,j_dx);
1204 this->
d2RdWdW.add(soln_dofs_indices[idof], soln_dofs_indices, dWidW);
1206 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
1207 const unsigned int j_dx = jdof+x_start;
1208 dWidX[jdof] = hes(i_dependent,i_dx,j_dx);
1210 this->
d2RdWdX.add(soln_dofs_indices[idof], metric_dofs_indices, dWidX);
1213 for (
unsigned int idof=0; idof<n_metric_dofs; ++idof) {
1215 const unsigned int i_dx = idof+x_start;
1217 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
1218 const unsigned int j_dx = jdof+x_start;
1219 dXidX[jdof] = hes(i_dependent,i_dx,j_dx);
1221 this->
d2RdXdX.add(metric_dofs_indices[idof], metric_dofs_indices, dXidX);
1224 th.deleteHessian(hes);
1227 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1228 tape.deactivateValue(local_solution[idof]);
1230 for(
int idim=0; idim<dim; idim++){
1231 tape.deactivateValue(local_aux_solution[idim][idof]);
1235 for(
unsigned int idof=0; idof<n_metric_dofs; ++idof)
1237 tape.deactivateValue(local_metric_coeff_int[idof]);
1243 template <
int dim,
int nspecies,
typename real,
typename MeshType>
1244 template <
typename adtype>
1245 typename std::enable_if<!std::is_same<adtype, double>::value,
void>::type
1247 typename dealii::DoFHandler<dim>::active_cell_iterator cell,
1248 const dealii::types::global_dof_index current_cell_index,
1249 const unsigned int iface,
1250 const unsigned int boundary_id,
1252 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices,
1253 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices,
1254 const unsigned int poly_degree,
1255 const unsigned int grid_degree,
1261 std::array<std::vector<adtype>,dim> &mapping_support_points,
1262 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_int,
1263 const dealii::FESystem<dim,dim> &fe_soln,
1264 std::vector<real> &local_rhs_cell,
1265 dealii::Tensor<1,dim,std::vector<real>> &local_auxiliary_RHS,
1266 const bool compute_auxiliary_right_hand_side,
1267 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R)
1269 const unsigned int n_soln_dofs = fe_soln.dofs_per_cell;
1270 const unsigned int n_metric_dofs = this->
high_order_grid->fe_system.dofs_per_cell;
1272 AssertDimension (n_soln_dofs, soln_dofs_indices.size());
1274 unsigned int w_start=0, w_end=0, x_start=0, x_end=0;
1275 if(compute_dRdW || compute_dRdX || compute_d2R)
1278 n_soln_dofs, n_metric_dofs,
1279 w_start, w_end, x_start, x_end );
1282 using TH = codi::TapeHelper<adtype>;
1284 typename adtype::TapeType &tape = adtype::getGlobalTape();
1285 if (compute_dRdW || compute_dRdX || compute_d2R) {
1286 th.startRecording();
1289 std::vector<adtype> local_solution(fe_soln.dofs_per_cell);
1290 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1291 const real val = this->
solution(soln_dofs_indices[idof]);
1292 local_solution[idof] = val;
1294 if (compute_dRdW || compute_d2R) {
1295 th.registerInput(local_solution[idof]);
1297 tape.deactivateValue(local_solution[idof]);
1301 std::vector<adtype> local_metric_coeff(n_metric_dofs);
1302 for(
unsigned int idof=0; idof<n_metric_dofs; ++idof)
1304 const real val = this->
high_order_grid->volume_nodes[metric_dofs_indices[idof]];
1305 local_metric_coeff[idof] = val;
1306 if (compute_dRdX || compute_d2R) {
1307 th.registerInput(local_metric_coeff[idof]);
1309 tape.deactivateValue(local_metric_coeff[idof]);
1313 if(compute_dRdX || compute_d2R)
1318 dealii::Tensor<1,dim,std::vector<adtype>> local_aux_solution;
1319 for(
int idim=0; idim<dim; idim++){
1320 local_aux_solution[idim].resize(n_soln_dofs);
1321 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1324 local_aux_solution[idim][idof] = val;
1326 tape.deactivateValue(local_aux_solution[idim][idof]);
1338 std::vector<real> local_dual(n_soln_dofs);
1339 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1341 local_dual[itest] = this->
dual[soln_dofs_indices[itest]];
1344 std::vector<adtype> rhs(n_soln_dofs);
1345 dealii::Tensor<1,dim,std::vector<adtype>> aux_rhs;
1346 if(compute_auxiliary_right_hand_side){
1347 for(
int idim=0; idim<dim; idim++){
1348 aux_rhs[idim].resize(n_soln_dofs);
1351 adtype dual_dot_residual = 0.0;
1365 soln_basis_projection_oper_int,
1368 mapping_support_points,
1369 fe_values_collection_face_int,
1374 compute_auxiliary_right_hand_side,
1377 if (compute_dRdW || compute_dRdX) {
1388 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1389 th.registerOutput(rhs[itest]);
1392 }
else if (compute_d2R) {
1393 th.registerOutput(dual_dot_residual);
1396 if (compute_dRdW || compute_dRdX || compute_d2R) {
1400 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1401 local_rhs_cell[itest] += getValue<adtype>(rhs[itest]);
1402 AssertIsFinite(local_rhs_cell[itest]);
1405 if(compute_auxiliary_right_hand_side){
1406 for(
int idim=0; idim<dim; idim++){
1407 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1408 local_auxiliary_RHS[idim][itest] += getValue<adtype>(aux_rhs[idim][itest]);
1409 AssertIsFinite(local_auxiliary_RHS[idim][itest]);
1415 typename TH::JacobianType& jac = th.createJacobian();
1416 th.evalJacobian(jac);
1417 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1419 std::vector<real> residual_derivatives(n_soln_dofs);
1420 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1421 const unsigned int i_dx = idof+w_start;
1422 residual_derivatives[idof] = jac(itest,i_dx);
1423 AssertIsFinite(residual_derivatives[idof]);
1425 const bool elide_zero_values =
false;
1426 this->
system_matrix.add(soln_dofs_indices[itest], soln_dofs_indices, residual_derivatives, elide_zero_values);
1428 th.deleteJacobian(jac);
1433 typename TH::JacobianType& jac = th.createJacobian();
1434 th.evalJacobian(jac);
1435 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1436 std::vector<real> residual_derivatives(n_metric_dofs);
1437 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1438 const unsigned int i_dx = idof+x_start;
1439 residual_derivatives[idof] = jac(itest,i_dx);
1441 this->
dRdXv.add(soln_dofs_indices[itest], metric_dofs_indices, residual_derivatives);
1443 th.deleteJacobian(jac);
1447 typename TH::HessianType& hes = th.createHessian();
1448 th.evalHessian(hes);
1450 int i_dependent = (compute_dRdW || compute_dRdX) ? n_soln_dofs : 0;
1452 std::vector<real> dWidW(n_soln_dofs);
1453 std::vector<real> dWidX(n_metric_dofs);
1454 std::vector<real> dXidX(n_metric_dofs);
1456 for (
unsigned int idof=0; idof<n_soln_dofs; ++idof) {
1458 const unsigned int i_dx = idof+w_start;
1460 for (
unsigned int jdof=0; jdof<n_soln_dofs; ++jdof) {
1461 const unsigned int j_dx = jdof+w_start;
1462 dWidW[jdof] = hes(i_dependent,i_dx,j_dx);
1464 this->
d2RdWdW.add(soln_dofs_indices[idof], soln_dofs_indices, dWidW);
1466 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
1467 const unsigned int j_dx = jdof+x_start;
1468 dWidX[jdof] = hes(i_dependent,i_dx,j_dx);
1470 this->
d2RdWdX.add(soln_dofs_indices[idof], metric_dofs_indices, dWidX);
1473 for (
unsigned int idof=0; idof<n_metric_dofs; ++idof) {
1475 const unsigned int i_dx = idof+x_start;
1477 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
1478 const unsigned int j_dx = jdof+x_start;
1479 dXidX[jdof] = hes(i_dependent,i_dx,j_dx);
1481 this->
d2RdXdX.add(metric_dofs_indices[idof], metric_dofs_indices, dXidX);
1484 th.deleteHessian(hes);
1487 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1488 tape.deactivateValue(local_solution[idof]);
1490 for(
int idim=0; idim<dim; idim++){
1491 tape.deactivateValue(local_aux_solution[idim][idof]);
1494 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1495 tape.deactivateValue(local_metric_coeff[idof]);
1501 template <
int dim,
int nspecies,
typename real,
typename MeshType>
1503 typename dealii::DoFHandler<dim>::active_cell_iterator cell,
1504 const dealii::types::global_dof_index current_cell_index,
1505 const unsigned int iface,
1506 const unsigned int boundary_id,
1508 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices,
1509 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices,
1510 const unsigned int poly_degree,
1511 const unsigned int grid_degree,
1517 std::array<std::vector<double>,dim> &mapping_support_points,
1518 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_int,
1519 const dealii::FESystem<dim,dim> &fe_soln,
1520 std::vector<real> &local_rhs_cell,
1521 dealii::Tensor<1,dim,std::vector<real>> &local_auxiliary_RHS,
1522 const bool compute_auxiliary_right_hand_side,
1523 const bool ,
const bool ,
const bool )
1525 const unsigned int n_soln_dofs = fe_soln.dofs_per_cell;
1526 const unsigned int n_metric_dofs = this->
high_order_grid->fe_system.dofs_per_cell;
1528 AssertDimension (n_soln_dofs, soln_dofs_indices.size());
1530 std::vector<double> local_solution(fe_soln.dofs_per_cell);
1531 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1532 local_solution[idof] = this->
solution(soln_dofs_indices[idof]);
1535 std::vector<double> local_metric_coeff(n_metric_dofs);
1536 for(
unsigned int idof=0; idof<n_metric_dofs; ++idof)
1538 local_metric_coeff[idof] = this->
high_order_grid->volume_nodes[metric_dofs_indices[idof]];
1541 dealii::Tensor<1,dim,std::vector<double>> local_aux_solution;
1542 for(
int idim=0; idim<dim; idim++){
1543 local_aux_solution[idim].resize(n_soln_dofs);
1544 for (
unsigned int idof = 0; idof < n_soln_dofs; ++idof) {
1546 local_aux_solution[idim][idof] = this->
auxiliary_solution[idim](soln_dofs_indices[idof]);
1551 std::vector<real> local_dual(n_soln_dofs);
1552 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1553 local_dual[itest] = 0.0;
1556 std::vector<double> rhs(n_soln_dofs);
1557 dealii::Tensor<1,dim,std::vector<double>> aux_rhs;
1558 if(compute_auxiliary_right_hand_side){
1559 for(
int idim=0; idim<dim; idim++){
1560 aux_rhs[idim].resize(n_soln_dofs);
1563 double dual_dot_residual = 0.0;
1577 soln_basis_projection_oper_int,
1580 mapping_support_points,
1581 fe_values_collection_face_int,
1586 compute_auxiliary_right_hand_side,
1589 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1590 local_rhs_cell[itest] += rhs[itest];
1593 if(compute_auxiliary_right_hand_side){
1594 for(
int idim=0; idim<dim; idim++){
1595 for (
unsigned int itest=0; itest<n_soln_dofs; ++itest) {
1596 local_auxiliary_RHS[idim][itest] += aux_rhs[idim][itest];
1604 template <
int dim,
int nspecies,
typename real,
typename MeshType>
1605 template <
typename adtype>
1606 typename std::enable_if<!std::is_same<adtype, double>::value,
void>::type
1608 typename dealii::DoFHandler<dim>::active_cell_iterator cell,
1609 typename dealii::DoFHandler<dim>::active_cell_iterator neighbor_cell,
1610 const dealii::types::global_dof_index current_cell_index,
1611 const dealii::types::global_dof_index neighbor_cell_index,
1612 const unsigned int iface,
1613 const unsigned int neighbor_iface,
1615 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_int,
1616 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_ext,
1617 dealii::hp::FESubfaceValues<dim,dim> &fe_values_collection_subface,
1618 const dealii::FESystem<dim,dim> &fe_int,
1619 const dealii::FESystem<dim,dim> &fe_ext,
1620 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices_int,
1621 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices_ext,
1622 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices_int,
1623 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices_ext,
1624 const unsigned int poly_degree_int,
1625 const unsigned int poly_degree_ext,
1626 const unsigned int grid_degree_int,
1627 const unsigned int grid_degree_ext,
1638 std::array<std::vector<adtype>,dim> &mapping_support_points,
1639 std::vector<real> &local_rhs_int_cell,
1640 std::vector<real> &local_rhs_ext_cell,
1641 dealii::Tensor<1,dim,std::vector<real>> ¤t_cell_rhs_aux,
1642 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
1643 std::array<dealii::LinearAlgebra::distributed::Vector<double>,dim> &rhs_aux,
1644 const bool compute_auxiliary_right_hand_side,
1645 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
1646 const bool is_a_subface,
1647 const unsigned int neighbor_i_subface)
1649 const dealii::FESystem<dim> &fe_metric = this->
high_order_grid->fe_system;
1650 const unsigned int n_metric_dofs = fe_metric.dofs_per_cell;
1651 const unsigned int n_soln_dofs_int = fe_int.dofs_per_cell;
1652 const unsigned int n_soln_dofs_ext = fe_ext.dofs_per_cell;
1654 AssertDimension (n_soln_dofs_int, soln_dofs_indices_int.size());
1655 AssertDimension (n_soln_dofs_ext, soln_dofs_indices_ext.size());
1658 unsigned int w_int_start=0, w_int_end=0, w_ext_start=0, w_ext_end=0,
1659 x_int_start=0, x_int_end=0, x_ext_start=0, x_ext_end=0;
1660 if(compute_dRdW || compute_dRdX || compute_d2R)
1663 compute_dRdW, compute_dRdX, compute_d2R,
1664 n_soln_dofs_int, n_soln_dofs_ext, n_metric_dofs,
1665 w_int_start, w_int_end, w_ext_start, w_ext_end,
1666 x_int_start, x_int_end, x_ext_start, x_ext_end);
1669 using TH = codi::TapeHelper<adtype>;
1671 typename adtype::TapeType &tape = adtype::getGlobalTape();
1672 if (compute_dRdW || compute_dRdX || compute_d2R) {
1673 th.startRecording();
1676 std::vector<adtype> soln_coeff_int(fe_int.dofs_per_cell);
1677 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
1678 const real val = this->
solution(soln_dofs_indices_int[idof]);
1679 soln_coeff_int[idof] = val;
1680 if (compute_dRdW || compute_d2R) {
1681 th.registerInput(soln_coeff_int[idof]);
1683 tape.deactivateValue(soln_coeff_int[idof]);
1687 std::vector<adtype> soln_coeff_ext(fe_ext.dofs_per_cell);
1688 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
1689 const real val = this->
solution(soln_dofs_indices_ext[idof]);
1690 soln_coeff_ext[idof] = val;
1691 if (compute_dRdW || compute_d2R) {
1692 th.registerInput(soln_coeff_ext[idof]);
1694 tape.deactivateValue(soln_coeff_ext[idof]);
1698 std::vector<adtype> metric_coeff_int(fe_metric.dofs_per_cell);
1699 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1700 const real val = this->
high_order_grid->volume_nodes[metric_dofs_indices_int[idof]];
1701 metric_coeff_int[idof] = val;
1702 if (compute_dRdX || compute_d2R) {
1703 th.registerInput(metric_coeff_int[idof]);
1705 tape.deactivateValue(metric_coeff_int[idof]);
1709 if(compute_dRdX || compute_d2R)
1715 std::vector<adtype> metric_coeff_ext(fe_metric.dofs_per_cell);
1716 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1717 const real val = this->
high_order_grid->volume_nodes[metric_dofs_indices_ext[idof]];
1718 metric_coeff_ext[idof] = val;
1719 if (compute_dRdX || compute_d2R) {
1720 th.registerInput(metric_coeff_ext[idof]);
1722 tape.deactivateValue(metric_coeff_ext[idof]);
1726 dealii::Tensor<1,dim,std::vector<adtype>> aux_soln_coeff_int;
1727 dealii::Tensor<1,dim,std::vector<adtype>> aux_soln_coeff_ext;
1728 for(
int idim=0; idim<dim; idim++){
1729 aux_soln_coeff_int[idim].resize(n_soln_dofs_int);
1730 aux_soln_coeff_ext[idim].resize(n_soln_dofs_ext);
1731 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
1734 aux_soln_coeff_int[idim][idof] = val;
1736 tape.deactivateValue(aux_soln_coeff_int[idim][idof]);
1745 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
1748 aux_soln_coeff_ext[idim][idof] = val;
1750 tape.deactivateValue(aux_soln_coeff_ext[idim][idof]);
1761 std::vector<double> dual_int(n_soln_dofs_int);
1762 std::vector<double> dual_ext(n_soln_dofs_ext);
1764 for (
unsigned int itest=0; itest<n_soln_dofs_int; ++itest) {
1765 const unsigned int global_residual_row = soln_dofs_indices_int[itest];
1767 dual_int[itest] = this->
dual[global_residual_row];
1769 for (
unsigned int itest=0; itest<n_soln_dofs_ext; ++itest) {
1770 const unsigned int global_residual_row = soln_dofs_indices_ext[itest];
1772 dual_ext[itest] = this->
dual[global_residual_row];
1775 std::vector<adtype> rhs_int(n_soln_dofs_int);
1776 std::vector<adtype> rhs_ext(n_soln_dofs_ext);
1777 dealii::Tensor<1,dim,std::vector<adtype>> aux_rhs_int;
1778 dealii::Tensor<1,dim,std::vector<adtype>> aux_rhs_ext;
1779 if(compute_auxiliary_right_hand_side){
1780 for(
int idim=0; idim<dim; idim++){
1781 aux_rhs_int[idim].resize(n_soln_dofs_int);
1782 aux_rhs_ext[idim].resize(n_soln_dofs_ext);
1785 adtype dual_dot_residual = 0.0;
1791 neighbor_cell_index,
1810 flux_basis_stiffness,
1811 soln_basis_projection_oper_int,
1812 soln_basis_projection_oper_ext,
1816 mapping_support_points,
1817 fe_values_collection_face_int,
1818 fe_values_collection_face_ext,
1819 fe_values_collection_subface,
1827 compute_auxiliary_right_hand_side,
1829 compute_dRdW, compute_dRdX, compute_d2R,
1831 neighbor_i_subface);
1833 if (compute_dRdW || compute_dRdX) {
1834 for (
unsigned int itest=0; itest<n_soln_dofs_int; ++itest) {
1835 th.registerOutput(rhs_int[itest]);
1837 for (
unsigned int itest=0; itest<n_soln_dofs_ext; ++itest) {
1838 th.registerOutput(rhs_ext[itest]);
1840 }
else if (compute_d2R) {
1841 th.registerOutput(dual_dot_residual);
1844 if (compute_dRdW || compute_dRdX || compute_d2R) {
1849 if(compute_auxiliary_right_hand_side){
1850 for(
int idim=0; idim<dim; idim++){
1851 for (
unsigned int itest_int=0; itest_int<n_soln_dofs_int; ++itest_int) {
1852 current_cell_rhs_aux[idim][itest_int] += getValue<adtype>(aux_rhs_int[idim][itest_int]);
1856 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
1857 rhs_aux[idim][soln_dofs_indices_ext[itest_ext]] += getValue<adtype>(aux_rhs_ext[idim][itest_ext]);
1862 for (
unsigned int itest_int=0; itest_int<n_soln_dofs_int; ++itest_int) {
1863 local_rhs_int_cell[itest_int] += getValue<adtype>(rhs_int[itest_int]);
1865 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
1866 local_rhs_ext_cell[itest_ext] += getValue<adtype>(rhs_ext[itest_ext]);
1870 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
1871 rhs[soln_dofs_indices_ext[itest_ext]] += local_rhs_ext_cell[itest_ext];
1875 if (compute_dRdW || compute_dRdX) {
1876 typename TH::JacobianType& jac = th.createJacobian();
1877 th.evalJacobian(jac);
1880 std::vector<real> residual_derivatives(n_soln_dofs_int);
1882 for (
unsigned int itest_int=0; itest_int<n_soln_dofs_int; ++itest_int) {
1883 int i_dependent = itest_int;
1886 residual_derivatives.resize(n_soln_dofs_int);
1887 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
1888 const unsigned int i_dx = idof+w_int_start;
1889 residual_derivatives[idof] = jac(i_dependent,i_dx);
1891 const bool elide_zero_values =
false;
1892 this->
system_matrix.add(soln_dofs_indices_int[itest_int], soln_dofs_indices_int, residual_derivatives, elide_zero_values);
1895 residual_derivatives.resize(n_soln_dofs_ext);
1896 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
1897 const unsigned int i_dx = idof+w_ext_start;
1898 residual_derivatives[idof] = jac(i_dependent,i_dx);
1900 this->
system_matrix.add(soln_dofs_indices_int[itest_int], soln_dofs_indices_ext, residual_derivatives, elide_zero_values);
1903 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
1905 int i_dependent = n_soln_dofs_int + itest_ext;
1908 residual_derivatives.resize(n_soln_dofs_int);
1909 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
1910 const unsigned int i_dx = idof+w_int_start;
1911 residual_derivatives[idof] = jac(i_dependent,i_dx);
1913 const bool elide_zero_values =
false;
1914 this->
system_matrix.add(soln_dofs_indices_ext[itest_ext], soln_dofs_indices_int, residual_derivatives, elide_zero_values);
1917 residual_derivatives.resize(n_soln_dofs_ext);
1918 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
1919 const unsigned int i_dx = idof+w_ext_start;
1920 residual_derivatives[idof] = jac(i_dependent,i_dx);
1922 this->
system_matrix.add(soln_dofs_indices_ext[itest_ext], soln_dofs_indices_ext, residual_derivatives, elide_zero_values);
1927 std::vector<real> residual_derivatives(n_metric_dofs);
1929 for (
unsigned int itest_int=0; itest_int<n_soln_dofs_int; ++itest_int) {
1931 int i_dependent = itest_int;
1934 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1935 const unsigned int i_dx = idof+x_int_start;
1936 residual_derivatives[idof] = jac(i_dependent,i_dx);
1938 this->
dRdXv.add(soln_dofs_indices_int[itest_int], metric_dofs_indices_int, residual_derivatives);
1941 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1942 const unsigned int i_dx = idof+x_ext_start;
1943 residual_derivatives[idof] = jac(i_dependent,i_dx);
1945 this->
dRdXv.add(soln_dofs_indices_int[itest_int], metric_dofs_indices_ext, residual_derivatives);
1948 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
1950 int i_dependent = n_soln_dofs_int + itest_ext;
1953 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1954 const unsigned int i_dx = idof+x_int_start;
1955 residual_derivatives[idof] = jac(i_dependent,i_dx);
1957 this->
dRdXv.add(soln_dofs_indices_ext[itest_ext], metric_dofs_indices_int, residual_derivatives);
1960 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
1961 const unsigned int i_dx = idof+x_ext_start;
1962 residual_derivatives[idof] = jac(i_dependent,i_dx);
1964 this->
dRdXv.add(soln_dofs_indices_ext[itest_ext], metric_dofs_indices_ext, residual_derivatives);
1968 th.deleteJacobian(jac);
1972 typename TH::HessianType& hes = th.createHessian();
1973 th.evalHessian(hes);
1975 std::vector<real> dWidW(n_soln_dofs_int);
1976 std::vector<real> dWidX(n_metric_dofs);
1977 std::vector<real> dXidX(n_metric_dofs);
1979 int i_dependent = (compute_dRdW || compute_dRdX) ? n_soln_dofs_int + n_soln_dofs_ext : 0;
1981 for (
unsigned int idof=0; idof<n_soln_dofs_int; ++idof) {
1983 const unsigned int i_dx = idof+w_int_start;
1986 for (
unsigned int jdof=0; jdof<n_soln_dofs_int; ++jdof) {
1987 const unsigned int j_dx = jdof+w_int_start;
1988 dWidW[jdof] = hes(i_dependent,i_dx,j_dx);
1990 this->
d2RdWdW.add(soln_dofs_indices_int[idof], soln_dofs_indices_int, dWidW);
1993 for (
unsigned int jdof=0; jdof<n_soln_dofs_ext; ++jdof) {
1994 const unsigned int j_dx = jdof+w_ext_start;
1995 dWidW[jdof] = hes(i_dependent,i_dx,j_dx);
1997 this->
d2RdWdW.add(soln_dofs_indices_int[idof], soln_dofs_indices_ext, dWidW);
2000 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2001 const unsigned int j_dx = jdof+x_int_start;
2002 dWidX[jdof] = hes(i_dependent,i_dx,j_dx);
2004 this->
d2RdWdX.add(soln_dofs_indices_int[idof], metric_dofs_indices_int, dWidX);
2007 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2008 const unsigned int j_dx = jdof+x_ext_start;
2009 dWidX[jdof] = hes(i_dependent,i_dx,j_dx);
2011 this->
d2RdWdX.add(soln_dofs_indices_int[idof], metric_dofs_indices_ext, dWidX);
2014 for (
unsigned int idof=0; idof<n_metric_dofs; ++idof) {
2016 const unsigned int i_dx = idof+x_int_start;
2019 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2020 const unsigned int j_dx = jdof+x_int_start;
2021 dXidX[jdof] = hes(i_dependent,i_dx,j_dx);
2023 this->
d2RdXdX.add(metric_dofs_indices_int[idof], metric_dofs_indices_int, dXidX);
2026 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2027 const unsigned int j_dx = jdof+x_ext_start;
2028 dXidX[jdof] = hes(i_dependent,i_dx,j_dx);
2030 this->
d2RdXdX.add(metric_dofs_indices_int[idof], metric_dofs_indices_ext, dXidX);
2033 dWidW.resize(n_soln_dofs_ext);
2035 for (
unsigned int idof=0; idof<n_soln_dofs_ext; ++idof) {
2037 const unsigned int i_dx = idof+w_ext_start;
2040 for (
unsigned int jdof=0; jdof<n_soln_dofs_int; ++jdof) {
2041 const unsigned int j_dx = jdof+w_int_start;
2042 dWidW[jdof] = hes(i_dependent,i_dx,j_dx);
2044 this->
d2RdWdW.add(soln_dofs_indices_ext[idof], soln_dofs_indices_int, dWidW);
2047 for (
unsigned int jdof=0; jdof<n_soln_dofs_ext; ++jdof) {
2048 const unsigned int j_dx = jdof+w_ext_start;
2049 dWidW[jdof] = hes(i_dependent,i_dx,j_dx);
2051 this->
d2RdWdW.add(soln_dofs_indices_ext[idof], soln_dofs_indices_ext, dWidW);
2054 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2055 const unsigned int j_dx = jdof+x_int_start;
2056 dWidX[jdof] = hes(i_dependent,i_dx,j_dx);
2058 this->
d2RdWdX.add(soln_dofs_indices_ext[idof], metric_dofs_indices_int, dWidX);
2061 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2062 const unsigned int j_dx = jdof+x_ext_start;
2063 dWidX[jdof] = hes(i_dependent,i_dx,j_dx);
2065 this->
d2RdWdX.add(soln_dofs_indices_ext[idof], metric_dofs_indices_ext, dWidX);
2068 for (
unsigned int idof=0; idof<n_metric_dofs; ++idof) {
2070 const unsigned int i_dx = idof+x_ext_start;
2073 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2074 const unsigned int j_dx = jdof+x_int_start;
2075 dXidX[jdof] = hes(i_dependent,i_dx,j_dx);
2077 this->
d2RdXdX.add(metric_dofs_indices_ext[idof], metric_dofs_indices_int, dXidX);
2080 for (
unsigned int jdof=0; jdof<n_metric_dofs; ++jdof) {
2081 const unsigned int j_dx = jdof+x_ext_start;
2082 dXidX[jdof] = hes(i_dependent,i_dx,j_dx);
2084 this->
d2RdXdX.add(metric_dofs_indices_ext[idof], metric_dofs_indices_ext, dXidX);
2087 th.deleteHessian(hes);
2090 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
2091 tape.deactivateValue(soln_coeff_int[idof]);
2093 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
2094 tape.deactivateValue(soln_coeff_ext[idof]);
2096 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
2097 tape.deactivateValue(metric_coeff_int[idof]);
2099 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
2100 tape.deactivateValue(metric_coeff_ext[idof]);
2103 for(
int idim=0; idim<dim; idim++){
2104 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
2105 tape.deactivateValue(aux_soln_coeff_int[idim][idof]);
2107 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
2108 tape.deactivateValue(aux_soln_coeff_ext[idim][idof]);
2114 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2116 typename dealii::DoFHandler<dim>::active_cell_iterator cell,
2117 typename dealii::DoFHandler<dim>::active_cell_iterator neighbor_cell,
2118 const dealii::types::global_dof_index current_cell_index,
2119 const dealii::types::global_dof_index neighbor_cell_index,
2120 const unsigned int iface,
2121 const unsigned int neighbor_iface,
2123 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_int,
2124 dealii::hp::FEFaceValues<dim,dim> &fe_values_collection_face_ext,
2125 dealii::hp::FESubfaceValues<dim,dim> &fe_values_collection_subface,
2126 const dealii::FESystem<dim,dim> &fe_int,
2127 const dealii::FESystem<dim,dim> &fe_ext,
2128 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices_int,
2129 const std::vector<dealii::types::global_dof_index> &soln_dofs_indices_ext,
2130 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices_int,
2131 const std::vector<dealii::types::global_dof_index> &metric_dofs_indices_ext,
2132 const unsigned int poly_degree_int,
2133 const unsigned int poly_degree_ext,
2134 const unsigned int grid_degree_int,
2135 const unsigned int grid_degree_ext,
2146 std::array<std::vector<double>,dim> &mapping_support_points,
2147 std::vector<real> &local_rhs_int_cell,
2148 std::vector<real> &local_rhs_ext_cell,
2149 dealii::Tensor<1,dim,std::vector<real>> ¤t_cell_rhs_aux,
2150 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
2151 std::array<dealii::LinearAlgebra::distributed::Vector<double>,dim> &rhs_aux,
2152 const bool compute_auxiliary_right_hand_side,
2153 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
2154 const bool is_a_subface,
2155 const unsigned int neighbor_i_subface)
2157 const dealii::FESystem<dim> &fe_metric = this->
high_order_grid->fe_system;
2158 const unsigned int n_metric_dofs = fe_metric.dofs_per_cell;
2159 const unsigned int n_soln_dofs_int = fe_int.dofs_per_cell;
2160 const unsigned int n_soln_dofs_ext = fe_ext.dofs_per_cell;
2162 AssertDimension (n_soln_dofs_int, soln_dofs_indices_int.size());
2163 AssertDimension (n_soln_dofs_ext, soln_dofs_indices_ext.size());
2165 std::vector<double> soln_coeff_int(fe_int.dofs_per_cell);
2166 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
2167 soln_coeff_int[idof] = this->
solution(soln_dofs_indices_int[idof]);
2170 std::vector<double> soln_coeff_ext(fe_ext.dofs_per_cell);
2171 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
2172 soln_coeff_ext[idof] = this->
solution(soln_dofs_indices_ext[idof]);
2175 std::vector<double> metric_coeff_int(fe_metric.dofs_per_cell);
2176 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
2177 metric_coeff_int[idof] = this->
high_order_grid->volume_nodes[metric_dofs_indices_int[idof]];
2180 std::vector<double> metric_coeff_ext(fe_metric.dofs_per_cell);
2181 for (
unsigned int idof = 0; idof < n_metric_dofs; ++idof) {
2182 metric_coeff_ext[idof] = this->
high_order_grid->volume_nodes[metric_dofs_indices_ext[idof]];
2185 dealii::Tensor<1,dim,std::vector<double>> aux_soln_coeff_int;
2186 dealii::Tensor<1,dim,std::vector<double>> aux_soln_coeff_ext;
2187 for(
int idim=0; idim<dim; idim++){
2188 aux_soln_coeff_int[idim].resize(n_soln_dofs_int);
2189 aux_soln_coeff_ext[idim].resize(n_soln_dofs_ext);
2191 for (
unsigned int idof = 0; idof < n_soln_dofs_int; ++idof) {
2192 aux_soln_coeff_int[idim][idof] = this->
auxiliary_solution[idim](soln_dofs_indices_int[idof]);
2194 for (
unsigned int idof = 0; idof < n_soln_dofs_ext; ++idof) {
2195 aux_soln_coeff_ext[idim][idof] = this->
auxiliary_solution[idim](soln_dofs_indices_ext[idof]);
2200 std::vector<double> dual_int(n_soln_dofs_int);
2201 std::vector<double> dual_ext(n_soln_dofs_ext);
2203 std::vector<double> rhs_int(n_soln_dofs_int);
2204 std::vector<double> rhs_ext(n_soln_dofs_ext);
2205 dealii::Tensor<1,dim,std::vector<double>> aux_rhs_int;
2206 dealii::Tensor<1,dim,std::vector<double>> aux_rhs_ext;
2207 if(compute_auxiliary_right_hand_side){
2208 for(
int idim=0; idim<dim; idim++){
2209 aux_rhs_int[idim].resize(n_soln_dofs_int);
2210 aux_rhs_ext[idim].resize(n_soln_dofs_ext);
2213 double dual_dot_residual = 0.0;
2219 neighbor_cell_index,
2238 flux_basis_stiffness,
2239 soln_basis_projection_oper_int,
2240 soln_basis_projection_oper_ext,
2244 mapping_support_points,
2245 fe_values_collection_face_int,
2246 fe_values_collection_face_ext,
2247 fe_values_collection_subface,
2255 compute_auxiliary_right_hand_side,
2257 compute_dRdW, compute_dRdX, compute_d2R,
2259 neighbor_i_subface);
2261 if(compute_auxiliary_right_hand_side){
2262 for(
int idim=0; idim<dim; idim++){
2263 for (
unsigned int itest_int=0; itest_int<n_soln_dofs_int; ++itest_int) {
2264 current_cell_rhs_aux[idim][itest_int] += aux_rhs_int[idim][itest_int];
2268 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
2269 rhs_aux[idim][soln_dofs_indices_ext[itest_ext]] += aux_rhs_ext[idim][itest_ext];
2274 for (
unsigned int itest_int=0; itest_int<n_soln_dofs_int; ++itest_int) {
2275 local_rhs_int_cell[itest_int] += rhs_int[itest_int];
2277 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
2278 local_rhs_ext_cell[itest_ext] += rhs_ext[itest_ext];
2282 for (
unsigned int itest_ext=0; itest_ext<n_soln_dofs_ext; ++itest_ext) {
2283 rhs[soln_dofs_indices_ext[itest_ext]] += local_rhs_ext_cell[itest_ext];
2288 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2289 template <
typename real2>
2292 if constexpr (std::is_same<real2, double>::value) {
2299 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2301 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
2302 const unsigned int n_soln_dofs,
const unsigned int n_metric_dofs,
2303 unsigned int &w_start,
unsigned int &w_end,
2304 unsigned int &x_start,
unsigned int &x_end)
2310 if (compute_d2R || (compute_dRdW && compute_dRdX)) {
2312 w_end = w_start + n_soln_dofs;
2314 x_end = x_start + n_metric_dofs;
2315 }
else if (compute_dRdW) {
2317 w_end = w_start + n_soln_dofs;
2318 }
else if (compute_dRdX) {
2320 x_end = x_start + n_metric_dofs;
2322 std::cout <<
"Called the derivative version of the residual without requesting the derivative" << std::endl;
2326 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2328 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
2329 const unsigned int n_soln_dofs_int,
const unsigned int n_soln_dofs_ext,
const unsigned int n_metric_dofs,
2330 unsigned int &w_int_start,
unsigned int &w_int_end,
unsigned int &w_ext_start,
unsigned int &w_ext_end,
2331 unsigned int &x_int_start,
unsigned int &x_int_end,
unsigned int &x_ext_start,
unsigned int &x_ext_end)
2334 w_int_start = 0; w_int_end = 0; w_ext_start = 0; w_ext_end = 0;
2335 x_int_start = 0; x_int_end = 0; x_ext_start = 0; x_ext_end = 0;
2336 if (compute_d2R || (compute_dRdW && compute_dRdX)) {
2338 w_int_end = w_int_start + n_soln_dofs_int;
2339 w_ext_start = w_int_end;
2340 w_ext_end = w_ext_start + n_soln_dofs_ext;
2342 x_int_start = w_ext_end;
2343 x_int_end = x_int_start + n_metric_dofs;
2344 x_ext_start = x_int_end;
2345 x_ext_end = x_ext_start + n_metric_dofs;
2346 }
else if (compute_dRdW) {
2348 w_int_end = w_int_start + n_soln_dofs_int;
2349 w_ext_start = w_int_end;
2350 w_ext_end = w_ext_start + n_soln_dofs_ext;
2351 }
else if (compute_dRdX) {
2353 x_int_end = x_int_start + n_metric_dofs;
2354 x_ext_start = x_int_end;
2355 x_ext_end = x_ext_start + n_metric_dofs;
2357 std::cout <<
"Called the derivative version of the residual without requesting the derivative" << std::endl;
2362 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2368 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2372 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
2373 const dealii::UpdateFlags update_flags = dealii::update_values | dealii::update_JxW_values;
2376 std::vector< double > soln_coeff_high;
2377 std::vector<dealii::types::global_dof_index> dof_indices;
2380 std::vector<dealii::types::global_dof_index> dof_indices_artificial_dissipation(n_dofs_arti_diss);
2384 for (
auto cell :
dof_handler.active_cell_iterators()) {
2385 if (!(cell->is_locally_owned() || cell->is_ghost()))
continue;
2387 dealii::types::global_dof_index cell_index = cell->active_cell_index();
2394 const int i_fele = cell->active_fe_index();
2395 const int i_quad = i_fele;
2396 const int i_mapp = 0;
2398 const dealii::FESystem<dim,dim> &fe_high =
fe_collection[i_fele];
2399 const unsigned int degree = fe_high.tensor_degree();
2401 if (degree == 0)
continue;
2403 const unsigned int nstate = fe_high.components;
2404 const unsigned int n_dofs_high = fe_high.dofs_per_cell;
2406 fe_values_collection_volume.reinit (cell, i_quad, i_mapp, i_fele);
2407 const dealii::FEValues<dim,dim> &fe_values_volume = fe_values_collection_volume.get_present_fe_values();
2409 dof_indices.resize(n_dofs_high);
2410 cell->get_dof_indices (dof_indices);
2412 soln_coeff_high.resize(n_dofs_high);
2413 for (
unsigned int idof=0; idof<n_dofs_high; ++idof) {
2414 soln_coeff_high[idof] =
solution[dof_indices[idof]];
2418 const unsigned int lower_degree = degree-1;
2419 const dealii::FE_DGQLegendre<dim> fe_dgq_lower(lower_degree);
2420 const dealii::FESystem<dim,dim> fe_lower(fe_dgq_lower, nstate);
2423 const dealii::QGauss<dim> projection_quadrature(degree+5);
2424 std::vector< double > soln_coeff_lower = project_function<dim,nspecies,double>( soln_coeff_high, fe_high, fe_lower, projection_quadrature);
2427 const dealii::Quadrature<dim> &quadrature = fe_values_volume.get_quadrature();
2428 const std::vector<dealii::Point<dim,double>> &unit_quad_pts = quadrature.get_points();
2430 const unsigned int n_quad_pts = quadrature.size();
2431 const unsigned int n_dofs_lower = fe_lower.dofs_per_cell;
2433 double element_volume = 0.0;
2435 double soln_norm = 0.0;
2436 std::vector<double> soln_high(nstate);
2437 std::vector<double> soln_lower(nstate);
2438 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
2439 for (
unsigned int s=0; s<
nstate; ++s) {
2441 soln_lower[s] = 0.0;
2444 for (
unsigned int idof=0; idof<n_dofs_high; ++idof) {
2445 const unsigned int istate = fe_high.system_to_component_index(idof).first;
2446 soln_high[istate] += soln_coeff_high[idof] * fe_high.shape_value_component(idof,unit_quad_pts[iquad],istate);
2449 for (
unsigned int idof=0; idof<n_dofs_lower; ++idof) {
2450 const unsigned int istate = fe_lower.system_to_component_index(idof).first;
2451 soln_lower[istate] += soln_coeff_lower[idof] * fe_lower.shape_value_component(idof,unit_quad_pts[iquad],istate);
2454 element_volume += fe_values_volume.JxW(iquad);
2456 for (
unsigned int s=0; s<1; ++s)
2458 error += (soln_high[s] - soln_lower[s]) * (soln_high[s] - soln_lower[s]) * fe_values_volume.JxW(iquad);
2459 soln_norm += soln_high[s] * soln_high[s] * fe_values_volume.JxW(iquad);
2466 if (soln_norm < 1e-12)
2472 S_e = sqrt(error / soln_norm);
2482 const double s_0 = -0.00 - 4.00*log10(degree);
2484 const double low = s_0 - kappa;
2485 const double upp = s_0 + kappa;
2487 const double diameter = std::pow(element_volume, 1.0/dim);
2488 const double eps_0 = mu_scale * diameter / (double)degree;
2492 if ( s_e < low)
continue;
2503 const double PI = 4*atan(1);
2504 double eps = 1.0 + sin(PI * (s_e - s_0) * 0.5 / kappa);
2516 typename dealii::DoFHandler<dim>::active_cell_iterator artificial_dissipation_cell(
2519 dof_indices_artificial_dissipation.resize(n_dofs_arti_diss);
2520 artificial_dissipation_cell->get_dof_indices (dof_indices_artificial_dissipation);
2521 for (
unsigned int idof=0; idof<n_dofs_arti_diss; ++idof) {
2522 const unsigned int index = dof_indices_artificial_dissipation[idof];
2540 dealii::ComponentMask(),
2543 if (boundary_dofs.is_element(i)) {
2552 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2554 const unsigned int poly_degree_int,
2555 const unsigned int poly_degree_ext,
2556 const unsigned int ,
2598 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2601 dealii::deal_II_exceptions::disable_abort_on_exception();
2602 Assert( !(compute_dRdW && compute_dRdX)
2603 && !(compute_dRdW && compute_d2R)
2604 && !(compute_dRdX && compute_d2R)
2605 , dealii::ExcMessage(
"Can only do one at a time compute_dRdW or compute_dRdX or compute_d2R"));
2610 pcout <<
" with dRdW...";
2614 const double l2_norm_sol = diff_sol.l2_norm();
2616 if (l2_norm_sol == 0.0) {
2620 const double l2_norm_node = diff_node.l2_norm();
2622 if (l2_norm_node == 0.0) {
2624 pcout <<
" which is already assembled..." << std::endl;
2630 int n_stencil = 1 + std::pow(2,dim);
2632 n_vmult += n_stencil*n_dofs_cell;
2642 pcout <<
" with dRdX...";
2646 const double l2_norm_sol = diff_sol.l2_norm();
2648 if (l2_norm_sol == 0.0) {
2652 const double l2_norm_node = diff_node.l2_norm();
2654 if (l2_norm_node == 0.0) {
2655 pcout <<
" which is already assembled..." << std::endl;
2669 pcout <<
" with d2RdWdW, d2RdWdX, d2RdXdX...";
2672 const double l2_norm_sol = diff_sol.l2_norm();
2674 if (l2_norm_sol == 0.0) {
2678 const double l2_norm_node = diff_node.l2_norm();
2680 if (l2_norm_node == 0.0) {
2682 auto diff_dual =
dual;
2684 const double l2_norm_dual = diff_dual.l2_norm();
2685 if (l2_norm_dual == 0.0) {
2686 pcout <<
" which is already assembled..." << std::endl;
2715 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
2724 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
2736 soln_basis_int, soln_basis_ext,
2737 flux_basis_int, flux_basis_ext,
2738 flux_basis_stiffness,
2739 soln_basis_projection_oper_int, soln_basis_projection_oper_ext,
2745 int assembly_error = 0;
2758 dealii::Timer timer;
2766 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell)
2768 if (!soln_cell->is_locally_owned())
continue;
2769 assemble_cell_residual_and_ad_derivatives<codi_HessianComputationType>(
2772 compute_dRdW, compute_dRdX, compute_d2R,
2773 fe_values_collection_volume,
2774 fe_values_collection_face_int,
2775 fe_values_collection_face_ext,
2776 fe_values_collection_subface,
2777 fe_values_collection_volume_lagrange,
2782 flux_basis_stiffness,
2783 soln_basis_projection_oper_int,
2784 soln_basis_projection_oper_ext,
2791 else if(compute_dRdW || compute_dRdX)
2793 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell)
2795 if (!soln_cell->is_locally_owned())
continue;
2796 assemble_cell_residual_and_ad_derivatives<codi_JacobianComputationType>(
2799 compute_dRdW, compute_dRdX, compute_d2R,
2800 fe_values_collection_volume,
2801 fe_values_collection_face_int,
2802 fe_values_collection_face_ext,
2803 fe_values_collection_subface,
2804 fe_values_collection_volume_lagrange,
2809 flux_basis_stiffness,
2810 soln_basis_projection_oper_int,
2811 soln_basis_projection_oper_ext,
2820 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell)
2822 if (!soln_cell->is_locally_owned())
continue;
2823 assemble_cell_residual_and_ad_derivatives<double>(
2826 compute_dRdW, compute_dRdX, compute_d2R,
2827 fe_values_collection_volume,
2828 fe_values_collection_face_int,
2829 fe_values_collection_face_ext,
2830 fe_values_collection_subface,
2831 fe_values_collection_volume_lagrange,
2836 flux_basis_stiffness,
2837 soln_basis_projection_oper_int,
2838 soln_basis_projection_oper_ext,
2854 const int mpi_assembly_error = dealii::Utilities::MPI::sum(assembly_error,
mpi_communicator);
2856 if (mpi_assembly_error != 0) {
2857 std::cout <<
"Invalid residual assembly encountered..." 2858 <<
" Filling up RHS with 1s. " << std::endl;
2862 std::cout <<
" Filling up Jacobian with mass matrix. " << std::endl;
2863 const bool do_inverse_mass_matrix =
false;
2879 if ( compute_dRdW ) {
2883 const bool do_inverse_mass_matrix =
false;
2886 if (CFL_mass != 0.0) {
2891 Epetra_CrsMatrix *input_matrix =
const_cast<Epetra_CrsMatrix *
>(&(
system_matrix.trilinos_matrix()));
2892 Epetra_CrsMatrix *output_matrix;
2894 const bool make_data_contiguous =
true;
2896 if (error_transpose) {
2897 std::cout <<
"Failed to create dRdW transpose... Aborting" << std::endl;
2900 bool copy_values =
true;
2902 delete(output_matrix);
2905 if ( compute_dRdX )
dRdXv.compress(dealii::VectorOperation::add);
2906 if ( compute_d2R ) {
2907 d2RdWdW.compress(dealii::VectorOperation::add);
2908 d2RdXdX.compress(dealii::VectorOperation::add);
2909 d2RdWdX.compress(dealii::VectorOperation::add);
2916 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2919 pcout <<
"Evaluating residual Linf-norm..." << std::endl;
2921 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
2923 double residual_linf_norm = 0.0;
2924 std::vector<dealii::types::global_dof_index> dofs_indices;
2925 const dealii::UpdateFlags update_flags = dealii::update_values | dealii::update_JxW_values;
2926 dealii::hp::FEValues<dim,dim> fe_values_collection_volume (mapping_collection,
2932 for (
const auto& cell :
dof_handler.active_cell_iterators()) {
2933 if (!cell->is_locally_owned())
continue;
2935 const int i_fele = cell->active_fe_index();
2936 const int i_quad = i_fele;
2937 const int i_mapp = 0;
2939 fe_values_collection_volume.reinit (cell, i_quad, i_mapp, i_fele);
2940 const dealii::FEValues<dim,dim> &fe_values_vol = fe_values_collection_volume.get_present_fe_values();
2942 const dealii::FESystem<dim,dim> &fe_ref =
fe_collection[i_fele];
2943 const unsigned int n_dofs = fe_ref.n_dofs_per_cell();
2944 const unsigned int n_quad = fe_values_vol.n_quadrature_points;
2946 dofs_indices.resize(n_dofs);
2947 cell->get_dof_indices (dofs_indices);
2949 for (
unsigned int iquad = 0; iquad < n_quad; ++iquad) {
2950 double residual_val = 0.0;
2951 for (
unsigned int idof = 0; idof <
n_dofs; ++idof) {
2952 const unsigned int istate = fe_values_vol.get_fe().system_to_component_index(idof).first;
2953 residual_val +=
right_hand_side[dofs_indices[idof]] * fe_values_vol.shape_value_component(idof, iquad, istate);
2955 residual_linf_norm = std::max(std::abs(residual_val), residual_val);
2959 const double mpi_residual_linf_norm = dealii::Utilities::MPI::max(residual_linf_norm,
mpi_communicator);
2960 return mpi_residual_linf_norm;
2964 template <
int dim,
int nspecies,
typename real,
typename MeshType>
2977 dealii::hp::MappingCollection<dim> mapping_collection(mapping);
2979 double residual_l2_norm = 0.0;
2980 double domain_volume = 0.0;
2981 std::vector<dealii::types::global_dof_index> dofs_indices;
2982 const dealii::UpdateFlags update_flags = dealii::update_values | dealii::update_JxW_values;
2983 dealii::hp::FEValues<dim,dim> fe_values_collection_volume (mapping_collection,
2989 for (
const auto& cell :
dof_handler.active_cell_iterators()) {
2990 if (!cell->is_locally_owned())
continue;
2992 const int i_fele = cell->active_fe_index();
2993 const int i_quad = i_fele;
2994 const int i_mapp = 0;
2996 fe_values_collection_volume.reinit (cell, i_quad, i_mapp, i_fele);
2997 const dealii::FEValues<dim,dim> &fe_values_vol = fe_values_collection_volume.get_present_fe_values();
2999 const dealii::FESystem<dim,dim> &fe_ref =
fe_collection[i_fele];
3000 const unsigned int n_dofs = fe_ref.n_dofs_per_cell();
3001 const unsigned int n_quad = fe_values_vol.n_quadrature_points;
3003 dofs_indices.resize(n_dofs);
3004 cell->get_dof_indices (dofs_indices);
3006 for (
unsigned int iquad = 0; iquad < n_quad; ++iquad) {
3007 double residual_val = 0.0;
3008 for (
unsigned int idof = 0; idof <
n_dofs; ++idof) {
3009 const unsigned int istate = fe_values_vol.get_fe().system_to_component_index(idof).first;
3010 residual_val +=
right_hand_side[dofs_indices[idof]] * fe_values_vol.shape_value_component(idof, iquad, istate);
3012 residual_l2_norm += residual_val*residual_val * fe_values_vol.JxW(iquad);
3013 domain_volume += fe_values_vol.JxW(iquad);
3017 const double mpi_residual_l2_norm = dealii::Utilities::MPI::sum(residual_l2_norm,
mpi_communicator);
3018 const double mpi_domain_volume = dealii::Utilities::MPI::sum(domain_volume,
mpi_communicator);
3019 return std::sqrt(mpi_residual_l2_norm) / mpi_domain_volume;
3022 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3030 template <
int dim,
typename DoFHandlerType = dealii::DoFHandler<dim>>
3031 class DataOutEulerFaces :
public dealii::DataOutFaces<dim, DoFHandlerType>
3033 static const unsigned int dimension = DoFHandlerType::dimension;
3034 static const unsigned int space_dimension = DoFHandlerType::space_dimension;
3035 using cell_iterator =
typename dealii::DataOut_DoFData<DoFHandlerType, dimension - 1, dimension>::cell_iterator;
3037 using FaceDescriptor =
typename std::pair<cell_iterator, unsigned int>;
3048 virtual FaceDescriptor first_face()
override;
3071 virtual FaceDescriptor next_face(
const FaceDescriptor &face)
override;
3075 template <
int dim,
typename DoFHandlerType>
3076 typename DataOutEulerFaces<dim, DoFHandlerType>::FaceDescriptor
3077 DataOutEulerFaces<dim, DoFHandlerType>::first_face()
3080 typename dealii::Triangulation<dimension, space_dimension>::active_cell_iterator
3083 if (cell->is_locally_owned())
3084 for (
const unsigned int f : dealii::GeometryInfo<dimension>::face_indices())
3085 if (cell->face(f)->at_boundary())
3086 if (cell->face(f)->boundary_id() == 1001)
3087 return FaceDescriptor(cell, f);
3092 return FaceDescriptor();
3095 template <
int dim,
typename DoFHandlerType>
3096 typename DataOutEulerFaces<dim, DoFHandlerType>::FaceDescriptor
3097 DataOutEulerFaces<dim, DoFHandlerType>::next_face(
const FaceDescriptor &old_face)
3099 FaceDescriptor face = old_face;
3103 Assert(face.first->is_locally_owned(), dealii::ExcInternalError());
3104 for (
unsigned int f = face.second + 1; f < dealii::GeometryInfo<dimension>::faces_per_cell; ++f)
3105 if (face.first->face(f)->at_boundary())
3106 if (face.first->face(f)->boundary_id() == 1001) {
3116 typename dealii::Triangulation<dimension, space_dimension>::active_cell_iterator
3117 active_cell = face.first;
3126 if (active_cell->is_locally_owned())
3127 for (
const unsigned int f : dealii::GeometryInfo<dimension>::face_indices())
3128 if (active_cell->face(f)->at_boundary())
3129 if (active_cell->face(f)->boundary_id() == 1001) {
3130 face.first = active_cell;
3147 class NormalPostprocessor :
public dealii::DataPostprocessorVector<dim>
3150 NormalPostprocessor ()
3151 : dealii::DataPostprocessorVector<dim> (
"normal", dealii::update_normal_vectors)
3154 evaluate_vector_field (
const dealii::DataPostprocessorInputs::Vector<dim> &input_data, std::vector<dealii::Vector<double>> &computed_quantities)
const override 3159 AssertDimension (input_data.normals.size(), computed_quantities.size());
3161 for (
unsigned int p=0; p<input_data.solution_gradients.size(); ++p) {
3167 AssertDimension (computed_quantities[p].size(), dim);
3168 for (
unsigned int d=0; d<dim; ++d)
3169 computed_quantities[p][d] = input_data.normals[p][d];
3173 evaluate_scalar_field (
const dealii::DataPostprocessorInputs::Scalar<dim> &input_data, std::vector<dealii::Vector<double> > &computed_quantities)
const override 3178 AssertDimension (input_data.normals.size(), computed_quantities.size());
3180 for (
unsigned int p=0; p<input_data.solution_gradients.size(); ++p) {
3186 AssertDimension (computed_quantities[p].size(), dim);
3187 for (
unsigned int d=0; d<dim; ++d)
3188 computed_quantities[p][d] = input_data.normals[p][d];
3195 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3197 const bool output_time_averaged_solution,
3198 const bool output_fluctuating_quantities)
3201 DataOutEulerFaces<dim, dealii::DoFHandler<dim>> data_out;
3205 std::vector<std::string> position_names;
3206 for(
int d=0;d<dim;++d) {
3207 if (d==0) position_names.push_back(
"x");
3208 if (d==1) position_names.push_back(
"y");
3209 if (d==2) position_names.push_back(
"z");
3211 std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation> data_component_interpretation(dim, dealii::DataComponentInterpretation::component_is_scalar);
3214 dealii::Vector<float> subdomain(
triangulation->n_active_cells());
3215 for (
unsigned int i = 0; i < subdomain.size(); ++i) {
3218 const std::string name =
"subdomain";
3219 data_out.add_data_vector(subdomain, name, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
3222 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);
3223 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);
3227 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);
3229 data_out.add_data_vector(
cell_volume, std::string(
"cell_volume"), dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
3234 if(output_time_averaged_solution && !output_fluctuating_quantities){
3235 data_out.add_data_vector (time_averaged_solution, *post_processor);
3236 }
else if(output_fluctuating_quantities && !output_time_averaged_solution){
3237 std::vector<std::string> fluctuating_quantities_names = {
"u'v'",
"u'u'",
"v'v'",
"w'w'",
"u'w'"};
3238 data_out.add_data_vector (fluctuating_quantities, fluctuating_quantities_names, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_dof_data);
3240 data_out.add_data_vector (
solution, *post_processor);
3244 NormalPostprocessor<dim> normals_post_processor;
3245 data_out.add_data_vector (
solution, normals_post_processor);
3248 std::vector<unsigned int> active_fe_indices;
3249 dof_handler.get_active_fe_indices(active_fe_indices);
3250 dealii::Vector<double> active_fe_indices_dealiivector(active_fe_indices.begin(), active_fe_indices.end());
3251 dealii::Vector<double> cell_poly_degree = active_fe_indices_dealiivector;
3253 data_out.add_data_vector (active_fe_indices_dealiivector,
"PolynomialDegree", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_cell_data);
3256 std::vector<std::string> residual_names;
3257 for(
int s=0;s<
nstate;++s) {
3258 std::string varname =
"residual" + dealii::Utilities::int_to_string(s,1);
3259 residual_names.push_back(varname);
3262 for (
auto &&rhs_value : residual) {
3263 if (std::signbit(rhs_value)) rhs_value = -rhs_value;
3264 if (rhs_value == 0.0) rhs_value = std::numeric_limits<double>::min();
3266 residual.update_ghost_values();
3267 data_out.add_data_vector (residual, residual_names, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim-1,dim>::DataVectorType::type_dof_data);
3285 const dealii::Mapping<dim> &mapping = (*(
high_order_grid->mapping_fe_field));
3289 const int n_subdivisions = grid_degree;
3290 data_out.build_patches(mapping, n_subdivisions);
3292 const bool write_higher_order_cells =
false;
3293 dealii::DataOutBase::VtkFlags vtkflags(current_time,cycle,
true,dealii::DataOutBase::VtkFlags::ZlibCompressionLevel::best_compression,write_higher_order_cells);
3294 data_out.set_flags(vtkflags);
3296 const int iproc = dealii::Utilities::MPI::this_mpi_process(
mpi_communicator);
3297 std::string filename_prefix =
"surface_solution";
3298 if(output_time_averaged_solution && !output_fluctuating_quantities) filename_prefix =
"time_averaged_surface_solution";
3299 else if(output_fluctuating_quantities && !output_time_averaged_solution) filename_prefix =
"fluctuating_surface_quantities";
3301 filename += dealii::Utilities::int_to_string(cycle, 4) +
".";
3302 filename += dealii::Utilities::int_to_string(iproc, 4);
3304 std::ofstream output(filename);
3305 data_out.write_vtu(output);
3309 std::vector<std::string> filenames;
3310 std::string filename_prefix =
"surface_solution";
3311 if(output_time_averaged_solution && !output_fluctuating_quantities) filename_prefix =
"time_averaged_surface_solution";
3312 else if(output_fluctuating_quantities && !output_time_averaged_solution) filename_prefix =
"fluctuating_surface_quantities";
3313 for (
unsigned int iproc = 0; iproc < dealii::Utilities::MPI::n_mpi_processes(
mpi_communicator); ++iproc) {;
3314 std::string fn = filename_prefix +
"-" + dealii::Utilities::int_to_string(dim, 1) +
"D_maxpoly"+dealii::Utilities::int_to_string(
max_degree, 2)+
"-";
3315 fn += dealii::Utilities::int_to_string(cycle, 4) +
".";
3316 fn += dealii::Utilities::int_to_string(iproc, 4);
3318 filenames.push_back(fn);
3321 master_fn += dealii::Utilities::int_to_string(cycle, 4) +
".pvtu";
3322 std::ofstream master_output(master_fn);
3323 data_out.write_pvtu_record(master_output, filenames);
3327 (output_time_averaged_solution ==
false) && (output_fluctuating_quantities ==
false)) {
3338 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3340 const bool output_time_averaged_solution,
3341 const bool output_fluctuating_quantities)
3348 dealii::DataOut<dim, dealii::DoFHandler<dim>> data_out;
3352 std::vector<std::string> position_names;
3353 for(
int d=0;d<dim;++d) {
3354 if (d==0) position_names.push_back(
"x");
3355 if (d==1) position_names.push_back(
"y");
3356 if (d==2) position_names.push_back(
"z");
3358 std::vector<dealii::DataComponentInterpretation::DataComponentInterpretation> data_component_interpretation(dim, dealii::DataComponentInterpretation::component_is_scalar);
3361 dealii::Vector<float> subdomain(
triangulation->n_active_cells());
3362 for (
unsigned int i = 0; i < subdomain.size(); ++i) {
3365 data_out.add_data_vector(subdomain,
"subdomain", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
3368 data_out.add_data_vector(
artificial_dissipation_coeffs,
"artificial_dissipation_coeffs", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
3369 data_out.add_data_vector(
artificial_dissipation_se,
"artificial_dissipation_se", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
3373 data_out.add_data_vector(
max_dt_cell,
"max_dt_cell", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
3375 data_out.add_data_vector(reduced_mesh_weights,
"reduced_mesh_weights", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
3377 data_out.add_data_vector(
cell_volume,
"cell_volume", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
3382 if(output_time_averaged_solution && !output_fluctuating_quantities){
3383 data_out.add_data_vector (time_averaged_solution, *post_processor);
3384 }
else if(output_fluctuating_quantities && !output_time_averaged_solution){
3385 std::vector<std::string> fluctuating_quantities_names = {
"u'v'",
"u'u'",
"v'v'",
"w'w'",
"u'w'"};
3386 data_out.add_data_vector (fluctuating_quantities, fluctuating_quantities_names, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_dof_data);
3388 data_out.add_data_vector (
solution, *post_processor);
3392 std::vector<unsigned int> active_fe_indices;
3393 dof_handler.get_active_fe_indices(active_fe_indices);
3394 dealii::Vector<double> active_fe_indices_dealiivector(active_fe_indices.begin(), active_fe_indices.end());
3395 dealii::Vector<double> cell_poly_degree = active_fe_indices_dealiivector;
3397 data_out.add_data_vector (active_fe_indices_dealiivector,
"PolynomialDegree", dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_cell_data);
3400 std::vector<std::string> residual_names;
3401 for(
int s=0;s<
nstate;++s) {
3402 std::string varname =
"residual" + dealii::Utilities::int_to_string(s,1);
3403 residual_names.push_back(varname);
3406 for (
auto &&rhs_value : residual) {
3407 if (std::signbit(rhs_value)) rhs_value = -rhs_value;
3408 if (rhs_value == 0.0) rhs_value = std::numeric_limits<double>::min();
3410 residual.update_ghost_values();
3411 data_out.add_data_vector (residual, residual_names, dealii::DataOut_DoFData<dealii::DoFHandler<dim>,dim>::DataVectorType::type_dof_data);
3413 typename dealii::DataOut<dim,dealii::DoFHandler<dim>>::CurvedCellRegion curved = dealii::DataOut<dim,dealii::DoFHandler<dim>>::CurvedCellRegion::curved_inner_cells;
3417 const dealii::Mapping<dim> &mapping = (*(
high_order_grid->mapping_fe_field));
3420 const int n_subdivisions = (enable_higher_order_vtk_output) ? std::max(grid_degree,
get_max_fe_degree()) : 0;
3421 data_out.build_patches(mapping, n_subdivisions, curved);
3422 const bool write_higher_order_cells = (n_subdivisions>1 && dim>1) ?
true :
false;
3423 dealii::DataOutBase::VtkFlags vtkflags(current_time,cycle,
true,dealii::DataOutBase::VtkFlags::ZlibCompressionLevel::best_compression,write_higher_order_cells);
3424 data_out.set_flags(vtkflags);
3426 const int iproc = dealii::Utilities::MPI::this_mpi_process(
mpi_communicator);
3427 std::string filename_prefix =
"solution";
3428 if(output_time_averaged_solution && !output_fluctuating_quantities) filename_prefix =
"time_averaged_solution";
3429 else if(output_fluctuating_quantities && !output_time_averaged_solution) filename_prefix =
"fluctuating_quantities";
3431 filename += dealii::Utilities::int_to_string(cycle, 4) +
".";
3432 filename += dealii::Utilities::int_to_string(iproc, 4);
3434 std::ofstream output(filename);
3435 data_out.write_vtu(output);
3439 std::vector<std::string> filenames;
3440 for (
unsigned int iproc = 0; iproc < dealii::Utilities::MPI::n_mpi_processes(
mpi_communicator); ++iproc) {
3441 std::string fn = filename_prefix +
"-" + dealii::Utilities::int_to_string(dim, 1) +
"D_maxpoly"+dealii::Utilities::int_to_string(
max_degree, 2)+
"-";
3442 fn += dealii::Utilities::int_to_string(cycle, 4) +
".";
3443 fn += dealii::Utilities::int_to_string(iproc, 4);
3445 filenames.push_back(fn);
3448 master_fn += dealii::Utilities::int_to_string(cycle, 4) +
".pvtu";
3449 std::ofstream master_output(master_fn);
3450 data_out.write_pvtu_record(master_output, filenames);
3455 (output_time_averaged_solution ==
false) && (output_fluctuating_quantities ==
false)) {
3465 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3468 for (
int idim=0; idim<dim; idim++) {
3477 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3479 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R)
3481 pcout <<
"Allocating DG system and initializing FEValues" << std::endl;
3489 dealii::DoFRenumbering::Cuthill_McKee(
dof_handler,
true);
3513 reduced_mesh_weights.reinit(
triangulation->n_active_cells());
3521 solution.add(std::numeric_limits<real>::lowest());
3528 time_averaged_solution *= 0.0;
3529 time_averaged_solution.add(std::numeric_limits<real>::lowest());
3534 fluctuating_quantities *= 0.0;
3535 fluctuating_quantities.add(std::numeric_limits<real>::lowest());
3538 std::cout <<
"\nNeed time-averaged solution to compute Reynolds stresses. Please set do_compute_time_averaged_solution=true. Aborting...\n";
3560 if (compute_dRdW || compute_dRdX || compute_d2R) {
3562 dealii::DoFTools::make_flux_sparsity_pattern(
dof_handler, dsp);
3605 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3610 dealii::IndexSet ghost_dofs_artificial_dissipation;
3611 dealii::IndexSet locally_relevant_dofs_artificial_dissipation;
3613 locally_relevant_dofs_artificial_dissipation = ghost_dofs_artificial_dissipation;
3614 ghost_dofs_artificial_dissipation.subtract_set(locally_owned_dofs_artificial_dissipation);
3624 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3631 const dealii::IndexSet &col_parallel_partitioning_d2RdWdX =
high_order_grid->locally_owned_dofs_grid;
3632 d2RdWdX.reinit(row_parallel_partitioning_d2RdWdX, col_parallel_partitioning_d2RdWdX, sparsity_pattern_d2RdWdX,
mpi_communicator);
3639 d2RdWdW.reinit(row_parallel_partitioning_d2RdWdW, col_parallel_partitioning_d2RdWdW, sparsity_pattern_d2RdWdW,
mpi_communicator);
3644 const dealii::IndexSet &row_parallel_partitioning_d2RdXdX =
high_order_grid->locally_owned_dofs_grid;
3645 const dealii::IndexSet &col_parallel_partitioning_d2RdXdX =
high_order_grid->locally_owned_dofs_grid;
3646 d2RdXdX.reinit(row_parallel_partitioning_d2RdXdX, col_parallel_partitioning_d2RdXdX, sparsity_pattern_d2RdXdX,
mpi_communicator);
3650 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3656 const dealii::IndexSet &col_parallel_partitioning =
high_order_grid->locally_owned_dofs_grid;
3657 dRdXv.reinit(row_parallel_partitioning, col_parallel_partitioning, dRdXv_sparsity_pattern, MPI_COMM_WORLD);
3660 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3662 const bool Cartesian_element,
3663 const unsigned int poly_degree,
const unsigned int grid_degree,
3683 if(grid_degree > 1 || !Cartesian_element){
3692 if(((FR_Type != FR_enum::cDG) ||
3693 (
use_auxiliary_eq && FR_Type_Aux != FR_Aux_enum::kDG) ) && (grid_degree > 1 || !Cartesian_element)){
3698 template <
int dim,
int nspecies,
typename real,
typename MeshType>
3713 dealii::DynamicSparsityPattern dsp(
dof_handler.n_dofs());
3714 std::vector<dealii::types::global_dof_index> dofs_indices;
3717 if (!cell->is_locally_owned())
continue;
3719 const unsigned int fe_index_curr_cell = cell->active_fe_index();
3722 const dealii::FESystem<dim,dim> ¤t_fe_ref =
fe_collection[fe_index_curr_cell];
3723 const unsigned int n_dofs_cell = current_fe_ref.n_dofs_per_cell();
3725 dofs_indices.resize(n_dofs_cell);
3726 cell->get_dof_indices (dofs_indices);
3727 for (
unsigned int itest=0; itest<n_dofs_cell; ++itest) {
3728 for (
unsigned int itrial=0; itrial<n_dofs_cell; ++itrial) {
3729 dsp.add(dofs_indices[itest], dofs_indices[itrial]);
3736 if (do_inverse_mass_matrix) {
3755 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
3764 const bool Cartesian_first_element = (first_cell->manifold_id() == dealii::numbers::flat_manifold_id);
3772 if (!cell->is_locally_owned())
continue;
3774 const bool Cartesian_element = (cell->manifold_id() == dealii::numbers::flat_manifold_id);
3776 const unsigned int fe_index_curr_cell = cell->active_fe_index();
3777 const unsigned int curr_grid_degree =
high_order_grid->fe_system.tensor_degree();
3784 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);
3795 const unsigned int n_dofs_cell =
fe_collection[fe_index_curr_cell].n_dofs_per_cell();
3800 const unsigned int n_metric_dofs =
high_order_grid->fe_system.dofs_per_cell;
3801 const unsigned int n_grid_nodes = n_metric_dofs/dim;
3802 std::vector<dealii::types::global_dof_index> metric_dofs_indices(n_metric_dofs);
3803 metric_cell->get_dof_indices (metric_dofs_indices);
3805 std::array<std::vector<real>,dim> mapping_support_points;
3806 for(
int idim=0; idim<dim; idim++){
3807 mapping_support_points[idim].resize(n_metric_dofs/dim);
3809 const std::vector<unsigned int > &index_renumbering = dealii::FETools::hierarchic_to_lexicographic_numbering<dim>(curr_grid_degree);
3810 for (
unsigned int idof = 0; idof< n_metric_dofs; ++idof) {
3811 const real val = (
high_order_grid->volume_nodes[metric_dofs_indices[idof]]);
3812 const unsigned int istate = fe_metric.system_to_component_index(idof).first;
3813 const unsigned int ishape = fe_metric.system_to_component_index(idof).second;
3814 const unsigned int igrid_node = index_renumbering[ishape];
3815 mapping_support_points[istate][igrid_node] = val;
3821 n_quad_pts, n_grid_nodes,
3822 mapping_support_points,
3826 dofs_indices.resize(n_dofs_cell);
3827 cell->get_dof_indices (dofs_indices);
3831 do_inverse_mass_matrix,
3839 reference_mass_matrix,
3846 if (do_inverse_mass_matrix) {
3865 template<
int dim,
int nspecies,
typename real,
typename MeshType>
3867 const bool Cartesian_element,
3868 const bool do_inverse_mass_matrix,
3869 const unsigned int poly_degree,
3870 const unsigned int ,
3871 const unsigned int n_quad_pts,
3872 const unsigned int n_dofs_cell,
3873 const std::vector<dealii::types::global_dof_index> dofs_indices,
3887 dealii::FullMatrix<real> local_mass_matrix(n_dofs_cell);
3888 dealii::FullMatrix<real> local_mass_matrix_inv(n_dofs_cell);
3889 dealii::FullMatrix<real> local_mass_matrix_aux(n_dofs_cell);
3890 dealii::FullMatrix<real> local_mass_matrix_aux_inv(n_dofs_cell);
3892 for(
int istate=0; istate<
nstate; istate++){
3893 const unsigned int n_shape_fns = n_dofs_cell /
nstate;
3894 dealii::FullMatrix<real> local_mass_matrix_state(n_shape_fns);
3895 dealii::FullMatrix<real> local_mass_matrix_inv_state(n_shape_fns);
3896 dealii::FullMatrix<real> local_mass_matrix_aux_state(n_shape_fns);
3897 dealii::FullMatrix<real> local_mass_matrix_aux_inv_state(n_shape_fns);
3901 if(Cartesian_element){
3902 local_mass_matrix_state.add(metric_oper.
det_Jac_vol[0],
3909 local_mass_matrix_aux_state.add(1.0, local_mass_matrix_state);
3911 if(FR_Type != FR_enum::cDG){
3912 local_mass_matrix_state.add(metric_oper.
det_Jac_vol[0],
3919 if(FR_Type_Aux != FR_Aux_enum::kDG){
3920 local_mass_matrix_aux_state.add(metric_oper.
det_Jac_vol[0],
3927 if(do_inverse_mass_matrix){
3928 local_mass_matrix_inv_state.invert(local_mass_matrix_state);
3930 local_mass_matrix_aux_inv_state.invert(local_mass_matrix_aux_state);
3939 n_shape_fns, n_quad_pts,
3944 if(
use_auxiliary_eq) local_mass_matrix_aux_state.add(1.0, local_mass_matrix_state);
3946 if(FR_Type != FR_enum::cDG){
3947 dealii::FullMatrix<real> local_FR(n_shape_fns);
3952 local_mass_matrix_state);
3953 local_mass_matrix_state.add(1.0, local_FR);
3956 if(FR_Type_Aux != FR_Aux_enum::kDG){
3957 dealii::FullMatrix<real> local_FR_aux(n_shape_fns);
3962 local_mass_matrix_aux_state);
3963 local_mass_matrix_aux_state.add(1.0, local_FR_aux);
3967 if(do_inverse_mass_matrix){
3968 local_mass_matrix_inv_state.invert(local_mass_matrix_state);
3970 local_mass_matrix_aux_inv_state.invert(local_mass_matrix_aux_state);
3977 std::vector<real> J_inv(n_quad_pts);
3978 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
3979 J_inv[iquad] = 1.0 / metric_oper.
det_Jac_vol[iquad];
3981 dealii::FullMatrix<real> local_weighted_mass_matrix(n_shape_fns);
3982 dealii::FullMatrix<real> local_weighted_mass_matrix_aux(n_shape_fns);
3985 n_shape_fns, n_quad_pts,
3990 local_weighted_mass_matrix_aux.add(1.0, local_weighted_mass_matrix);
3992 if(FR_Type != FR_enum::cDG){
3993 dealii::FullMatrix<real> local_FR(n_shape_fns);
3998 local_weighted_mass_matrix);
3999 local_weighted_mass_matrix.add(1.0, local_FR);
4003 if(FR_Type_Aux != FR_Aux_enum::kDG){
4004 dealii::FullMatrix<real> local_FR_aux(n_shape_fns);
4010 local_weighted_mass_matrix_aux.add(1.0, local_FR_aux);
4013 dealii::FullMatrix<real> ref_mass_dim(n_shape_fns);
4019 if(FR_Type != FR_enum::cDG){
4020 dealii::FullMatrix<real> local_FR(n_shape_fns);
4025 ref_mass_dim.add(1.0, local_FR);
4027 dealii::FullMatrix<real> ref_mass_dim_inv(n_shape_fns);
4028 ref_mass_dim_inv.invert(ref_mass_dim);
4029 dealii::FullMatrix<real> temp(n_shape_fns);
4030 ref_mass_dim_inv.mmult(temp, local_weighted_mass_matrix);
4031 temp.mmult(local_mass_matrix_inv_state, ref_mass_dim_inv);
4032 local_mass_matrix_state.invert(local_mass_matrix_inv_state);
4034 dealii::FullMatrix<real> temp2(n_shape_fns);
4035 ref_mass_dim_inv.mmult(temp2, local_weighted_mass_matrix_aux);
4036 temp2.mmult(local_mass_matrix_aux_inv_state, ref_mass_dim_inv);
4037 local_mass_matrix_aux_state.invert(local_mass_matrix_aux_inv_state);
4041 for(
unsigned int test_shape=0; test_shape<n_shape_fns; test_shape++){
4043 const unsigned int test_index = istate * n_shape_fns + test_shape;
4045 for(
unsigned int trial_shape=test_shape; trial_shape<n_shape_fns; trial_shape++){
4046 const unsigned int trial_index = istate * n_shape_fns + trial_shape;
4047 local_mass_matrix[test_index][trial_index] = local_mass_matrix_state[test_shape][trial_shape];
4048 local_mass_matrix[trial_index][test_index] = local_mass_matrix_state[test_shape][trial_shape];
4050 local_mass_matrix_inv[test_index][trial_index] = local_mass_matrix_inv_state[test_shape][trial_shape];
4051 local_mass_matrix_inv[trial_index][test_index] = local_mass_matrix_inv_state[test_shape][trial_shape];
4054 local_mass_matrix_aux[test_index][trial_index] = local_mass_matrix_aux_state[test_shape][trial_shape];
4055 local_mass_matrix_aux[trial_index][test_index] = local_mass_matrix_aux_state[test_shape][trial_shape];
4057 local_mass_matrix_aux_inv[test_index][trial_index] = local_mass_matrix_aux_inv_state[test_shape][trial_shape];
4058 local_mass_matrix_aux_inv[trial_index][test_index] = local_mass_matrix_aux_inv_state[test_shape][trial_shape];
4065 if (do_inverse_mass_matrix) {
4088 template<
int dim,
int nspecies,
typename real,
typename MeshType>
4090 const dealii::LinearAlgebra::distributed::Vector<double> &input_vector,
4091 dealii::LinearAlgebra::distributed::Vector<double> &output_vector,
4100 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
4111 const unsigned int grid_degree = this->
high_order_grid->fe_system.tensor_degree();
4113 const unsigned int n_metric_dofs =
high_order_grid->fe_system.dofs_per_cell;
4117 const bool Cartesian_first_element = (first_cell->manifold_id() == dealii::numbers::flat_manifold_id) ?
true :
false;
4119 if(Cartesian_first_element){
4120 if(use_auxiliary_eq){
4128 if(use_auxiliary_eq){
4136 dealii::Timer timer;
4141 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell) {
4142 if (!soln_cell->is_locally_owned())
continue;
4144 const unsigned int poly_degree = soln_cell->active_fe_index();
4145 const unsigned int n_dofs_cell =
fe_collection[poly_degree].n_dofs_per_cell();
4146 std::vector<dealii::types::global_dof_index> current_dofs_indices;
4147 current_dofs_indices.resize(n_dofs_cell);
4148 soln_cell->get_dof_indices (current_dofs_indices);
4150 const bool Cartesian_element = (soln_cell->manifold_id() == dealii::numbers::flat_manifold_id);
4153 if((poly_degree != mass_inv.
current_degree && Cartesian_element && !use_auxiliary_eq) ||
4154 (poly_degree != projection_oper.
current_degree && (grid_degree > 1 || Cartesian_element) && !use_auxiliary_eq))
4157 if(Cartesian_element){
4159 if(use_auxiliary_eq){
4165 if(use_auxiliary_eq){
4173 std::vector<dealii::types::global_dof_index> metric_dofs_indices(n_metric_dofs);
4174 metric_cell->get_dof_indices (metric_dofs_indices);
4176 std::array<std::vector<real>,dim> mapping_support_points;
4177 for(
int idim=0; idim<dim; idim++){
4178 mapping_support_points[idim].resize(n_metric_dofs/dim);
4180 const std::vector<unsigned int > &index_renumbering = dealii::FETools::hierarchic_to_lexicographic_numbering<dim>(grid_degree);
4181 for (
unsigned int idof = 0; idof< n_metric_dofs; ++idof) {
4182 const real val = (
high_order_grid->volume_nodes[metric_dofs_indices[idof]]);
4183 const unsigned int istate = fe_metric.system_to_component_index(idof).first;
4184 const unsigned int ishape = fe_metric.system_to_component_index(idof).second;
4185 const unsigned int igrid_node = index_renumbering[ishape];
4186 mapping_support_points[istate][igrid_node] = val;
4190 const unsigned int n_grid_nodes = n_metric_dofs / dim;
4194 n_quad_pts, n_grid_nodes,
4195 mapping_support_points,
4198 for(
int istate=0; istate<
nstate; istate++){
4199 const unsigned int n_shape_fns = n_dofs_cell /
nstate;
4200 std::vector<real> local_input_vector(n_shape_fns);
4201 std::vector<real> local_output_vector(n_shape_fns);
4203 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
4204 const unsigned int idof = istate * n_shape_fns + ishape;
4205 local_input_vector[ishape] = input_vector[current_dofs_indices[idof]];
4208 if(Cartesian_element){
4209 if(use_auxiliary_eq){
4221 if(use_auxiliary_eq){
4222 std::vector<real> projection_of_input(n_quad_pts);
4226 std::vector<real> JxW_inv(n_quad_pts);
4227 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
4228 JxW_inv[iquad] = 1.0 / (quad_weights[iquad] * metric_oper.
det_Jac_vol[iquad]);
4231 local_output_vector,
4235 std::vector<real> projection_of_input(n_quad_pts);
4239 std::vector<real> JxW_inv(n_quad_pts);
4240 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
4241 JxW_inv[iquad] = 1.0 / (quad_weights[iquad] * metric_oper.
det_Jac_vol[iquad]);
4244 local_output_vector,
4249 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
4250 const unsigned int idof = istate * n_shape_fns + ishape;
4251 output_vector[current_dofs_indices[idof]] = local_output_vector[ishape];
4262 template<
int dim,
int nspecies,
typename real,
typename MeshType>
4264 const dealii::LinearAlgebra::distributed::Vector<double> &input_vector,
4265 dealii::LinearAlgebra::distributed::Vector<double> &output_vector,
4267 const bool use_unmodified_mass_matrix)
4271 const FR_enum FR_cDG = FR_enum::cDG;
4275 const double FR_user_specified_correction_parameter_value = this->all_parameters->FR_user_specified_correction_parameter_value;
4276 const FR_Aux_enum FR_Type_Aux = this->all_parameters->flux_reconstruction_aux_type;
4278 const unsigned int init_grid_degree =
high_order_grid->fe_system.tensor_degree();
4288 const unsigned int grid_degree = this->
high_order_grid->fe_system.tensor_degree();
4290 const unsigned int n_metric_dofs =
high_order_grid->fe_system.dofs_per_cell;
4294 const bool Cartesian_first_element = (first_cell->manifold_id() == dealii::numbers::flat_manifold_id);
4296 if(use_auxiliary_eq){
4298 if(grid_degree>1 || !Cartesian_first_element){
4304 if(grid_degree>1 || !Cartesian_first_element){
4309 for (
auto soln_cell =
dof_handler.begin_active(); soln_cell !=
dof_handler.end(); ++soln_cell, ++metric_cell) {
4310 if (!soln_cell->is_locally_owned())
continue;
4312 const unsigned int poly_degree = soln_cell->active_fe_index();
4313 const unsigned int n_dofs_cell =
fe_collection[poly_degree].n_dofs_per_cell();
4314 std::vector<dealii::types::global_dof_index> current_dofs_indices;
4315 current_dofs_indices.resize(n_dofs_cell);
4316 soln_cell->get_dof_indices (current_dofs_indices);
4318 const bool Cartesian_element = (soln_cell->manifold_id() == dealii::numbers::flat_manifold_id) ?
true :
false;
4321 if((poly_degree != mass.
current_degree && (grid_degree == 1 || Cartesian_element) && !use_auxiliary_eq) ||
4322 (poly_degree != projection_oper.
current_degree && (grid_degree > 1 || !Cartesian_element) && !use_auxiliary_eq)){
4324 if(use_auxiliary_eq){
4326 if(grid_degree>1 || !Cartesian_element){
4332 if(grid_degree>1 || !Cartesian_element){
4340 std::vector<dealii::types::global_dof_index> metric_dofs_indices(n_metric_dofs);
4341 metric_cell->get_dof_indices (metric_dofs_indices);
4343 std::array<std::vector<real>,dim> mapping_support_points;
4344 for(
int idim=0; idim<dim; idim++){
4345 mapping_support_points[idim].resize(n_metric_dofs/dim);
4347 const std::vector<unsigned int > &index_renumbering = dealii::FETools::hierarchic_to_lexicographic_numbering<dim>(grid_degree);
4348 for (
unsigned int idof = 0; idof< n_metric_dofs; ++idof) {
4349 const real val = (
high_order_grid->volume_nodes[metric_dofs_indices[idof]]);
4350 const unsigned int istate = fe_metric.system_to_component_index(idof).first;
4351 const unsigned int ishape = fe_metric.system_to_component_index(idof).second;
4352 const unsigned int igrid_node = index_renumbering[ishape];
4353 mapping_support_points[istate][igrid_node] = val;
4357 const unsigned int n_grid_nodes = n_metric_dofs / dim;
4361 n_quad_pts, n_grid_nodes,
4362 mapping_support_points,
4366 for(
int istate=0; istate<
nstate; istate++){
4367 const unsigned int n_shape_fns = n_dofs_cell /
nstate;
4368 std::vector<real> local_input_vector(n_shape_fns);
4369 std::vector<real> local_output_vector(n_shape_fns);
4371 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
4372 const unsigned int idof = istate * n_shape_fns + ishape;
4373 local_input_vector[ishape] = input_vector[current_dofs_indices[idof]];
4375 if(Cartesian_element){
4376 if(use_auxiliary_eq){
4390 if(use_auxiliary_eq){
4392 dealii::FullMatrix<double> proj_mass(n_quad_pts_1D, n_dofs_1D);
4395 std::vector<real> projection_of_input(n_quad_pts);
4398 std::vector<real> JxW(n_quad_pts);
4399 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
4400 JxW[iquad] = (metric_oper.
det_Jac_vol[iquad] / quad_weights[iquad]);
4403 local_output_vector,
4409 std::vector<real> proj_mass(n_shape_fns);
4412 std::vector<real> projection_of_input(n_quad_pts);
4413 std::vector<real> ones(n_shape_fns, 1.0);
4416 std::vector<real> JxW(n_quad_pts);
4417 for(
unsigned int iquad=0; iquad<n_quad_pts; iquad++){
4418 JxW[iquad] = (metric_oper.
det_Jac_vol[iquad] / quad_weights[iquad])
4419 * projection_of_input[iquad];
4421 std::vector<real> temp(n_shape_fns);
4426 local_output_vector,
4432 for(
unsigned int ishape=0; ishape<n_shape_fns; ishape++){
4433 const unsigned int idof = istate * n_shape_fns + ishape;
4434 output_vector[current_dofs_indices[idof]] = local_output_vector[ishape];
4440 template<
int dim,
int nspecies,
typename real,
typename MeshType>
4445 template<
int dim,
int nspecies,
typename real,
typename MeshType>
4450 template<
int dim,
int nspecies,
typename real,
typename MeshType>
4455 std::vector<dealii::types::global_dof_index> dofs_indices;
4458 if (!cell->is_locally_owned())
continue;
4460 const unsigned int fe_index_curr_cell = cell->active_fe_index();
4463 const dealii::FESystem<dim,dim> ¤t_fe_ref =
fe_collection[fe_index_curr_cell];
4464 const unsigned int n_dofs_cell = current_fe_ref.n_dofs_per_cell();
4466 dofs_indices.resize(n_dofs_cell);
4467 cell->get_dof_indices (dofs_indices);
4469 const double max_dt =
max_dt_cell[cell->active_cell_index()];
4471 for (
unsigned int itest=0; itest<n_dofs_cell; ++itest) {
4472 const unsigned int istate_test = current_fe_ref.system_to_component_index(itest).first;
4473 for (
unsigned int itrial=itest; itrial<n_dofs_cell; ++itrial) {
4474 const unsigned int istate_trial = current_fe_ref.system_to_component_index(itrial).first;
4476 if(istate_test==istate_trial) {
4477 const unsigned int row = dofs_indices[itest];
4478 const unsigned int col = dofs_indices[itrial];
4480 const double new_val = value / (dt_scale * max_dt);
4481 AssertIsFinite(new_val);
4491 template<
int dim,
int nspecies,
typename real>
4493 const std::vector< real > &function_coeff,
4494 const dealii::FESystem<dim,dim> &fe_input,
4495 const dealii::FESystem<dim,dim> &fe_output,
4496 const dealii::QGauss<dim> &projection_quadrature)
4498 const unsigned int nstate = fe_input.n_components();
4499 const unsigned int n_vector_dofs_in = fe_input.dofs_per_cell;
4500 const unsigned int n_vector_dofs_out = fe_output.dofs_per_cell;
4501 const unsigned int n_dofs_in = n_vector_dofs_in /
nstate;
4502 const unsigned int n_dofs_out = n_vector_dofs_out /
nstate;
4504 assert(n_vector_dofs_in == function_coeff.size());
4505 assert(nstate == fe_output.n_components());
4507 const unsigned int n_quad_pts = projection_quadrature.size();
4508 const std::vector<dealii::Point<dim,double>> &unit_quad_pts = projection_quadrature.get_points();
4510 std::vector< real > function_coeff_out(n_vector_dofs_out);
4511 for (
unsigned istate = 0; istate <
nstate; ++istate) {
4513 std::vector< real > function_at_quad(n_quad_pts);
4516 dealii::FullMatrix<double> interpolation_operator(n_dofs_out,n_quad_pts);
4518 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
4519 function_at_quad[iquad] = 0.0;
4520 for (
unsigned int idof=0; idof<n_dofs_in; ++idof) {
4521 const unsigned int idof_vector = fe_input.component_to_system_index(istate,idof);
4522 function_at_quad[iquad] += function_coeff[idof_vector] * fe_input.shape_value_component(idof_vector,unit_quad_pts[iquad],istate);
4524 function_at_quad[iquad] *= projection_quadrature.weight(iquad);
4526 for (
unsigned int idof=0; idof<n_dofs_out; ++idof) {
4527 const unsigned int idof_vector = fe_output.component_to_system_index(istate,idof);
4528 interpolation_operator[idof][iquad] = fe_output.shape_value_component(idof_vector,unit_quad_pts[iquad],istate);
4532 std::vector< real > rhs(n_dofs_out);
4533 for (
unsigned int idof=0; idof<n_dofs_out; ++idof) {
4535 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
4536 rhs[idof] += interpolation_operator[idof][iquad] * function_at_quad[iquad];
4540 dealii::FullMatrix<double> mass(n_dofs_out, n_dofs_out);
4541 for(
unsigned int row=0; row<n_dofs_out; ++row) {
4542 for(
unsigned int col=0; col<n_dofs_out; ++col) {
4546 for(
unsigned int row=0; row<n_dofs_out; ++row) {
4547 for(
unsigned int col=0; col<n_dofs_out; ++col) {
4548 for(
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
4549 mass[row][col] += interpolation_operator[row][iquad] * interpolation_operator[col][iquad] * projection_quadrature.weight(iquad);
4553 dealii::FullMatrix<double> inverse_mass(n_dofs_out, n_dofs_out);
4554 inverse_mass.invert(mass);
4556 for(
unsigned int row=0; row<n_dofs_out; ++row) {
4557 const unsigned int idof_vector = fe_output.component_to_system_index(istate,row);
4558 function_coeff_out[idof_vector] = 0.0;
4559 for(
unsigned int col=0; col<n_dofs_out; ++col) {
4560 function_coeff_out[idof_vector] += inverse_mass[row][col] * rhs[col];
4565 return function_coeff_out;
4569 template <
int dim,
int nspecies,
typename real,
typename MeshType>
4570 template <
typename real2>
4572 const dealii::Quadrature<dim> &volume_quadrature,
4573 const std::vector< real2 > &soln_coeff_high,
4574 const dealii::FiniteElement<dim,dim> &fe_high,
4575 const std::vector<real2> &jac_det)
4577 const unsigned int degree = fe_high.tensor_degree();
4579 if (degree == 0)
return 0;
4581 const unsigned int nstate = fe_high.components;
4582 const unsigned int n_dofs_high = fe_high.dofs_per_cell;
4585 const unsigned int lower_degree = degree-1;
4586 const dealii::FE_DGQLegendre<dim> fe_dgq_lower(lower_degree);
4587 const dealii::FESystem<dim,dim> fe_lower(fe_dgq_lower, nstate);
4590 const dealii::QGauss<dim> projection_quadrature(degree+5);
4591 std::vector< real2 > soln_coeff_lower = project_function<dim,nspecies,real2>( soln_coeff_high, fe_high, fe_lower, projection_quadrature);
4594 const std::vector<dealii::Point<dim,double>> &unit_quad_pts = volume_quadrature.get_points();
4596 const unsigned int n_quad_pts = volume_quadrature.size();
4597 const unsigned int n_dofs_lower = fe_lower.dofs_per_cell;
4599 real2 element_volume = 0.0;
4601 real2 soln_norm = 0.0;
4602 std::vector<real2> soln_high(nstate);
4603 std::vector<real2> soln_lower(nstate);
4604 for (
unsigned int iquad=0; iquad<n_quad_pts; ++iquad) {
4605 for (
unsigned int s=0; s<
nstate; ++s) {
4607 soln_lower[s] = 0.0;
4610 for (
unsigned int idof=0; idof<n_dofs_high; ++idof) {
4611 const unsigned int istate = fe_high.system_to_component_index(idof).first;
4612 soln_high[istate] += soln_coeff_high[idof] * fe_high.shape_value_component(idof,unit_quad_pts[iquad],istate);
4615 for (
unsigned int idof=0; idof<n_dofs_lower; ++idof) {
4616 const unsigned int istate = fe_lower.system_to_component_index(idof).first;
4617 soln_lower[istate] += soln_coeff_lower[idof] * fe_lower.shape_value_component(idof,unit_quad_pts[iquad],istate);
4620 const real2 JxW = jac_det[iquad] * volume_quadrature.weight(iquad);
4621 element_volume += JxW;
4624 for (
unsigned int s=0; s<1; ++s)
4626 error += (soln_high[s] - soln_lower[s]) * (soln_high[s] - soln_lower[s]) * JxW;
4627 soln_norm += soln_high[s] * soln_high[s] * JxW;
4631 if (soln_norm < 1e-15)
return 0;
4633 const real2 S_e = sqrt(error / soln_norm);
4634 const real2 s_e = log10(S_e);
4637 const double s_0 = -0.00 - 4.00*log10(degree);
4639 const double low = s_0 - kappa;
4640 const double upp = s_0 + kappa;
4642 const real2 diameter = pow(element_volume, 1.0/dim);
4643 const real2 eps_0 = mu_scale * diameter / (double)degree;
4645 if ( s_e < low)
return 0.0;
4652 const double PI = 4*atan(1);
4653 real2 eps = 1.0 + sin(PI * (s_e - s_0) * 0.5 / kappa);
4658 template <
int dim,
int nspecies,
typename real,
typename MeshType>
4661 this->current_time = current_time_input;
4695 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
4696 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
4697 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
4698 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
4699 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
4700 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
4701 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
4702 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
4711 const bool compute_auxiliary_right_hand_side,
4712 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
4713 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
4717 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
4718 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
4719 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
4720 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
4721 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
4722 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
4723 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
4724 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
4733 const bool compute_auxiliary_right_hand_side,
4734 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
4735 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
4738 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
4739 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
4740 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
4741 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
4742 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
4743 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
4744 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
4745 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
4754 const bool compute_auxiliary_right_hand_side,
4755 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
4756 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
4760 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
4761 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
4762 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
4763 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
4764 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
4765 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
4766 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
4767 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
4776 const bool compute_auxiliary_right_hand_side,
4777 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
4778 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
4784 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
4785 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
4786 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
4787 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
4788 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
4789 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
4790 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
4791 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
4800 const bool compute_auxiliary_right_hand_side,
4801 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
4802 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
4806 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_cell,
4807 const dealii::TriaActiveIterator<dealii::DoFCellAccessor<PHILIP_DIM, PHILIP_DIM, false>> ¤t_metric_cell,
4808 const bool compute_dRdW,
const bool compute_dRdX,
const bool compute_d2R,
4809 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume,
4810 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_int,
4811 dealii::hp::FEFaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_face_ext,
4812 dealii::hp::FESubfaceValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_subface,
4813 dealii::hp::FEValues<PHILIP_DIM,PHILIP_DIM> &fe_values_collection_volume_lagrange,
4822 const bool compute_auxiliary_right_hand_side,
4823 dealii::LinearAlgebra::distributed::Vector<double> &rhs,
4824 std::array<dealii::LinearAlgebra::distributed::Vector<double>,PHILIP_DIM> &rhs_aux);
bool do_compute_Reynolds_stress
Flag for computing time-averaged Reynolds stresses.
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.
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 > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis)
Builds needed operators for cell residual loop.
std::enable_if<!std::is_same< adtype, double >::value, void >::type assemble_face_codi_taped_derivatives_ad(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, 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, const dealii::FESystem< dim, dim > &fe_int, const dealii::FESystem< dim, dim > &fe_ext, const std::vector< dealii::types::global_dof_index > &soln_dofs_indices_int, const std::vector< dealii::types::global_dof_index > &soln_dofs_indices_ext, const std::vector< dealii::types::global_dof_index > &metric_dofs_indices_int, const std::vector< dealii::types::global_dof_index > &metric_dofs_indices_ext, 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 > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< adtype, dim, 2 *dim > &metric_oper_int, OPERATOR::metric_operators< adtype, dim, 2 *dim > &metric_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis, std::array< std::vector< adtype >, dim > &mapping_support_points, std::vector< real > &local_rhs_int_cell, std::vector< real > &local_rhs_ext_cell, dealii::Tensor< 1, dim, std::vector< 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, const bool is_a_subface=false, const unsigned int neighbor_i_subface=0)
Computes face term of the cell and performs automatic differentiation.
PartialDifferentialEquation pde_type
Store the PDE type to be solved.
void add_time_scaled_mass_matrices()
Add time scaled mass matrices to the system.
const dealii::hp::FECollection< dim > fe_collection_lagrange
Lagrange basis used in strong form.
The metric independent inverse of the FR mass matrix .
dealii::SparsityPattern get_d2RdXdX_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXdX.
void allocate_artificial_dissipation()
Allocates variables of artificial dissipation.
Sacado::Fad::DFad< FadType > FadFadType
Sacado AD type that allows 2nd derivatives.
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.
void add_mass_matrices(const real scale)
Add mass matrices to the system scaled by a factor (likely time-step)
double max_artificial_dissipation_coeff
Stores maximum artificial dissipation while assembling the residual.
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...
dealii::Point< dim > coordinates_of_highest_refined_cell(bool check_for_p_refined_cell=false)
Returns the coordinates of the most refined cell.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
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...
virtual void assemble_boundary_term_and_build_operators_ad(typename dealii::DoFHandler< dim >::active_cell_iterator cell, const dealii::types::global_dof_index current_cell_index, const std::vector< double > &soln_coeffs, const dealii::Tensor< 1, dim, std::vector< double >> &aux_soln_coeffs, const std::vector< double > &metric_coeffs, const std::vector< real > &local_dual, const unsigned int face_number, const unsigned int boundary_id, const unsigned int poly_degree, const unsigned int grid_degree, OPERATOR::basis_functions< dim, 2 *dim > &soln_basis, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::metric_operators< double, dim, 2 *dim > &metric_oper, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis, std::array< std::vector< double >, dim > &mapping_support_points, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_int, const dealii::FESystem< dim, dim > &fe_soln, const real penalty, std::vector< double > &rhs, dealii::Tensor< 1, dim, std::vector< double >> &local_auxiliary_RHS, const bool compute_auxiliary_right_hand_side, double &dual_dot_residual)=0
Builds the necessary operators/fe values and assembles boundary residual. For double type...
dealii::LinearAlgebra::distributed::Vector< double > artificial_dissipation_c0
Artificial dissipation coefficients.
FlowSolverParam flow_solver_param
Contains the parameters for simulation cases (flow solver test)
Sacado::Fad::DFad< double > FadType
Sacado AD type for first derivatives.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
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 dRdXv
bool output_face_results_vtk
Flag for outputting the surface solution vtk files.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
const dealii::FE_Q< dim > fe_q_artificial_dissipation
Continuous distribution of artificial dissipation.
double assemble_residual_time
Computational time for assembling residual.
dealii::ConditionalOStream pcout
Parallel std::cout that only outputs on mpi_rank==0.
codi_JacobianComputationType RadType
CoDiPaco reverse-AD type for first derivatives.
dealii::IndexSet ghost_dofs
Locally relevant ghost degrees of freedom.
unsigned int current_degree
Stores the degree of the current poly degree.
The metric independent FR mass matrix for auxiliary equation .
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.
bool freeze_artificial_dissipation
Flag to freeze artificial dissipation.
virtual void set_store_surf_flux_nodes()=0
Set store_surf_flux_nodes flag.
virtual void allocate_second_derivatives()
Allocates the second derivatives.
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.
void output_face_results_vtk(const unsigned int cycle, const double current_time=0.0, const bool output_time_averaged_solution=false, const bool output_fluctuating_quantities=false)
Output Euler face solution.
const dealii::UpdateFlags neighbor_face_update_flags
Update flags needed at neighbor' face points.
bool use_energy
Flag to use an energy monotonicity test.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
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 > &mapping_basis)
Builds just the determinant of the volume metric determinant.
Projection operator corresponding to basis functions onto -norm for auxiliary equation.
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...
dealii::hp::QCollection< dim-1 > face_quadrature_collection
Quadrature used to evaluate face integrals.
virtual void update_model_variables()=0
Update the necessary variables declared in src/physics/model.h.
dealii::TrilinosWrappers::SparseMatrix global_mass_matrix_auxiliary
Global auxiliary mass matrix.
dealii::LinearAlgebra::distributed::Vector< double > volume_nodes_d2R
unsigned int current_degree
Stores the degree of the current poly degree.
Files for the baseline physics.
dealii::DoFHandler< dim > dof_handler_artificial_dissipation
Degrees of freedom handler for C0 artificial dissipation.
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.
dealii::TrilinosWrappers::SparseMatrix system_matrix_transpose
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
void allocate_auxiliary_equation()
Allocates the auxiliary equations' variables and right hand side (primarily for Strong form diffusive...
bool use_weak_form
Flag to use weak or strong form of DG.
dealii::TrilinosWrappers::SparseMatrix global_mass_matrix
Global mass matrix.
double time_to_start_averaging
Flag for starting time-averaged solution.
double get_residual_linfnorm() const
Returns the Linf-norm of the right_hand_side vector.
dealii::QGauss< 0 > oneD_face_quadrature
1D surface quadrature is always one single point for all poly degrees.
void reinit()
Reinitializes the DG object after a change of triangulation.
std::enable_if<!std::is_same< adtype, double >::value, void >::type assemble_boundary_codi_taped_derivatives_ad(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 > &soln_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 > &soln_basis, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::metric_operators< adtype, dim, 2 *dim > &metric_oper, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis, std::array< std::vector< adtype >, dim > &mapping_support_points, dealii::hp::FEFaceValues< dim, dim > &fe_values_collection_face_int, const dealii::FESystem< dim, dim > &fe_soln, std::vector< real > &local_rhs_cell, dealii::Tensor< 1, dim, std::vector< real >> &local_auxiliary_RHS, const bool compute_auxiliary_right_hand_side, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R)
Computes boundary term of the cell if the cell has a face at the boundary and performs automatic diff...
std::shared_ptr< HighOrderGrid< dim, real, MeshType > > high_order_grid
High order grid that will provide the MappingFEField.
double get_residual_l2norm() const
Returns the L2-norm of the right_hand_side vector.
unsigned int current_degree
Stores the degree of the current poly degree.
const int nstate
Number of state variables.
dealii::hp::QCollection< dim > volume_quadrature_collection
Finite Element Collection to represent the high-order grid.
Flux_Reconstruction
Type of correction in Flux Reconstruction.
Flux_Reconstruction_Aux flux_reconstruction_aux_type
Store flux reconstruction type for the auxiliary variables.
-th order modal derivative of basis fuctions, ie/
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 > &basis, OPERATOR::local_mass< dim, 2 *dim > &reference_mass_matrix, OPERATOR::local_Flux_Reconstruction_operator< dim, 2 *dim > &reference_FR, OPERATOR::local_Flux_Reconstruction_operator_aux< dim, 2 *dim > &reference_FR_aux, OPERATOR::derivative_p< dim, 2 *dim > &deriv_p)
Evaluates the metric dependent local mass matrices and inverses, then sets them in the global matrice...
virtual void assemble_auxiliary_residual(const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R)=0
Asembles the auxiliary equations' residuals and solves. Note: This function cannot be automatically d...
dealii::TrilinosWrappers::SparseMatrix d2RdWdX
virtual void allocate_dual_vector(const bool compute_d2R)=0
Allocate the dual vector for optimization.
Main parameter class that contains the various other sub-parameter classes.
std::unique_ptr< Epetra_RowMatrixTransposer > epetra_rowmatrixtransposer_dRdW
Epetra_RowMatrixTransposer used to transpose the system_matrix.
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.
unsigned int current_degree
Stores the degree of the current poly degree.
void build_1D_surface_gradient_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 0 > &quadrature)
Assembles the one dimensional operator.
dealii::LinearAlgebra::distributed::Vector< double > solution_dRdX
dealii::Vector< double > artificial_dissipation_se
Artificial dissipation error ratio sensor in each cell.
void set_all_cells_fe_degree(const unsigned int degree)
Refers to a collection Mappings, which represents the high-order grid.
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.
dealii::DoFHandler< dim > dof_handler
Finite Element Collection to represent the high-order grid.
unsigned int n_dofs() const
Number of degrees of freedom.
bool enable_higher_order_vtk_output
Enable writing of higher-order vtk results.
Flux_Reconstruction flux_reconstruction_type
Store flux reconstruction type.
bool use_auxiliary_eq
Flag for using the auxiliary equation.
dealii::TrilinosWrappers::SparseMatrix system_matrix
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 > &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 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 > &mapping_basis, OPERATOR::basis_functions< dim, 2 *dim > &basis, OPERATOR::local_mass< dim, 2 *dim > &reference_mass_matrix, OPERATOR::local_Flux_Reconstruction_operator< dim, 2 *dim > &reference_FR, OPERATOR::local_Flux_Reconstruction_operator_aux< dim, 2 *dim > &reference_FR_aux, OPERATOR::derivative_p< dim, 2 *dim > &deriv_p)
Builds needed operators to compute mass matrices/inverses efficiently.
dealii::Vector< double > cell_volume
Time it takes for the maximum wavespeed to cross the cell domain.
const Parameters::AllParameters *const all_parameters
Pointer to all parameters.
dealii::FullMatrix< double > oneD_transpose_vol_operator
Stores the transpose of the operator for fast weight-adjusted solves.
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)...
virtual void assemble_volume_term_and_build_operators_ad(typename dealii::DoFHandler< dim >::active_cell_iterator cell, const dealii::types::global_dof_index current_cell_index, const std::vector< double > &soln_coeffs, const dealii::Tensor< 1, dim, std::vector< double >> &aux_soln_coeffs, const std::vector< double > &metric_coeffs, const std::vector< real > &local_dual, const std::vector< dealii::types::global_dof_index > &soln_dofs_indices, const std::vector< dealii::types::global_dof_index > &metric_dofs_indices, const unsigned int poly_degree, const unsigned int grid_degree, OPERATOR::basis_functions< dim, 2 *dim > &soln_basis, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis, OPERATOR::local_basis_stiffness< dim, 2 *dim > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< double, dim, 2 *dim > &metric_oper, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis, std::array< std::vector< double >, 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 > &fe_soln, std::vector< double > &rhs, dealii::Tensor< 1, dim, std::vector< double >> &local_auxiliary_RHS, const bool compute_auxiliary_right_hand_side, double &dual_dot_residual)=0
Builds the necessary operators/fe values and assembles volume residual. For double type...
MPI_Comm mpi_communicator
MPI communicator.
dealii::LinearAlgebra::distributed::Vector< double > dual_d2R
unsigned int current_degree
Stores the degree of the current poly degree.
void automatic_differentiation_indexing_1(const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R, const unsigned int n_soln_dofs, const unsigned int n_metric_dofs, unsigned int &w_start, unsigned int &w_end, unsigned int &x_start, unsigned int &x_end)
dealii::LinearAlgebra::distributed::Vector< double > volume_nodes_dRdW
bool do_renumber_dofs
Flag for renumbering DOFs.
dealii::IndexSet locally_owned_dofs
Locally own degrees of freedom.
Base metric operators class that stores functions used in both the volume and on surface.
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.
const unsigned int initial_degree
Initial polynomial degree assigned during constructor.
dealii::SparsityPattern sparsity_pattern
Sparsity pattern used on the system_matrix.
ESFR correction matrix for AUX EQUATION without jac dependence.
std::array< dealii::LinearAlgebra::distributed::Vector< double >, dim > auxiliary_solution
The auxiliary equations' solution.
dealii::FullMatrix< double > oneD_vol_operator
Stores the one dimensional volume operator.
void assemble_cell_residual_and_ad_derivatives(const dealii::TriaActiveIterator< dealii::DoFCellAccessor< dim, dim, false >> ¤t_cell, const dealii::TriaActiveIterator< dealii::DoFCellAccessor< dim, dim, false >> ¤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 > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim > &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().
bool do_compute_time_averaged_solution
Flag for computing time-averaged solution.
The mapping shape functions evaluated at the desired nodes (facet set included in volume grid nodes f...
unsigned int current_degree
Stores the degree of the current poly degree.
double getValue(const real2 &x)
Returns the value from a CoDiPack variable.
unsigned int current_grid_degree
Stores the degree of the current grid degree.
dealii::Vector< double > max_dt_cell
Time it takes for the maximum wavespeed to cross the cell domain.
virtual void allocate_model_variables()=0
Allocate the necessary variables declared in src/physics/model.h.
double FR_user_specified_correction_parameter_value
User specified flux recontruction correction parameter value.
unsigned int get_min_fe_degree()
Gets the minimum value of currently active FE degree.
dealii::SparsityPattern get_d2RdWdX_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdXdW.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
dealii::LinearAlgebra::distributed::Vector< double > solution_dRdW
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 .
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
void inner_product_1D(const std::vector< real > &input_vect, const std::vector< double > &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.
virtual void set_use_auxiliary_eq()=0
Set use_auxiliary_eq flag.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
dealii::LinearAlgebra::distributed::Vector< double > volume_nodes_dRdX
dealii::LinearAlgebra::distributed::Vector< double > right_hand_side
Residual of the current solution.
dealii::hp::QCollection< 1 > oneD_quadrature_collection
1D quadrature to generate Lagrange polynomials for the sake of flux interpolation.
const dealii::UpdateFlags volume_update_flags
Update flags needed at volume points.
double kappa_artificial_dissipation
Parameter kappa from Persson and Peraire, 2008.
Flux_Reconstruction_Aux
Type of correction in Flux Reconstruction for the auxiliary variables.
std::array< dealii::LinearAlgebra::distributed::Vector< double >, dim > auxiliary_right_hand_side
The auxiliary equations' right hand sides.
dealii::TrilinosWrappers::SparseMatrix d2RdXdX
virtual void build_volume_metric_operators(const unsigned int poly_degree, const unsigned int grid_degree, const std::vector< double > &metric_coeffs, OPERATOR::metric_operators< double, dim, 2 *dim > &metric_oper, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis, std::array< std::vector< double >, dim > &mapping_support_points)=0
Builds volume metric operators (metric cofactor and determinant of metric Jacobian). For double type.
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::LinearAlgebra::distributed::Vector< double > solution
Current modal coefficients of the solution.
unsigned int current_degree
Stores the degree of the current poly degree.
double mu_artificial_dissipation
Parameter mu from Persson & Peraire, 2008.
dealii::LinearAlgebra::distributed::Vector< real > dual
Current optimization dual variables corresponding to the residual constraints also known as the adjoi...
bool store_surf_flux_nodes
Flag for storing surface flux nodes.
void update_artificial_dissipation_discontinuity_sensor()
Update discontinuity sensor.
RenumberDofsType
Renumber dofs type.
real evaluate_penalty_scaling(const DoFCellAccessorType &cell, const int iface, const dealii::hp::FECollection< dim > fe_collection) const
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 .
Projection operator corresponding to basis functions onto -norm.
const dealii::hp::FECollection< 1 > oneD_fe_collection
1D Finite Element Collection for p-finite-element to represent the solution
dealii::SparsityPattern mass_sparsity_pattern
Sparsity pattern used on the system_matrix.
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.
const unsigned int max_degree
Maximum degree used for p-refi1nement.
dealii::Vector< double > artificial_dissipation_coeffs
Artificial dissipation in each cell.
FluxNodes flux_nodes_type
Store selected FluxNodes from the input file.
real current_time
The current time set in set_current_time()
dealii::IndexSet locally_relevant_dofs
Union of locally owned degrees of freedom and relevant ghost degrees of freedom.
double CFL_mass_dRdW
CFL used to add mass matrix in the optimization FlowConstraints class.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
double time_to_start_computing_Reynolds_stress
Flag for starting to compute Reynolds stresses. This needs to be after the time-averaging has started...
dealii::TrilinosWrappers::SparseMatrix global_inverse_mass_matrix
Global inverser mass matrix.
void set_current_time(const real current_time_input)
Sets the current time within DG to be used for unsteady source terms.
dealii::TrilinosWrappers::SparseMatrix time_scaled_global_mass_matrix
Global mass matrix divided by the time scales.
const dealii::UpdateFlags face_update_flags
Update flags needed at face points.
bool add_artificial_dissipation
Flag to add artificial dissipation from Persson's shock capturing paper.
const unsigned int max_grid_degree
Maximum grid degree used for hp-refi1nement.
dealii::SparsityPattern get_d2RdWdW_sparsity_pattern()
Evaluate SparsityPattern of the residual Hessian dual.d2RdWdW.
void evaluate_mass_matrices(bool do_inverse_mass_matrix=false)
Allocates and evaluates the mass matrices for the entire grid.
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...
std::shared_ptr< Triangulation > triangulation
Mesh.
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...
double sipg_penalty_factor
Scaling of Symmetric Interior Penalty term to ensure coercivity.
MassiveCollectionTuple create_collection_tuple(const unsigned int max_degree, const int nstate, const Parameters::AllParameters *const parameters_input) const
Used in the delegated constructor.
bool use_weight_adjusted_mass
Flag to use weight-adjusted Mass Matrix for curvilinear elements.
const dealii::hp::FECollection< dim > fe_collection
Finite Element Collection for p-finite-element to represent the solution.
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.
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.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
DGBase is independent of the number of state variables.
const dealii::hp::FECollection< 1 > oneD_fe_collection_flux
1D collocated flux basis used in strong form
void time_scaled_mass_matrices(const real scale)
virtual void set_store_vol_flux_nodes()=0
Set store_vol_flux_nodes flag.
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.
std::enable_if<!std::is_same< adtype, double >::value, void >::type assemble_volume_codi_taped_derivatives_ad(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 > &soln_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 > &soln_basis, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis, OPERATOR::local_basis_stiffness< dim, 2 *dim > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< adtype, dim, 2 *dim > &metric_oper, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis, std::array< std::vector< adtype >, 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 > &fe_soln, std::vector< real > &local_rhs_cell, dealii::Tensor< 1, dim, std::vector< real >> &local_auxiliary_RHS, const bool compute_auxiliary_right_hand_side, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R)
Computes the volume term of the cell and performs automatic differentiation.
void automatic_differentiation_indexing_2(const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R, const unsigned int n_soln_dofs_int, const unsigned int n_soln_dofs_ext, const unsigned int n_metric_dofs, unsigned int &w_int_start, unsigned int &w_int_end, unsigned int &w_ext_start, unsigned int &w_ext_end, unsigned int &x_int_start, unsigned int &x_int_end, unsigned int &x_ext_start, unsigned int &x_ext_end)
ArtificialDissipationParam artificial_dissipation_param
Contains parameters for artificial dissipation.
codi_HessianComputationType RadFadType
Nested reverse-forward mode type for Jacobian and Hessian computation using TapeHelper.
RenumberDofsType renumber_dofs_type
Store selected RenumberDofsType from the input file.
virtual void allocate_dRdX()
Allocates the residual derivatives w.r.t the volume nodes.
void build_1D_volume_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
void build_1D_surface_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 0 > &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.
virtual void allocate_system(const bool compute_dRdW=true, const bool compute_dRdX=true, const bool compute_d2R=true)
Allocates the system.
static std::unique_ptr< dealii::DataPostprocessor< dim > > create_Postprocessor(const Parameters::AllParameters *const parameters_input)
Create the post-processor with the correct template parameters.
unsigned int get_max_fe_degree()
Gets the maximum value of currently active FE degree.
void build_1D_gradient_operator(const dealii::FESystem< 1, 1 > &finite_element, const dealii::Quadrature< 1 > &quadrature)
Assembles the one dimensional operator.
Projection operator corresponding to basis functions onto M-norm (L2).
unsigned int current_degree
Stores the degree of the current poly degree.
dealii::FullMatrix< double > oneD_transpose_vol_operator
Stores the transpose of the operator for fast weight-adjusted solves.
dealii::SparsityPattern get_dRdX_sparsity_pattern()
Evaluate SparsityPattern of dRdX.
Local stiffness matrix without jacobian dependence.
virtual void assemble_face_term_and_build_operators_ad(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 std::vector< double > &soln_coeff_int, const std::vector< double > &soln_coeff_ext, const dealii::Tensor< 1, dim, std::vector< double >> &aux_soln_coeff_int, const dealii::Tensor< 1, dim, std::vector< double >> &aux_soln_coeff_ext, const std::vector< double > &metric_coefF_int, const std::vector< double > &metric_coefF_ext, const std::vector< double > &dual_int, const std::vector< double > &dual_ext, 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 > &soln_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &soln_basis_ext, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_int, OPERATOR::basis_functions< dim, 2 *dim > &flux_basis_ext, OPERATOR::local_basis_stiffness< dim, 2 *dim > &flux_basis_stiffness, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_int, OPERATOR::vol_projection_operator< dim, 2 *dim > &soln_basis_projection_oper_ext, OPERATOR::metric_operators< double, dim, 2 *dim > &metric_oper_int, OPERATOR::metric_operators< double, dim, 2 *dim > &metric_oper_ext, OPERATOR::mapping_shape_functions< dim, 2 *dim > &mapping_basis, std::array< std::vector< double >, 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::hp::FESubfaceValues< dim, dim > &fe_values_collection_subface, const dealii::FESystem< dim, dim > &fe_int, const dealii::FESystem< dim, dim > &fe_ext, const real penalty, std::vector< double > &rhs_int, std::vector< double > &rhs_ext, dealii::Tensor< 1, dim, std::vector< double >> &aux_rhs_int, dealii::Tensor< 1, dim, std::vector< double >> &aux_rhs_ext, const bool compute_auxiliary_right_hand_side, double &dual_dot_residual, const bool compute_dRdW, const bool compute_dRdX, const bool compute_d2R, const bool is_a_subface, const unsigned int neighbor_i_subface)=0
Builds the necessary operators/fe values and assembles face residual. For double type.
FluxNodes
Flux nodes type.
int overintegration
Number of additional quadrature points to use.
void output_results_vtk(const unsigned int cycle, const double current_time=0.0, const bool output_time_averaged_solution=false, const bool output_fluctuating_quantities=false)
Output solution.
bool store_residual_cpu_time
Flag to store the residual local processor cpu time.
unsigned int current_degree
Stores the degree of the current poly degree.
dealii::LinearAlgebra::distributed::Vector< double > solution_d2R
dealii::TrilinosWrappers::SparseMatrix d2RdWdW
dealii::TrilinosWrappers::SparseMatrix global_inverse_mass_matrix_auxiliary
Global inverse of the auxiliary mass matrix.
bool store_vol_flux_nodes
Flag for storing volume flux nodes.