Loading...
Searching...
No Matches
PETScBaseMatrix.h
// Copyright (C) 2005-2006 Anders Logg
//
// 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 Fredrik Valdmanis, 2011
//
// First added: 2005-01-17
// Last changed: 2011-09-07
#ifndef __PETSC_BASE_MATRIX_H
#define __PETSC_BASE_MATRIX_H
#ifdef HAS_PETSC
#include <cinttypes>
#include <cstddef>
#include <memory>
#include <string>
#include <utility>
#include <petscmat.h>
#include <dolfin/common/types.h>
#include <dolfin/common/Variable.h>
#include "PETScObject.h"
#include "PETScVector.h"
namespace dolfin
{
class GenericVector;
class PETScVector;
class PETScBaseMatrix : public PETScObject, public virtual Variable
{
public:
PETScBaseMatrix() : _matA(nullptr) {}
explicit PETScBaseMatrix(Mat A);
PETScBaseMatrix(const PETScBaseMatrix& A);
~PETScBaseMatrix();
std::size_t size(std::size_t dim) const;
std::pair<std::int64_t, std::int64_t> size() const;
std::pair<std::int64_t, std::int64_t> local_range(std::size_t dim) const;
void init_vector(GenericVector& z, std::size_t dim) const;
Mat mat() const
{ return _matA; }
MPI_Comm mpi_comm() const;
virtual std::string str(bool verbose) const
{ return "No str function for this PETSc matrix operator."; }
protected:
// PETSc Mat pointer
Mat _matA;
};
}
#endif
#endif
dolfin::GenericVector
This class defines a common interface for vectors.
Definition GenericVector.h:48
dolfin::PETScBaseMatrix
Definition PETScBaseMatrix.h:50
dolfin::PETScBaseMatrix::size
std::pair< std::int64_t, std::int64_t > size() const
Definition PETScBaseMatrix.cpp:79
dolfin::PETScBaseMatrix::~PETScBaseMatrix
~PETScBaseMatrix()
Destructor.
Definition PETScBaseMatrix.cpp:45
dolfin::PETScBaseMatrix::str
virtual std::string str(bool verbose) const
Return informal string representation (pretty-print).
Definition PETScBaseMatrix.h:93
dolfin::PETScBaseMatrix::init_vector
void init_vector(GenericVector &z, std::size_t dim) const
Definition PETScBaseMatrix.cpp:106
dolfin::PETScBaseMatrix::mat
Mat mat() const
Return PETSc Mat pointer.
Definition PETScBaseMatrix.h:86
dolfin::PETScBaseMatrix::local_range
std::pair< std::int64_t, std::int64_t > local_range(std::size_t dim) const
Return local range along dimension dim.
Definition PETScBaseMatrix.cpp:89
dolfin::PETScBaseMatrix::PETScBaseMatrix
PETScBaseMatrix()
Constructor.
Definition PETScBaseMatrix.h:54
dolfin::PETScBaseMatrix::mpi_comm
MPI_Comm mpi_comm() const
Return the MPI communicator.
Definition PETScBaseMatrix.cpp:141
dolfin::PETScObject::PETScObject
PETScObject()
Constructor. Ensures that PETSc has been initialised.
Definition PETScObject.h:38
dolfin::PETScVector
Definition PETScVector.h:61
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition Variable.cpp:31
dolfin
Definition adapt.h:30