19#ifndef TESTS_SAMPLE_PROBLEM_HPP
20#define TESTS_SAMPLE_PROBLEM_HPP
22#include "arccore/alina/ValueTypeInterface.h"
27template <
typename ValueType,
typename ColType,
typename PtrType,
typename RhsType>
28int sample_problem(ptrdiff_t n,
29 std::vector<ValueType>& val,
30 std::vector<ColType>& col,
31 std::vector<PtrType>& ptr,
32 std::vector<RhsType>& rhs,
33 double anisotropy = 1.0)
35 ptrdiff_t n3 = n * n * n;
47 const auto one = Arcane::Alina::math::identity<ValueType>();
50 double hy = hx * anisotropy;
51 double hz = hy * anisotropy;
54 for (ptrdiff_t k = 0, idx = 0; k < n; ++k) {
55 for (ptrdiff_t j = 0; j < n; ++j) {
56 for (ptrdiff_t i = 0; i < n; ++i, ++idx) {
58 col.push_back(idx - n * n);
59 val.push_back(-1.0 / (hz * hz) * one);
63 col.push_back(idx - n);
64 val.push_back(-1.0 / (hy * hy) * one);
68 col.push_back(idx - 1);
69 val.push_back(-1.0 / (hx * hx) * one);
73 val.push_back((2 / (hx * hx) + 2 / (hy * hy) + 2 / (hz * hz)) * one);
76 col.push_back(idx + 1);
77 val.push_back(-1.0 / (hx * hx) * one);
81 col.push_back(idx + n);
82 val.push_back(-1.0 / (hy * hy) * one);
86 col.push_back(idx + n * n);
87 val.push_back(-1.0 / (hz * hz) * one);
90 rhs.push_back(Arcane::Alina::math::constant<RhsType>(1.0));
91 ptr.push_back(
static_cast<PtrType
>(col.size()));