DOLFINx
0.11.0
DOLFINx C++
Toggle main menu visibility
Loading...
Searching...
No Matches
dolfinx
fem
Constant.h
1
// Copyright (C) 2019-2023 Chris Richardson, Michal Habera and Garth N.
2
// Wells
3
//
4
// This file is part of DOLFINx (https://www.fenicsproject.org)
5
//
6
// SPDX-License-Identifier: LGPL-3.0-or-later
7
8
#pragma once
9
10
#include "dolfinx/common/types.h"
11
#include <span>
12
#include <vector>
13
14
namespace
dolfinx::fem
15
{
20
template
<dolfinx::scalar T>
21
class
Constant
22
{
23
public
:
25
using
value_type
= T;
26
29
explicit
Constant
(
value_type
c) :
value
({c}) {}
30
33
explicit
Constant
(std::span<const value_type> c)
34
:
Constant
(c, std::vector<std::size_t>{c.size()})
35
{
36
}
37
41
Constant
(std::span<const value_type> c, std::span<const std::size_t>
shape
)
42
:
value
(c.begin(), c.end()),
shape
(
shape
.begin(),
shape
.end())
43
{
44
}
45
47
std::vector<value_type>
value
;
48
50
std::vector<std::size_t>
shape
;
51
};
52
}
// namespace dolfinx::fem
dolfinx::fem::Constant::Constant
Constant(std::span< const value_type > c, std::span< const std::size_t > shape)
Create a rank-d constant.
Definition
Constant.h:41
dolfinx::fem::Constant::Constant
Constant(value_type c)
Create a rank-0 (scalar-valued) constant.
Definition
Constant.h:29
dolfinx::fem::Constant::Constant
Constant(std::span< const value_type > c)
Create a rank-1 (vector-valued) constant.
Definition
Constant.h:33
dolfinx::fem::Constant::value
std::vector< value_type > value
Values, stored as a row-major flattened array.
Definition
Constant.h:47
dolfinx::fem::Constant::shape
std::vector< std::size_t > shape
Shape.
Definition
Constant.h:50
dolfinx::fem::Constant::value_type
T value_type
Field type.
Definition
Constant.h:25
dolfinx::fem
Finite element method functionality.
Definition
assemble_expression_impl.h:23
Generated by
1.17.0