--- /dev/null
+New: There is a new header, <tt>lac/trilinos_index_access.h</tt>, that provides
+index and size functions for some common Trilinos objects that work correctly for
+both 32 and 64 bit code.
+<br> (David Wells, 2017/05/10)
--- /dev/null
+// ---------------------------------------------------------------------
+//
+// Copyright (C) 2017 by the deal.II authors
+//
+// This file is part of the deal.II library.
+//
+// The deal.II library is free software; you can use it, redistribute
+// it, and/or modify it under the terms of the GNU Lesser General
+// Public License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+// The full text of the license can be found in the file LICENSE at
+// the top level of the deal.II distribution.
+//
+// ---------------------------------------------------------------------
+
+#ifndef dealii__trilinos_index_access_h
+#define dealii__trilinos_index_access_h
+
+#include <deal.II/base/config.h>
+
+#ifdef DEAL_II_WITH_TRILINOS
+
+#include <deal.II/base/types.h>
+
+#include <Epetra_BlockMap.h>
+#include <Epetra_CrsGraph.h>
+#include <Epetra_CrsMatrix.h>
+#include <Epetra_MultiVector.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace TrilinosWrappers
+{
+ /**
+ * A helper function that queries the size of an Epetra_BlockMap object
+ * and calls either the 32 or 64 bit function to get the number of global
+ * elements in the map.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ n_global_elements(const Epetra_BlockMap &map)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return map.NumGlobalElements64();
+#else
+ return map.NumGlobalElements();
+#endif
+ }
+
+ /**
+ * A helper function that finds the minimum global index value on the
+ * calling processor by calling either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ min_my_gid(const Epetra_BlockMap &map)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return map.MinMyGID64();
+#else
+ return map.MinMyGID();
+#endif
+ }
+
+ /**
+ * A helper function that finds the maximum global index value on the
+ * calling processor by calling either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ max_my_gid(const Epetra_BlockMap &map)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return map.MaxMyGID64();
+#else
+ return map.MaxMyGID();
+#endif
+ }
+
+ /**
+ * A helper function that converts a local index to a global one calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ global_index(const Epetra_BlockMap &map,
+ const dealii::types::global_dof_index i)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return map.GID64(i);
+#else
+ return map.GID(i);
+#endif
+ }
+
+ /**
+ * A helper function that returns a pointer to the array containing the
+ * global indices assigned to the current process by calling either the 32
+ * or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type *
+ my_global_elements(const Epetra_BlockMap &map)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return map.MyGlobalElements64();
+#else
+ return map.MyGlobalElements();
+#endif
+ }
+
+ /**
+ * A helper function that finds the global number of rows by calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ n_global_rows(const Epetra_CrsGraph &graph)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return graph.NumGlobalRows64();
+#else
+ return graph.NumGlobalRows();
+#endif
+ }
+
+ /**
+ * A helper function that finds the global number of columns by calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ n_global_cols(const Epetra_CrsGraph &graph)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return graph.NumGlobalCols64();
+#else
+ return graph.NumGlobalCols();
+#endif
+ }
+
+ /**
+ * A helper function that finds the number of global entries by calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ n_global_entries(const Epetra_CrsGraph &graph)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return graph.NumGlobalEntries64();
+#else
+ return graph.NumGlobalEntries();
+#endif
+ }
+
+ /**
+ * A helper function that finds the global row index by calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ global_row_index(const Epetra_CrsMatrix &matrix,
+ const dealii::types::global_dof_index i)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return matrix.GRID64(i);
+#else
+ return matrix.GRID(i);
+#endif
+ }
+
+ /**
+ * A helper function that finds the global column index by calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ global_column_index(const Epetra_CrsMatrix &matrix,
+ const dealii::types::global_dof_index i)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return matrix.GCID64(i);
+#else
+ return matrix.GCID(i);
+#endif
+ }
+
+ /**
+ * A helper function that finds the global length of a vector by calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ global_length (const Epetra_MultiVector &vector)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return vector.GlobalLength64();
+#else
+ return vector.GlobalLength();
+#endif
+ }
+
+ /**
+ * A helper function that finds the global number of rows by calling
+ * either the 32 or 64 bit function.
+ */
+ inline
+ TrilinosWrappers::types::int_type
+ n_global_rows(const Epetra_RowMatrix &matrix)
+ {
+#ifdef DEAL_II_WITH_64BIT_INDICES
+ return matrix.NumGlobalRows64();
+#else
+ return matrix.NumGlobalRows();
+#endif
+ }
+}
+
+DEAL_II_NAMESPACE_CLOSE
+#endif // DEAL_II_WITH_TRILINOS
+#endif // dealii__trilinos_index_access_h
#ifdef DEAL_II_WITH_TRILINOS
-# include <deal.II/lac/trilinos_block_sparse_matrix.h>
+#include <deal.II/lac/trilinos_index_access.h>
+
+#include <deal.II/lac/trilinos_block_sparse_matrix.h>
DEAL_II_NAMESPACE_OPEN
namespace TrilinosWrappers
{
- namespace
- {
- // define a helper function that queries the size of an Epetra_Map object
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
-#ifndef DEAL_II_WITH_64BIT_INDICES
- int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements();
- }
-#else
- long long int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements64();
- }
-#endif
- }
-
-
namespace MPI
{
BlockVector &
std::vector<size_type> block_sizes (no_blocks);
for (size_type i=0; i<no_blocks; ++i)
- block_sizes[i] = n_global_elements(input_maps[i]);
+ block_sizes[i] = TrilinosWrappers::n_global_elements(input_maps[i]);
this->block_indices.reinit (block_sizes);
//
// ---------------------------------------------------------------------
+#include <deal.II/lac/trilinos_index_access.h>
#include <deal.II/lac/trilinos_precondition.h>
#ifdef DEAL_II_WITH_TRILINOS
# include <deal.II/lac/vector.h>
# include <deal.II/lac/sparse_matrix.h>
# include <deal.II/lac/trilinos_sparse_matrix.h>
+# include <deal.II/lac/trilinos_index_access.h>
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
# include <Ifpack.h>
namespace TrilinosWrappers
{
- namespace
- {
-#ifndef DEAL_II_WITH_64BIT_INDICES
- int n_global_rows (const Epetra_RowMatrix &matrix)
- {
- return matrix.NumGlobalRows();
- }
-
- int global_length (const Epetra_MultiVector &vector)
- {
- return vector.GlobalLength();
- }
-
- int gid(const Epetra_Map &map, unsigned int i)
- {
- return map.GID(i);
- }
-#else
- long long int n_global_rows (const Epetra_RowMatrix &matrix)
- {
- return matrix.NumGlobalRows64();
- }
-
- long long int global_length (const Epetra_MultiVector &vector)
- {
- return vector.GlobalLength64();
- }
-
- long long int gid(const Epetra_Map &map, dealii::types::global_dof_index i)
- {
- return map.GID64(i);
- }
-#endif
- }
-
-
-
/* -------------------------- PreconditionAMG -------------------------- */
PreconditionAMG::AdditionalData::
if (constant_modes_dimension > 0)
{
- const size_type global_size = n_global_rows(matrix);
+ const size_type global_size = TrilinosWrappers::n_global_rows(matrix);
(void)global_length; // work around compiler warning about unused function in release mode
Assert (global_size ==
- static_cast<size_type>(global_length(distributed_constant_modes)),
+ static_cast<size_type>(TrilinosWrappers::global_length(distributed_constant_modes)),
ExcDimensionMismatch(global_size,
- global_length(distributed_constant_modes)));
+ TrilinosWrappers::global_length(distributed_constant_modes)));
const bool constant_modes_are_global
= additional_data.constant_modes[0].size() == global_size;
const size_type my_size = domain_map.NumMyElements();
for (size_type row=0; row<my_size; ++row)
{
const TrilinosWrappers::types::int_type mode_index =
- constant_modes_are_global ? gid(domain_map,row) : row;
+ constant_modes_are_global ? TrilinosWrappers::global_index(domain_map,row) : row;
distributed_constant_modes[d][row] =
additional_data.constant_modes[d][mode_index];
}
//
// ---------------------------------------------------------------------
+#include <deal.II/lac/trilinos_index_access.h>
#include <deal.II/lac/trilinos_precondition.h>
#ifdef DEAL_II_WITH_TRILINOS
# include <deal.II/lac/vector.h>
# include <deal.II/lac/sparse_matrix.h>
+# include <deal.II/lac/trilinos_index_access.h>
# include <deal.II/lac/trilinos_sparse_matrix.h>
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
namespace TrilinosWrappers
{
- namespace
- {
-#ifndef DEAL_II_WITH_64BIT_INDICES
- int n_global_rows (const Epetra_RowMatrix &matrix)
- {
- return matrix.NumGlobalRows();
- }
-
- int global_length (const Epetra_MultiVector &vector)
- {
- return vector.GlobalLength();
- }
-
- int gid(const Epetra_Map &map, unsigned int i)
- {
- return map.GID(i);
- }
-#else
- long long int n_global_rows (const Epetra_RowMatrix &matrix)
- {
- return matrix.NumGlobalRows64();
- }
-
- long long int global_length (const Epetra_MultiVector &vector)
- {
- return vector.GlobalLength64();
- }
-
- long long int gid(const Epetra_Map &map, dealii::types::global_dof_index i)
- {
- return map.GID64(i);
- }
-#endif
- }
-
-
-
PreconditionAMGMueLu::AdditionalData::
AdditionalData (const bool elliptic,
const unsigned int n_cycles,
if (constant_modes_dimension > 0)
{
- const size_type n_rows = n_global_rows(matrix);
+ const size_type n_rows = TrilinosWrappers::n_global_rows(matrix);
const bool constant_modes_are_global =
additional_data.constant_modes[0].size() == n_rows;
const size_type n_relevant_rows =
Assert (n_relevant_rows == my_size,
ExcDimensionMismatch(n_relevant_rows, my_size));
Assert (n_rows ==
- static_cast<size_type>(global_length(distributed_constant_modes)),
+ static_cast<size_type>(TrilinosWrappers::global_length(distributed_constant_modes)),
ExcDimensionMismatch(n_rows,
- global_length(distributed_constant_modes)));
+ TrilinosWrappers::global_length(distributed_constant_modes)));
(void)n_relevant_rows;
(void)global_length;
for (size_type row=0; row<my_size; ++row)
{
TrilinosWrappers::types::int_type global_row_id =
- constant_modes_are_global ? gid(domain_map,row) : row;
+ constant_modes_are_global ? TrilinosWrappers::global_index(domain_map,row) : row;
distributed_constant_modes[d][row] =
additional_data.constant_modes[d][global_row_id];
}
//
// ---------------------------------------------------------------------
+#include <deal.II/lac/trilinos_index_access.h>
#include <deal.II/lac/trilinos_sparse_matrix.h>
#ifdef DEAL_II_WITH_TRILINOS
# include <deal.II/lac/dynamic_sparsity_pattern.h>
# include <deal.II/lac/sparsity_tools.h>
# include <deal.II/lac/la_parallel_vector.h>
+# include <deal.II/lac/trilinos_index_access.h>
# include <deal.II/lac/trilinos_precondition.h>
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
namespace TrilinosWrappers
{
- namespace
- {
-#ifndef DEAL_II_WITH_64BIT_INDICES
- // define a helper function that queries the size of an Epetra_Map object
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
- int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements();
- }
-
- int min_my_gid(const Epetra_BlockMap &map)
- {
- return map.MinMyGID();
- }
-
- int max_my_gid(const Epetra_BlockMap &map)
- {
- return map.MaxMyGID();
- }
-
- int n_global_cols(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalCols();
- }
-
- int global_column_index(const Epetra_CrsMatrix &matrix, int i)
- {
- return matrix.GCID(i);
- }
-
- int global_row_index(const Epetra_CrsMatrix &matrix, int i)
- {
- return matrix.GRID(i);
- }
-#else
- // define a helper function that queries the size of an Epetra_Map object
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
- long long int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements64();
- }
-
- long long int min_my_gid(const Epetra_BlockMap &map)
- {
- return map.MinMyGID64();
- }
-
- long long int max_my_gid(const Epetra_BlockMap &map)
- {
- return map.MaxMyGID64();
- }
-
- long long int n_global_cols(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalCols64();
- }
-
- long long int global_column_index(const Epetra_CrsMatrix &matrix, int i)
- {
- return matrix.GCID64(i);
- }
-
- long long int global_row_index(const Epetra_CrsMatrix &matrix, int i)
- {
- return matrix.GRID64(i);
- }
-#endif
- }
-
namespace internal
{
template <typename VectorType>
if (input_row_map.Comm().MyPID() == 0)
{
AssertDimension (sparsity_pattern.n_rows(),
- static_cast<size_type>(n_global_elements(input_row_map)));
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(input_row_map)));
AssertDimension (sparsity_pattern.n_cols(),
- static_cast<size_type>(n_global_elements(input_col_map)));
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(input_col_map)));
}
column_space_map.reset (new Epetra_Map (input_col_map));
return;
}
- const size_type first_row = min_my_gid(input_row_map),
- last_row = max_my_gid(input_row_map)+1;
+ const size_type first_row = TrilinosWrappers::min_my_gid(input_row_map),
+ last_row = TrilinosWrappers::max_my_gid(input_row_map)+1;
std::vector<int> n_entries_per_row(last_row-first_row);
for (size_type row=first_row; row<last_row; ++row)
// check whether we got the number of columns right.
AssertDimension (sparsity_pattern.n_cols(),
- static_cast<size_type>(n_global_cols(*graph)));
+ static_cast<size_type>(TrilinosWrappers::n_global_cols(*graph)));
(void)n_global_cols;
// And now finally generate the matrix.
nonlocal_matrix_exporter.reset();
AssertDimension (sparsity_pattern.n_rows(),
- static_cast<size_type>(n_global_elements(input_row_map)));
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(input_row_map)));
AssertDimension (sparsity_pattern.n_cols(),
- static_cast<size_type>(n_global_elements(input_col_map)));
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(input_col_map)));
column_space_map.reset (new Epetra_Map (input_col_map));
// serial case
if (relevant_rows.size() == 0)
{
- relevant_rows.set_size(n_global_elements(input_row_map));
- relevant_rows.add_range(0, n_global_elements(input_row_map));
+ relevant_rows.set_size(TrilinosWrappers::n_global_elements(input_row_map));
+ relevant_rows.add_range(0, TrilinosWrappers::n_global_elements(input_row_map));
}
relevant_rows.compress();
Assert(relevant_rows.n_elements() >= static_cast<unsigned int>(input_row_map.NumMyElements()),
graph->OptimizeStorage();
AssertDimension (sparsity_pattern.n_cols(),static_cast<size_type>(
- n_global_cols(*graph)));
+ TrilinosWrappers::n_global_cols(*graph)));
matrix.reset (new Epetra_FECrsMatrix(Copy, *graph, false));
}
inputleft.range_partitioner());
Assert (inputleft.domain_partitioner().LinearMap() == true,
ExcMessage("Matrix must be partitioned contiguously between procs."));
- for (unsigned int i=0; i<inputleft.local_size(); ++i)
+ for (dealii::types::global_dof_index i=0; i<inputleft.local_size(); ++i)
{
int num_entries, * indices;
inputleft.trilinos_sparsity_pattern().ExtractMyRowView(i, num_entries,
indices);
Assert (num_entries >= 0, ExcInternalError());
-#ifndef DEAL_II_WITH_64BIT_INDICES
- const size_type GID = inputleft.trilinos_matrix().RowMap().GID(i);
- for (TrilinosWrappers::types::int_type j=0; j<num_entries; ++j)
- sparsity_transposed.add (inputleft.trilinos_matrix().ColMap().GID(indices[j]),
- GID);
-#else
- const size_type GID = inputleft.trilinos_matrix().RowMap().GID64(i);
+
+ const auto &trilinos_matrix = inputleft.trilinos_matrix();
+ const size_type GID = TrilinosWrappers::global_index(trilinos_matrix.RowMap(), i);
for (TrilinosWrappers::types::int_type j=0; j<num_entries; ++j)
- sparsity_transposed.add (inputleft.trilinos_matrix().ColMap().GID64(indices[j]),
- GID);
-#endif
+ sparsity_transposed.add
+ (TrilinosWrappers::global_index(trilinos_matrix.ColMap(),
+ indices[j]),
+ GID);
}
sparsity_transposed.compress();
transposed_mat.reinit (sparsity_transposed);
- for (unsigned int i=0; i<inputleft.local_size(); ++i)
+ for (dealii::types::global_dof_index i=0; i<inputleft.local_size(); ++i)
{
int num_entries, * indices;
double *values;
inputleft.trilinos_matrix().ExtractMyRowView(i, num_entries,
values, indices);
Assert (num_entries >= 0, ExcInternalError());
-#ifndef DEAL_II_WITH_64BIT_INDICES
- const size_type GID = inputleft.trilinos_matrix().RowMap().GID(i);
- for (TrilinosWrappers::types::int_type j=0; j<num_entries; ++j)
- transposed_mat.set (inputleft.trilinos_matrix().ColMap().GID(indices[j]),
- GID, values[j]);
-#else
- const size_type GID = inputleft.trilinos_matrix().RowMap().GID64(i);
+
+ const auto &trilinos_matrix = inputleft.trilinos_matrix();
+ const size_type GID = TrilinosWrappers::global_index(trilinos_matrix.RowMap(), i);
for (TrilinosWrappers::types::int_type j=0; j<num_entries; ++j)
- transposed_mat.set (inputleft.trilinos_matrix().ColMap().GID64(indices[j]),
+ transposed_mat.set (TrilinosWrappers::global_index(trilinos_matrix.ColMap(),
+ indices[j]),
GID, values[j]);
-#endif
}
transposed_mat.compress(VectorOperation::insert);
ML_Operator_WrapEpetraCrsMatrix
{
matrix->ExtractMyRowView (i, num_entries, values, indices);
for (TrilinosWrappers::types::int_type j=0; j<num_entries; ++j)
- out << "(" << global_row_index(*matrix,i) << ","
- << global_column_index(*matrix,indices[j]) << ") "
+ out << "(" << TrilinosWrappers::global_row_index(*matrix,i) << ","
+ << TrilinosWrappers::global_column_index(*matrix,indices[j]) << ") "
<< values[j] << std::endl;
}
}
//
// ---------------------------------------------------------------------
+#include <deal.II/lac/trilinos_index_access.h>
#include <deal.II/lac/trilinos_sparsity_pattern.h>
#ifdef DEAL_II_WITH_TRILINOS
# include <deal.II/base/utilities.h>
# include <deal.II/base/mpi.h>
-# include <deal.II/lac/sparsity_pattern.h>
+
# include <deal.II/lac/dynamic_sparsity_pattern.h>
+# include <deal.II/lac/sparsity_pattern.h>
+# include <deal.II/lac/trilinos_index_access.h>
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
# include <Epetra_Export.h>
namespace TrilinosWrappers
{
- namespace
- {
- // define a helper function that queries the size of an Epetra_Map object
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
-#ifndef DEAL_II_WITH_64BIT_INDICES
- int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements();
- }
-
- int min_my_gid(const Epetra_BlockMap &map)
- {
- return map.MinMyGID();
- }
-
- int max_my_gid(const Epetra_BlockMap &map)
- {
- return map.MaxMyGID();
- }
-
- int n_global_rows(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalRows();
- }
-
- int n_global_cols(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalCols();
- }
-
- int n_global_entries(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalEntries();
- }
-
- int local_to_global_index(const Epetra_BlockMap &map, int i)
- {
- return map.GID(i);
- }
-#else
- long long int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements64();
- }
-
- long long int min_my_gid(const Epetra_BlockMap &map)
- {
- return map.MinMyGID64();
- }
-
- long long int max_my_gid(const Epetra_BlockMap &map)
- {
- return map.MaxMyGID64();
- }
-
- long long int n_global_rows(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalRows64();
- }
-
- long long int n_global_cols(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalCols64();
- }
-
- long long int n_global_entries(const Epetra_CrsGraph &graph)
- {
- return graph.NumGlobalEntries64();
- }
-
- long long int local_to_global_index(const Epetra_BlockMap &map, int i)
- {
- return map.GID64(i);
- }
-#endif
- }
-
namespace SparsityPatternIterators
{
void
nonlocal_graph.reset();
graph.reset ();
AssertDimension (n_entries_per_row.size(),
- static_cast<size_type>(n_global_elements(row_map)));
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(row_map)));
column_space_map.reset (new Epetra_Map (col_map));
- std::vector<int> local_entries_per_row(max_my_gid(row_map)-
- min_my_gid(row_map));
+ std::vector<int> local_entries_per_row(TrilinosWrappers::max_my_gid(row_map)-
+ TrilinosWrappers::min_my_gid(row_map));
for (unsigned int i=0; i<local_entries_per_row.size(); ++i)
- local_entries_per_row[i] = n_entries_per_row[min_my_gid(row_map)+i];
+ local_entries_per_row[i] = n_entries_per_row[TrilinosWrappers::min_my_gid(row_map)+i];
if (row_map.Comm().NumProc() > 1)
graph.reset(new Epetra_FECrsGraph(Copy, row_map,
graph.reset ();
AssertDimension (sp.n_rows(),
- static_cast<size_type>(n_global_elements(row_map)));
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(row_map)));
AssertDimension (sp.n_cols(),
- static_cast<size_type>(n_global_elements(col_map)));
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(col_map)));
column_space_map.reset (new Epetra_Map (col_map));
Assert (row_map.LinearMap() == true,
ExcMessage ("This function only works if the row map is contiguous."));
- const size_type first_row = min_my_gid(row_map),
- last_row = max_my_gid(row_map)+1;
+ const size_type first_row = TrilinosWrappers::min_my_gid(row_map),
+ last_row = TrilinosWrappers::max_my_gid(row_map)+1;
std::vector<int> n_entries_per_row(last_row - first_row);
// Trilinos wants the row length as an int this is hopefully never going
if (graph->Filled() == true)
n_cols = n_global_cols(*graph);
else
- n_cols = n_global_elements(*column_space_map);
+ n_cols = TrilinosWrappers::n_global_elements(*column_space_map);
return n_cols;
}
SparsityPattern::local_range () const
{
size_type begin, end;
- begin = min_my_gid(graph->RowMap());
- end = max_my_gid(graph->RowMap())+1;
+ begin = TrilinosWrappers::min_my_gid(graph->RowMap());
+ end = TrilinosWrappers::max_my_gid(graph->RowMap())+1;
return std::make_pair (begin, end);
}
{
graph->ExtractMyRowView (i, num_entries, indices);
for (int j=0; j<num_entries; ++j)
- out << "(" << local_to_global_index(graph->RowMap(), i)
- << "," << local_to_global_index(graph->ColMap(), indices[j]) << ") "
+ out << "(" << TrilinosWrappers::global_index(graph->RowMap(), i)
+ << "," << TrilinosWrappers::global_index(graph->ColMap(), indices[j]) << ") "
<< std::endl;
}
}
SparsityPattern::print_gnuplot (std::ostream &out) const
{
Assert (graph->Filled() == true, ExcInternalError());
- for (unsigned int row=0; row<local_size(); ++row)
+ for (dealii::types::global_dof_index row=0; row<local_size(); ++row)
{
int *indices;
int num_entries;
graph->ExtractMyRowView (row, num_entries, indices);
- for (int j=0; j<num_entries; ++j)
+ Assert(num_entries >= 0, ExcInternalError());
+ // avoid sign comparison warning
+ const dealii::types::global_dof_index num_entries_ = num_entries;
+ for (dealii::types::global_dof_index j=0; j<num_entries_; ++j)
// while matrix entries are usually
// written (i,j), with i vertical and
// j horizontal, gnuplot output is
// x-y, that is we have to exchange
// the order of output
- out << static_cast<int>(local_to_global_index(graph->ColMap(), indices[j]))
- << " " << -static_cast<int>(local_to_global_index(graph->RowMap(), row)) << std::endl;
+ out << static_cast<int>(TrilinosWrappers::global_index(graph->ColMap(), indices[j]))
+ << " " << -static_cast<int>(TrilinosWrappers::global_index(graph->RowMap(), row)) << std::endl;
}
AssertThrow (out, ExcIO());
//
// ---------------------------------------------------------------------
+#include <deal.II/lac/trilinos_index_access.h>
#include <deal.II/lac/trilinos_vector.h>
#ifdef DEAL_II_WITH_TRILINOS
# include <deal.II/base/mpi.h>
-# include <deal.II/lac/trilinos_sparse_matrix.h>
# include <deal.II/lac/trilinos_block_vector.h>
+# include <deal.II/lac/trilinos_index_access.h>
+# include <deal.II/lac/trilinos_sparse_matrix.h>
DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
# include <Epetra_Import.h>
namespace TrilinosWrappers
{
- namespace
- {
-#ifndef DEAL_II_WITH_64BIT_INDICES
- // define a helper function that queries the size of an Epetra_BlockMap object
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
- int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements();
- }
- // define a helper function that queries the pointer to internal array
- // containing list of global IDs assigned to the calling processor
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
- int *my_global_elements(const Epetra_BlockMap &map)
- {
- return map.MyGlobalElements();
- }
- // define a helper function that queries the global vector length of an
- // Epetra_FEVector object by calling either the 32- or 64-bit
- // function necessary.
- int global_length(const Epetra_FEVector &vector)
- {
- return vector.GlobalLength();
- }
-#else
- // define a helper function that queries the size of an Epetra_BlockMap object
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
- long long int n_global_elements (const Epetra_BlockMap &map)
- {
- return map.NumGlobalElements64();
- }
- // define a helper function that queries the pointer to internal array
- // containing list of global IDs assigned to the calling processor
- // by calling either the 32- or 64-bit function necessary, and returns the
- // result in the correct data type so that we can use it in calling other
- // Epetra member functions that are overloaded by index type
- long long int *my_global_elements(const Epetra_BlockMap &map)
- {
- return map.MyGlobalElements64();
- }
- // define a helper function that queries the global vector length of an
- // Epetra_FEVector object by calling either the 32- or 64-bit
- // function necessary.
- long long int global_length(const Epetra_FEVector &vector)
- {
- return vector.GlobalLength64();
- }
-#endif
- }
-
namespace MPI
{
-
-
Vector::Vector ()
{
last_action = Zero;
VectorBase()
{
AssertThrow (parallel_partitioner.size() ==
- static_cast<size_type>(n_global_elements(v.vector->Map())),
+ static_cast<size_type>(TrilinosWrappers::n_global_elements(v.vector->Map())),
ExcDimensionMismatch (parallel_partitioner.size(),
- n_global_elements(v.vector->Map())));
+ TrilinosWrappers::n_global_elements(v.vector->Map())));
last_action = Zero;
for (size_type block=0; block<v.n_blocks(); ++block)
{
TrilinosWrappers::types::int_type *glob_elements =
- my_global_elements(v.block(block).vector_partitioner());
+ TrilinosWrappers::my_global_elements(v.block(block).vector_partitioner());
for (size_type i=0; i<v.block(block).local_size(); ++i)
global_ids[added_elements++] = glob_elements[i] + block_offset;
owned_elements.add_indices(v.block(block).owned_elements,
if (import_data == true)
{
- AssertThrow (static_cast<size_type>(global_length(*actual_vec))
+ AssertThrow (static_cast<size_type>(TrilinosWrappers::global_length(*actual_vec))
== v.size(),
- ExcDimensionMismatch (global_length(*actual_vec),
+ ExcDimensionMismatch (TrilinosWrappers::global_length(*actual_vec),
v.size()));
Epetra_Import data_exchange (vector->Map(), actual_vec->Map());
Vector::reinit (const Epetra_Map &input_map,
const bool /*omit_zeroing_entries*/)
{
- Epetra_LocalMap map (n_global_elements(input_map),
+ Epetra_LocalMap map (TrilinosWrappers::n_global_elements(input_map),
input_map.IndexBase(),
input_map.Comm());
vector.reset (new Epetra_FEVector(map));
- owned_elements = complete_index_set(n_global_elements(input_map));
+ owned_elements = complete_index_set(TrilinosWrappers::n_global_elements(input_map));
last_action = Zero;
}
#endif
if (!same_communicators || local_range() != v.local_range())
{
- Epetra_LocalMap map (global_length(*(v.vector)),
+ Epetra_LocalMap map (TrilinosWrappers::global_length(*(v.vector)),
v.vector->Map().IndexBase(),
v.vector->Comm());
vector.reset (new Epetra_FEVector(map));
{
if (size() != v.size())
{
- Epetra_LocalMap map (n_global_elements(v.vector->Map()),
+ Epetra_LocalMap map (TrilinosWrappers::n_global_elements(v.vector->Map()),
v.vector->Map().IndexBase(),
v.vector->Comm());
vector.reset (new Epetra_FEVector(map));
{
if (size() != v.size())
{
- Epetra_LocalMap map (n_global_elements(v.vector->Map()),
+ Epetra_LocalMap map (TrilinosWrappers::n_global_elements(v.vector->Map()),
v.vector->Map().IndexBase(),
v.vector->Comm());
vector.reset (new Epetra_FEVector(map));