From 2a7c75e23a280bafd613e50cacc1ad66fc092567 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 8 Aug 2017 17:58:43 -0500 Subject: [PATCH] Rename ConstraintLine::line to ConstraintLine::index --- include/deal.II/lac/constraint_matrix.h | 11 ++-- .../deal.II/lac/constraint_matrix.templates.h | 26 ++++---- source/lac/constraint_matrix.cc | 62 +++++++++---------- 3 files changed, 50 insertions(+), 49 deletions(-) diff --git a/include/deal.II/lac/constraint_matrix.h b/include/deal.II/lac/constraint_matrix.h index 1957cc4a21..233fd53b91 100644 --- a/include/deal.II/lac/constraint_matrix.h +++ b/include/deal.II/lac/constraint_matrix.h @@ -1134,10 +1134,11 @@ public: typedef std::vector > Entries; /** - * Number of this line. Since only very few lines are stored, we can not - * assume a specific order and have to store the line number explicitly. + * Global DoF index of this line. Since only very few lines are stored, + * we can not assume a specific order and have to store the index + * explicitly. */ - size_type line; + size_type index; /** * Row numbers and values of the entries in this line. @@ -1504,7 +1505,7 @@ ConstraintMatrix::add_line (const size_type line) // push a new line to the end of the list lines.emplace_back (); - lines.back().line = line; + lines.back().index = line; lines.back().inhomogeneity = 0.; lines_cache[line_index] = lines.size()-1; } @@ -1538,7 +1539,7 @@ ConstraintMatrix::add_entry (const size_type line, Assert (!local_lines.size() || local_lines.is_element(column), ExcColumnNotStoredHere(line, column)); ConstraintLine *line_ptr = &lines[lines_cache[line_index]]; - Assert (line_ptr->line == line, ExcInternalError()); + Assert (line_ptr->index == line, ExcInternalError()); for (ConstraintLine::Entries::const_iterator p=line_ptr->entries.begin(); p != line_ptr->entries.end(); ++p) diff --git a/include/deal.II/lac/constraint_matrix.templates.h b/include/deal.II/lac/constraint_matrix.templates.h index 2f973b755d..1cb91e2649 100644 --- a/include/deal.II/lac/constraint_matrix.templates.h +++ b/include/deal.II/lac/constraint_matrix.templates.h @@ -87,7 +87,7 @@ ConstraintMatrix::condense (const VectorType &vec_ghosted, ExcMessage ("Inhomogeneous constraint cannot be condensed " "without any matrix specified.")); - const typename VectorType::value_type old_value = vec_ghosted(constraint_line->line); + const typename VectorType::value_type old_value = vec_ghosted(constraint_line->index); for (size_type q=0; q!=constraint_line->entries.size(); ++q) if (vec.in_local_range(constraint_line->entries[q].first) == true) vec(constraint_line->entries[q].first) @@ -101,8 +101,8 @@ ConstraintMatrix::condense (const VectorType &vec_ghosted, for (std::vector::const_iterator constraint_line = lines.begin(); constraint_line!=lines.end(); ++constraint_line) - if (vec.in_local_range(constraint_line->line) == true) - vec(constraint_line->line) = 0.; + if (vec.in_local_range(constraint_line->index) == true) + vec(constraint_line->index) = 0.; vec.compress(VectorOperation::insert); } @@ -152,7 +152,7 @@ ConstraintMatrix::condense (SparseMatrix &uncondensed, numbers::invalid_size_type); for (size_type c=0; c &uncondensed, vec(lines[distribute[row]].entries[q].first) += (vec(row) * lines[distribute[row]].entries[q].second); - vec(lines[distribute[row]].line) = 0.; + vec(lines[distribute[row]].index) = 0.; } } } @@ -350,7 +350,7 @@ ConstraintMatrix::condense (BlockSparseMatrix &uncondensed, numbers::invalid_size_type); for (size_type c=0; c &uncondensed, vec(lines[distribute[row]].entries[q].first) += (vec(row) * lines[distribute[row]].entries[q].second); - vec(lines[distribute[row]].line) = 0.; + vec(lines[distribute[row]].index) = 0.; } } } @@ -612,7 +612,7 @@ ConstraintMatrix::set_zero (VectorType &vec) const // above. therefore, copy the content which is cheap std::vector constrained_lines(lines.size()); for (unsigned int i=0; i::const_iterator constraint_iterator; for (constraint_iterator it = lines.begin(); it != lines.end(); ++it) - if (vec_owned_elements.is_element(it->line)) + if (vec_owned_elements.is_element(it->index)) for (unsigned int i=0; ientries.size(); ++i) if (!vec_owned_elements.is_element(it->entries[i].first)) needed_elements.add_index(it->entries[i].first); @@ -888,7 +888,7 @@ ConstraintMatrix::distribute (VectorType &vec) const for (constraint_iterator it = lines.begin(); it != lines.end(); ++it) - if (vec_owned_elements.is_element(it->line)) + if (vec_owned_elements.is_element(it->index)) { typename VectorType::value_type new_value = it->inhomogeneity; @@ -898,7 +898,7 @@ ConstraintMatrix::distribute (VectorType &vec) const ghosted_vector, it->entries[i].first)) * it->entries[i].second); AssertIsFinite(new_value); - internal::ElementAccess::set(new_value, it->line, vec); + internal::ElementAccess::set(new_value, it->index, vec); } // now compress to communicate the entries that we added to @@ -917,7 +917,7 @@ ConstraintMatrix::distribute (VectorType &vec) const for (; next_constraint != lines.end(); ++next_constraint) { // fill entry in line - // next_constraint.line by adding the + // next_constraint.index by adding the // different contributions typename VectorType::value_type new_value = next_constraint->inhomogeneity; @@ -927,7 +927,7 @@ ConstraintMatrix::distribute (VectorType &vec) const vec, next_constraint->entries[i].first))* next_constraint->entries[i].second); AssertIsFinite(new_value); - internal::ElementAccess::set(new_value, next_constraint->line, + internal::ElementAccess::set(new_value, next_constraint->index, vec); } } diff --git a/source/lac/constraint_matrix.cc b/source/lac/constraint_matrix.cc index 31694628e5..f9aa08942c 100644 --- a/source/lac/constraint_matrix.cc +++ b/source/lac/constraint_matrix.cc @@ -74,7 +74,7 @@ ConstraintMatrix::check_zero_weight (const std::pair &p) bool ConstraintMatrix::ConstraintLine::operator < (const ConstraintLine &a) const { - return line < a.line; + return index < a.index; } @@ -82,7 +82,7 @@ ConstraintMatrix::ConstraintLine::operator < (const ConstraintLine &a) const bool ConstraintMatrix::ConstraintLine::operator == (const ConstraintLine &a) const { - return line == a.line; + return index == a.index; } @@ -90,7 +90,7 @@ ConstraintMatrix::ConstraintLine::operator == (const ConstraintLine &a) const std::size_t ConstraintMatrix::ConstraintLine::memory_consumption () const { - return (MemoryConsumption::memory_consumption (line) + + return (MemoryConsumption::memory_consumption (index) + MemoryConsumption::memory_consumption (entries) + MemoryConsumption::memory_consumption (inhomogeneity)); } @@ -135,7 +135,7 @@ ConstraintMatrix::add_entries Assert (is_constrained(line), ExcLineInexistant(line)); ConstraintLine *line_ptr = &lines[lines_cache[calculate_line_index(line)]]; - Assert (line_ptr->line == line, ExcInternalError()); + Assert (line_ptr->index == line, ExcInternalError()); // if in debug mode, check whether an entry for this column already // exists and if its the same as the one entered at present @@ -174,13 +174,13 @@ void ConstraintMatrix::add_selected_constraints if (constraints.n_constraints() == 0) return; - Assert (filter.size() > constraints.lines.back().line, + Assert (filter.size() > constraints.lines.back().index, ExcMessage ("Filter needs to be larger than constraint matrix size.")); for (std::vector::const_iterator line=constraints.lines.begin(); line!=constraints.lines.end(); ++line) - if (filter.is_element(line->line)) + if (filter.is_element(line->index)) { - const size_type row = filter.index_within_set (line->line); + const size_type row = filter.index_within_set (line->index); add_line (row); set_inhomogeneity (row, line->inhomogeneity); for (size_type i=0; ientries.size(); ++i) @@ -208,14 +208,14 @@ void ConstraintMatrix::close () size_type counter = 0; for (std::vector::const_iterator line=lines.begin(); line!=lines.end(); ++line, ++counter) - new_lines[calculate_line_index(line->line)] = counter; + new_lines[calculate_line_index(line->index)] = counter; std::swap (lines_cache, new_lines); } // in debug mode: check whether we really set the pointers correctly. for (size_type i=0; ientries[entry].first; const double weight = line->entries[entry].second; - Assert (dof_index != line->line, + Assert (dof_index != line->index, ExcMessage ("Cycle in constraints detected!")); const ConstraintLine *constrained_line = &lines[lines_cache[calculate_line_index(dof_index)]]; - Assert (constrained_line->line == dof_index, + Assert (constrained_line->index == dof_index, ExcInternalError()); // now we have to replace an entry by its expansion. we do @@ -471,7 +471,7 @@ void ConstraintMatrix::close () // make sure that entry->first is not the index of a line itself const bool is_circle = is_constrained(entry->first); Assert (is_circle == false, - ExcDoFConstrainedToConstrainedDoF(line->line, entry->first)); + ExcDoFConstrainedToConstrainedDoF(line->index, entry->first)); } #endif @@ -559,7 +559,7 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints, for (std::vector::const_iterator line = lines.begin(); line != lines.end(); ++line) { - size_type local_line_no = calculate_line_index(line->line); + size_type local_line_no = calculate_line_index(line->index); if (local_line_no >= lines_cache.size()) lines_cache.resize(local_line_no+1, numbers::invalid_size_type); lines_cache[local_line_no] = index++; @@ -569,7 +569,7 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints, for (std::vector::const_iterator line = other_constraints.lines.begin(); line != other_constraints.lines.end(); ++line) { - const size_type local_line_no = calculate_line_index(line->line); + const size_type local_line_no = calculate_line_index(line->index); if (local_line_no >= lines_cache.size()) { lines_cache.resize(local_line_no+1, numbers::invalid_size_type); @@ -590,7 +590,7 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints, { case no_conflicts_allowed: AssertThrow (false, - ExcDoFIsConstrainedFromBothObjects (line->line)); + ExcDoFIsConstrainedFromBothObjects (line->index)); break; case left_object_wins: @@ -611,7 +611,7 @@ ConstraintMatrix::merge (const ConstraintMatrix &other_constraints, // check that we set the pointers correctly for (size_type i=0; i::iterator i = lines.begin(); i != lines.end(); ++i) { - i->line += offset; + i->index += offset; for (ConstraintLine::Entries::iterator j = i->entries.begin(); j != i->entries.end(); ++j) @@ -651,7 +651,7 @@ void ConstraintMatrix::shift (const size_type offset) // are still linked correctly for (size_type i=0; i(c); + distribute[lines[c].index] = static_cast(c); const size_type n_rows = sparsity.n_rows(); for (size_type row=0; row 0) { for (size_type j=0; j 0) for (size_type j=0; j" << lines[i].entries[j].first + out << " " << lines[i].index << "->" << lines[i].entries[j].first << "; // weight: " << lines[i].entries[j].second << "\n"; else - out << " " << lines[i].line << "\n"; + out << " " << lines[i].index << "\n"; } out << "}" << std::endl; } -- 2.39.5