DOLFIN-X
DOLFIN-X C++ interface
Constant.h
1 // Copyright (C) 2019 Chris Richardson and Michal Habera
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 <Eigen/Dense>
10 #include <petscsys.h>
11 #include <vector>
12 
13 namespace dolfinx::function
14 {
15 
18 class Constant
19 {
20 
21 public:
23  Constant(PetscScalar c);
24 
26  Constant(const std::vector<PetscScalar>& c);
27 
29  Constant(const Eigen::Ref<Eigen::Array<PetscScalar, Eigen::Dynamic,
30  Eigen::Dynamic, Eigen::RowMajor>>& c);
31 
33  Constant(std::vector<int> shape, std::vector<PetscScalar> value);
34 
36  std::vector<int> shape;
37 
39  std::vector<PetscScalar> value;
40 };
41 } // namespace dolfinx::function
dolfinx::function::Constant::Constant
Constant(PetscScalar c)
Create a rank-0 (scalar-valued) constant.
Definition: Constant.cpp:15
dolfinx::function::Constant
A constant value which can be attached to a Form. Constants may be scalar (rank 0),...
Definition: Constant.h:18
dolfinx::function::Constant::shape
std::vector< int > shape
Shape.
Definition: Constant.h:36
dolfinx::function
Functions tools, including FEM functions and pointwise defined functions.
Definition: assemble_matrix_impl.h:18
dolfinx::function::Constant::value
std::vector< PetscScalar > value
Values, stored as a flattened array.
Definition: Constant.h:39