Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/dolfinx/v0.9.0/cpp/doxygen/d0/d75/fem_2petsc_8h_source.html
DOLFINx  0.5.1
DOLFINx C++ interface
petsc.h
1 // Copyright (C) 2018-2021 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 "Form.h"
10 #include <map>
11 #include <memory>
12 #include <petscmat.h>
13 #include <petscvec.h>
14 #include <span>
15 #include <utility>
16 #include <vector>
17 
18 namespace dolfinx::common
19 {
20 class IndexMap;
21 }
22 
23 namespace dolfinx::fem
24 {
25 template <typename T>
26 class DirichletBC;
27 class FunctionSpace;
28 
30 namespace petsc
31 {
38 Mat create_matrix(const Form<PetscScalar>& a,
39  const std::string& type = std::string());
40 
50  const std::vector<std::vector<const Form<PetscScalar>*>>& a,
51  const std::string& type = std::string());
52 
57  const std::vector<std::vector<const Form<PetscScalar>*>>& a,
58  const std::vector<std::vector<std::string>>& types);
59 
64  const std::vector<
65  std::pair<std::reference_wrapper<const common::IndexMap>, int>>& maps);
66 
69  const std::vector<
70  std::pair<std::reference_wrapper<const common::IndexMap>, int>>& maps);
71 
72 // -- Vectors ----------------------------------------------------------------
73 
85 void assemble_vector(
86  Vec b, const Form<PetscScalar>& L,
87  const std::span<const PetscScalar>& constants,
88  const std::map<std::pair<IntegralType, int>,
89  std::pair<std::span<const PetscScalar>, int>>& coeffs);
90 
100 void assemble_vector(Vec b, const Form<PetscScalar>& L);
101 
102 // FIXME: clarify how x0 is used
103 // FIXME: if bcs entries are set
104 
105 // FIXME: need to pass an array of Vec for x0?
106 // FIXME: clarify zeroing of vector
107 
120 void apply_lifting(
121  Vec b, const std::vector<std::shared_ptr<const Form<PetscScalar>>>& a,
122  const std::vector<std::span<const PetscScalar>>& constants,
123  const std::vector<std::map<std::pair<IntegralType, int>,
124  std::pair<std::span<const PetscScalar>, int>>>&
125  coeffs,
126  const std::vector<
127  std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>>& bcs1,
128  const std::vector<Vec>& x0, double scale);
129 
130 // FIXME: clarify how x0 is used
131 // FIXME: if bcs entries are set
132 
133 // FIXME: need to pass an array of Vec for x0?
134 // FIXME: clarify zeroing of vector
135 
148 void apply_lifting(
149  Vec b, const std::vector<std::shared_ptr<const Form<PetscScalar>>>& a,
150  const std::vector<
151  std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>>& bcs1,
152  const std::vector<Vec>& x0, double scale);
153 
154 // -- Setting bcs ------------------------------------------------------------
155 
156 // FIXME: Move these function elsewhere?
157 
158 // FIXME: clarify x0
159 // FIXME: clarify what happens with ghosts
160 
164 void set_bc(
165  Vec b,
166  const std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>& bcs,
167  const Vec x0, double scale = 1.0);
168 } // namespace petsc
169 } // namespace dolfinx::fem
Object for setting (strong) Dirichlet boundary conditions.
Definition: DirichletBC.h:125
A representation of finite element variational forms.
Definition: Form.h:63
Miscellaneous classes, functions and types.
void set_bc(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 PETSc vector, multiplied by 'scale'. The vectors b and x0 ...
Definition: petsc.cpp:395
Mat create_matrix_nest(const std::vector< std::vector< const Form< PetscScalar > * >> &a, const std::vector< std::vector< std::string >> &types)
Create nested (MatNest) matrix.
Definition: petsc.cpp:179
void apply_lifting(Vec b, const std::vector< std::shared_ptr< const Form< PetscScalar >>> &a, const std::vector< std::span< const PetscScalar >> &constants, const std::vector< std::map< std::pair< IntegralType, int >, std::pair< std::span< const PetscScalar >, int >>> &coeffs, 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:300
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:246
Mat create_matrix(const Form< PetscScalar > &a, const std::string &type=std::string())
Create a matrix.
Definition: petsc.cpp:21
Mat create_matrix_block(const std::vector< std::vector< const Form< PetscScalar > * >> &a, const std::string &type=std::string())
Initialise a monolithic matrix for an array of bilinear forms.
Definition: petsc.cpp:33
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:221
void assemble_vector(Vec b, const Form< PetscScalar > &L, const std::span< const PetscScalar > &constants, const std::map< std::pair< IntegralType, int >, std::pair< std::span< const PetscScalar >, int >> &coeffs)
Assemble linear form into an already allocated PETSc vector. Ghost contributions are not accumulated ...
Definition: petsc.cpp:268
Finite element method functionality.
Definition: assemble_matrix_impl.h:25