Note: this is documentation for an old release. View the latest documentation at docs.fenicsproject.org/v0.3.0/v0.9.0/cpp
DOLFINx  0.3.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 <dolfinx/common/array2d.h>
10 #include <memory>
11 #include <petscmat.h>
12 #include <petscvec.h>
13 #include <vector>
14 #include <xtl/xspan.hpp>
15 
16 namespace dolfinx::common
17 {
18 class IndexMap;
19 }
20 
21 namespace dolfinx::fem
22 {
23 
24 template <typename T>
25 class DirichletBC;
26 template <typename T>
27 class Form;
28 class FunctionSpace;
29 
36 Mat create_matrix(const Form<PetscScalar>& a,
37  const std::string& type = std::string());
38 
48  const std::vector<std::vector<const fem::Form<PetscScalar>*>>& a,
49  const std::string& type = std::string());
50 
55  const std::vector<std::vector<const fem::Form<PetscScalar>*>>& a,
56  const std::vector<std::vector<std::string>>& types);
57 
62  const std::vector<
63  std::pair<std::reference_wrapper<const common::IndexMap>, int>>& maps);
64 
67  const std::vector<
68  std::pair<std::reference_wrapper<const common::IndexMap>, int>>& maps);
69 
70 // -- Vectors ----------------------------------------------------------------
71 
83 void assemble_vector_petsc(Vec b, const Form<PetscScalar>& L,
84  const xtl::span<const PetscScalar>& constants,
85  const array2d<PetscScalar>& coeffs);
86 
96 void assemble_vector_petsc(Vec b, const Form<PetscScalar>& L);
97 
98 // FIXME: clarify how x0 is used
99 // FIXME: if bcs entries are set
100 
101 // FIXME: need to pass an array of Vec for x0?
102 // FIXME: clarify zeroing of vector
103 
117  Vec b, const std::vector<std::shared_ptr<const Form<PetscScalar>>>& a,
118  const std::vector<xtl::span<const PetscScalar>>& constants,
119  const std::vector<const array2d<PetscScalar>*>& coeffs,
120  const std::vector<
121  std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>>& bcs1,
122  const std::vector<Vec>& x0, double scale);
123 
124 // FIXME: clarify how x0 is used
125 // FIXME: if bcs entries are set
126 
127 // FIXME: need to pass an array of Vec for x0?
128 // FIXME: clarify zeroing of vector
129 
143  Vec b, const std::vector<std::shared_ptr<const Form<PetscScalar>>>& a,
144  const std::vector<
145  std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>>& bcs1,
146  const std::vector<Vec>& x0, double scale);
147 
148 // -- Setting bcs ------------------------------------------------------------
149 
150 // FIXME: Move these function elsewhere?
151 
152 // FIXME: clarify x0
153 // FIXME: clarify what happens with ghosts
154 
158 void set_bc_petsc(
159  Vec b,
160  const std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>& bcs,
161  const Vec x0, double scale = 1.0);
162 
163 } // namespace dolfinx::fem
Miscellaneous classes, functions and types.
Finite element method functionality.
Definition: assemble_matrix_impl.h:23
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
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:398
void apply_lifting_petsc(Vec b, const std::vector< std::shared_ptr< const Form< PetscScalar >>> &a, const std::vector< xtl::span< const PetscScalar >> &constants, const std::vector< const array2d< PetscScalar > * > &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:305
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
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
void assemble_vector_petsc(Vec b, const Form< PetscScalar > &L, const xtl::span< const PetscScalar > &constants, const array2d< PetscScalar > &coeffs)
Assemble linear form into an already allocated PETSc vector. Ghost contributions are not accumulated ...
Definition: petsc.cpp:275
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:253
Mat create_matrix(const Form< PetscScalar > &a, const std::string &type=std::string())
Create a matrix.
Definition: petsc.cpp:20