Skip to content

Commit

Permalink
Alternate fix for diffusion_1
Browse files Browse the repository at this point in the history
Signed-off-by: Steven Hahn <[email protected]>
  • Loading branch information
quantumsteve committed Mar 15, 2024
1 parent 9b573b7 commit 24b0453
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/pde/pde_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ class PDE
// each set of analytical solution functions must have num_dim functions
for (const auto &md_func : exact_vector_funcs)
{
expect(md_func.size() == static_cast<unsigned>(num_dims));
expect(std::clamp(md_func.size(), static_cast<size_t>(num_dims), static_cast<size_t>(num_dims) + 1u) == md_func.size());
}
}

Expand Down
13 changes: 9 additions & 4 deletions src/pde/pde_diffusion1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,22 @@ class PDE_diffusion_1d : public PDE<P>
/* exact solutions */
static fk::vector<P> exact_solution_0(fk::vector<P> const x, P const t = 0)
{
ignore(t);
fk::vector<P> fx(x.size());
P const time = source_0_t(t);
std::transform(x.begin(), x.end(), fx.begin(),
[time](P const &x_v) { return std::cos(nu * x_v) * time; });
[](P const &x_v) { return std::cos(nu * x_v); });
return fx;
}

static P exact_time(P const time) { return source_0_t(time); }
static fk::vector<P> exact_time(fk::vector<P> x, P const time)
{
x.resize(1);
x[0] = source_0_t(time);
return x;
}

inline static std::vector<vector_func<P>> const exact_vector_funcs_ = {
exact_solution_0};
exact_solution_0, exact_time};

/* This is not used ever */
inline static scalar_func<P> const exact_scalar_func_ = source_0_t;
Expand Down
2 changes: 1 addition & 1 deletion src/transformations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ inline void transform_and_combine_dimensions(
P const time_multiplier, fk::vector<P, mem_type::view> result)

{
expect(v_functions.size() == dims.size());
expect(std::clamp(v_functions.size(), dims.size(), dims.size() + 1u) == v_functions.size());
expect(start <= stop);
expect(stop < table.size());
expect(degree >= 0);
Expand Down

0 comments on commit 24b0453

Please sign in to comment.