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.6.0
DOLFINx C++ interface
Loading...
Searching...
No Matches
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
18namespace dolfinx::common
19{
20class IndexMap;
21}
22
23namespace dolfinx::fem
24{
25template <typename T>
26class DirichletBC;
27class FunctionSpace;
28
30namespace petsc
31{
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
86 Vec b, const Form<PetscScalar>& L, std::span<const PetscScalar> constants,
87 const std::map<std::pair<IntegralType, int>,
88 std::pair<std::span<const PetscScalar>, int>>& coeffs);
89
99void assemble_vector(Vec b, const Form<PetscScalar>& L);
100
101// FIXME: clarify how x0 is used
102// FIXME: if bcs entries are set
103
104// FIXME: need to pass an array of Vec for x0?
105// FIXME: clarify zeroing of vector
106
119void apply_lifting(
120 Vec b, const std::vector<std::shared_ptr<const Form<PetscScalar>>>& a,
121 const std::vector<std::span<const PetscScalar>>& constants,
122 const std::vector<std::map<std::pair<IntegralType, int>,
123 std::pair<std::span<const PetscScalar>, int>>>&
124 coeffs,
125 const std::vector<
126 std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>>& bcs1,
127 const std::vector<Vec>& x0, double scale);
128
129// FIXME: clarify how x0 is used
130// FIXME: if bcs entries are set
131
132// FIXME: need to pass an array of Vec for x0?
133// FIXME: clarify zeroing of vector
134
147void apply_lifting(
148 Vec b, const std::vector<std::shared_ptr<const Form<PetscScalar>>>& a,
149 const std::vector<
150 std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>>& bcs1,
151 const std::vector<Vec>& x0, double scale);
152
153// -- Setting bcs ------------------------------------------------------------
154
155// FIXME: Move these function elsewhere?
156
157// FIXME: clarify x0
158// FIXME: clarify what happens with ghosts
159
163void set_bc(
164 Vec b,
165 const std::vector<std::shared_ptr<const DirichletBC<PetscScalar>>>& bcs,
166 const Vec x0, double scale = 1.0);
167} // namespace petsc
168} // namespace dolfinx::fem
Object for setting (strong) Dirichlet boundary conditions.
Definition: DirichletBC.h:133
A representation of finite element variational forms.
Definition: Form.h:64
Miscellaneous classes, functions and types.
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:299
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 assemble_vector(Vec b, const Form< PetscScalar > &L, 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
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:394
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
Mat create_matrix(const Form< PetscScalar > &a, const std::string &type=std::string())
Create a matrix.
Definition: petsc.cpp:21
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
Finite element method functionality.
Definition: assemble_matrix_impl.h:25