Skip to content

Commit 8ba13e5

Browse files
committed
Fix Copilot code
1 parent c055c5f commit 8ba13e5

19 files changed

+436
-731
lines changed

src/Rodin/FormLanguage/List.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ namespace Rodin::FormLanguage
119119
return m_list.size();
120120
}
121121

122+
constexpr bool empty() const
123+
{
124+
return m_list.empty();
125+
}
126+
122127
constexpr Iterator begin() noexcept
123128
{
124129
return Iterator(m_list.begin());

src/Rodin/Variational/BooleanFunction.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ namespace Rodin::Variational
2424
{
2525
public:
2626
using Parent = FunctionBase<BooleanFunctionBase<Derived>>;
27-
using Parent::traceOf;
2827
using Parent::operator();
2928

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

50+
template <class ... Args>
51+
constexpr
52+
Derived& traceOf(const Args& ... args)
53+
{
54+
return static_cast<Derived&>(*this).traceOf(args...);
55+
}
56+
5157
virtual BooleanFunctionBase* copy() const noexcept override = 0;
5258
};
5359

@@ -81,6 +87,13 @@ namespace Rodin::Variational
8187
return m_v;
8288
}
8389

90+
template <class ... Args>
91+
constexpr
92+
BooleanFunction& traceOf(const Args& ... args)
93+
{
94+
return *this;
95+
}
96+
8497
BooleanFunction* copy() const noexcept final override
8598
{
8699
return new BooleanFunction(*this);

src/Rodin/Variational/GridFunction.h

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,52 @@ namespace Rodin::Variational
111111
return m_ref.get().getValue(p);
112112
}
113113

114+
constexpr
115+
decltype(auto) x() const
116+
{
117+
return m_ref.get().x();
118+
}
119+
120+
constexpr
121+
decltype(auto) y() const
122+
{
123+
return m_ref.get().y();
124+
}
125+
126+
constexpr
127+
decltype(auto) z() const
128+
{
129+
return m_ref.get().z();
130+
}
131+
132+
template <class DataType>
133+
constexpr
134+
decltype(auto) setData(const DataType& data, size_t offset = 0)
135+
{
136+
return m_ref.get().setData(data, offset);
137+
}
138+
139+
/**
140+
* @brief Returns a constant reference to the GridFunction data.
141+
*/
142+
constexpr
143+
auto& getData()
144+
{
145+
return m_ref.get().getData();
146+
}
147+
148+
constexpr
149+
const auto& getFiniteElementSpace() const
150+
{
151+
return m_ref.get().getFiniteElementSpace();
152+
}
153+
154+
constexpr
155+
size_t getSize() const
156+
{
157+
return m_ref.get().getSize();
158+
}
159+
114160
GridFunctionBaseReference* copy() const noexcept final override
115161
{
116162
return new GridFunctionBaseReference(*this);
@@ -192,23 +238,23 @@ namespace Rodin::Variational
192238
{
193239
static_assert(std::is_same_v<RangeType, Math::Vector<ScalarType>>);
194240
assert(m_fes.get().getVectorDimension() >= 1);
195-
return Component(static_cast<Derived&>(*this), 0);
241+
return Component(static_cast<const Derived&>(*this), 0);
196242
}
197243

198244
constexpr
199245
auto y() const
200246
{
201247
static_assert(std::is_same_v<RangeType, Math::Vector<ScalarType>>);
202248
assert(m_fes.get().getVectorDimension() >= 2);
203-
return Component(static_cast<Derived&>(*this), 1);
249+
return Component(static_cast<const Derived&>(*this), 1);
204250
}
205251

206252
constexpr
207253
auto z() const
208254
{
209255
static_assert(std::is_same_v<RangeType, Math::Vector<ScalarType>>);
210256
assert(m_fes.get().getVectorDimension() >= 3);
211-
return Component(static_cast<Derived&>(*this), 2);
257+
return Component(static_cast<const Derived&>(*this), 2);
212258
}
213259

214260
constexpr
@@ -682,14 +728,14 @@ namespace Rodin::Variational
682728
GridFunction& operator+=(const ScalarType& rhs)
683729
{
684730
static_assert(std::is_same_v<RangeType, ScalarType>);
685-
this->getData() += rhs;
731+
this->getData().array() += rhs;
686732
return *this;
687733
}
688734

689735
GridFunction& operator-=(const ScalarType& rhs)
690736
{
691737
static_assert(std::is_same_v<RangeType, ScalarType>);
692-
this->getData() -= rhs;
738+
this->getData().array() -= rhs;
693739
return *this;
694740
}
695741

src/Rodin/Variational/MatrixFunction.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,13 @@ namespace Rodin::Variational
6363
return static_cast<const Derived&>(*this).getValue(p);
6464
}
6565

66+
template <class ... Args>
67+
constexpr
68+
Derived& traceOf(const Args& ... args)
69+
{
70+
return static_cast<Derived&>(*this).traceOf(args...);
71+
}
72+
6673
/**
6774
* @brief Gets the number of rows in the matrix
6875
* @returns Number of rows

src/Rodin/Variational/RealFunction.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,13 @@ namespace Rodin::Variational
6262
return static_cast<const Derived&>(*this).getValue(p);
6363
}
6464

65+
template <class ... Args>
66+
constexpr
67+
Derived& traceOf(const Args& ... args)
68+
{
69+
return static_cast<Derived&>(*this).traceOf(args...);
70+
}
71+
6572
virtual RealFunctionBase* copy() const noexcept override = 0;
6673
};
6774

@@ -149,6 +156,12 @@ namespace Rodin::Variational
149156
return m_x;
150157
}
151158

159+
template <class ... Args>
160+
RealFunction& traceOf(Args&&... args) noexcept
161+
{
162+
return *this;
163+
}
164+
152165
RealFunction* copy() const noexcept override
153166
{
154167
return new RealFunction(*this);
@@ -196,6 +209,12 @@ namespace Rodin::Variational
196209
return m_x;
197210
}
198211

212+
template <class ... Args>
213+
RealFunction& traceOf(Args&&... args) noexcept
214+
{
215+
return *this;
216+
}
217+
199218
RealFunction* copy() const noexcept override
200219
{
201220
return new RealFunction(*this);
@@ -241,6 +260,12 @@ namespace Rodin::Variational
241260
return m_f(v);
242261
}
243262

263+
template <class ... Args>
264+
RealFunction& traceOf(Args&&... args) noexcept
265+
{
266+
return *this;
267+
}
268+
244269
RealFunction* copy() const noexcept override
245270
{
246271
return new RealFunction(*this);

src/Rodin/Variational/VectorFunction.h

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ namespace Rodin::Variational
4848

4949
using Parent = FunctionBase<VectorFunctionBase<Scalar, Derived>>;
5050

51-
using Parent::traceOf;
52-
5351
using Parent::operator();
5452

5553
VectorFunctionBase() = default;
@@ -122,6 +120,13 @@ namespace Rodin::Variational
122120
return static_cast<const Derived&>(*this).getDimension();
123121
}
124122

123+
template <class ... Args>
124+
constexpr
125+
Derived& traceOf(const Args& ... args)
126+
{
127+
return static_cast<Derived&>(*this).traceOf(args...);
128+
}
129+
125130
virtual VectorFunctionBase* copy() const noexcept override
126131
{
127132
return static_cast<const Derived&>(*this).copy();
@@ -171,8 +176,9 @@ namespace Rodin::Variational
171176
return m_vector.get().size();
172177
}
173178

179+
template <class ... Args>
174180
constexpr
175-
VectorFunction& traceOf(Geometry::Attribute attr)
181+
VectorFunction& traceOf(const Args& ... args)
176182
{
177183
return *this;
178184
}
@@ -259,10 +265,11 @@ namespace Rodin::Variational
259265
return 1 + sizeof...(Values);
260266
}
261267

268+
template <class ... Args>
262269
constexpr
263-
VectorFunction& traceOf(Geometry::Attribute attrs)
270+
VectorFunction& traceOf(const Args&... attrs)
264271
{
265-
std::apply([&](auto& s) { s.traceOf(attrs); }, m_fs);
272+
std::apply([&](auto&... s) { (s.traceOf(attrs...), ...); }, m_fs);
266273
return *this;
267274
}
268275

@@ -311,6 +318,13 @@ namespace Rodin::Variational
311318
return m_f(p);
312319
}
313320

321+
template <class ... Args>
322+
constexpr
323+
VectorFunction& traceOf(const Args&... attrs)
324+
{
325+
return *this;
326+
}
327+
314328
VectorFunction* copy() const noexcept override
315329
{
316330
return new VectorFunction(*this);

0 commit comments

Comments
 (0)