Attention une mise à jour du service Gitlab va être effectuée le mardi 14 décembre entre 13h30 et 14h00. Cette mise à jour va générer une interruption du service dont nous ne maîtrisons pas complètement la durée mais qui ne devrait pas excéder quelques minutes.

GlobalMatrix.cpp 2.22 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
///
////// \file
///
///
/// Created by Sebastien Gilles <sebastien.gilles@inria.fr> on the Mon, 27 Apr 2015 09:33:06 +0200
/// Copyright (c) Inria. All rights reserved.
///
/// \ingroup CoreGroup
/// \addtogroup CoreGroup
/// \{
11

12 13
#include <algorithm>

14 15 16 17 18
#ifndef NDEBUG
# include <iostream>
#endif // NDEBUG


19 20 21
#include "Utilities/Containers/Print.hpp" //\todo #820 DEV
#include "Utilities/Exceptions/Exception.hpp"
#include "Utilities/Exceptions/PrintAndAbort.hpp"
22

23
#include "ThirdParty/Wrappers/Petsc/Matrix/MatrixPattern.hpp"
24

25 26
#include "Core/LinearAlgebra/GlobalMatrix.hpp"
#include "Core/NumberingSubset/NumberingSubset.hpp"
27 28 29 30 31 32


namespace HappyHeart
{
    
    
33 34
    GlobalMatrix::GlobalMatrix(const NumberingSubset& row_numbering_subset,
                               const NumberingSubset& col_numbering_subset)
35
    : Crtp::NumberingSubsetForMatrix<GlobalMatrix>(row_numbering_subset, col_numbering_subset)
36 37 38
    { }
    
    
39
    GlobalMatrix::GlobalMatrix(const GlobalMatrix& rhs)
40 41
    : petsc_parent(rhs),
    numbering_subset_parent(rhs)
42 43 44 45 46
    { }
    
    
    void Swap(GlobalMatrix& A, GlobalMatrix& B)
    {
47
        // We swap the content of two matrices that share the same numbering subsets.
48 49
        assert(A.GetColNumberingSubset() == B.GetColNumberingSubset());
        assert(A.GetRowNumberingSubset() == B.GetRowNumberingSubset());
50
        
51
        using parent = GlobalMatrix::petsc_parent;
52
        
53
        Swap(static_cast<parent&>(A), static_cast<parent&>(B));
54
    }
55 56
    
    
57
    # ifndef NDEBUG
58 59 60 61 62 63
    void AssertSameNumberingSubset(const GlobalMatrix& matrix1,
                                   const GlobalMatrix& matrix2)
    {
        assert(matrix1.GetRowNumberingSubset() == matrix2.GetRowNumberingSubset());
        assert(matrix1.GetColNumberingSubset() == matrix2.GetColNumberingSubset());
    }
64 65 66 67 68 69 70 71 72
    
    
    void PrintNumberingSubset(std::string&& matrix_name,
                              const GlobalMatrix& matrix)
    {
        std::cout << "Numbering subsets for matrix '" << matrix_name << "': row -> "
        << matrix.GetRowNumberingSubset().GetUniqueId() << " and col -> "
        << matrix.GetColNumberingSubset().GetUniqueId() << std::endl;
    }
73
    # endif // NDEBUG
74

75
    
76
} // namespace HappyHeart
77 78 79


/// @} // addtogroup CoreGroup