/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/FEM/assembler/ddg.hh Source File#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
ddg.hh
Go to the documentation of this file.
22 return named_tuple<std::tuple<T &...>, StringSet<"fe_functions", "fe_derivatives", "fe_hessians", "extractors",
28 return named_tuple<std::tuple<T &...>, StringSet<"fe_functions", "fe_derivatives", "fe_hessians">>(
92 solution_grad_interface[0].resize(q_face_size, std::vector<Tensor<1, dim, NumberType>>(n_components));
93 solution_grad_interface[1].resize(q_face_size, std::vector<Tensor<1, dim, NumberType>>(n_components));
94 solution_hess_interface[0].resize(q_face_size, std::vector<Tensor<2, dim, NumberType>>(n_components));
95 solution_hess_interface[1].resize(q_face_size, std::vector<Tensor<2, dim, NumberType>>(n_components));
220 reinit_la_vector(vec, discretization.get_locally_owned_dofs(), discretization.get_communicator());
224 reinit_la_matrix(matrix, get_sparsity_pattern_jacobian(), discretization.get_locally_owned_dofs(),
228 virtual MPI_Comm get_communicator() const override { return discretization.get_communicator(); }
231 view.reinit(discretization.get_locally_owned_dofs(), discretization.get_locally_relevant_dofs(),
246 finalize_la_sparsity<SparseMatrixType>(dsp, sparsity_pattern_mass, discretization.get_locally_owned_dofs(),
251 MatrixCreator::create_mass_matrix(dof_handler, quadrature, mass_matrix, (Function<dim, NumberType> *)nullptr,
276 finalize_la_sparsity<SparseMatrixType>(dsp, sparsity_pattern_jacobian, discretization.get_locally_owned_dofs(),
281 virtual const get_type::SparsityPattern<SparseMatrixType> &get_sparsity_pattern_jacobian() const override
293 virtual void refinement_indicator(Vector<double> &indicator, const VectorType &solution_global) override
299 const auto cell_worker = [&](const Iterator &t_cell, Scratch &scratch_data, CopyData ©_data) {
324 const auto face_worker = [&](const Iterator &t_cell, const uint &f, const uint &sf, const Iterator &t_ncell,
383 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
387 virtual void mass(VectorType &mass, const VectorType &solution_global, const VectorType &solution_global_dot,
395 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
438 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
447 virtual void residual(VectorType &residual, const VectorType &solution_global, NumberType weight,
462 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
512 const auto boundary_worker = [&](const Iterator &cell, const uint &face_no, Scratch &scratch_data,
547 scalar_product(numflux[component_i], normals[q_index])); // phi_i(x_q) * numflux(x_q, u_q) * n(x_q)
551 const auto face_worker = [&](const Iterator &cell, const uint &f, const unsigned int &sf, const Iterator &ncell,
588 comp[i] = cd_i[0] == numbers::invalid_unsigned_int ? fe.system_to_component_index(cd_i[1]).first
619 MeshWorker::AssembleFlags flags = MeshWorker::assemble_own_cells | MeshWorker::assemble_boundary_faces |
627 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
645 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
696 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
706 virtual void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight,
725 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
755 SimpleMatrix<Tensor<1, dim, Tensor<1, dim, NumberType>>, Components::count_fe_functions()> j_grad_flux;
756 SimpleMatrix<Tensor<1, dim, Tensor<2, dim, NumberType>>, Components::count_fe_functions()> j_hess_flux;
757 SimpleMatrix<Tensor<1, dim, NumberType>, Components::count_fe_functions(), Components::count_extractors()>
762 SimpleMatrix<NumberType, Components::count_fe_functions(), Components::count_extractors()> j_extr_source;
831 const auto boundary_worker = [&](const Iterator &cell, const uint &face_no, Scratch &scratch_data,
863 SimpleMatrix<Tensor<1, dim, NumberType>, Components::count_fe_functions(), Components::count_extractors()>
871 model.template jacobian_boundary_numflux_grad<1>(j_grad_boundary_numflux, normals[q_index], x_q,
875 model.template jacobian_boundary_numflux_hess<2>(j_hess_boundary_numflux, normals[q_index], x_q,
880 model.template jacobian_boundary_numflux_extr<3>(j_extr_boundary_numflux, normals[q_index], x_q,
924 const auto face_worker = [&](const Iterator &cell, const uint &f, const uint &sf, const Iterator &ncell,
976 array<SimpleMatrix<Tensor<1, dim, Tensor<1, dim, NumberType>>, Components::count_fe_functions()>, 2>
978 array<SimpleMatrix<Tensor<1, dim, Tensor<2, dim, NumberType>>, Components::count_fe_functions()>, 2>
1000 fe_tie(solution_s[q_index], solution_grad_s[q_index], solution_hess_s[q_index], extracted_data,
1002 fe_tie(solution_n[q_index], solution_grad_n[q_index], solution_hess_n[q_index], extracted_data,
1007 fe_tie(solution_s[q_index], solution_grad_s[q_index], solution_hess_s[q_index], extracted_data,
1009 fe_tie(solution_n[q_index], solution_grad_n[q_index], solution_hess_n[q_index], extracted_data,
1016 fe_iv.get_fe_face_values(face_no_arr[k]).shape_value_component(local_dof_arr[k], q_index, comp[k]);
1018 fe_iv.get_fe_face_values(face_no_arr[k]).shape_grad_component(local_dof_arr[k], q_index, comp[k]);
1020 fe_iv.get_fe_face_values(face_no_arr[k]).shape_hessian_component(local_dof_arr[k], q_index, comp[k]);
1061 FullMatrix<NumberType> extractor_dependence(cdf.joint_dof_indices.size(), extractor_dof_indices.size());
1063 constraints.distribute_local_to_global(extractor_dependence, cdf.joint_dof_indices, extractor_dof_indices,
1068 FullMatrix<NumberType> extractor_dependence(c.local_dof_indices.size(), extractor_dof_indices.size());
1070 constraints.distribute_local_to_global(extractor_dependence, c.local_dof_indices, extractor_dof_indices,
1077 MeshWorker::AssembleFlags flags = MeshWorker::assemble_own_cells | MeshWorker::assemble_boundary_faces |
1085 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
A hierarchical configuration tree, readable from JSON and TOML files.
Definition config_tree.hh:32
The basic assembler that can be used for any standard CG scheme with flux and source.
Definition common.hh:42
FullMatrix< NumberType > extractor_jacobian
Definition common.hh:459
void extract(std::array< NumberType, Components::count_extractors()> &data, const VectorType &solution_global, const VectorType &variables, bool search_EoM, bool set_EoM, bool postprocess) const
Definition common.hh:274
bool jacobian_extractors(FullMatrix< NumberType > &extractor_jacobian, const VectorType &solution_global, const VectorType &variables)
Definition common.hh:302
virtual void reinit() override
Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.
Definition common.hh:116
std::vector< types::global_dof_index > extractor_dof_indices
Definition common.hh:463
AssemblySchedule schedule_for(const double cost_ns) const
The mesh_loop schedule for a loop whose cell worker costs cost_ns nanoseconds.
Definition common.hh:418
Decides, without any user input, which rank computes which part of each map().
Definition map_scheduler.hh:195
A simple NxM-matrix class, which is used for cell-wise Jacobians.
Definition tuples.hh:170
A read-only, fully-replicated view of the solution.
Definition solution_view.hh:48
void reinit(const dealii::IndexSet &, const dealii::IndexSet &, MPI_Comm)
Establish the layout. No-op for the serial policy.
Definition solution_view.hh:58
The basic assembler that can be used for any standard DG scheme with flux and source.
Definition ddg.hh:197
virtual void reinit() override
Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.
Definition ddg.hh:235
virtual void refinement_indicator(Vector< double > &indicator, const VectorType &solution_global) override
refinement indicator for adaptivity. Calls the model's cell_indicator and face_indicator functions.
Definition ddg.hh:293
get_type::SparsityPattern< SparseMatrixType > sparsity_pattern_mass
Definition ddg.hh:1144
std::vector< double > timings_jacobian
Definition ddg.hh:1150
double average_time_residual_assembly() const
Definition ddg.hh:1113
typename Discretization::SparseMatrixType SparseMatrixType
Definition ddg.hh:205
virtual const get_type::SparsityPattern< SparseMatrixType > & get_sparsity_pattern_jacobian() const override
Obtain the sparsity pattern of the jacobian matrix.
Definition ddg.hh:281
typename Discretization::NumberType NumberType
Definition ddg.hh:203
virtual void reinit_matrix(SparseMatrixType &matrix) const override
Definition ddg.hh:222
Assembler(Discretization &discretization, Model &model, const ConfigTree &config)
Definition ddg.hh:209
std::vector< double > timings_residual
Definition ddg.hh:1149
virtual const SparseMatrixType & get_mass_matrix() const override
Obtain the mass matrix.
Definition ddg.hh:285
double average_time_jacobian_assembly() const
Definition ddg.hh:1123
virtual void jacobian_mass(SparseMatrixType &jacobian, const VectorType &solution_global, const VectorType &solution_global_dot, NumberType alpha, NumberType beta) override
Definition ddg.hh:637
typename Discretization::VectorType VectorType
Definition ddg.hh:204
virtual void mass(VectorType &mass, const VectorType &solution_global, const VectorType &solution_global_dot, NumberType weight) override
Definition ddg.hh:387
virtual void rebuild_jacobian_sparsity() override
Definition ddg.hh:267
std::vector< types::global_dof_index > extractor_dof_indices
Definition common.hh:463
virtual MPI_Comm get_communicator() const override
The communicator this assembler's linear algebra lives on.
Definition ddg.hh:228
virtual void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight, const VectorType &solution_global_dot, NumberType alpha, NumberType beta, const VectorType &variables=VectorType()) override
Definition ddg.hh:706
AssemblySchedule schedule_for(const double cost_ns) const
The mesh_loop schedule for a loop whose cell worker costs cost_ns nanoseconds.
Definition common.hh:418
typename Discretization::Components Components
Definition ddg.hh:207
virtual void residual(VectorType &residual, const VectorType &solution_global, NumberType weight, const VectorType &solution_global_dot, NumberType weight_mass, const VectorType &variables=VectorType()) override
Definition ddg.hh:447
get_type::SparsityPattern< SparseMatrixType > sparsity_pattern_jacobian
Definition ddg.hh:1145
virtual void reinit_vector(VectorType &vec) const override
Definition ddg.hh:218
virtual void reinit_solution_view(SolutionView< VectorType > &view) const override
Definition ddg.hh:229
All compile-time knowledge about which linear algebra types DiFfRG uses.
constexpr double local_fe
Local FE work only: mass matrices, refinement indicators. ~0.2-0.3 us/cell for CG p=3.
Definition assembly_schedule.hh:48
constexpr double momentum_integral
Definition assembly_schedule.hh:53
typename internal::_SparsityPattern< SparseMatrixType >::value SparsityPattern
Definition linear_algebra.hh:155
double cell_width(const CellIterator &cell)
The smallest face-normal width over all faces of cell.
Definition cell_geometry.hh:42
Definition complex_math.hh:10
auto locally_owned_cells(const dealii::DoFHandler< dim > &dof_handler)
The cells this rank assembles.
Definition assembly_schedule.hh:154
void reinit_la_matrix(SparseMatrixType &matrix, const get_type::SparsityPattern< SparseMatrixType > &pattern, const dealii::IndexSet &locally_owned, MPI_Comm comm)
Size a matrix from a finalized sparsity pattern.
Definition la_policy.hh:92
void reinit_la_vector(VectorType &vec, const dealii::IndexSet &locally_owned, MPI_Comm comm)
Size a vector to the rank's share of the rows.
Definition la_policy.hh:27
void finalize_la_sparsity(dealii::DynamicSparsityPattern &dsp, get_type::SparsityPattern< SparseMatrixType > &pattern, const dealii::IndexSet &locally_owned, const dealii::IndexSet &locally_relevant, MPI_Comm comm)
Turn a freshly built DynamicSparsityPattern into the pattern type the matrix wants.
Definition la_policy.hh:50
Definition tuples.hh:34
Definition run_reporter.hh:73
SummaryEvent & timing(const std::string_view name, const double average_ms, const std::size_t calls)
Definition run_reporter.hh:78
Definition ddg.hh:179
std::array< uint, 2 > cell_indices
Definition ddg.hh:180
std::array< double, 2 > values
Definition ddg.hh:181
Definition ddg.hh:178
std::vector< CopyFaceData_I > face_data
Definition ddg.hh:183
Definition ddg.hh:148
FullMatrix< NumberType > extractor_cell_jacobian
Definition ddg.hh:150
std::vector< types::global_dof_index > joint_dof_indices
Definition ddg.hh:151
FullMatrix< NumberType > cell_jacobian
Definition ddg.hh:149
void reinit(const FEInterfaceValues< dim > &fe_iv, uint n_extractors)
Definition ddg.hh:153
Definition ddg.hh:147
void reinit(const Iterator &cell, uint dofs_per_cell, uint n_extractors)
Definition ddg.hh:167
FullMatrix< NumberType > extractor_cell_jacobian
Definition ddg.hh:163
std::vector< CopyDataFace_J > face_data
Definition ddg.hh:165
FullMatrix< NumberType > cell_jacobian
Definition ddg.hh:162
std::vector< types::global_dof_index > local_dof_indices
Definition ddg.hh:164
Definition ddg.hh:122
std::vector< types::global_dof_index > joint_dof_indices
Definition ddg.hh:124
void reinit(const FEInterfaceValues< dim > &fe_iv)
Definition ddg.hh:126
Vector< NumberType > cell_residual
Definition ddg.hh:123
Definition ddg.hh:121
Vector< NumberType > cell_residual
Definition ddg.hh:133
std::vector< CopyDataFace_R > face_data
Definition ddg.hh:135
void reinit(const Iterator &cell, uint dofs_per_cell)
Definition ddg.hh:137
std::vector< types::global_dof_index > local_dof_indices
Definition ddg.hh:134
Class to hold data for each assembly thread, i.e. FEValues for cells, interfaces, as well as pre-allo...
Definition ddg.hh:40
std::vector< Vector< NumberType > > solution_dot
Definition ddg.hh:110
std::vector< Tensor< 1, dim > > cached_shape_grads
Definition ddg.hh:117
std::vector< double > cached_shape_values
Definition ddg.hh:116
std::vector< Vector< NumberType > > solution
Definition ddg.hh:107
typename Discretization::NumberType NumberType
Definition ddg.hh:42
std::vector< std::vector< Tensor< 1, dim, NumberType > > > solution_grad
Definition ddg.hh:108
array< std::vector< std::vector< Tensor< 1, dim, NumberType > > >, 2 > solution_grad_interface
Definition ddg.hh:112
ScratchData(const ScratchData< Discretization > &scratch_data)
Definition ddg.hh:74
array< std::vector< Vector< NumberType > >, 2 > solution_interface
Definition ddg.hh:111
ScratchData(const Mapping< dim > &mapping, const FiniteElement< dim > &fe, const dealii::Quadrature< dim > &quadrature, const dealii::Quadrature< dim - 1 > &quadrature_face, const UpdateFlags update_flags=update_values|update_gradients|update_quadrature_points|update_JxW_values|update_hessians, const UpdateFlags interface_update_flags=update_values|update_gradients|update_quadrature_points|update_JxW_values|update_normal_vectors|update_hessians)
Definition ddg.hh:44
std::vector< Tensor< 2, dim > > cached_shape_hessians
Definition ddg.hh:118
FEInterfaceValues< dim > fe_interface_values
Definition ddg.hh:105
std::vector< std::vector< Tensor< 2, dim, NumberType > > > solution_hess
Definition ddg.hh:109
array< std::vector< std::vector< Tensor< 2, dim, NumberType > > >, 2 > solution_hess_interface
Definition ddg.hh:113
std::conditional_t< CarriesModel< D >, typename D::Model, D > type
Definition types.hh:63
A class to store a tuple with elements that can be accessed by name. The names are stored as FixedStr...
Definition tuples.hh:56
Generated by