/home/runner/work/DiFfRG_current/DiFfRG_current/DiFfRG/include/DiFfRG/discretization/FEM/assembler/cg.hh Source File#
|
DiFfRG
Discretization Framework for functional Renormalization Group flows
|
cg.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">>(
93 solution_grad_interface[0].resize(q_face_size, std::vector<Tensor<1, dim, NumberType>>(n_components));
94 solution_grad_interface[1].resize(q_face_size, std::vector<Tensor<1, dim, NumberType>>(n_components));
95 solution_hess_interface[0].resize(q_face_size, std::vector<Tensor<2, dim, NumberType>>(n_components));
96 solution_hess_interface[1].resize(q_face_size, std::vector<Tensor<2, dim, NumberType>>(n_components));
193 reinit_la_vector(vec, discretization.get_locally_owned_dofs(), discretization.get_communicator());
197 reinit_la_matrix(matrix, get_sparsity_pattern_jacobian(), discretization.get_locally_owned_dofs(),
201 virtual MPI_Comm get_communicator() const override { return discretization.get_communicator(); }
204 view.reinit(discretization.get_locally_owned_dofs(), discretization.get_locally_relevant_dofs(),
219 finalize_la_sparsity<SparseMatrixType>(dsp, sparsity_pattern_mass, discretization.get_locally_owned_dofs(),
224 MatrixCreator::create_mass_matrix(dof_handler, quadrature, mass_matrix, (Function<dim, NumberType> *)nullptr,
238 const auto metadata = DiFfRG::internal::build_affine_constraint_metadata<Components, dim>(discretization);
257 finalize_la_sparsity<SparseMatrixType>(dsp, sparsity_pattern_jacobian, discretization.get_locally_owned_dofs(),
262 virtual const get_type::SparsityPattern<SparseMatrixType> &get_sparsity_pattern_jacobian() const override
275 virtual void refinement_indicator(Vector<double> &indicator, const VectorType &solution_global) override
281 const auto cell_worker = [&](const Iterator &t_cell, Scratch &scratch_data, CopyData ©_data) {
315 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data,
319 virtual void mass(VectorType &mass, const VectorType &solution_global, const VectorType &solution_global_dot,
327 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
352 copy_data.cell_residual(i) += weight * JxW[q_index] * fe_v.shape_value_component(i, q_index, comp[i]) *
368 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
377 virtual void residual(VectorType &residual, const VectorType &solution_global, NumberType weight,
392 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
436 copy_data.cell_residual(i) += weight_mass * JxW[q_index] * fe_v.shape_value_component(i, q_index, ci) *
441 const auto boundary_worker = [&](const Iterator &cell, const uint &face_no, Scratch &scratch_data,
486 MeshWorker::AssembleFlags flags = MeshWorker::assemble_own_cells | MeshWorker::assemble_boundary_faces;
492 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
510 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
559 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
569 virtual void jacobian(SparseMatrixType &jacobian, const VectorType &solution_global, NumberType weight,
587 const auto cell_worker = [&](const Iterator &cell, Scratch &scratch_data, CopyData ©_data) {
613 SimpleMatrix<Tensor<1, dim, Tensor<1, dim, NumberType>>, Components::count_fe_functions()> j_grad_flux;
614 SimpleMatrix<Tensor<1, dim, Tensor<2, dim, NumberType>>, Components::count_fe_functions()> j_hess_flux;
615 SimpleMatrix<Tensor<1, dim, NumberType>, Components::count_fe_functions(), Components::count_extractors()>
620 SimpleMatrix<NumberType, Components::count_fe_functions(), Components::count_extractors()> j_extr_source;
670 contribution += JxW[q_index] * sv[j] * sv_i * (alpha * j_mass_dot(ci, cj) + beta * j_mass(ci, cj));
680 tbb::blocked_range2d<uint>(0, n_dofs, 0, n_dofs), [&](const tbb::blocked_range2d<uint> &range) {
699 const auto boundary_worker = [&](const Iterator &cell, const uint &face_no, Scratch &scratch_data,
727 SimpleMatrix<Tensor<1, dim, NumberType>, Components::count_fe_functions(), Components::count_extractors()>
735 model.template jacobian_boundary_numflux_grad<1>(j_grad_boundary_numflux, normals[q_index], x_q,
739 model.template jacobian_boundary_numflux_hess<2>(j_hess_boundary_numflux, normals[q_index], x_q,
744 model.template jacobian_boundary_numflux_extr<3>(j_extr_boundary_numflux, normals[q_index], x_q,
781 tbb::blocked_range2d<uint>(0, n_dofs, 0, n_dofs), [&](const tbb::blocked_range2d<uint> &range) {
782 do_bnd_work(range.rows().begin(), range.rows().end(), range.cols().begin(), range.cols().end());
802 FullMatrix<NumberType> extractor_dependence(c.local_dof_indices.size(), extractor_dof_indices.size());
804 constraints.distribute_local_to_global(extractor_dependence, c.local_dof_indices, extractor_dof_indices,
811 MeshWorker::AssembleFlags flags = MeshWorker::assemble_own_cells | MeshWorker::assemble_boundary_faces;
817 MeshWorker::mesh_loop(locally_owned_cells(dof_handler), cell_worker, copier, scratch_data, copy_data, flags,
Definition affine_constraint_metadata.hh:24
The basic assembler that can be used for any standard CG scheme with flux and source.
Definition cg.hh:170
virtual void reinit_solution_view(SolutionView< VectorType > &view) const override
Definition cg.hh:202
virtual void mass(VectorType &mass, const VectorType &solution_global, const VectorType &solution_global_dot, NumberType weight) override
Definition cg.hh:319
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 cg.hh:569
virtual MPI_Comm get_communicator() const override
The communicator this assembler's linear algebra lives on.
Definition cg.hh:201
virtual void refinement_indicator(Vector< double > &indicator, const VectorType &solution_global) override
refinement indicator for adaptivity. Only calls the model's cell_indicator function,...
Definition cg.hh:275
get_type::SparsityPattern< SparseMatrixType > sparsity_pattern_jacobian
Definition cg.hh:877
double average_time_residual_assembly() const
Definition cg.hh:845
typename Discretization::SparseMatrixType SparseMatrixType
Definition cg.hh:178
double average_time_jacobian_assembly() const
Definition cg.hh:855
virtual const get_type::SparsityPattern< SparseMatrixType > & get_sparsity_pattern_jacobian() const override
Obtain the sparsity pattern of the jacobian matrix.
Definition cg.hh:262
virtual void rebuild_jacobian_sparsity() override
Definition cg.hh:248
virtual void reinit() override
Reinitialize the assembler. This is necessary if the mesh has changed, e.g. after a mesh refinement.
Definition cg.hh:208
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 cg.hh:377
virtual void reinit_matrix(SparseMatrixType &matrix) const override
Definition cg.hh:195
get_type::SparsityPattern< SparseMatrixType > sparsity_pattern_mass
Definition cg.hh:876
virtual void jacobian_mass(SparseMatrixType &jacobian, const VectorType &solution_global, const VectorType &solution_global_dot, NumberType alpha, NumberType beta) override
Definition cg.hh:502
virtual const SparseMatrixType & get_mass_matrix() const override
Obtain the mass matrix.
Definition cg.hh:266
std::vector< types::global_dof_index > extractor_dof_indices
Definition common.hh:463
Assembler(Discretization &discretization, Model &model, const ConfigTree &config)
Definition cg.hh:182
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
virtual void reinit_vector(VectorType &vec) const override
Definition cg.hh:191
typename DiFfRG::internal::components_of< ModelOrComponents_ >::type Components
Definition cg.hh:47
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
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
AffineConstraintMetadata< dim > build_affine_constraint_metadata(const Discretization &discretization)
Definition affine_constraint_metadata.hh:99
double cell_width(const CellIterator &cell)
The smallest face-normal width over all faces of cell.
Definition cell_geometry.hh:42
void apply_model_affine_constraints(Model &model, Constraints &constraints, const Context &context)
Definition affine_constraint_metadata.hh:79
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 cg.hh:152
std::array< double, 2 > values
Definition cg.hh:154
std::array< uint, 2 > cell_indices
Definition cg.hh:153
Definition cg.hh:151
std::vector< CopyFaceData_I > face_data
Definition cg.hh:156
Definition cg.hh:137
FullMatrix< NumberType > extractor_cell_jacobian
Definition cg.hh:139
std::vector< types::global_dof_index > local_dof_indices
Definition cg.hh:140
FullMatrix< NumberType > cell_jacobian
Definition cg.hh:138
void reinit(const Iterator &cell, uint dofs_per_cell, uint n_extractors)
Definition cg.hh:142
Definition cg.hh:125
void reinit(const Iterator &cell, uint dofs_per_cell)
Definition cg.hh:129
Vector< NumberType > cell_residual
Definition cg.hh:126
std::vector< types::global_dof_index > local_dof_indices
Definition cg.hh:127
Class to hold data for each assembly thread, i.e. FEValues for cells, interfaces, as well as pre-allo...
Definition cg.hh:40
std::vector< Vector< NumberType > > solution
Definition cg.hh:109
array< std::vector< std::vector< Tensor< 1, dim, NumberType > > >, 2 > solution_grad_interface
Definition cg.hh:114
array< std::vector< std::vector< Tensor< 2, dim, NumberType > > >, 2 > solution_hess_interface
Definition cg.hh:115
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 cg.hh:44
std::vector< Tensor< 1, dim > > cached_shape_grads
Definition cg.hh:121
std::vector< std::vector< Tensor< 1, dim, NumberType > > > solution_grad
Definition cg.hh:110
std::vector< double > cached_shape_values
Definition cg.hh:120
FEInterfaceValues< dim > fe_interface_values
Definition cg.hh:107
ScratchData(const ScratchData< Discretization > &scratch_data)
Definition cg.hh:75
std::vector< Tensor< 2, dim > > cached_shape_hessians
Definition cg.hh:122
array< std::vector< Vector< NumberType > >, 2 > solution_interface
Definition cg.hh:113
std::vector< std::vector< Tensor< 2, dim, NumberType > > > solution_hess
Definition cg.hh:111
std::vector< Vector< NumberType > > solution_dot
Definition cg.hh:112
typename Discretization::NumberType NumberType
Definition cg.hh:42
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
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