Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.1.0/v0.9.0/cpp
DOLFINx  0.1.0
DOLFINx C++ interface
petsc.h
1 // Copyright (C) 2018-2020 Garth N. Wells
2 //
3 // This file is part of DOLFINx (https://www.fenicsproject.org)
4 //
5 // SPDX-License-Identifier: LGPL-3.0-or-later
6 
7 #pragma once
8 
9 #include <memory>
10 #include <petscmat.h>
11 #include <petscvec.h>
12 #include <vector>
13 
14 namespace dolfinx::common
15 {
16 class IndexMap;
17 }
18 
19 namespace dolfinx::fem
20 {
21 
22 template <typename T>
23 class DirichletBC;
24 template <typename T>
25 class Form;
26 class FunctionSpace;
27 
34 Mat create_matrix(const Form<PetscScalar>& a,
35  const std::string& type = std::string());
36 
46  const std::vector<std::vector<const fem::Form<PetscScalar>*>>& a,
47  const std::string& type = std::string());
48 
53  const std::vector<std::vector<const fem::Form<PetscScalar>*>>& a,
54  const std::vector<std::vector<std::string>>& types);
55 
60  const std::vector<
61  std::pair<std::reference_wrapper<const common::IndexMap>, int>>& maps);
62 
65  const std::vector<
66  std::pair<std::reference_wrapper<const common::IndexMap>, int>>& maps);
67 
68 // -- Vectors ----------------------------------------------------------------
69 
79 void assemble_vector_petsc(Vec b, const Form<PetscScalar>& L);
80 
81 // FIXME: clarify how x0 is used
82 // FIXME: if bcs entries are set
83 
84 // FIXME: need to pass an array of Vec for x0?
85 // FIXME: clarify zeroing of vector
86 
100  Vec b, const std::vector<std::shared_ptr<const Form<PetscScalar>>>& a,
101  const std::vector<
102  std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>>& bcs1,
103  const std::vector<Vec>& x0, double scale);
104 
105 // -- Setting bcs ------------------------------------------------------------
106 
107 // FIXME: Move these function elsewhere?
108 
109 // FIXME: clarify x0
110 // FIXME: clarify what happens with ghosts
111 
115 void set_bc_petsc(
116  Vec b,
117  const std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>& bcs,
118  const Vec x0, double scale = 1.0);
119 
120 } // namespace dolfinx::fem
dolfinx::fem::set_bc_petsc
void set_bc_petsc(Vec b, const std::vector< std::shared_ptr< const DirichletBC< PetscScalar >>> &bcs, const Vec x0, double scale=1.0)
Set bc values in owned (local) part of the PETScVector, multiplied by 'scale'. The vectors b and x0 m...
Definition: petsc.cpp:333
dolfinx::fem::create_vector_nest
Vec create_vector_nest(const std::vector< std::pair< std::reference_wrapper< const common::IndexMap >, int >> &maps)
Create nested (VecNest) vector. Vector is not zeroed.
Definition: petsc.cpp:252
dolfinx::fem::create_matrix
Mat create_matrix(const Form< PetscScalar > &a, const std::string &type=std::string())
Create a matrix.
Definition: petsc.cpp:20
dolfinx::fem::create_matrix_block
Mat create_matrix_block(const std::vector< std::vector< const fem::Form< PetscScalar > * >> &a, const std::string &type=std::string())
Initialise a monolithic matrix for an array of bilinear forms.
Definition: petsc.cpp:32
dolfinx::common
Miscellaneous classes, functions and types.
dolfinx::fem::apply_lifting_petsc
void apply_lifting_petsc(Vec b, const std::vector< std::shared_ptr< const Form< PetscScalar >>> &a, const std::vector< std::vector< std::shared_ptr< const DirichletBC< PetscScalar >>>> &bcs1, const std::vector< Vec > &x0, double scale)
Modify b such that:
Definition: petsc.cpp:288
dolfinx::fem::assemble_vector_petsc
void assemble_vector_petsc(Vec b, const Form< PetscScalar > &L)
Assemble linear form into an already allocated PETSc vector. Ghost contributions are not accumulated ...
Definition: petsc.cpp:274
dolfinx::fem::create_vector_block
Vec create_vector_block(const std::vector< std::pair< std::reference_wrapper< const common::IndexMap >, int >> &maps)
Initialise monolithic vector. Vector is not zeroed.
Definition: petsc.cpp:216
dolfinx::fem
Finite element method functionality.
Definition: assemble_matrix_impl.h:22
dolfinx::fem::create_matrix_nest
Mat create_matrix_nest(const std::vector< std::vector< const fem::Form< PetscScalar > * >> &a, const std::vector< std::vector< std::string >> &types)
Create nested (MatNest) matrix.
Definition: petsc.cpp:174