Arcane  v3.14.11.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
case1a.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 case1a()
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", index_manager->global_size());
13
14 Vector v_b(space);
15 Vector v_x(space);
16 Matrix m_a(space,space);
17
18 // Fill matrix m_a
19 {
20 MatrixIJBuilder build_a(m_a, index_manager);
21
22 // Cell-Cell contribution on area U.
23 ENUMERATE_CELL(icell, areaU.own()) {
24 build_a(icell,icell) += fij(icell, icell);
25 ENUMERATE_SUB_ITEM(Cell, isubcell, icell) {
26 build_a(icell, isubcell) += fij(icell, isubcell);
27 }
28 }
29
30 ENUMERATE_NODE(inode, areaP.own()) {
31 ENUMERATE_SUB_ITEM(Cell, isubcell, inode) {
32 build_a(inode, isubcell) += fij(inode, isubcell);
33 }
34 }
35 //End of scope for build_a -> matrix build.
36 // Not a good idea ...
37 }
38
39 // Fill vector v_b
40 {
41 VectorAccessor va_b (v_b, index_manager);
42
43 ENUMERATE_CELL(icell, areaU.own()) {
44 va_b(icell) = var_cell[icell];
45 }
46 ENUMERATE_NODE(inode, areaP.own()) {
47 va_b(inode) = var_node[inode];
48 }
49 //End of scope for va_b -> vector build.
50 // Not a good idea ...
51 }
52
53 Solver solver = solverMng->createSolver(alg_mng, options);
54 v_x = solver.solve(m_a, v_b);
55
56 if (!solver.failed()) {
57 Fatal("Unable to solve Ax=b");
58 }
59
60 // res is automatically in the good space.
61 Vector v_residual = v_b - m_a*v_x;
62
63 info() << "Residual norm_2 = " << norm2(v_residual);
64}
#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.