/usr/include/dolfin/la/SparsityPattern.h is in libdolfin-dev 1.4.0+dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | // Copyright (C) 2007-2011 Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can 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 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Anders Logg, 2007-2009.
//
// First added: 2007-03-13
// Last changed: 2011-01-02
#ifndef __SPARSITY_PATTERN_H
#define __SPARSITY_PATTERN_H
#include <string>
#include <utility>
#include <vector>
#include "dolfin/common/Set.h"
#include "dolfin/common/types.h"
#include "GenericSparsityPattern.h"
#include <boost/unordered_map.hpp>
namespace dolfin
{
/// This class implements the GenericSparsityPattern interface.
/// It is used by most linear algebra backends.
class SparsityPattern : public GenericSparsityPattern
{
// NOTE: Do not change this typedef without performing careful
// performance profiling
// Set type used for the rows of the sparsity pattern
typedef dolfin::Set<std::size_t> set_type;
public:
/// Create empty sparsity pattern
SparsityPattern(std::size_t primary_dim);
/// Create sparsity pattern for a generic tensor
SparsityPattern(const MPI_Comm mpi_comm,
const std::vector<std::size_t>& dims,
const std::vector<std::pair<std::size_t,
std::size_t> >& ownership_range,
const std::vector<const boost::unordered_map<std::size_t,
unsigned int>* > off_process_owner,
std::size_t primary_dim);
/// Initialize sparsity pattern for a generic tensor
void init(const MPI_Comm mpi_comm,
const std::vector<std::size_t>& dims,
const std::vector<std::pair<std::size_t,
std::size_t> >& ownership_range,
const std::vector<const boost::unordered_map<std::size_t,
unsigned int>* > off_process_owner);
/// Insert non-zero entries
void
insert(const std::vector<const std::vector<dolfin::la_index>* >& entries);
/// Add edges (vertex = [index, owning process])
void add_edges(const std::pair<dolfin::la_index, std::size_t>& vertex,
const std::vector<dolfin::la_index>& edges);
/// Return rank
std::size_t rank() const;
/// Return local range for dimension dim
std::pair<std::size_t, std::size_t> local_range(std::size_t dim) const;
/// Return number of local nonzeros
std::size_t num_nonzeros() const;
/// Fill array with number of nonzeros for diagonal block in
/// local_range for dimension 0. For matrices, fill array with number
/// of nonzeros per local row for diagonal block
void num_nonzeros_diagonal(std::vector<std::size_t>& num_nonzeros) const;
/// Fill array with number of nonzeros for off-diagonal block in
/// local_range for dimension 0. For matrices, fill array with number
/// of nonzeros per local row for off-diagonal block
void
num_nonzeros_off_diagonal(std::vector<std::size_t>& num_nonzeros) const;
/// Fill vector with number of nonzeros in local_range for dimension 0
void num_local_nonzeros(std::vector<std::size_t>& num_nonzeros) const;
/// Fill vector with edges for given vertex
void get_edges(std::size_t vertex,
std::vector<dolfin::la_index>& edges) const;
/// Finalize sparsity pattern
void apply();
// Return MPI communicator
MPI_Comm mpi_comm() const
{ return _mpi_comm; }
/// Return informal string representation (pretty-print)
std::string str(bool verbose) const;
/// Return underlying sparsity pattern (diagonal). Options are
/// 'sorted' and 'unsorted'.
std::vector<std::vector<std::size_t> > diagonal_pattern(Type type) const;
/// Return underlying sparsity pattern (off-diagional). Options are
/// 'sorted' and 'unsorted'.
std::vector<std::vector<std::size_t> >
off_diagonal_pattern(Type type) const;
private:
// Print some useful information
void info_statistics() const;
// MPI communicator
MPI_Comm _mpi_comm;
// Ownership range for each dimension
std::vector<std::pair<std::size_t, std::size_t> > _local_range;
// Sparsity patterns for diagonal and off-diagonal blocks
std::vector<set_type> diagonal;
std::vector<set_type> off_diagonal;
// Sparsity pattern for non-local entries stored as [i0, j0, i1, j1, ...]
std::vector<std::size_t> non_local;
// Map from non-local vertex to owning process index
std::vector<boost::unordered_map<std::size_t, unsigned int> >
_off_process_owner;
};
}
#endif
|