Loading...
Searching...
No Matches
Constant.h
// Copyright (C) 2019-2023 Chris Richardson, Michal Habera and Garth N.
// Wells
//
// This file is part of DOLFINx (https://www.fenicsproject.org)
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include "dolfinx/common/types.h"
#include <span>
#include <vector>
namespace dolfinx::fem
{
template <dolfinx::scalar T>
class Constant
{
public:
using value_type = T;
explicit Constant(value_type c) : value({c}) {}
explicit Constant(std::span<const value_type> c)
: Constant(c, std::vector<std::size_t>{c.size()})
{
}
Constant(std::span<const value_type> c, std::span<const std::size_t> shape)
: value(c.begin(), c.end()), shape(shape.begin(), shape.end())
{
}
std::vector<value_type> value;
std::vector<std::size_t> shape;
};
} // 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