Arcane  v3.14.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
case1b.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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//-----------------------------------------------------------------------------
7void case1b()
8{
9 IAlgebraicMng *alg_mng = createAlgebraicMng(m_parallel_mng);
10
11 // Not the perfect way to create space
12 IndexedSpace space = alg_mng->createSpace("Nom",
13 index_manager->global_size());
14
15 Vector v_b(space);
16 Vector v_x(space);
17 Matrix m_a(space,space);
18
19 // Fill matrix m_a
20 {
21 MatrixEditor edit_a(m_a, index_manager);
22 // edit_a is a "copy (CoW ?)" of m_a data.
23 // m_a contents is thus always valid !
24
25 // Cell-Cell contribution on area U.
26 ENUMERATE_CELL(icell, areaU.own()) {
27 edit_a(icell,icell) = fij(icell, icell);
28 ENUMERATE_SUB_ITEM(Cell, isubcell, icell) {
29 edit_a(icell, isubcell) += fij(icell, isubcell);
30 }
31 }
32
33 ENUMERATE_NODE(inode, areaP.own()) {
34 ENUMERATE_SUB_ITEM(Cell, isubcell, inode) {
35 edit_a(inode, isubcell) += fij(inode, isubcell);
36 }
37 }
38
39 m_a.replace(edit_a);
40 // m_a.add_contrib(build_a);
41 }
42
43 // Fill vector v_b
44 {
45 VectorEditor ve_b (v_b, index_manager);
46
47 ENUMERATE_CELL(icell, areaU.own()) {
48 ve_b(icell) = var_cell[icell];
49 }
50 ENUMERATE_NODE(inode, areaP.own()) {
51 ve_b(inode) = var_node[inode];
52 }
53 v_b.replace(ve_b);
54 }
55
56 Solver solver = solverMng->createSolver(alg_mng, options);
57 v_x = solver.solve(m_a, v_b);
58
59 if (!solver.failed()) {
60 Fatal("Unable to solve Ax=b");
61 }
62
63 // res is automatically in the good space.
64 Vector v_residual = v_b - m_a*v_x;
65
66 info() << "Residual norm_2 = " << norm2(v_residual);
67}
#define ENUMERATE_CELL(name, group)
Enumérateur générique d'un groupe de mailles.
#define ENUMERATE_SUB_ITEM(_item_type, _name, _parent_item)
Enumérateur sur sous-élément d'un ItemPairGroup.
#define ENUMERATE_NODE(name, group)
Enumérateur générique d'un groupe de noeuds.