From 24b04533fc05e182695d1de0b20ab89654925ebb Mon Sep 17 00:00:00 2001 From: Steven Hahn Date: Fri, 15 Mar 2024 13:46:41 -0400 Subject: [PATCH] Alternate fix for diffusion_1 Signed-off-by: Steven Hahn --- src/pde/pde_base.hpp | 2 +- src/pde/pde_diffusion1.hpp | 13 +++++++++---- src/transformations.hpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pde/pde_base.hpp b/src/pde/pde_base.hpp index 526bbdea9..fa1f6c4d8 100644 --- a/src/pde/pde_base.hpp +++ b/src/pde/pde_base.hpp @@ -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(num_dims)); + expect(std::clamp(md_func.size(), static_cast(num_dims), static_cast(num_dims) + 1u) == md_func.size()); } } diff --git a/src/pde/pde_diffusion1.hpp b/src/pde/pde_diffusion1.hpp index 41d71c3d4..12ad5900a 100644 --- a/src/pde/pde_diffusion1.hpp +++ b/src/pde/pde_diffusion1.hpp @@ -151,17 +151,22 @@ class PDE_diffusion_1d : public PDE

/* exact solutions */ static fk::vector

exact_solution_0(fk::vector

const x, P const t = 0) { + ignore(t); fk::vector

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

exact_time(fk::vector

x, P const time) + { + x.resize(1); + x[0] = source_0_t(time); + return x; + } inline static std::vector> const exact_vector_funcs_ = { - exact_solution_0}; + exact_solution_0, exact_time}; /* This is not used ever */ inline static scalar_func

const exact_scalar_func_ = source_0_t; diff --git a/src/transformations.hpp b/src/transformations.hpp index 987f48ec5..7c0d5c2c3 100644 --- a/src/transformations.hpp +++ b/src/transformations.hpp @@ -242,7 +242,7 @@ inline void transform_and_combine_dimensions( P const time_multiplier, fk::vector 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);