TrialFunction

Represents a function which belongs to a trial space.

Defined in Rodin/Variational/TrialFunction.h

template <
  class Solution,
  class FES>
class TrialFunction;
Template parameters
FES Type of finite element space

Trial function (unknown solution) in a finite element space.

In the weak formulation of a partial differential equation, the trial function represents the unknown solution being sought. Given a finite element space $ U_h $ , the trial function $ u \in U_h $ is the function to be determined by solving the variational problem.

Mathematical Foundation

The weak formulation seeks $ u \in U_h $ such that:

\[ a(u, v) = l(v) \quad \forall v \in V_h \]

where:

  • $ u $ is the trial function (unknown)
  • $ v $ is a test function
  • $ a(\cdot, \cdot) $ is a bilinear form
  • $ l(\cdot) $ is a linear functional
  • $ U_h $ is the trial space

The TrialFunction internally manages a GridFunction that stores the degrees of freedom of the solution after the problem is solved.

Usage Example

P1 Uh(mesh);                    // Define finite element space
TrialFunction u(Uh);             // Define trial function
TestFunction v(Uh);              // Define test function

// Define problem
Problem problem(u, v);
problem = Integral(Grad(u), Grad(v)) - Integral(f, v);

// Solve
problem.solve(solver);

// Access solution
auto& solution = u.getSolution();
Direct inheritance by class family
↓
TrialFunction
↓

Inherits from

Base classResponsibility
TrialFunctionReference<Solution, FES>public
Full type
TrialFunctionReference< Solution, FES >
Reference wrapper for trial functions.

Derived classes

Derived classDescription
PETSc::Variational::TrialFunction<Solution, …>public
Full type
PETSc::Variational::TrialFunction< Solution, FES >
PETSc-aware trial function wrapper.

Inherited interface

Declared inMembers
TrialFunctionReference
6 members

Public types

using FESType = FES
Finite element space type.
using SolutionType = Solution
Solution grid function type.
using Parent = TrialFunctionReference<SolutionType, FESType>
Parent class type.

Public static variables

static ShapeFunctionSpaceType Space constexpr
Space type (trial space).

Constructors, destructors, conversion operators

TrialFunction(const FES& fes) constexpr
Constructs a trial function in the given finite element space.
TrialFunction(const TrialFunction& other) constexpr
Copy constructor.
TrialFunction(TrialFunction&& other) constexpr
Move constructor.

Public functions

void operator=(const TrialFunction& other) deleted
Copy assignment is deleted.
void operator=(TrialFunction&& other) deleted
Move assignment is deleted.
auto x() const -> auto constexpr
Gets the x-component of a vector-valued trial function.
auto y() const -> auto constexpr
Gets the y-component of a vector-valued trial function.
auto z() const -> auto constexpr
Gets the z-component of a vector-valued trial function.
auto getLeaf() const -> const TrialFunction& constexpr
Gets the leaf (innermost) expression in the shape function tree.
auto getSolution() -> SolutionType& constexpr
Gets the solution grid function (mutable).
auto getSolution() const -> const SolutionType& constexpr
Gets the solution grid function (const).
auto setName(const std::string& name) -> TrialFunction&
Sets the name of the field.
auto getName() const -> Optional<StringView> override
Gets the name of the field.

Function documentation

TrialFunction(const FES& fes) constexpr

Constructs a trial function in the given finite element space.

Parameters
fes in Finite element space

Creates a trial function with an associated solution grid function initialized to zero.

TrialFunction(const TrialFunction& other) constexpr

Copy constructor.

Parameters
other in Trial function to copy

TrialFunction(TrialFunction&& other) constexpr

Move constructor.

Parameters
other in Trial function to move

void operator=(const TrialFunction& other) deleted

Copy assignment is deleted.

Parameters
other Object to copy from.

void operator=(TrialFunction&& other) deleted

Move assignment is deleted.

Parameters
other Object to move from.

auto x() const constexpr

Gets the x-component of a vector-valued trial function.

Returns Component expression representing $ u_x $

auto y() const constexpr

Gets the y-component of a vector-valued trial function.

Returns Component expression representing $ u_y $

auto z() const constexpr

Gets the z-component of a vector-valued trial function.

Returns Component expression representing $ u_z $

const TrialFunction& getLeaf() const constexpr

Gets the leaf (innermost) expression in the shape function tree.

Returns Reference to this trial function

SolutionType& getSolution() constexpr

Gets the solution grid function (mutable).

Returns Reference to the solution

The solution grid function stores the degrees of freedom of the computed solution after solving the variational problem.

const SolutionType& getSolution() const constexpr

Gets the solution grid function (const).

Returns Const reference to the solution

TrialFunction& setName(const std::string& name)

Sets the name of the field.

Parameters
name Name of the object.
Returns Reference to this object after the operation.

Optional<StringView> getName() const override

Gets the name of the field.

Returns The name of the field.