libMesh
Public Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
libMesh::SparsityPattern::Build Class Reference

This helper class can be called on multiple threads to compute the sparsity pattern (or graph) of the sparse matrix resulting from the discretization. More...

#include <sparsity_pattern.h>

Inheritance diagram for libMesh::SparsityPattern::Build:
[legend]

Public Member Functions

 Build (const DofMap &dof_map_in, const CouplingMatrix *dof_coupling_in, const std::set< GhostingFunctor *> &coupling_functors_in, const bool implicit_neighbor_dofs_in, const bool need_full_sparsity_pattern_in, const bool calculate_constrained_in=false, const StaticCondensationDofMap *sc=nullptr)
 
 Build (const Build &)=default
 Special functions. More...
 
Buildoperator= (const Build &)=delete
 
 Build (Build &&)=default
 
Buildoperator= (Build &&)=delete
 
 ~Build ()=default
 
 Build (Build &other, Threads::split)
 Splitting constructor, for use in multithreaded loops. More...
 
void operator() (const ConstElemRange &range)
 Add entries from a range of elements to this object's sparsity pattern. More...
 
void join (const Build &other)
 Combine the sparsity pattern in other with this object's sparsity pattern. More...
 
void parallel_sync ()
 Send sparsity pattern data relevant to other processors to those processors, and receive and incorporate data relevant to us. More...
 
const SparsityPattern::Graphget_sparsity_pattern () const
 Rows of sparse matrix indices, indexed by the offset from the first DoF on this processor. More...
 
const SparsityPattern::NonlocalGraphget_nonlocal_pattern () const
 Rows of sparse matrix indices, mapped from global DoF number, which belong on other processors. More...
 
std::size_t n_nonzeros () const
 The total number of nonzeros in the global matrix. More...
 
const std::vector< dof_id_type > & get_n_nz () const
 The number of on-processor nonzeros in my portion of the global matrix. More...
 
const std::vector< dof_id_type > & get_n_oz () const
 The number of off-processor nonzeros in my portion of the global matrix. More...
 
void apply_extra_sparsity_object (SparsityPattern::AugmentSparsityPattern &asp)
 Let a user-provided AugmentSparsityPattern subclass modify our sparsity structure. More...
 
void apply_extra_sparsity_function (void(*func)(SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context), void *context)
 Let a user-provided function modify our sparsity structure. More...
 
void clear_full_sparsity ()
 Clear the "full" details of our sparsity structure, leaving only the counts of non-zero entries. More...
 
const Parallel::Communicatorcomm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Protected Attributes

const Parallel::Communicator_communicator
 

Private Member Functions

void handle_vi_vj (const std::vector< dof_id_type > &element_dofs_i, const std::vector< dof_id_type > &element_dofs_j)
 
void sorted_connected_dofs (const Elem *elem, std::vector< dof_id_type > &dofs_vi, unsigned int vi)
 

Private Attributes

const DofMapdof_map
 
const CouplingMatrixdof_coupling
 
const std::set< GhostingFunctor * > & coupling_functors
 
const bool implicit_neighbor_dofs
 
const bool need_full_sparsity_pattern
 
const bool calculate_constrained
 
const StaticCondensationDofMap *const sc
 
std::unordered_set< dof_id_typehashed_dof_sets
 If there are "spider" nodes in the mesh (i.e. More...
 
std::vector< dof_id_typedummy_vec
 A dummy work vector to avoid repeated memory allocations. More...
 
SparsityPattern::Graph sparsity_pattern
 
SparsityPattern::NonlocalGraph nonlocal_pattern
 
std::vector< dof_id_typen_nz
 
std::vector< dof_id_typen_oz
 

Detailed Description

This helper class can be called on multiple threads to compute the sparsity pattern (or graph) of the sparse matrix resulting from the discretization.

This pattern may be used directly by a particular sparse matrix format (e.g. LaspackMatrix) or indirectly (e.g. PetscMatrixBase). In the latter case the number of nonzeros per row of the matrix is needed for efficient preallocation. In this case it suffices to provide estimate (but bounding) values, and in this case the threaded method can take some short-cuts for efficiency.

Definition at line 103 of file sparsity_pattern.h.

Constructor & Destructor Documentation

◆ Build() [1/4]

libMesh::SparsityPattern::Build::Build ( const DofMap dof_map_in,
const CouplingMatrix dof_coupling_in,
const std::set< GhostingFunctor *> &  coupling_functors_in,
const bool  implicit_neighbor_dofs_in,
const bool  need_full_sparsity_pattern_in,
const bool  calculate_constrained_in = false,
const StaticCondensationDofMap sc = nullptr 
)

Definition at line 47 of file sparsity_pattern.C.

53  :
54  ParallelObject(dof_map_in),
55  dof_map(dof_map_in),
56  dof_coupling(dof_coupling_in),
57  coupling_functors(coupling_functors_in),
58  implicit_neighbor_dofs(implicit_neighbor_dofs_in),
59  need_full_sparsity_pattern(need_full_sparsity_pattern_in),
60  calculate_constrained(calculate_constrained_in),
61  sc(sc_in),
64  n_nz(),
65  n_oz()
66 {}
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
SparsityPattern::Graph sparsity_pattern
const std::set< GhostingFunctor * > & coupling_functors
const CouplingMatrix * dof_coupling
std::vector< dof_id_type > n_nz
SparsityPattern::NonlocalGraph nonlocal_pattern
const StaticCondensationDofMap *const sc
std::vector< dof_id_type > n_oz

◆ Build() [2/4]

libMesh::SparsityPattern::Build::Build ( const Build )
default

Special functions.

  • The Build object holds references to DofMap and coupling functors, therefore it can't be assigned.

◆ Build() [3/4]

libMesh::SparsityPattern::Build::Build ( Build &&  )
default

◆ ~Build()

libMesh::SparsityPattern::Build::~Build ( )
default

◆ Build() [4/4]

libMesh::SparsityPattern::Build::Build ( Build other,
Threads::split   
)

Splitting constructor, for use in multithreaded loops.

Definition at line 70 of file sparsity_pattern.C.

70  :
71  ParallelObject(other),
72  dof_map(other.dof_map),
73  dof_coupling(other.dof_coupling),
74  coupling_functors(other.coupling_functors),
75  implicit_neighbor_dofs(other.implicit_neighbor_dofs),
76  need_full_sparsity_pattern(other.need_full_sparsity_pattern),
77  calculate_constrained(other.calculate_constrained),
78  sc(other.sc),
79  hashed_dof_sets(other.hashed_dof_sets),
82  n_nz(),
83  n_oz()
84 {}
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
SparsityPattern::Graph sparsity_pattern
const std::set< GhostingFunctor * > & coupling_functors
std::unordered_set< dof_id_type > hashed_dof_sets
If there are "spider" nodes in the mesh (i.e.
const CouplingMatrix * dof_coupling
std::vector< dof_id_type > n_nz
SparsityPattern::NonlocalGraph nonlocal_pattern
const StaticCondensationDofMap *const sc
std::vector< dof_id_type > n_oz

Member Function Documentation

◆ apply_extra_sparsity_function()

void libMesh::SparsityPattern::Build::apply_extra_sparsity_function ( void(*)(SparsityPattern::Graph &sparsity, std::vector< dof_id_type > &n_nz, std::vector< dof_id_type > &n_oz, void *context)  func,
void *  context 
)
inline

Let a user-provided function modify our sparsity structure.

Definition at line 191 of file sparsity_pattern.h.

References n_nz, n_oz, and sparsity_pattern.

196  { func(sparsity_pattern, n_nz, n_oz, context); }
SparsityPattern::Graph sparsity_pattern
std::vector< dof_id_type > n_nz
std::vector< dof_id_type > n_oz

◆ apply_extra_sparsity_object()

void libMesh::SparsityPattern::Build::apply_extra_sparsity_object ( SparsityPattern::AugmentSparsityPattern asp)

Let a user-provided AugmentSparsityPattern subclass modify our sparsity structure.

Definition at line 578 of file sparsity_pattern.C.

References libMesh::SparsityPattern::AugmentSparsityPattern::augment_sparsity_pattern(), n_nz, n_oz, and sparsity_pattern.

579 {
580  asp.augment_sparsity_pattern (sparsity_pattern, n_nz, n_oz);
581 }
SparsityPattern::Graph sparsity_pattern
std::vector< dof_id_type > n_nz
std::vector< dof_id_type > n_oz

◆ clear_full_sparsity()

void libMesh::SparsityPattern::Build::clear_full_sparsity ( )
inline

Clear the "full" details of our sparsity structure, leaving only the counts of non-zero entries.

Definition at line 202 of file sparsity_pattern.h.

References nonlocal_pattern, and sparsity_pattern.

203  {
204  sparsity_pattern.clear();
205  nonlocal_pattern.clear();
206  }
SparsityPattern::Graph sparsity_pattern
SparsityPattern::NonlocalGraph nonlocal_pattern

◆ comm()

const Parallel::Communicator& libMesh::ParallelObject::comm ( ) const
inlineinherited
Returns
A reference to the Parallel::Communicator object used by this mesh.

Definition at line 97 of file parallel_object.h.

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::__libmesh_petsc_diff_solver_jacobian(), libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_tao_equality_constraints(), libMesh::__libmesh_tao_equality_constraints_jacobian(), libMesh::__libmesh_tao_gradient(), libMesh::__libmesh_tao_hessian(), libMesh::__libmesh_tao_inequality_constraints(), libMesh::__libmesh_tao_inequality_constraints_jacobian(), libMesh::__libmesh_tao_objective(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult(), libMesh::SlepcEigenSolver< libMesh::Number >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< Number >::_petsc_shell_matrix_mult_add(), libMesh::MeshRefinement::_refine_elements(), libMesh::MeshRefinement::_smooth_flags(), libMesh::DofMap::add_constraints_to_send_list(), add_cube_convex_hull_to_mesh(), libMesh::PetscDMWrapper::add_dofs_helper(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::TransientRBConstruction::add_IC_to_RB_space(), libMesh::RBEIMEvaluation::add_interpolation_data(), libMesh::CondensedEigenSystem::add_matrices(), libMesh::EigenSystem::add_matrices(), libMesh::System::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::System::add_vector(), libMesh::MeshTools::Modification::all_tri(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::TransientRBConstruction::allocate_data_structures(), libMesh::RBConstruction::allocate_data_structures(), libMesh::TransientRBConstruction::assemble_affine_expansion(), libMesh::AdvectionSystem::assemble_claw_rhs(), libMesh::FEMSystem::assemble_qoi(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::MeshCommunication::assign_global_indices(), libMesh::Partitioner::assign_partitioning(), libMesh::MeshTools::Generation::build_extrusion(), libMesh::Partitioner::build_graph(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::PetscDMWrapper::build_section(), libMesh::PetscDMWrapper::build_sf(), libMesh::MeshBase::cache_elem_data(), libMesh::System::calculate_norm(), libMesh::DofMap::check_dirichlet_bcid_consistency(), libMesh::RBConstruction::compute_Fq_representor_innerprods(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::RBConstruction::compute_output_dual_innerprods(), libMesh::RBConstruction::compute_residual_dual_norm_slow(), libMesh::RBSCMConstruction::compute_SCM_bounds_on_training_set(), libMesh::DofMap::computed_sparsity_already(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ContinuationSystem::ContinuationSystem(), libMesh::MeshBase::copy_constraint_rows(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::CondensedEigenSystem::copy_super_to_sub(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshTools::create_bounding_box(), libMesh::DofMap::create_dof_constraints(), libMesh::MeshTools::create_nodal_bounding_box(), libMesh::MeshRefinement::create_parent_error_vector(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::MeshTools::create_subdomain_bounding_box(), libMesh::PetscMatrix< T >::create_submatrix_nosort(), create_wrapped_function(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::RBEIMEvaluation::distribute_bfs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_interiors(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_nodes(), libMesh::RBEIMConstruction::enrich_eim_approximation_on_sides(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_error_tolerance(), libMesh::MeshRefinement::flag_elements_by_mean_stddev(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::RBEIMEvaluation::get_eim_basis_function_node_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_side_value(), libMesh::RBEIMEvaluation::get_eim_basis_function_value(), libMesh::MeshBase::get_info(), libMesh::System::get_info(), libMesh::DofMap::get_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::RBEIMConstruction::get_max_abs_value(), libMesh::RBEIMConstruction::get_node_max_abs_value(), libMesh::RBEIMEvaluation::get_parametrized_function_node_value(), libMesh::RBEIMEvaluation::get_parametrized_function_side_value(), libMesh::RBEIMEvaluation::get_parametrized_function_value(), libMesh::RBEIMConstruction::get_random_point(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::AdvectionSystem::init_data(), libMesh::ClawSystem::init_data(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_parametrized_functions_in_training_set(), libMesh::RBEIMConstruction::inner_product(), integrate_function(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_equal_connectivity(), libMesh::MeshTools::libmesh_assert_equal_points(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_constraint_rows(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_flags(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_p_levels(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshTools::libmesh_assert_valid_unique_ids(), libMesh::libmesh_petsc_linesearch_shellfunc(), libMesh::libmesh_petsc_preconditioner_apply(), libMesh::libmesh_petsc_recalculate_monitor(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_interface(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), libMesh::libmesh_petsc_snes_precheck(), libMesh::libmesh_petsc_snes_residual(), libMesh::libmesh_petsc_snes_residual_helper(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::limit_overrefined_boundary(), libMesh::MeshRefinement::limit_underrefined_boundary(), libMesh::LinearImplicitSystem::LinearImplicitSystem(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_new_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_new_nodes_parallel_consistent(), libMesh::MeshCommunication::make_node_bcids_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_unique_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshCommunication::make_p_levels_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::TransientRBConstruction::mass_matrix_scaled_matvec(), libMesh::FEMSystem::mesh_position_set(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::DofMap::n_constrained_dofs(), libMesh::MeshBase::n_constraint_rows(), libMesh::DofMap::n_dofs(), libMesh::DofMap::n_dofs_per_processor(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), MixedOrderTest::n_neighbor_links(), libMesh::BoundaryInfo::n_nodeset_conds(), n_nonzeros(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_distribute_bfs(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::RBEIMConstruction::node_inner_product(), libMesh::MeshBase::operator==(), libMesh::DistributedMesh::parallel_max_elem_id(), libMesh::DistributedMesh::parallel_max_node_id(), libMesh::ReplicatedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_max_unique_id(), libMesh::DistributedMesh::parallel_n_elem(), libMesh::DistributedMesh::parallel_n_nodes(), parallel_sync(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::MeshTools::paranoid_n_levels(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Partitioner::processor_pairs_to_interface_nodes(), libMesh::InterMeshProjection::project_system_vectors(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEIMEvaluation::read_in_interior_basis_functions(), libMesh::RBEIMEvaluation::read_in_node_basis_functions(), libMesh::RBEIMEvaluation::read_in_side_basis_functions(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), scale_mesh_and_plot(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::send_and_insert_dof_values(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::Partitioner::set_interface_node_processor_ids_BFS(), libMesh::Partitioner::set_interface_node_processor_ids_linear(), libMesh::Partitioner::set_interface_node_processor_ids_petscpartitioner(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::Partitioner::set_parent_processor_ids(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::RBEIMEvaluation::side_distribute_bfs(), libMesh::RBEIMEvaluation::side_gather_bfs(), libMesh::RBEIMConstruction::side_inner_product(), libMesh::Partitioner::single_partition(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::VariationalMeshSmoother::smooth(), libMesh::ClawSystem::solve_conservation_law(), libMesh::split_mesh(), libMesh::RBEIMConstruction::store_eim_solutions_for_training_set(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), ConstraintOperatorTest::test1DCoarseningNewNodes(), ConstraintOperatorTest::test1DCoarseningOperator(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), DofMapTest::testBadElemFECombo(), SystemsTest::testBlockRestrictedVarNDofs(), BoundaryInfoTest::testBoundaryOnChildrenErrors(), VolumeTest::testC0PolygonMethods(), VolumeTest::testC0PolyhedronMethods(), ConstraintOperatorTest::testCoreform(), ConnectedComponentsTest::testEdge(), MeshInputTest::testExodusIGASidesets(), MeshTriangulationTest::testFoundCenters(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), PointLocatorTest::testPlanar(), MeshTriangulationTest::testPoly2TriRefinementBase(), SystemsTest::testProjectCubeWithMeshFunction(), BoundaryInfoTest::testRenumber(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), MeshTriangulationTest::testTriangulatorInterp(), MeshTriangulationTest::testTriangulatorMeshedHoles(), MeshTriangulationTest::testTriangulatorRoundHole(), libMesh::MeshTools::total_weight(), libMesh::RBConstruction::train_reduced_basis_with_POD(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::Poly2TriTriangulator::triangulate(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), update_current_local_solution(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), libMesh::RBEvaluation::write_out_vectors(), libMesh::TransientRBConstruction::write_riesz_representors_to_files(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::TransientRBEvaluationSerialization::write_to_file(), libMesh::RBDataSerialization::RBEIMEvaluationSerialization::write_to_file(), and libMesh::RBDataSerialization::RBSCMEvaluationSerialization::write_to_file().

98  { return _communicator; }
const Parallel::Communicator & _communicator

◆ get_n_nz()

const std::vector<dof_id_type>& libMesh::SparsityPattern::Build::get_n_nz ( ) const
inline

The number of on-processor nonzeros in my portion of the global matrix.

Definition at line 172 of file sparsity_pattern.h.

References n_nz.

Referenced by libMesh::StaticCondensation::init().

173  { return n_nz; }
std::vector< dof_id_type > n_nz

◆ get_n_oz()

const std::vector<dof_id_type>& libMesh::SparsityPattern::Build::get_n_oz ( ) const
inline

The number of off-processor nonzeros in my portion of the global matrix.

Definition at line 179 of file sparsity_pattern.h.

References n_oz.

Referenced by libMesh::StaticCondensation::init().

180  { return n_oz; }
std::vector< dof_id_type > n_oz

◆ get_nonlocal_pattern()

const SparsityPattern::NonlocalGraph& libMesh::SparsityPattern::Build::get_nonlocal_pattern ( ) const
inline

Rows of sparse matrix indices, mapped from global DoF number, which belong on other processors.

Stored here only temporarily until a parallel_sync() sends them where they belong.

Definition at line 160 of file sparsity_pattern.h.

References nonlocal_pattern.

161  { return nonlocal_pattern; }
SparsityPattern::NonlocalGraph nonlocal_pattern

◆ get_sparsity_pattern()

const SparsityPattern::Graph& libMesh::SparsityPattern::Build::get_sparsity_pattern ( ) const
inline

Rows of sparse matrix indices, indexed by the offset from the first DoF on this processor.

Definition at line 152 of file sparsity_pattern.h.

References sparsity_pattern.

153  { return sparsity_pattern; }
SparsityPattern::Graph sparsity_pattern

◆ handle_vi_vj()

void libMesh::SparsityPattern::Build::handle_vi_vj ( const std::vector< dof_id_type > &  element_dofs_i,
const std::vector< dof_id_type > &  element_dofs_j 
)
private

Definition at line 152 of file sparsity_pattern.C.

References dof_map, libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), hashed_dof_sets, libMesh::Utility::hashword(), libMesh::Utility::hashword2(), nonlocal_pattern, libMesh::ParallelObject::processor_id(), libMesh::SparsityPattern::sort_row(), and sparsity_pattern.

Referenced by operator()().

154 {
155  const unsigned int n_dofs_on_element_i =
156  cast_int<unsigned int>(element_dofs_i.size());
157 
158  const processor_id_type proc_id = dof_map.processor_id();
159  const dof_id_type first_dof_on_proc = dof_map.first_dof(proc_id);
160  const dof_id_type end_dof_on_proc = dof_map.end_dof(proc_id);
161 
162  std::vector<dof_id_type>
163  dofs_to_add;
164 
165  const unsigned int n_dofs_on_element_j =
166  cast_int<unsigned int>(element_dofs_j.size());
167 
168  // It only makes sense to compute hashes and see if we can skip
169  // doing work when there are a "large" amount of DOFs for a given
170  // element. The cutoff for "large" is somewhat arbitrarily chosen
171  // based on a test case with a spider node that resulted in O(10^3)
172  // entries in element_dofs_i for O(10^3) elements. Making this
173  // number larger will disable the hashing optimization in more
174  // cases.
175  bool dofs_seen = false;
176  if (n_dofs_on_element_j > 0 && n_dofs_on_element_i > 256)
177  {
178  auto hash_i = Utility::hashword(element_dofs_i);
179  auto hash_j = Utility::hashword(element_dofs_j);
180  auto final_hash = Utility::hashword2(hash_i, hash_j);
181  auto result = hashed_dof_sets.insert(final_hash);
182  // if insert failed, we have already seen these dofs
183  dofs_seen = !result.second;
184  }
185 
186  // there might be 0 dofs for the other variable on the same element
187  // (when subdomain variables do not overlap) and that's when we do
188  // not do anything
189  if (n_dofs_on_element_j > 0 && !dofs_seen)
190  {
191  for (unsigned int i=0; i<n_dofs_on_element_i; i++)
192  {
193  const dof_id_type ig = element_dofs_i[i];
194 
195  SparsityPattern::Row * row;
196 
197  // We save non-local row components for now so we can
198  // communicate them to other processors later.
199 
200  if ((ig >= first_dof_on_proc) &&
201  (ig < end_dof_on_proc))
202  {
203  // This is what I mean
204  // libmesh_assert_greater_equal ((ig - first_dof_on_proc), 0);
205  // but do the test like this because ig and
206  // first_dof_on_proc are unsigned ints
207  libmesh_assert_greater_equal (ig, first_dof_on_proc);
208  libmesh_assert_less (ig, (sparsity_pattern.size() +
209  first_dof_on_proc));
210 
211  row = &sparsity_pattern[ig - first_dof_on_proc];
212  }
213  else
214  {
215  row = &nonlocal_pattern[ig];
216  }
217 
218  // If the row is empty we will add *all*
219  // the element j DOFs, so just do that.
220  if (row->empty())
221  {
222  row->insert(row->end(),
223  element_dofs_j.begin(),
224  element_dofs_j.end());
225  }
226  else
227  {
228  // Build a list of the DOF indices not found in the
229  // sparsity pattern
230  dofs_to_add.clear();
231 
232  // Cache iterators. Low will move forward, subsequent
233  // searches will be on smaller ranges
234  SparsityPattern::Row::iterator
235  low = std::lower_bound
236  (row->begin(), row->end(), element_dofs_j.front()),
237  high = std::upper_bound
238  (low, row->end(), element_dofs_j.back());
239 
240  for (unsigned int j=0; j<n_dofs_on_element_j; j++)
241  {
242  const dof_id_type jg = element_dofs_j[j];
243 
244  // See if jg is in the sorted range
245  std::pair<SparsityPattern::Row::iterator,
246  SparsityPattern::Row::iterator>
247  pos = std::equal_range (low, high, jg);
248 
249  // Must add jg if it wasn't found
250  if (pos.first == pos.second)
251  dofs_to_add.push_back(jg);
252 
253  // pos.first is now a valid lower bound for any
254  // remaining element j DOFs. (That's why we sorted them.)
255  // Use it for the next search
256  low = pos.first;
257  }
258 
259  // Add to the sparsity pattern
260  if (!dofs_to_add.empty())
261  {
262  const std::size_t old_size = row->size();
263 
264  row->insert (row->end(),
265  dofs_to_add.begin(),
266  dofs_to_add.end());
267 
269  (row->begin(), row->begin()+old_size,
270  row->end());
271  }
272  }
273  } // End dofs-of-var-i loop
274  } // End if-dofs-of-var-j
275 }
SparsityPattern::Graph sparsity_pattern
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map_base.h:191
std::unordered_set< dof_id_type > hashed_dof_sets
If there are "spider" nodes in the mesh (i.e.
std::vector< dof_id_type, Threads::scalable_allocator< dof_id_type > > Row
uint32_t hashword(const uint32_t *k, size_t length, uint32_t initval=0)
The hashword function takes an array of uint32_t&#39;s of length &#39;length&#39; and computes a single key from ...
Definition: hashword.h:158
uint8_t processor_id_type
SparsityPattern::NonlocalGraph nonlocal_pattern
uint32_t hashword2(const uint32_t &first, const uint32_t &second, uint32_t initval=0)
This is a hard-coded version of hashword for hashing exactly 2 numbers.
Definition: hashword.h:215
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map_base.h:185
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:67
static void sort_row(const BidirectionalIterator begin, BidirectionalIterator middle, const BidirectionalIterator end)
Splices the two sorted ranges [begin,middle) and [middle,end) into one sorted range [begin...

◆ join()

void libMesh::SparsityPattern::Build::join ( const Build other)

Combine the sparsity pattern in other with this object's sparsity pattern.

Useful in multithreaded loops.

Definition at line 367 of file sparsity_pattern.C.

References dof_map, libMesh::DofMapBase::end_dof(), hashed_dof_sets, libMesh::libmesh_assert(), libMesh::DofMap::n_local_dofs(), nonlocal_pattern, libMesh::ParallelObject::processor_id(), and sparsity_pattern.

368 {
369  libmesh_assert_equal_to (sparsity_pattern.size(), other.sparsity_pattern.size());
370 
371  for (dof_id_type r=0; r<dof_map.n_local_dofs(); r++)
372  {
373  // increment the number of on and off-processor nonzeros in this row
374  // (note this will be an upper bound unless we need the full sparsity pattern)
376  const SparsityPattern::Row & their_row = other.sparsity_pattern[r];
377 
378  // simple copy if I have no dofs
379  if (my_row.empty())
380  my_row = their_row;
381 
382  // otherwise add their DOFs to mine, resort, and re-unique the row
383  else if (!their_row.empty()) // do nothing for the trivial case where
384  { // their row is empty
385  my_row.insert (my_row.end(),
386  their_row.begin(),
387  their_row.end());
388 
389  // We cannot use SparsityPattern::sort_row() here because it expects
390  // the [begin,middle) [middle,end) to be non-overlapping. This is not
391  // necessarily the case here, so use std::sort()
392  std::sort (my_row.begin(), my_row.end());
393 
394  my_row.erase(std::unique (my_row.begin(), my_row.end()), my_row.end());
395  }
396  }
397 
398  // Move nonlocal row information to ourselves; the other thread
399  // won't need it in the map after that.
400  for (const auto & p : other.nonlocal_pattern)
401  {
402 #ifndef NDEBUG
403  const dof_id_type dof_id = p.first;
404 
405  processor_id_type dbg_proc_id = 0;
406  while (dof_id >= dof_map.end_dof(dbg_proc_id))
407  dbg_proc_id++;
408  libmesh_assert (dbg_proc_id != this->processor_id());
409 #endif
410 
411  const SparsityPattern::Row & their_row = p.second;
412 
413  // We should have no empty values in a map
414  libmesh_assert (!their_row.empty());
415 
416  if (auto my_it = nonlocal_pattern.find(p.first);
417  my_it == nonlocal_pattern.end())
418  {
419  // nonlocal_pattern[it->first].swap(their_row);
420  nonlocal_pattern[p.first] = their_row;
421  }
422  else
423  {
424  SparsityPattern::Row & my_row = my_it->second;
425 
426  my_row.insert (my_row.end(),
427  their_row.begin(),
428  their_row.end());
429 
430  // We cannot use SparsityPattern::sort_row() here because it expects
431  // the [begin,middle) [middle,end) to be non-overlapping. This is not
432  // necessarily the case here, so use std::sort()
433  std::sort (my_row.begin(), my_row.end());
434 
435  my_row.erase(std::unique (my_row.begin(), my_row.end()), my_row.end());
436  }
437  }
438 
439  // Combine the other thread's hashed_dof_sets with ours.
440  hashed_dof_sets.insert(other.hashed_dof_sets.begin(),
441  other.hashed_dof_sets.end());
442 }
SparsityPattern::Graph sparsity_pattern
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map_base.h:191
dof_id_type n_local_dofs(const unsigned int vn) const
Definition: dof_map.h:686
std::unordered_set< dof_id_type > hashed_dof_sets
If there are "spider" nodes in the mesh (i.e.
std::vector< dof_id_type, Threads::scalable_allocator< dof_id_type > > Row
uint8_t processor_id_type
libmesh_assert(ctx)
SparsityPattern::NonlocalGraph nonlocal_pattern
processor_id_type processor_id() const
uint8_t dof_id_type
Definition: id_types.h:67

◆ n_nonzeros()

std::size_t libMesh::SparsityPattern::Build::n_nonzeros ( ) const

The total number of nonzeros in the global matrix.

Definition at line 584 of file sparsity_pattern.C.

References libMesh::ParallelObject::comm(), n_nz, n_oz, and TIMPI::Communicator::sum().

585 {
586  // At some point I'll remember that "C++17" compilers don't always
587  // come with complete C++17 standard libraries.
588  // std::size_t total_nonzeros = std::reduce(n_nz.begin(), n_nz.end(), std::size_t(0));
589  // total_nonzeros += std::reduce(n_oz.begin(), n_oz.end(), std::size_t(0));
590 
591  std::size_t total_nonzeros = 0;
592  for (auto nnzi : n_nz)
593  total_nonzeros += nnzi;
594  for (auto nozi : n_oz)
595  total_nonzeros += nozi;
596 
597  this->comm().sum(total_nonzeros);
598  return total_nonzeros;
599 }
void sum(T &r) const
const Parallel::Communicator & comm() const
std::vector< dof_id_type > n_nz
std::vector< dof_id_type > n_oz

◆ n_processors()

processor_id_type libMesh::ParallelObject::n_processors ( ) const
inlineinherited
Returns
The number of processors in the group.

Definition at line 103 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, libMesh::libmesh_assert(), and TIMPI::Communicator::size().

Referenced by libMesh::Partitioner::_find_global_index_by_pid_map(), libMesh::BoundaryInfo::_find_id_maps(), libMesh::DofMap::add_constraints_to_send_list(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::System::add_vector(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::Partitioner::build_graph(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::copy_nodes_and_elements(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::MeshBase::get_info(), libMesh::StaticCondensation::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_petscdm(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::DistributedMesh::insert_elem(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_new_node_procids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_topology_consistent_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_boundary_ids(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::DofMap::n_dofs_per_processor(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::CheckpointIO::read_connectivity(), libMesh::XdrIO::read_header(), libMesh::CheckpointIO::read_nodes(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::Partitioner::repartition(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), WriteVecAndScalar::setupTests(), libMesh::RBEIMEvaluation::side_gather_bfs(), DistributedMeshTest::testRemoteElemError(), CheckpointIOTest::testSplitter(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().

104  {
105  processor_id_type returnval =
106  cast_int<processor_id_type>(_communicator.size());
107  libmesh_assert(returnval); // We never have an empty comm
108  return returnval;
109  }
const Parallel::Communicator & _communicator
processor_id_type size() const
uint8_t processor_id_type
libmesh_assert(ctx)

◆ operator()()

void libMesh::SparsityPattern::Build::operator() ( const ConstElemRange range)

Add entries from a range of elements to this object's sparsity pattern.

Definition at line 279 of file sparsity_pattern.C.

References libMesh::DofMap::coupling_functors_begin(), libMesh::DofMap::coupling_functors_end(), dof_map, handle_vi_vj(), libMesh::MeshTools::Generation::Private::idx(), libMesh::DofObject::invalid_processor_id, libMesh::DofMap::merge_ghost_functor_outputs(), libMesh::DofMap::n_local_dofs(), libMesh::DofMap::n_variables(), sorted_connected_dofs(), and sparsity_pattern.

280 {
281  // Compute the sparsity structure of the global matrix. This can be
282  // fed into a PetscMatrixBase to allocate exactly the number of nonzeros
283  // necessary to store the matrix. This algorithm should be linear
284  // in the (# of elements)*(# nodes per element)
286 
287  // Handle dof coupling specified by library and user coupling functors
288  {
289  const unsigned int n_var = dof_map.n_variables();
290 
291  std::vector<std::vector<dof_id_type> > element_dofs_i(n_var);
292 
293  std::vector<const Elem *> coupled_neighbors;
294  for (const auto & elem : range)
295  {
296  // Make some fake element iterators defining a range
297  // pointing to only this element.
298  Elem * const * elempp = const_cast<Elem * const *>(&elem);
299  Elem * const * elemend = elempp+1;
300 
301  const MeshBase::const_element_iterator fake_elem_it =
302  MeshBase::const_element_iterator(elempp,
303  elemend,
304  Predicates::NotNull<Elem * const *>());
305 
306  const MeshBase::const_element_iterator fake_elem_end =
307  MeshBase::const_element_iterator(elemend,
308  elemend,
309  Predicates::NotNull<Elem * const *>());
310 
311  GhostingFunctor::map_type elements_to_couple;
312  DofMap::CouplingMatricesSet temporary_coupling_matrices;
313 
314  dof_map.merge_ghost_functor_outputs(elements_to_couple,
315  temporary_coupling_matrices,
318  fake_elem_it,
319  fake_elem_end,
321  for (unsigned int vi=0; vi<n_var; vi++)
322  this->sorted_connected_dofs(elem, element_dofs_i[vi], vi);
323 
324  for (unsigned int vi=0; vi<n_var; vi++)
325  for (const auto & [partner, ghost_coupling] : elements_to_couple)
326  {
327  // Loop over coupling matrix row variables if we have a
328  // coupling matrix, or all variables if not.
329  if (ghost_coupling)
330  {
331  libmesh_assert_equal_to (ghost_coupling->size(), n_var);
332  ConstCouplingRow ccr(vi, *ghost_coupling);
333 
334  for (const auto & idx : ccr)
335  {
336  if (partner == elem)
337  this->handle_vi_vj(element_dofs_i[vi], element_dofs_i[idx]);
338  else
339  {
340  std::vector<dof_id_type> partner_dofs;
341  this->sorted_connected_dofs(partner, partner_dofs, idx);
342  this->handle_vi_vj(element_dofs_i[vi], partner_dofs);
343  }
344  }
345  }
346  else
347  {
348  for (unsigned int vj = 0; vj != n_var; ++vj)
349  {
350  if (partner == elem)
351  this->handle_vi_vj(element_dofs_i[vi], element_dofs_i[vj]);
352  else
353  {
354  std::vector<dof_id_type> partner_dofs;
355  this->sorted_connected_dofs(partner, partner_dofs, vj);
356  this->handle_vi_vj(element_dofs_i[vi], partner_dofs);
357  }
358  }
359  }
360  } // End ghosted element loop
361  } // End range element loop
362  } // End ghosting functor section
363 }
SparsityPattern::Graph sparsity_pattern
std::set< GhostingFunctor * >::const_iterator coupling_functors_begin() const
Beginning of range of coupling functors.
Definition: dof_map.h:359
std::map< const Elem *, const CouplingMatrix *, CompareDofObjectsByPIDAndThenID > map_type
What elements do we care about and what variables do we care about on each element?
dof_id_type n_local_dofs(const unsigned int vn) const
Definition: dof_map.h:686
static void merge_ghost_functor_outputs(GhostingFunctor::map_type &elements_to_ghost, CouplingMatricesSet &temporary_coupling_matrices, const std::set< GhostingFunctor *>::iterator &gf_begin, const std::set< GhostingFunctor *>::iterator &gf_end, const MeshBase::const_element_iterator &elems_begin, const MeshBase::const_element_iterator &elems_end, processor_id_type p)
Definition: dof_map.C:1614
std::set< std::unique_ptr< CouplingMatrix >, Utility::CompareUnderlying > CouplingMatricesSet
Definition: dof_map.h:1848
static const processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition: dof_object.h:493
unsigned int n_variables() const override
Definition: dof_map.h:628
void sorted_connected_dofs(const Elem *elem, std::vector< dof_id_type > &dofs_vi, unsigned int vi)
std::set< GhostingFunctor * >::const_iterator coupling_functors_end() const
End of range of coupling functors.
Definition: dof_map.h:365
void handle_vi_vj(const std::vector< dof_id_type > &element_dofs_i, const std::vector< dof_id_type > &element_dofs_j)
unsigned int idx(const ElemType type, const unsigned int nx, const unsigned int i, const unsigned int j)
A useful inline function which replaces the macros used previously.

◆ operator=() [1/2]

Build& libMesh::SparsityPattern::Build::operator= ( const Build )
delete

◆ operator=() [2/2]

Build& libMesh::SparsityPattern::Build::operator= ( Build &&  )
delete

◆ parallel_sync()

void libMesh::SparsityPattern::Build::parallel_sync ( )

Send sparsity pattern data relevant to other processors to those processors, and receive and incorporate data relevant to us.

Definition at line 446 of file sparsity_pattern.C.

References libMesh::ParallelObject::comm(), dof_map, libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::first_dof(), libMesh::libmesh_assert(), libMesh::DofMap::local_index(), libMesh::DofMap::n_local_dofs(), n_nz, n_oz, need_full_sparsity_pattern, nonlocal_pattern, and sparsity_pattern.

447 {
448  parallel_object_only();
450 
451  const auto n_dofs_on_proc = dof_map.n_local_dofs();
452  const auto local_first_dof = dof_map.first_dof();
453 
454  // The data to send
455  std::map<processor_id_type, std::vector<dof_id_type>> ids_to_send;
456  std::map<processor_id_type, std::vector<Row>> rows_to_send;
457 
458  // Loop over the nonlocal rows and transform them into the new datastructure
459  NonlocalGraph::iterator it = nonlocal_pattern.begin();
460  while (it != nonlocal_pattern.end())
461  {
462  const auto dof_id = it->first;
463  auto & row = it->second;
464 
465  processor_id_type proc_id = 0;
466  while (dof_id >= dof_map.end_dof(proc_id))
467  proc_id++;
468 
469  ids_to_send[proc_id].push_back(dof_id);
470 
471  // Note this invalidates the data in nonlocal_pattern
472  rows_to_send[proc_id].push_back(std::move(row));
473 
474  // Might as well remove it since it's invalidated anyway
475  it = nonlocal_pattern.erase(it);
476  }
477 
478  std::map<processor_id_type, std::vector<dof_id_type>> received_ids_map;
479 
480  auto ids_action_functor =
481  [& received_ids_map]
482  (processor_id_type pid,
483  const std::vector<dof_id_type> & received_ids)
484  {
485  received_ids_map.emplace(pid, received_ids);
486  };
487 
488  Parallel::push_parallel_vector_data(this->comm(), ids_to_send,
489  ids_action_functor);
490 
491  auto rows_action_functor =
492  [this,
493  & received_ids_map,
494  local_first_dof]
495  (processor_id_type pid,
496  const std::vector<Row> & received_rows)
497  {
498  const std::vector<dof_id_type> & received_ids = libmesh_map_find(received_ids_map, pid);
499 
500  std::size_t n_rows = received_rows.size();
501  libmesh_assert_equal_to(n_rows, received_ids.size());
502 
503  for (auto i : IntRange<std::size_t>(0, n_rows))
504  {
505  const auto r = received_ids[i];
507 
508  const auto my_r = r - local_first_dof;
509 
510  auto & their_row = received_rows[i];
511 
512  auto & my_row = sparsity_pattern[my_r];
513 
514  // They wouldn't have sent an empty row
515  libmesh_assert(!their_row.empty());
516 
517  // We can end up with an empty row on a dof that touches our
518  // inactive elements but not our active ones
519  if (my_row.empty())
520  {
521  my_row.assign (their_row.begin(), their_row.end());
522  }
523  else
524  {
525  my_row.insert (my_row.end(),
526  their_row.begin(),
527  their_row.end());
528 
529  // We cannot use SparsityPattern::sort_row() here because it expects
530  // the [begin,middle) [middle,end) to be non-overlapping. This is not
531  // necessarily the case here, so use std::sort()
532  std::sort (my_row.begin(), my_row.end());
533 
534  my_row.erase(std::unique (my_row.begin(), my_row.end()), my_row.end());
535  }
536 
537  }
538  };
539 
540  Parallel::push_parallel_vector_data(this->comm(), rows_to_send,
541  rows_action_functor);
542 
543  // We should have sent everything at this point.
545 
546  // assert these are empty because std::vector::resize will only append the specified element value
547  // if the new size is greater than the current size. Elements whose indices are less than the
548  // current size are untouched
549  libmesh_assert(n_nz.empty());
550  libmesh_assert(n_oz.empty());
551  n_nz.resize (n_dofs_on_proc, 0);
552  n_oz.resize (n_dofs_on_proc, 0);
553 
554  const dof_id_type first_dof_on_proc = dof_map.first_dof();
555  const dof_id_type end_dof_on_proc = dof_map.end_dof();
556 
557  for (dof_id_type i=0; i<n_dofs_on_proc; i++)
558  {
559  // Get the row of the sparsity pattern
561 
562  for (const auto & df : row)
563  if ((df < first_dof_on_proc) || (df >= end_dof_on_proc))
564  n_oz[i]++;
565  else
566  n_nz[i]++;
567 
568  libmesh_assert(n_nz[i] <= n_dofs_on_proc);
569 
570  // If we're not building a full sparsity pattern, then we want
571  // to avoid overcounting these entries as much as possible.
573  row.clear();
574  }
575 }
SparsityPattern::Graph sparsity_pattern
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map_base.h:191
const Parallel::Communicator & comm() const
dof_id_type n_local_dofs(const unsigned int vn) const
Definition: dof_map.h:686
std::vector< dof_id_type, Threads::scalable_allocator< dof_id_type > > Row
uint8_t processor_id_type
libmesh_assert(ctx)
std::vector< dof_id_type > n_nz
SparsityPattern::NonlocalGraph nonlocal_pattern
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map_base.h:185
uint8_t dof_id_type
Definition: id_types.h:67
bool local_index(dof_id_type dof_index) const
Definition: dof_map.h:839
std::vector< dof_id_type > n_oz

◆ processor_id()

processor_id_type libMesh::ParallelObject::processor_id ( ) const
inlineinherited
Returns
The rank of this processor in the group.

Definition at line 114 of file parallel_object.h.

References libMesh::ParallelObject::_communicator, and TIMPI::Communicator::rank().

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::PetscDMWrapper::add_dofs_to_section(), libMesh::DistributedMesh::add_elem(), libMesh::BoundaryInfo::add_elements(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::DistributedMesh::add_node(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO::assert_symmetric_cmaps(), libMesh::Partitioner::assign_partitioning(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::Partitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::EquationSystems::build_parallel_solution_vector(), libMesh::MeshFunction::check_found_elem(), libMesh::DistributedMesh::clear(), libMesh::DistributedMesh::clear_elems(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::RBConstruction::compute_max_error_bound(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::Nemesis_IO::copy_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_scalar_dofs(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMapBase::end_dof(), libMesh::DofMapBase::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::GenericProjector< FFunctor, GFunctor, FValue, ProjectionAction >::SubFunctor::find_dofs_to_send(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMapBase::first_dof(), libMesh::DofMapBase::first_old_dof(), libMesh::RBEIMEvaluation::gather_bfs(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::RBEIMEvaluation::get_interior_basis_functions_as_vecs(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::get_local_constraints(), libMesh::MeshBase::get_local_constraints(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), handle_vi_vj(), libMesh::LaplaceMeshSmoother::init(), libMesh::SystemSubsetBySubdomain::init(), HeatSystem::init_data(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::DistributedMesh::insert_elem(), libMesh::DofMap::is_evaluable(), join(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::MeshTools::libmesh_assert_consistent_distributed(), libMesh::MeshTools::libmesh_assert_consistent_distributed_nodes(), libMesh::MeshTools::libmesh_assert_contiguous_dof_ids(), libMesh::MeshTools::libmesh_assert_parallel_consistent_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_neighbors(), libMesh::DistributedMesh::libmesh_assert_valid_parallel_object_ids(), libMesh::DofMap::local_variable_indices(), main(), libMesh::MeshRefinement::make_coarsening_compatible(), AugmentSparsityOnInterface::mesh_reinit(), libMesh::TriangulatorInterface::MeshedHole::MeshedHole(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::MeshTools::n_connected_components(), libMesh::MeshBase::n_constraint_rows(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMapBase::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), libMesh::RBEIMEvaluation::node_gather_bfs(), libMesh::DistributedMesh::own_node(), libMesh::BoundaryInfo::parallel_sync_node_ids(), libMesh::BoundaryInfo::parallel_sync_side_ids(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::print_constraint_rows(), libMesh::DofMap::print_dof_constraints(), libMesh::DofMap::process_mesh_constraint_rows(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read(), libMesh::EquationSystems::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::ExodusII_IO::read_header(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::DynaIO::read_mesh(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::TransientRBConstruction::read_riesz_representors_from_files(), libMesh::RBConstruction::read_riesz_representors_from_files(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs_helper(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::Nemesis_IO_Helper::read_var_names_impl(), libMesh::SimplexRefiner::refine_via_edges(), libMesh::StaticCondensationDofMap::reinit(), libMesh::DistributedMesh::renumber_dof_objects(), libMesh::DistributedMesh::renumber_nodes_and_elements(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DistributedMesh::set_next_unique_id(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::RBEIMEvaluation::side_gather_bfs(), ExodusTest< elem_type >::test_read_gold(), ExodusTest< elem_type >::test_write(), MeshInputTest::testAbaqusRead(), MeshInputTest::testBadGmsh(), MeshInputTest::testCopyElementSolutionImpl(), MeshInputTest::testCopyElementVectorImpl(), MeshInputTest::testCopyNodalSolutionImpl(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaFileMappings(), MeshInputTest::testDynaNoSplines(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusFileMappings(), MeshInputTest::testExodusIGASidesets(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), MeshInputTest::testGmshBCIDOverlap(), MeshInputTest::testGoodGmsh(), MeshInputTest::testGoodSTL(), MeshInputTest::testGoodSTLBinary(), MeshInputTest::testLowOrderEdgeBlocks(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), MeshInputTest::testSingleElementImpl(), WriteVecAndScalar::testSolution(), CheckpointIOTest::testSplitter(), MeshInputTest::testTetgenIO(), libMesh::MeshTools::total_weight(), libMesh::NetGenMeshInterface::triangulate(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), libMesh::MeshTools::volume(), libMesh::STLIO::write(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::CheckpointIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_element_values_element_major(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO_Helper::write_elemset_data(), libMesh::ExodusII_IO_Helper::write_elemsets(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodeset_data(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEIMEvaluation::write_out_interior_basis_functions(), libMesh::RBEIMEvaluation::write_out_node_basis_functions(), libMesh::RBEIMEvaluation::write_out_side_basis_functions(), write_output_solvedata(), libMesh::System::write_parallel_data(), libMesh::RBConstruction::write_riesz_representors_to_files(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs_helper(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sideset_data(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), libMesh::ExodusII_IO_Helper::write_timestep(), and libMesh::ExodusII_IO::write_timestep_discontinuous().

115  { return cast_int<processor_id_type>(_communicator.rank()); }
processor_id_type rank() const
const Parallel::Communicator & _communicator

◆ sorted_connected_dofs()

void libMesh::SparsityPattern::Build::sorted_connected_dofs ( const Elem elem,
std::vector< dof_id_type > &  dofs_vi,
unsigned int  vi 
)
private

Definition at line 96 of file sparsity_pattern.C.

References libMesh::DofMap::dof_indices(), dof_map, dummy_vec, libMesh::DofMap::find_connected_dofs(), libMesh::invalid_uint, libMesh::Elem::p_level(), sc, and libMesh::StaticCondensationDofMap::uncondensed_vars().

Referenced by operator()().

99 {
100  if (this->sc)
101  {
102  // We build a sparsity pattern that will match the size of the condensed system. This is so that
103  // we have the data necessary to init the reduced system matrix
104  dofs_vi.clear();
105 
106  auto total_and_uncondensed_from_scalar_dofs_functor =
107  [&dofs_vi](const Elem & /*elem*/,
108  std::vector<dof_id_type> & dof_indices,
109  const std::vector<dof_id_type> & scalar_dof_indices)
110  {
111  dof_indices.insert(dof_indices.end(), scalar_dof_indices.begin(), scalar_dof_indices.end());
112  dofs_vi.insert(dofs_vi.end(), scalar_dof_indices.begin(), scalar_dof_indices.end());
113  };
114 
115  auto total_and_uncondensed_from_field_dofs_functor =
116  [&dofs_vi, this](const Elem & functor_elem,
117  const unsigned int node_num,
118  const unsigned int var_num,
119  std::vector<dof_id_type> & dof_indices,
120  const dof_id_type field_dof)
121  {
122  dof_indices.push_back(field_dof);
123  if (this->sc->uncondensed_vars().count(var_num) ||
124  (node_num != invalid_uint && !functor_elem.is_internal(node_num)))
125  dofs_vi.push_back(field_dof);
126  };
127 
128  dof_map.dof_indices(elem,
129  dummy_vec,
130  vi,
131  total_and_uncondensed_from_scalar_dofs_functor,
132  total_and_uncondensed_from_field_dofs_functor,
133  elem->p_level());
134  }
135  else
136  dof_map.dof_indices (elem, dofs_vi, vi);
137 
138 #ifdef LIBMESH_ENABLE_CONSTRAINTS
139  dof_map.find_connected_dofs (dofs_vi);
140 #endif
141  // We can be more efficient if we sort the element DOFs into
142  // increasing order
143  std::sort(dofs_vi.begin(), dofs_vi.end());
144 
145  // Handle cases where duplicate nodes are intentionally assigned to
146  // a single element.
147  dofs_vi.erase(std::unique(dofs_vi.begin(), dofs_vi.end()), dofs_vi.end());
148 }
void find_connected_dofs(std::vector< dof_id_type > &elem_dofs) const
Finds all the DOFS associated with the element DOFs elem_dofs.
Definition: dof_map.C:2855
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition: libmesh.h:310
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Definition: dof_map.C:2164
std::vector< dof_id_type > dummy_vec
A dummy work vector to avoid repeated memory allocations.
const std::unordered_set< unsigned int > & uncondensed_vars() const
const StaticCondensationDofMap *const sc
uint8_t dof_id_type
Definition: id_types.h:67

Member Data Documentation

◆ _communicator

const Parallel::Communicator& libMesh::ParallelObject::_communicator
protectedinherited

◆ calculate_constrained

const bool libMesh::SparsityPattern::Build::calculate_constrained
private

Definition at line 214 of file sparsity_pattern.h.

◆ coupling_functors

const std::set<GhostingFunctor *>& libMesh::SparsityPattern::Build::coupling_functors
private

Definition at line 211 of file sparsity_pattern.h.

◆ dof_coupling

const CouplingMatrix* libMesh::SparsityPattern::Build::dof_coupling
private

Definition at line 210 of file sparsity_pattern.h.

◆ dof_map

const DofMap& libMesh::SparsityPattern::Build::dof_map
private

◆ dummy_vec

std::vector<dof_id_type> libMesh::SparsityPattern::Build::dummy_vec
private

A dummy work vector to avoid repeated memory allocations.

Definition at line 231 of file sparsity_pattern.h.

Referenced by sorted_connected_dofs().

◆ hashed_dof_sets

std::unordered_set<dof_id_type> libMesh::SparsityPattern::Build::hashed_dof_sets
private

If there are "spider" nodes in the mesh (i.e.

a single node which is connected to many 1D elements) and Constraints, we can end up sorting the same set of DOFs multiple times in handle_vi_vj(), only to find that it has no net effect on the final sparsity. In such cases it is much faster to keep track of (element_dofs_i, element_dofs_j) pairs which have already been handled and not repeat the computation. We use this data structure to keep track of hashes of sets of dofs we have already seen, thus avoiding unnecessary calculations.

Definition at line 228 of file sparsity_pattern.h.

Referenced by handle_vi_vj(), and join().

◆ implicit_neighbor_dofs

const bool libMesh::SparsityPattern::Build::implicit_neighbor_dofs
private

Definition at line 212 of file sparsity_pattern.h.

◆ n_nz

std::vector<dof_id_type> libMesh::SparsityPattern::Build::n_nz
private

◆ n_oz

std::vector<dof_id_type> libMesh::SparsityPattern::Build::n_oz
private

◆ need_full_sparsity_pattern

const bool libMesh::SparsityPattern::Build::need_full_sparsity_pattern
private

Definition at line 213 of file sparsity_pattern.h.

Referenced by parallel_sync().

◆ nonlocal_pattern

SparsityPattern::NonlocalGraph libMesh::SparsityPattern::Build::nonlocal_pattern
private

◆ sc

const StaticCondensationDofMap* const libMesh::SparsityPattern::Build::sc
private

Definition at line 215 of file sparsity_pattern.h.

Referenced by sorted_connected_dofs().

◆ sparsity_pattern

SparsityPattern::Graph libMesh::SparsityPattern::Build::sparsity_pattern
private

The documentation for this class was generated from the following files: