Loading...
Searching...
No Matches
PETScDMCollection.h
// Copyright (C) 2016 Patrick E. Farrell and 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/>.
#ifndef __PETSC_DM_COLLECTION_H
#define __PETSC_DM_COLLECTION_H
#ifdef HAS_PETSC
#include <memory>
#include <vector>
#include <petscdm.h>
#include <petscvec.h>
#include <dolfin/common/MPI.h>
#include <dolfin/la/PETScMatrix.h>
#include <dolfin/log/log.h>
namespace dolfin
{
class FunctionSpace;
class BoundingBoxTree;
class PETScDMCollection : public PETScObject
{
public:
PETScDMCollection(std::vector<std::shared_ptr<const FunctionSpace>> function_spaces);
~PETScDMCollection();
DM get_dm(int i);
void check_ref_count() const;
void reset(int i);
static std::shared_ptr<PETScMatrix>
create_transfer_matrix(const FunctionSpace& coarse_space,
const FunctionSpace& fine_space);
private:
// Find the nearest cells to points which lie outside the domain
static void find_exterior_points(MPI_Comm mpi_comm,
std::shared_ptr<const BoundingBoxTree> treec,
int dim, int data_size,
const std::vector<double>& send_points,
const std::vector<int>& send_indices,
std::vector<int>& indices,
std::vector<std::size_t>& cell_ids,
std::vector<double>& points);
// Pointers to functions that are used in PETSc DM call-backs
static PetscErrorCode create_global_vector(DM dm, Vec* vec);
static PetscErrorCode create_interpolation(DM dmc, DM dmf, Mat *mat,
Vec *vec);
static PetscErrorCode coarsen(DM dmf, MPI_Comm comm, DM* dmc);
static PetscErrorCode refine(DM dmc, MPI_Comm comm, DM* dmf);
// The FunctionSpaces associated with each level, starting with
// the coarest space
std::vector<std::shared_ptr<const FunctionSpace>> _spaces;
// The PETSc DM objects
std::vector<DM> _dms;
};
}
#endif
#endif
dolfin::BoundingBoxTree
Definition BoundingBoxTree.h:41
dolfin::FunctionSpace
Definition FunctionSpace.h:54
dolfin::PETScDMCollection::create_transfer_matrix
static std::shared_ptr< PETScMatrix > create_transfer_matrix(const FunctionSpace &coarse_space, const FunctionSpace &fine_space)
Definition PETScDMCollection.cpp:212
dolfin::PETScDMCollection::~PETScDMCollection
~PETScDMCollection()
Destructor.
Definition PETScDMCollection.cpp:176
dolfin::PETScDMCollection::check_ref_count
void check_ref_count() const
These are test/debugging functions that will be removed.
Definition PETScDMCollection.cpp:193
dolfin::PETScDMCollection::reset
void reset(int i)
Debugging use - to be removed.
Definition PETScDMCollection.cpp:203
dolfin::PETScDMCollection::PETScDMCollection
PETScDMCollection(std::vector< std::shared_ptr< const FunctionSpace > > function_spaces)
Definition PETScDMCollection.cpp:135
dolfin::PETScDMCollection::get_dm
DM get_dm(int i)
Definition PETScDMCollection.cpp:186
dolfin::PETScObject::PETScObject
PETScObject()
Constructor. Ensures that PETSc has been initialised.
Definition PETScObject.h:38
dolfin
Definition adapt.h:30