libMesh
Public Member Functions | Public Attributes | 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 MeshBase &mesh_in, 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)
 
 Build (Build &other, Threads::split)
 
void operator() (const ConstElemRange &range)
 
void join (const Build &other)
 
void parallel_sync ()
 
const Parallel::Communicator & comm () const
 
processor_id_type n_processors () const
 
processor_id_type processor_id () const
 

Public Attributes

SparsityPattern::Graph sparsity_pattern
 
SparsityPattern::NonlocalGraph nonlocal_pattern
 
std::vector< dof_id_typen_nz
 
std::vector< dof_id_typen_oz
 

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 MeshBasemesh
 
const DofMapdof_map
 
const CouplingMatrixdof_coupling
 
const std::set< GhostingFunctor * > & coupling_functors
 
const bool implicit_neighbor_dofs
 
const bool need_full_sparsity_pattern
 
std::unordered_set< dof_id_typehashed_dof_sets
 

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. PetscMatrix). 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 81 of file sparsity_pattern.h.

Constructor & Destructor Documentation

◆ Build() [1/2]

libMesh::SparsityPattern::Build::Build ( const MeshBase mesh_in,
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 
)

Definition at line 44 of file sparsity_pattern.C.

49  :
50  ParallelObject(dof_map_in),
51  mesh(mesh_in),
52  dof_map(dof_map_in),
53  dof_coupling(dof_coupling_in),
54  coupling_functors(coupling_functors_in),
55  implicit_neighbor_dofs(implicit_neighbor_dofs_in),
56  need_full_sparsity_pattern(need_full_sparsity_pattern_in),
59  n_nz(),
60  n_oz()
61 {}

◆ Build() [2/2]

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

Definition at line 65 of file sparsity_pattern.C.

65  :
66  ParallelObject(other),
67  mesh(other.mesh),
68  dof_map(other.dof_map),
69  dof_coupling(other.dof_coupling),
70  coupling_functors(other.coupling_functors),
71  implicit_neighbor_dofs(other.implicit_neighbor_dofs),
72  need_full_sparsity_pattern(other.need_full_sparsity_pattern),
73  hashed_dof_sets(other.hashed_dof_sets),
76  n_nz(),
77  n_oz()
78 {}

Member Function Documentation

◆ comm()

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

Definition at line 94 of file parallel_object.h.

95  { return _communicator; }

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::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::EquationSystems::_read_impl(), 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::ImplicitSystem::add_matrix(), libMesh::RBConstruction::add_scaled_matrix_and_vector(), libMesh::DynaIO::add_spline_constraints(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), 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::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::Generation::build_extrusion(), 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::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::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_scalar_solution(), 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::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshJacobian(), DMlibMeshSetSystem_libMesh(), DMVariableBounds_libMesh(), libMesh::DTKSolutionTransfer::DTKSolutionTransfer(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::RBEIMConstruction::enrich_RB_space(), libMesh::TransientRBConstruction::enrich_RB_space(), libMesh::RBConstruction::enrich_RB_space(), libMesh::EpetraVector< T >::EpetraVector(), AssembleOptimization::equality_constraints(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::RBEIMConstruction::evaluate_mesh_function(), 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::DofMap::gather_constraints(), libMesh::MeshfreeInterpolation::gather_remote_data(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::DofMap::get_info(), libMesh::ImplicitSystem::get_linear_solver(), AssembleOptimization::inequality_constraints(), AssembleOptimization::inequality_constraints_jacobian(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::EigenSystem::init_matrices(), libMesh::OptimizationSystem::initialize_equality_constraints_storage(), libMesh::OptimizationSystem::initialize_inequality_constraints_storage(), libMesh::RBEIMConstruction::initialize_rb_construction(), 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_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::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_preconditioner_apply(), libMesh::libmesh_petsc_snes_fd_residual(), libMesh::libmesh_petsc_snes_jacobian(), libMesh::libmesh_petsc_snes_mffd_residual(), libMesh::libmesh_petsc_snes_postcheck(), 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(), 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_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(), LinearElasticityWithContact::move_mesh(), libMesh::DistributedMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::DofMap::n_constrained_dofs(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::BoundaryInfo::n_shellface_conds(), 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::MeshTools::paranoid_n_levels(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), FEMParameters::read(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), 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::MeshRefinement::refine_and_coarsen_elements(), libMesh::DistributedMesh::renumber_dof_objects(), LinearElasticityWithContact::residual_and_jacobian(), OverlappingAlgebraicGhostingTest::run_ghosting_test(), OverlappingCouplingGhostingTest::run_sparsity_pattern_test(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::TransientRBConstruction::set_error_temporal_data(), libMesh::RBEIMConstruction::set_explicit_sys_subvector(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::PetscDiffSolver::setup_petsc_data(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::split_mesh(), libMesh::BoundaryInfo::sync(), libMesh::MeshRefinement::test_level_one(), MeshfunctionDFEM::test_mesh_function_dfem(), MeshfunctionDFEM::test_mesh_function_dfem_grad(), MeshFunctionTest::test_p_level(), libMesh::MeshRefinement::test_unflagged(), SystemsTest::testBlockRestrictedVarNDofs(), PointLocatorTest::testLocator(), BoundaryInfoTest::testMesh(), SystemsTest::testProjectCubeWithMeshFunction(), CheckpointIOTest::testSplitter(), libMesh::MeshTools::total_weight(), libMesh::MeshFunctionSolutionTransfer::transfer(), libMesh::MeshfreeSolutionTransfer::transfer(), libMesh::TransientRBConstruction::truth_assembly(), libMesh::RBConstruction::truth_assembly(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::TransientRBConstruction::update_RB_initial_condition_all_N(), libMesh::RBEIMConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_RB_system_matrices(), libMesh::RBConstruction::update_RB_system_matrices(), libMesh::TransientRBConstruction::update_residual_terms(), libMesh::RBConstruction::update_residual_terms(), libMesh::NameBasedIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write_nodal_data(), 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().

◆ 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 105 of file sparsity_pattern.C.

107 {
108  const unsigned int n_dofs_on_element_i =
109  cast_int<unsigned int>(element_dofs_i.size());
110 
111  const processor_id_type proc_id = mesh.processor_id();
112  const dof_id_type first_dof_on_proc = dof_map.first_dof(proc_id);
113  const dof_id_type end_dof_on_proc = dof_map.end_dof(proc_id);
114 
115  std::vector<dof_id_type>
116  dofs_to_add;
117 
118  const unsigned int n_dofs_on_element_j =
119  cast_int<unsigned int>(element_dofs_j.size());
120 
121  // It only makes sense to compute hashes and see if we can skip
122  // doing work when there are a "large" amount of DOFs for a given
123  // element. The cutoff for "large" is somewhat arbitrarily chosen
124  // based on a test case with a spider node that resulted in O(10^3)
125  // entries in element_dofs_i for O(10^3) elements. Making this
126  // number larger will disable the hashing optimization in more
127  // cases.
128  bool dofs_seen = false;
129  if (n_dofs_on_element_j > 0 && n_dofs_on_element_i > 256)
130  {
131  auto hash_i = Utility::hashword(element_dofs_i);
132  auto hash_j = Utility::hashword(element_dofs_j);
133  auto final_hash = Utility::hashword2(hash_i, hash_j);
134  auto result = hashed_dof_sets.insert(final_hash);
135  // if insert failed, we have already seen these dofs
136  dofs_seen = !result.second;
137  }
138 
139  // there might be 0 dofs for the other variable on the same element
140  // (when subdomain variables do not overlap) and that's when we do
141  // not do anything
142  if (n_dofs_on_element_j > 0 && !dofs_seen)
143  {
144  for (unsigned int i=0; i<n_dofs_on_element_i; i++)
145  {
146  const dof_id_type ig = element_dofs_i[i];
147 
148  SparsityPattern::Row * row;
149 
150  // We save non-local row components for now so we can
151  // communicate them to other processors later.
152 
153  if ((ig >= first_dof_on_proc) &&
154  (ig < end_dof_on_proc))
155  {
156  // This is what I mean
157  // libmesh_assert_greater_equal ((ig - first_dof_on_proc), 0);
158  // but do the test like this because ig and
159  // first_dof_on_proc are unsigned ints
160  libmesh_assert_greater_equal (ig, first_dof_on_proc);
161  libmesh_assert_less (ig, (sparsity_pattern.size() +
162  first_dof_on_proc));
163 
164  row = &sparsity_pattern[ig - first_dof_on_proc];
165  }
166  else
167  {
168  row = &nonlocal_pattern[ig];
169  }
170 
171  // If the row is empty we will add *all*
172  // the element j DOFs, so just do that.
173  if (row->empty())
174  {
175  row->insert(row->end(),
176  element_dofs_j.begin(),
177  element_dofs_j.end());
178  }
179  else
180  {
181  // Build a list of the DOF indices not found in the
182  // sparsity pattern
183  dofs_to_add.clear();
184 
185  // Cache iterators. Low will move forward, subsequent
186  // searches will be on smaller ranges
187  SparsityPattern::Row::iterator
188  low = std::lower_bound
189  (row->begin(), row->end(), element_dofs_j.front()),
190  high = std::upper_bound
191  (low, row->end(), element_dofs_j.back());
192 
193  for (unsigned int j=0; j<n_dofs_on_element_j; j++)
194  {
195  const dof_id_type jg = element_dofs_j[j];
196 
197  // See if jg is in the sorted range
198  std::pair<SparsityPattern::Row::iterator,
199  SparsityPattern::Row::iterator>
200  pos = std::equal_range (low, high, jg);
201 
202  // Must add jg if it wasn't found
203  if (pos.first == pos.second)
204  dofs_to_add.push_back(jg);
205 
206  // pos.first is now a valid lower bound for any
207  // remaining element j DOFs. (That's why we sorted them.)
208  // Use it for the next search
209  low = pos.first;
210  }
211 
212  // Add to the sparsity pattern
213  if (!dofs_to_add.empty())
214  {
215  const std::size_t old_size = row->size();
216 
217  row->insert (row->end(),
218  dofs_to_add.begin(),
219  dofs_to_add.end());
220 
222  (row->begin(), row->begin()+old_size,
223  row->end());
224  }
225  }
226  } // End dofs-of-var-i loop
227  } // End if-dofs-of-var-j
228 }

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

Referenced by operator()().

◆ join()

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

Definition at line 366 of file sparsity_pattern.C.

367 {
368  const processor_id_type proc_id = mesh.processor_id();
369  const dof_id_type n_global_dofs = dof_map.n_dofs();
370  const dof_id_type n_dofs_on_proc = dof_map.n_dofs_on_processor(proc_id);
371  const dof_id_type first_dof_on_proc = dof_map.first_dof(proc_id);
372  const dof_id_type end_dof_on_proc = dof_map.end_dof(proc_id);
373 
374  libmesh_assert_equal_to (sparsity_pattern.size(), other.sparsity_pattern.size());
375  libmesh_assert_equal_to (n_nz.size(), sparsity_pattern.size());
376  libmesh_assert_equal_to (n_oz.size(), sparsity_pattern.size());
377 
378  for (dof_id_type r=0; r<n_dofs_on_proc; r++)
379  {
380  // increment the number of on and off-processor nonzeros in this row
381  // (note this will be an upper bound unless we need the full sparsity pattern)
383  {
385  const SparsityPattern::Row & their_row = other.sparsity_pattern[r];
386 
387  // simple copy if I have no dofs
388  if (my_row.empty())
389  my_row = their_row;
390 
391  // otherwise add their DOFs to mine, resort, and re-unique the row
392  else if (!their_row.empty()) // do nothing for the trivial case where
393  { // their row is empty
394  my_row.insert (my_row.end(),
395  their_row.begin(),
396  their_row.end());
397 
398  // We cannot use SparsityPattern::sort_row() here because it expects
399  // the [begin,middle) [middle,end) to be non-overlapping. This is not
400  // necessarily the case here, so use std::sort()
401  std::sort (my_row.begin(), my_row.end());
402 
403  my_row.erase(std::unique (my_row.begin(), my_row.end()), my_row.end());
404  }
405 
406  // fix the number of on and off-processor nonzeros in this row
407  n_nz[r] = n_oz[r] = 0;
408 
409  for (const auto & df : my_row)
410  if ((df < first_dof_on_proc) || (df >= end_dof_on_proc))
411  n_oz[r]++;
412  else
413  n_nz[r]++;
414  }
415  else
416  {
417  n_nz[r] += other.n_nz[r];
418  n_nz[r] = std::min(n_nz[r], n_dofs_on_proc);
419  n_oz[r] += other.n_oz[r];
420  n_oz[r] =std::min(n_oz[r], static_cast<dof_id_type>(n_global_dofs-n_nz[r]));
421  }
422  }
423 
424  // Move nonlocal row information to ourselves; the other thread
425  // won't need it in the map after that.
426  for (const auto & p : other.nonlocal_pattern)
427  {
428 #ifndef NDEBUG
429  const dof_id_type dof_id = p.first;
430 
431  processor_id_type dbg_proc_id = 0;
432  while (dof_id >= dof_map.end_dof(dbg_proc_id))
433  dbg_proc_id++;
434  libmesh_assert (dbg_proc_id != this->processor_id());
435 #endif
436 
437  const SparsityPattern::Row & their_row = p.second;
438 
439  // We should have no empty values in a map
440  libmesh_assert (!their_row.empty());
441 
442  NonlocalGraph::iterator my_it = nonlocal_pattern.find(p.first);
443  if (my_it == nonlocal_pattern.end())
444  {
445  // nonlocal_pattern[it->first].swap(their_row);
446  nonlocal_pattern[p.first] = their_row;
447  }
448  else
449  {
450  SparsityPattern::Row & my_row = my_it->second;
451 
452  my_row.insert (my_row.end(),
453  their_row.begin(),
454  their_row.end());
455 
456  // We cannot use SparsityPattern::sort_row() here because it expects
457  // the [begin,middle) [middle,end) to be non-overlapping. This is not
458  // necessarily the case here, so use std::sort()
459  std::sort (my_row.begin(), my_row.end());
460 
461  my_row.erase(std::unique (my_row.begin(), my_row.end()), my_row.end());
462  }
463  }
464 
465  // Combine the other thread's hashed_dof_sets with ours.
466  hashed_dof_sets.insert(other.hashed_dof_sets.begin(),
467  other.hashed_dof_sets.end());
468 }

References dof_map, libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), hashed_dof_sets, libMesh::libmesh_assert(), mesh, libMesh::DofMap::n_dofs(), libMesh::DofMap::n_dofs_on_processor(), n_nz, n_oz, need_full_sparsity_pattern, nonlocal_pattern, libMesh::ParallelObject::processor_id(), and sparsity_pattern.

◆ n_processors()

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

Definition at line 100 of file parallel_object.h.

101  { return cast_int<processor_id_type>(_communicator.size()); }

References libMesh::ParallelObject::_communicator.

Referenced by 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::LaplaceMeshSmoother::allgather_graph(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO::copy_scalar_solution(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::MeshTools::create_processor_bounding_box(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), libMesh::Nemesis_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::partition(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::prepare_send_list(), 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(), OverlappingFunctorTest::run_partitioner_test(), libMesh::DofMap::scatter_constraints(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::VTKIO::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().

◆ operator()()

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

Definition at line 232 of file sparsity_pattern.C.

233 {
234  // Compute the sparsity structure of the global matrix. This can be
235  // fed into a PetscMatrix to allocate exactly the number of nonzeros
236  // necessary to store the matrix. This algorithm should be linear
237  // in the (# of elements)*(# nodes per element)
238  const processor_id_type proc_id = mesh.processor_id();
239  const dof_id_type n_dofs_on_proc = dof_map.n_dofs_on_processor(proc_id);
240  const dof_id_type first_dof_on_proc = dof_map.first_dof(proc_id);
241  const dof_id_type end_dof_on_proc = dof_map.end_dof(proc_id);
242 
243  sparsity_pattern.resize(n_dofs_on_proc);
244 
245  // Handle dof coupling specified by library and user coupling functors
246  {
247  const unsigned int n_var = dof_map.n_variables();
248 
249  std::vector<std::vector<dof_id_type> > element_dofs_i(n_var);
250 
251  std::vector<const Elem *> coupled_neighbors;
252  for (const auto & elem : range)
253  {
254  // Make some fake element iterators defining a range
255  // pointing to only this element.
256  Elem * const * elempp = const_cast<Elem * const *>(&elem);
257  Elem * const * elemend = elempp+1;
258 
259  const MeshBase::const_element_iterator fake_elem_it =
260  MeshBase::const_element_iterator(elempp,
261  elemend,
262  Predicates::NotNull<Elem * const *>());
263 
264  const MeshBase::const_element_iterator fake_elem_end =
265  MeshBase::const_element_iterator(elemend,
266  elemend,
267  Predicates::NotNull<Elem * const *>());
268 
269  GhostingFunctor::map_type elements_to_couple;
270 
271  // Man, I wish we had guaranteed unique_ptr availability...
272  std::set<CouplingMatrix *> temporary_coupling_matrices;
273 
274  dof_map.merge_ghost_functor_outputs(elements_to_couple,
275  temporary_coupling_matrices,
278  fake_elem_it,
279  fake_elem_end,
281  for (unsigned int vi=0; vi<n_var; vi++)
282  this->sorted_connected_dofs(elem, element_dofs_i[vi], vi);
283 
284  for (unsigned int vi=0; vi<n_var; vi++)
285  for (const auto & pr : elements_to_couple)
286  {
287  const Elem * const partner = pr.first;
288  const CouplingMatrix * ghost_coupling = pr.second;
289 
290  // Loop over coupling matrix row variables if we have a
291  // coupling matrix, or all variables if not.
292  if (ghost_coupling)
293  {
294  libmesh_assert_equal_to (ghost_coupling->size(), n_var);
295  ConstCouplingRow ccr(vi, *ghost_coupling);
296 
297  for (const auto & idx : ccr)
298  {
299  if (partner == elem)
300  this->handle_vi_vj(element_dofs_i[vi], element_dofs_i[idx]);
301  else
302  {
303  std::vector<dof_id_type> partner_dofs;
304  this->sorted_connected_dofs(partner, partner_dofs, idx);
305  this->handle_vi_vj(element_dofs_i[vi], partner_dofs);
306  }
307  }
308  }
309  else
310  {
311  for (unsigned int vj = 0; vj != n_var; ++vj)
312  {
313  if (partner == elem)
314  this->handle_vi_vj(element_dofs_i[vi], element_dofs_i[vj]);
315  else
316  {
317  std::vector<dof_id_type> partner_dofs;
318  this->sorted_connected_dofs(partner, partner_dofs, vj);
319  this->handle_vi_vj(element_dofs_i[vi], partner_dofs);
320  }
321  }
322  }
323  } // End ghosted element loop
324 
325  for (auto & mat : temporary_coupling_matrices)
326  delete mat;
327 
328  } // End range element loop
329  } // End ghosting functor section
330 
331  // Now a new chunk of sparsity structure is built for all of the
332  // DOFs connected to our rows of the matrix.
333 
334  // If we're building a full sparsity pattern, then we've got
335  // complete rows to work with, so we can just count them from
336  // scratch.
338  {
339  n_nz.clear();
340  n_oz.clear();
341  }
342 
343  n_nz.resize (n_dofs_on_proc, 0);
344  n_oz.resize (n_dofs_on_proc, 0);
345 
346  for (dof_id_type i=0; i<n_dofs_on_proc; i++)
347  {
348  // Get the row of the sparsity pattern
350 
351  for (const auto & df : row)
352  if ((df < first_dof_on_proc) || (df >= end_dof_on_proc))
353  n_oz[i]++;
354  else
355  n_nz[i]++;
356 
357  // If we're not building a full sparsity pattern, then we want
358  // to avoid overcounting these entries as much as possible.
360  row.clear();
361  }
362 }

References libMesh::DofMap::coupling_functors_begin(), libMesh::DofMap::coupling_functors_end(), dof_map, libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), handle_vi_vj(), libMesh::MeshTools::Generation::Private::idx(), libMesh::DofObject::invalid_processor_id, libMesh::DofMap::merge_ghost_functor_outputs(), mesh, libMesh::DofMap::n_dofs_on_processor(), n_nz, n_oz, libMesh::DofMap::n_variables(), need_full_sparsity_pattern, libMesh::ParallelObject::processor_id(), libMesh::CouplingMatrix::size(), sorted_connected_dofs(), and sparsity_pattern.

◆ parallel_sync()

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

Definition at line 472 of file sparsity_pattern.C.

473 {
474  parallel_object_only();
476 
477  auto & comm = this->comm();
478  auto pid = comm.rank();
479  auto num_procs = comm.size();
480 
481  auto dof_tag = comm.get_unique_tag();
482  auto row_tag = comm.get_unique_tag();
483 
484  const auto n_global_dofs = dof_map.n_dofs();
485  const auto n_dofs_on_proc = dof_map.n_dofs_on_processor(pid);
486  const auto local_first_dof = dof_map.first_dof();
487  const auto local_end_dof = dof_map.end_dof();
488 
489  // The data to send
490  std::map<processor_id_type, std::pair<std::vector<dof_id_type>, std::vector<Row>>> data_to_send;
491 
492  // True/false if we're sending to that processor
493  std::vector<char> will_send_to(num_procs);
494 
495  processor_id_type num_sends = 0;
496 
497  // Loop over the nonlocal rows and transform them into the new datastructure
498  NonlocalGraph::iterator it = nonlocal_pattern.begin();
499  while (it != nonlocal_pattern.end())
500  {
501  const auto dof_id = it->first;
502  auto & row = it->second;
503 
504  processor_id_type proc_id = 0;
505  while (dof_id >= dof_map.end_dof(proc_id))
506  proc_id++;
507 
508  // Count the unique sends
509  if (!will_send_to[proc_id])
510  num_sends++;
511 
512  will_send_to[proc_id] = true;
513 
514  // rhs [] on purpose
515  auto & proc_data = data_to_send[proc_id];
516 
517  proc_data.first.push_back(dof_id);
518 
519  // Note this invalidates the data in nonlocal_pattern
520  proc_data.second.emplace_back(std::move(row));
521 
522  // Might as well remove it since it's invalidated anyway
523  it = nonlocal_pattern.erase(it);
524  }
525 
526  // Tell everyone about where everyone will send to
527  comm.alltoall(will_send_to);
528 
529  // will_send_to now represents who we'll receive from
530  // give it a good name
531  auto & will_receive_from = will_send_to;
532 
533  std::vector<Parallel::Request> dof_sends(num_sends);
534  std::vector<Parallel::Request> row_sends(num_sends);
535 
536  // Post all of the sends
537  processor_id_type current_send = 0;
538  for (auto & proc_data : data_to_send)
539  {
540  auto proc_id = proc_data.first;
541 
542  auto & dofs = proc_data.second.first;
543  auto & rows = proc_data.second.second;
544 
545  comm.send(proc_id, dofs, dof_sends[current_send], dof_tag);
546  comm.send(proc_id, rows, row_sends[current_send], row_tag);
547 
548  current_send++;
549  }
550 
551  // Figure out how many receives we're going to have and make a
552  // quick list of who's sending
553  processor_id_type num_receives = 0;
554  std::vector<processor_id_type> receiving_from;
555  for (processor_id_type proc_id = 0; proc_id < num_procs; proc_id++)
556  {
557  auto will = will_receive_from[proc_id];
558 
559  if (will)
560  {
561  num_receives++;
562  receiving_from.push_back(proc_id);
563  }
564  }
565 
566  // Post the receives and handle the data
567  for (auto proc_id : receiving_from)
568  {
569  std::vector<dof_id_type> in_dofs;
570  std::vector<Row> in_rows;
571 
572  // Receive dofs
573  comm.receive(proc_id, in_dofs, dof_tag);
574  comm.receive(proc_id, in_rows, row_tag);
575 
576  const std::size_t n_rows = in_dofs.size();
577  for (std::size_t i = 0; i != n_rows; ++i)
578  {
579  const auto r = in_dofs[i];
580  const auto my_r = r - local_first_dof;
581 
582  auto & their_row = in_rows[i];
583 
585  {
586  auto & my_row = sparsity_pattern[my_r];
587 
588  // They wouldn't have sent an empty row
589  libmesh_assert(!their_row.empty());
590 
591  // We can end up with an empty row on a dof that touches our
592  // inactive elements but not our active ones
593  if (my_row.empty())
594  {
595  my_row.assign (their_row.begin(), their_row.end());
596  }
597  else
598  {
599  my_row.insert (my_row.end(),
600  their_row.begin(),
601  their_row.end());
602 
603  // We cannot use SparsityPattern::sort_row() here because it expects
604  // the [begin,middle) [middle,end) to be non-overlapping. This is not
605  // necessarily the case here, so use std::sort()
606  std::sort (my_row.begin(), my_row.end());
607 
608  my_row.erase(std::unique (my_row.begin(), my_row.end()), my_row.end());
609  }
610 
611  // fix the number of on and off-processor nonzeros in this row
612  n_nz[my_r] = n_oz[my_r] = 0;
613 
614  for (const auto & df : my_row)
615  if ((df < local_first_dof) || (df >= local_end_dof))
616  n_oz[my_r]++;
617  else
618  n_nz[my_r]++;
619  }
620  else
621  {
622  for (const auto & df : their_row)
623  if ((df < local_first_dof) || (df >= local_end_dof))
624  n_oz[my_r]++;
625  else
626  n_nz[my_r]++;
627 
628  n_nz[my_r] = std::min(n_nz[my_r], n_dofs_on_proc);
629  n_oz[my_r] = std::min(n_oz[my_r],
630  static_cast<dof_id_type>(n_global_dofs-n_nz[my_r]));
631  }
632  }
633  }
634 
635  // We should have sent everything at this point.
637 
638  // Make sure to cleanup requests
639  Parallel::wait(dof_sends);
640  Parallel::wait(row_sends);
641 }

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

◆ processor_id()

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

Definition at line 106 of file parallel_object.h.

107  { return cast_int<processor_id_type>(_communicator.rank()); }

References libMesh::ParallelObject::_communicator.

Referenced by libMesh::BoundaryInfo::_find_id_maps(), libMesh::EquationSystems::_read_impl(), 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::UnstructuredMesh::all_second_order(), libMesh::MeshTools::Modification::all_tri(), libMesh::DofMap::allgather_recursive_constraints(), libMesh::FEMSystem::assembly(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::BoundaryInfo::build_node_list_from_side_list(), libMesh::EquationSystems::build_parallel_elemental_solution_vector(), libMesh::DistributedMesh::clear(), 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_scalar_solution(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::ExodusII_IO_Helper::create(), libMesh::DistributedMesh::delete_elem(), libMesh::DistributedMesh::delete_node(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DistributedMesh::DistributedMesh(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::RBEIMConstruction::evaluate_mesh_function(), libMesh::MeshFunction::find_element(), libMesh::MeshFunction::find_elements(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), 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::DofMap::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::DofMap::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::SystemSubsetBySubdomain::init(), libMesh::PetscDMWrapper::init_and_attach_petscdm(), 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::DofMap::last_dof(), libMesh::TransientRBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEvaluation::legacy_write_offline_data_to_files(), libMesh::RBSCMEvaluation::legacy_write_offline_data_to_files(), libMesh::RBEIMEvaluation::legacy_write_out_interpolation_points_elem(), 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::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::BoundaryInfo::n_shellface_conds(), operator()(), libMesh::DistributedMesh::own_node(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::DofMap::print_dof_constraints(), 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::ExodusII_IO_Helper::read_elem_num_map(), libMesh::ExodusII_IO_Helper::read_global_values(), libMesh::CheckpointIO::read_header(), libMesh::XdrIO::read_header(), libMesh::System::read_header(), libMesh::RBEvaluation::read_in_vectors_from_multiple_files(), libMesh::System::read_legacy_data(), 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::DistributedMesh::renumber_dof_objects(), libMesh::DofMap::scatter_constraints(), libMesh::CheckpointIO::select_split_config(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::PetscDMWrapper::set_point_range_in_section(), libMesh::LaplaceMeshSmoother::smooth(), DefaultCouplingTest::testCoupling(), PointNeighborCouplingTest::testCoupling(), MeshInputTest::testDynaReadElem(), MeshInputTest::testDynaReadPatch(), MeshInputTest::testExodusCopyElementSolution(), MeshInputTest::testExodusWriteElementDataFromDiscontinuousNodalData(), SystemsTest::testProjectMatrix1D(), SystemsTest::testProjectMatrix2D(), SystemsTest::testProjectMatrix3D(), BoundaryInfoTest::testShellFaceConstraints(), CheckpointIOTest::testSplitter(), WriteVecAndScalar::testWrite(), libMesh::MeshTools::total_weight(), libMesh::MeshRefinement::uniformly_coarsen(), libMesh::Parallel::Packing< Node * >::unpack(), libMesh::Parallel::Packing< Elem * >::unpack(), libMesh::DistributedMesh::update_parallel_id_counts(), libMesh::DTKAdapter::update_variable_values(), 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::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::VTKIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::RBEvaluation::write_out_vectors(), 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().

◆ 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 90 of file sparsity_pattern.C.

93 {
94  dof_map.dof_indices (elem, dofs_vi, vi);
95 #ifdef LIBMESH_ENABLE_CONSTRAINTS
96  dof_map.find_connected_dofs (dofs_vi);
97 #endif
98  // We can be more efficient if we sort the element DOFs into
99  // increasing order
100  std::sort(dofs_vi.begin(), dofs_vi.end());
101 }

References libMesh::DofMap::dof_indices(), dof_map, and libMesh::DofMap::find_connected_dofs().

Referenced by operator()().

Member Data Documentation

◆ _communicator

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

◆ coupling_functors

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

Definition at line 87 of file sparsity_pattern.h.

◆ dof_coupling

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

Definition at line 86 of file sparsity_pattern.h.

◆ dof_map

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

◆ hashed_dof_sets

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

Definition at line 100 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 88 of file sparsity_pattern.h.

◆ mesh

const MeshBase& libMesh::SparsityPattern::Build::mesh
private

Definition at line 84 of file sparsity_pattern.h.

Referenced by handle_vi_vj(), join(), and operator()().

◆ n_nz

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

Definition at line 114 of file sparsity_pattern.h.

Referenced by join(), operator()(), and parallel_sync().

◆ n_oz

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

Definition at line 115 of file sparsity_pattern.h.

Referenced by join(), operator()(), and parallel_sync().

◆ need_full_sparsity_pattern

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

Definition at line 89 of file sparsity_pattern.h.

Referenced by join(), operator()(), and parallel_sync().

◆ nonlocal_pattern

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

Definition at line 112 of file sparsity_pattern.h.

Referenced by handle_vi_vj(), join(), and parallel_sync().

◆ sparsity_pattern

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

Definition at line 111 of file sparsity_pattern.h.

Referenced by handle_vi_vj(), join(), operator()(), and parallel_sync().


The documentation for this class was generated from the following files:
libMesh::dof_id_type
uint8_t dof_id_type
Definition: id_types.h:67
libMesh::SparsityPattern::Row
std::vector< dof_id_type, Threads::scalable_allocator< dof_id_type > > Row
Definition: sparsity_pattern.h:51
libMesh::SparsityPattern::Build::sorted_connected_dofs
void sorted_connected_dofs(const Elem *elem, std::vector< dof_id_type > &dofs_vi, unsigned int vi)
Definition: sparsity_pattern.C:90
libMesh::DofMap::dof_indices
void dof_indices(const Elem *const elem, std::vector< dof_id_type > &di) const
Fills the vector di with the global degree of freedom indices for the element.
Definition: dof_map.C:1967
libMesh::SparsityPattern::Build::handle_vi_vj
void handle_vi_vj(const std::vector< dof_id_type > &element_dofs_i, const std::vector< dof_id_type > &element_dofs_j)
Definition: sparsity_pattern.C:105
libMesh::SparsityPattern::Build::nonlocal_pattern
SparsityPattern::NonlocalGraph nonlocal_pattern
Definition: sparsity_pattern.h:112
libMesh::SparsityPattern::Build::dof_map
const DofMap & dof_map
Definition: sparsity_pattern.h:85
libMesh::DofMap::n_dofs
dof_id_type n_dofs() const
Definition: dof_map.h:625
libMesh::DofMap::coupling_functors_begin
std::set< GhostingFunctor * >::const_iterator coupling_functors_begin() const
Beginning of range of coupling functors.
Definition: dof_map.h:329
libMesh::ParallelObject::comm
const Parallel::Communicator & comm() const
Definition: parallel_object.h:94
libMesh::DofMap::n_variables
unsigned int n_variables() const
Definition: dof_map.h:592
libMesh::GhostingFunctor::map_type
std::unordered_map< const Elem *, const CouplingMatrix * > map_type
What elements do we care about and what variables do we care about on each element?
Definition: ghosting_functor.h:171
libMesh::SparsityPattern::Build::hashed_dof_sets
std::unordered_set< dof_id_type > hashed_dof_sets
Definition: sparsity_pattern.h:100
libMesh::SparsityPattern::Build::sparsity_pattern
SparsityPattern::Graph sparsity_pattern
Definition: sparsity_pattern.h:111
libMesh::DofMap::first_dof
dof_id_type first_dof(const processor_id_type proc) const
Definition: dof_map.h:650
libMesh::SparsityPattern::sort_row
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,...
libMesh::SparsityPattern::Build::n_oz
std::vector< dof_id_type > n_oz
Definition: sparsity_pattern.h:115
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::ParallelObject::ParallelObject
ParallelObject(const Parallel::Communicator &comm_in)
Constructor.
Definition: parallel_object.h:63
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::SparsityPattern::Build::dof_coupling
const CouplingMatrix * dof_coupling
Definition: sparsity_pattern.h:86
libMesh::SparsityPattern::Build::coupling_functors
const std::set< GhostingFunctor * > & coupling_functors
Definition: sparsity_pattern.h:87
libMesh::ParallelObject::_communicator
const Parallel::Communicator & _communicator
Definition: parallel_object.h:112
libMesh::processor_id_type
uint8_t processor_id_type
Definition: id_types.h:104
libMesh::DofMap::find_connected_dofs
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:2773
libMesh::Utility::hashword2
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:210
libMesh::MeshTools::Generation::Private::idx
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.
Definition: mesh_generation.C:72
libMesh::SparsityPattern::Build::need_full_sparsity_pattern
const bool need_full_sparsity_pattern
Definition: sparsity_pattern.h:89
libMesh::DofMap::n_dofs_on_processor
dof_id_type n_dofs_on_processor(const processor_id_type proc) const
Definition: dof_map.h:641
libMesh::Utility::hashword
uint32_t hashword(const uint32_t *k, size_t length, uint32_t initval=0)
The hashword function takes an array of uint32_t's of length 'length' and computes a single key from ...
Definition: hashword.h:153
libMesh::DofMap::coupling_functors_end
std::set< GhostingFunctor * >::const_iterator coupling_functors_end() const
End of range of coupling functors.
Definition: dof_map.h:335
libMesh::SparsityPattern::Build::n_nz
std::vector< dof_id_type > n_nz
Definition: sparsity_pattern.h:114
libMesh::DofObject::invalid_processor_id
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:432
libMesh::SparsityPattern::Build::implicit_neighbor_dofs
const bool implicit_neighbor_dofs
Definition: sparsity_pattern.h:88
libMesh::SparsityPattern::Build::mesh
const MeshBase & mesh
Definition: sparsity_pattern.h:84
libMesh::DofMap::end_dof
dof_id_type end_dof(const processor_id_type proc) const
Definition: dof_map.h:692
libMesh::DofMap::merge_ghost_functor_outputs
static void merge_ghost_functor_outputs(GhostingFunctor::map_type &elements_to_ghost, std::set< CouplingMatrix * > &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:1440