Arcane  v4.1.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
TestIO.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/*---------------------------------------------------------------------------*/
9/*
10 * This file is based on the work on AMGCL library (version march 2026)
11 * which can be found at https://github.com/ddemidov/amgcl.
12 *
13 * Copyright (c) 2012-2022 Denis Demidov <dennis.demidov@gmail.com>
14 * SPDX-License-Identifier: MIT
15 */
16/*---------------------------------------------------------------------------*/
17/*---------------------------------------------------------------------------*/
18
19#include <gtest/gtest.h>
20
21#include "arccore/alina/IO.h"
22#include "arccore/alina/Adapters.h"
23#include "arccore/alina/Profiler.h"
24#include "SampleProblemCommon.h"
25
26using namespace Arcane;
27
28namespace
29{
31}
32
33TEST(alina_test_io, io_mm)
34{
35 std::vector<ptrdiff_t> ptr, ptr2;
36 std::vector<ptrdiff_t> col, col2;
37 std::vector<double> val, val2;
38 std::vector<double> rhs, rhs2;
39
40 size_t n = sample_problem(16, val, col, ptr, rhs);
41
42 auto A = std::tie(n, ptr, col, val);
43
44 Alina::IO::mm_write("test_io_crs.mm", A);
45 Alina::IO::mm_write("test_io_vec.mm", rhs.data(), n, 1);
46
47 size_t rows, cols;
48 std::tie(rows, cols) = Alina::IO::mm_reader("test_io_crs.mm")(ptr2, col2, val2);
49
50 ASSERT_EQ(n, rows);
51 ASSERT_EQ(n, cols);
52 ASSERT_EQ(ptr.back(), ptr2.back());
53 for (size_t i = 0; i < n; ++i) {
54 ASSERT_EQ(ptr[i], ptr2[i]);
55 for (ptrdiff_t j = ptr[i], e = ptr[i + 1]; j < e; ++j) {
56 ASSERT_EQ(col[j], col2[j]);
57 ASSERT_NEAR(val[j] - val2[j], 0.0, 1e-12);
58 }
59 }
60
61 std::tie(rows, cols) = Alina::IO::mm_reader("test_io_vec.mm")(rhs2);
62 ASSERT_EQ(n, rows);
63 ASSERT_EQ(1, cols);
64 for (size_t i = 0; i < n; ++i) {
65 ASSERT_NEAR(rhs[i] - rhs2[i], 0.0, 1e-12);
66 }
67}
Matrix market reader.
Definition IO.h:52
Profiler class.
Definition Profiler.h:50
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-