19#ifndef TESTS_SAMPLE_PROBLEM_HPP
20#define TESTS_SAMPLE_PROBLEM_HPP
25#include "arccore/alina/ValueTypeInterface.h"
28template <
typename ValueType,
typename ColType,
typename PtrType,
typename RhsType>
29int sample_problem(ptrdiff_t n,
30 std::vector<ValueType>& val,
31 std::vector<ColType>& col,
32 std::vector<PtrType>& ptr,
33 std::vector<RhsType>& rhs,
34 double anisotropy = 1.0)
36 ptrdiff_t n3 = n * n * n;
48 const auto one = Arcane::Alina::math::identity<ValueType>();
51 double hy = hx * anisotropy;
52 double hz = hy * anisotropy;
55 for (ptrdiff_t k = 0, idx = 0; k < n; ++k) {
56 for (ptrdiff_t j = 0; j < n; ++j) {
57 for (ptrdiff_t i = 0; i < n; ++i, ++idx) {
59 col.push_back(idx - n * n);
60 val.push_back(-1.0 / (hz * hz) * one);
64 col.push_back(idx - n);
65 val.push_back(-1.0 / (hy * hy) * one);
69 col.push_back(idx - 1);
70 val.push_back(-1.0 / (hx * hx) * one);
74 val.push_back((2 / (hx * hx) + 2 / (hy * hy) + 2 / (hz * hz)) * one);
77 col.push_back(idx + 1);
78 val.push_back(-1.0 / (hx * hx) * one);
82 col.push_back(idx + n);
83 val.push_back(-1.0 / (hy * hy) * one);
87 col.push_back(idx + n * n);
88 val.push_back(-1.0 / (hz * hz) * one);
91 rhs.push_back(Arcane::Alina::math::constant<RhsType>(1.0));
92 ptr.push_back(
static_cast<PtrType
>(col.size()));