Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Rodin/Assembly/Sequential.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

#include "Rodin/Variational/ForwardDecls.h"

#include "Rodin/Assembly/AssemblyBase.h"

#include "ForwardDecls.h"

namespace Rodin::Assembly
Expand Down
5 changes: 5 additions & 0 deletions src/Rodin/FormLanguage/List.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ namespace Rodin::FormLanguage
return m_list.size();
}

constexpr bool empty() const
{
return m_list.empty();
}

constexpr Iterator begin() noexcept
{
return Iterator(m_list.begin());
Expand Down
15 changes: 14 additions & 1 deletion src/Rodin/Variational/BooleanFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ namespace Rodin::Variational
{
public:
using Parent = FunctionBase<BooleanFunctionBase<Derived>>;
using Parent::traceOf;
using Parent::operator();

BooleanFunctionBase() = default;
Expand All @@ -48,6 +47,13 @@ namespace Rodin::Variational
return static_cast<const Derived&>(*this).getValue(p);
}

template <class ... Args>
constexpr
Derived& traceOf(const Args& ... args)
{
return static_cast<Derived&>(*this).traceOf(args...);
}

virtual BooleanFunctionBase* copy() const noexcept override = 0;
};

Expand Down Expand Up @@ -81,6 +87,13 @@ namespace Rodin::Variational
return m_v;
}

template <class ... Args>
constexpr
BooleanFunction& traceOf(const Args& ... args)
{
return *this;
}

BooleanFunction* copy() const noexcept final override
{
return new BooleanFunction(*this);
Expand Down
12 changes: 6 additions & 6 deletions src/Rodin/Variational/Component.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ namespace Rodin::Variational
}

constexpr
decltype(auto) getValue(const Geometry::Point& p) const
auto getValue(const Geometry::Point& p) const
{
return getOperand().getValue(p).coeff(m_idx);
return this->getOperand().getValue(p).coeff(m_idx);
}

Component* copy() const noexcept override
Expand Down Expand Up @@ -143,9 +143,9 @@ namespace Rodin::Variational
}

constexpr
decltype(auto) getValue(const Geometry::Point& p) const
auto getValue(const Geometry::Point& p) const
{
return getOperand().getValue(p).coeff(m_i, m_j);
return this->getOperand().getValue(p).coeff(m_i, m_j);
}


Expand Down Expand Up @@ -216,7 +216,7 @@ namespace Rodin::Variational
}

constexpr
decltype(auto) getValue(const Geometry::Point& p) const
auto getValue(const Geometry::Point& p) const
{
return m_u.get().getValue(p).coeff(m_idx);
}
Expand Down Expand Up @@ -318,7 +318,7 @@ namespace Rodin::Variational
}

constexpr
decltype(auto) getBasis(size_t local) const
auto getBasis(size_t local) const
{
return this->object(this->getOperand().getBasis(local)).coeff(m_idx);
}
Expand Down
56 changes: 51 additions & 5 deletions src/Rodin/Variational/GridFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,52 @@ namespace Rodin::Variational
return m_ref.get().getValue(p);
}

constexpr
decltype(auto) x() const
{
return m_ref.get().x();
}

constexpr
decltype(auto) y() const
{
return m_ref.get().y();
}

constexpr
decltype(auto) z() const
{
return m_ref.get().z();
}

template <class DataType>
constexpr
decltype(auto) setData(const DataType& data, size_t offset = 0)
{
return m_ref.get().setData(data, offset);
}

/**
* @brief Returns a constant reference to the GridFunction data.
*/
constexpr
auto& getData()
{
return m_ref.get().getData();
}

constexpr
const auto& getFiniteElementSpace() const
{
return m_ref.get().getFiniteElementSpace();
}

constexpr
size_t getSize() const
{
return m_ref.get().getSize();
}

GridFunctionBaseReference* copy() const noexcept final override
{
return new GridFunctionBaseReference(*this);
Expand Down Expand Up @@ -192,23 +238,23 @@ namespace Rodin::Variational
{
static_assert(std::is_same_v<RangeType, Math::Vector<ScalarType>>);
assert(m_fes.get().getVectorDimension() >= 1);
return Component(static_cast<Derived&>(*this), 0);
return Component(static_cast<const Derived&>(*this), 0);
}

constexpr
auto y() const
{
static_assert(std::is_same_v<RangeType, Math::Vector<ScalarType>>);
assert(m_fes.get().getVectorDimension() >= 2);
return Component(static_cast<Derived&>(*this), 1);
return Component(static_cast<const Derived&>(*this), 1);
}

constexpr
auto z() const
{
static_assert(std::is_same_v<RangeType, Math::Vector<ScalarType>>);
assert(m_fes.get().getVectorDimension() >= 3);
return Component(static_cast<Derived&>(*this), 2);
return Component(static_cast<const Derived&>(*this), 2);
}

constexpr
Expand Down Expand Up @@ -682,14 +728,14 @@ namespace Rodin::Variational
GridFunction& operator+=(const ScalarType& rhs)
{
static_assert(std::is_same_v<RangeType, ScalarType>);
this->getData() += rhs;
this->getData().array() += rhs;
return *this;
}

GridFunction& operator-=(const ScalarType& rhs)
{
static_assert(std::is_same_v<RangeType, ScalarType>);
this->getData() -= rhs;
this->getData().array() -= rhs;
return *this;
}

Expand Down
7 changes: 0 additions & 7 deletions src/Rodin/Variational/Jump.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,6 @@ namespace Rodin::Variational
// return getOperand().getLeaf();
// }

// inline
// constexpr
// RangeShape getRangeShape() const
// {
// return getOperand().getRangeShape();
// }

// inline
// constexpr
// size_t getDOFs(const Geometry::Polytope& element) const
Expand Down
7 changes: 7 additions & 0 deletions src/Rodin/Variational/MatrixFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ namespace Rodin::Variational
return static_cast<const Derived&>(*this).getValue(p);
}

template <class ... Args>
constexpr
Derived& traceOf(const Args& ... args)
{
return static_cast<Derived&>(*this).traceOf(args...);
}

/**
* @brief Gets the number of rows in the matrix
* @returns Number of rows
Expand Down
25 changes: 25 additions & 0 deletions src/Rodin/Variational/RealFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ namespace Rodin::Variational
return static_cast<const Derived&>(*this).getValue(p);
}

template <class ... Args>
constexpr
Derived& traceOf(const Args& ... args)
{
return static_cast<Derived&>(*this).traceOf(args...);
}

virtual RealFunctionBase* copy() const noexcept override = 0;
};

Expand Down Expand Up @@ -149,6 +156,12 @@ namespace Rodin::Variational
return m_x;
}

template <class ... Args>
RealFunction& traceOf(Args&&... args) noexcept
{
return *this;
}

RealFunction* copy() const noexcept override
{
return new RealFunction(*this);
Expand Down Expand Up @@ -196,6 +209,12 @@ namespace Rodin::Variational
return m_x;
}

template <class ... Args>
RealFunction& traceOf(Args&&... args) noexcept
{
return *this;
}

RealFunction* copy() const noexcept override
{
return new RealFunction(*this);
Expand Down Expand Up @@ -241,6 +260,12 @@ namespace Rodin::Variational
return m_f(v);
}

template <class ... Args>
RealFunction& traceOf(Args&&... args) noexcept
{
return *this;
}

RealFunction* copy() const noexcept override
{
return new RealFunction(*this);
Expand Down
12 changes: 5 additions & 7 deletions src/Rodin/Variational/Sqrt.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,26 @@ namespace Rodin::Variational
m_v(std::move(other.m_v))
{}

inline
template <class ... Args>
constexpr
Sqrt& traceOf(Geometry::Attribute attrs)
Sqrt& traceOf(const Args& ... args)
{
m_v.traceOf(attrs);
m_v->traceOf(args...);
return *this;
}

inline
Real getValue(const Geometry::Point& p) const
{
return Math::sqrt(getOperand().getValue(p));
return Math::sqrt(this->getOperand().getValue(p));
}

inline
const OperandType& getOperand() const
{
assert(m_v);
return *m_v;
}

inline Sqrt* copy() const noexcept override
Sqrt* copy() const noexcept override
{
return new Sqrt(*this);
}
Expand Down
23 changes: 12 additions & 11 deletions src/Rodin/Variational/Tangent.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,26 +40,21 @@ namespace Rodin::Variational
constexpr
Tan(const Tan& other)
: Parent(other),
m_operand(other.m_v->copy())
m_operand(other.m_operand->copy())
{}

constexpr
Tan(Tan&& other)
: Parent(std::move(other)),
m_operand(std::move(other.m_v))
m_operand(std::move(other.m_operand))
{}

template <class ... Args>
constexpr
Tan& traceOf(Geometry::Attribute attr)
Tan& traceOf(Args&& ... args)
{
m_operand->traceOf(attr);
return *this;
}

constexpr
Tan& traceOf(const FlatSet<Geometry::Attribute>& attrs)
{
m_operand->traceOf(attrs);
Parent::traceOf(std::forward<Args>(args)...);
m_operand->traceOf(std::forward<Args>(args)...);
return *this;
}

Expand All @@ -86,6 +81,12 @@ namespace Rodin::Variational

template <class NestedDerived>
Tan(const FunctionBase<NestedDerived>&) -> Tan<FunctionBase<NestedDerived>>;

template <class NestedDerived>
auto tan(const FunctionBase<NestedDerived>& f)
{
return Tan(f);
}
}

#endif
Expand Down
Loading
Loading