Feel++ 0.111.0-preview.14
Finite Element Embedded Library in C++
/data/cemosis/github-actions-runner/actions-runner-feelpp-1/_work/feelpp/feelpp/feelpp/feel/feelvf/concepts.hpp

A type that represents a Feel++ variational formulation expression.

A type that represents a Feel++ variational formulation expression A VfExpr is the fundamental concept for all variational formulation expressions. It represents any expression that can be used in integrals, forms, projections, and other variational operations.

Requirements:

// Functions accepting any vf expression
template <VfExpr E>
auto integrate(E&& expr, Range const& range);
template <VfExpr E>
auto project(E&& expr, FunctionSpace const& space);
// Concept-constrained operator overloads
template <VfExpr E1, VfExpr E2>
auto operator+(E1&& e1, E2&& e2);
Definition: test_factory.cpp:77
Feel::vf::detail::LinearForm< SpaceType, VectorType, ElemContType > operator+(Feel::vf::detail::LinearForm< SpaceType, VectorType, ElemContType > const &a, Feel::vf::detail::LinearForm< SpaceType, VectorType, ElemContType > const &b)
operator + with two linear forms
Definition: linearform.hpp:1232
FunctionSpaceType::element_type project(std::shared_ptr< FunctionSpaceType > const &__functionspace, IteratorRange const &range_it, Expr< ExprT > const &__expr, GeomapStrategyType geomap=GeomapStrategyType::GEOMAP_HO)
nodal projection of __expr onto the subspace of __functionspace described by the range range_it
Definition: projectors.hpp:217
/* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=cpp:et:sw=4:ts=4:sts=4
This file is part of the Feel library
Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
Date: 2026-01-02
Copyright (C) 2026 Feel++ Consortium
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#ifndef FEELPP_VF_CONCEPTS_HPP
#define FEELPP_VF_CONCEPTS_HPP 1
#include <concepts>
#include <map>
#include <string>
#include <utility>
namespace Feel
{
//
// Expression Base Concepts
//
template <typename T>
concept VfExpr = requires(T t) {
typename T::value_type;
{ t.context };
{ t.is_terminal };
};
template <typename T>
concept EvaluableExpr = VfExpr<T> && requires(T t) {
{ t.evaluate(true) };
};
template <typename T>
concept ParametricExpr = VfExpr<T> && requires(T t, std::map<std::string, double> params) {
{ t.setParameterValues(params) };
};
template <typename T, typename SymbolExprType = T>
concept DifferentiableExpr = VfExpr<T> && requires(T t, std::string varname, SymbolExprType se) {
{ t.hasSymbolDependency(varname, se) } -> std::convertible_to<bool>;
};
template <typename T>
concept HasSymbolDependency = VfExpr<T> && requires(T const& t, std::string varname) {
{ t.hasSymbolDependency(varname) } -> std::convertible_to<bool>;
};
template <typename T, typename SymbolExprType>
concept HasSymbolDependencyWith = VfExpr<T> && requires(T const& t, std::string varname, SymbolExprType const& se) {
{ t.hasSymbolDependency(varname, se) } -> std::convertible_to<bool>;
};
template <typename T, typename SymbolExprType>
concept AppliesSymbolExpr = VfExpr<T> && requires(T const& t, SymbolExprType const& se) {
t.applySymbolsExpr(se);
};
template <typename T>
concept ParametricSymbolExpr = ParametricExpr<T>;
template <typename T>
concept SymbolicallyDifferentiableExpr = VfExpr<T> && requires(T const& t, std::string varname) {
t.template diff<1>(varname);
};
//
// Expression Type Categories
//
template <typename T>
concept ScalarExpr = VfExpr<T> && requires {
requires T::rank == 0;
requires T::nComponents == 1;
};
template <typename T>
concept VectorExpr = VfExpr<T> && requires {
requires T::rank == 1;
requires T::nComponents > 1;
};
template <typename T>
concept MatrixExpr = VfExpr<T> && requires {
requires T::rank == 2;
};
template <typename T>
concept TensorExpr = VfExpr<T> && requires {
{ T::rank } -> std::convertible_to<int>;
};
//
// Integration and Form Concepts
//
template <typename T>
concept RangeConcept = requires(T t) {
{ t.begin() };
{ t.end() };
};
template <typename T>
concept Quadrature = requires {
typename T::return_type;
{ T::Degree } -> std::convertible_to<int>;
} || std::integral<T>; // Allow integer order specifications
template <typename T>
concept BilinearFormConcept = requires(T t) {
typename T::test_space_type;
typename T::trial_space_type;
{ t.matrix() };
};
template <typename T>
concept LinearFormConcept = requires(T t) {
typename T::test_space_type;
{ t.vector() };
};
//
// Mesh and Geometry Concepts
//
template <typename T>
concept ElementRange = RangeConcept<T> && requires(T t) {
typename std::decay_t<decltype(*t.begin())>::mesh_type;
};
template <typename T>
concept FaceRange = RangeConcept<T> && requires {
// Faces have mesh_type through their iterator
requires requires(T t) { typename std::decay_t<decltype(*t.begin())>::mesh_type; };
};
//
// Backend and Linear Algebra Concepts
//
template <typename T>
concept BackendConcept = requires(T t) {
typename T::vector_type;
typename T::sparse_matrix_type;
};
template <typename T>
concept PreconditionerConcept = requires(T t) {
typename T::backend_type;
{ t.setMatrix(std::declval<typename T::backend_type::sparse_matrix_type>()) };
};
//
// Operator Concepts
//
template <typename Op, typename Expr>
concept UnaryOperator = VfExpr<Expr> && requires(Op op, Expr e) {
{ op(e) } -> VfExpr;
};
template <typename Op, typename E1, typename E2>
concept BinaryOperator = VfExpr<E1> && VfExpr<E2> && requires(Op op, E1 e1, E2 e2) {
{ op(e1, e2) } -> VfExpr;
};
//
// Backward Compatibility Bridges
//
#ifdef FEELPP_ENABLE_CONCEPT_COMPATIBILITY
template <typename T>
constexpr bool is_vf_expr_v = VfExpr<T>;
template <typename T>
constexpr bool has_evaluate_without_context_v = EvaluableExpr<T>;
template <typename T>
constexpr bool has_symbolic_parameter_values_v = ParametricExpr<T>;
#endif
} // namespace Feel
#endif /* FEELPP_VF_CONCEPTS_HPP */
C++20 concepts for Feel++ core types.
-*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-w...
Definition: about.cpp:37
rank_type rank(RangeT const &range)
get the rank of a range of entities
Definition: filters.hpp:79