GlobalMatrix.cpp 2.26 KB
Newer Older
GILLES Sebastien's avatar
GILLES Sebastien committed
1 2 3 4 5 6 7 8 9 10 11 12 13
/*!
//
// \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
// \{
*/

14

15 16
#include <algorithm>

17 18 19 20 21
#ifndef NDEBUG
# include <iostream>
#endif // NDEBUG


22 23 24
#include "Utilities/Containers/Print.hpp" //\todo #820 DEV
#include "Utilities/Exceptions/Exception.hpp"
#include "Utilities/Exceptions/PrintAndAbort.hpp"
25

26
#include "ThirdParty/Wrappers/Petsc/Matrix/MatrixPattern.hpp"
27

28 29
#include "Core/LinearAlgebra/GlobalMatrix.hpp"
#include "Core/NumberingSubset/NumberingSubset.hpp"
30 31


32
namespace MoReFEM
33 34 35
{
    
    
36 37 38
    GlobalMatrix::~GlobalMatrix() = default;
    
    
39 40
    GlobalMatrix::GlobalMatrix(const NumberingSubset& row_numbering_subset,
                               const NumberingSubset& col_numbering_subset)
41
    : Crtp::NumberingSubsetForMatrix<GlobalMatrix>(row_numbering_subset, col_numbering_subset)
42 43 44
    { }
    
    
45
    GlobalMatrix::GlobalMatrix(const GlobalMatrix& rhs)
46 47
    : petsc_parent(rhs),
    numbering_subset_parent(rhs)
48
    { }
49

50 51 52
    
    void Swap(GlobalMatrix& A, GlobalMatrix& B)
    {
53
        // We swap the content of two matrices that share the same numbering subsets.
54 55
        assert(A.GetColNumberingSubset() == B.GetColNumberingSubset());
        assert(A.GetRowNumberingSubset() == B.GetRowNumberingSubset());
56
        
57
        using parent = GlobalMatrix::petsc_parent;
58
        
59
        Swap(static_cast<parent&>(A), static_cast<parent&>(B));
60
    }
61 62
    
    
63
    # ifndef NDEBUG
64 65 66 67 68 69
    void AssertSameNumberingSubset(const GlobalMatrix& matrix1,
                                   const GlobalMatrix& matrix2)
    {
        assert(matrix1.GetRowNumberingSubset() == matrix2.GetRowNumberingSubset());
        assert(matrix1.GetColNumberingSubset() == matrix2.GetColNumberingSubset());
    }
70 71
    
    
72
    void PrintNumberingSubset(std::string_view matrix_name,
73 74 75 76 77 78
                              const GlobalMatrix& matrix)
    {
        std::cout << "Numbering subsets for matrix '" << matrix_name << "': row -> "
        << matrix.GetRowNumberingSubset().GetUniqueId() << " and col -> "
        << matrix.GetColNumberingSubset().GetUniqueId() << std::endl;
    }
79
    # endif // NDEBUG
80

81
    
82
} // namespace MoReFEM
83 84 85


/// @} // addtogroup CoreGroup