EpetraExt Package Browser (Single Doxygen Collection)
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
transform
EpetraExt_LPTrans_From_MatrixTrans.cpp
Go to the documentation of this file.
1
//@HEADER
2
// ***********************************************************************
3
//
4
// EpetraExt: Epetra Extended - Linear Algebra Services Package
5
// Copyright (2011) Sandia Corporation
6
//
7
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
8
// the U.S. Government retains certain rights in this software.
9
//
10
// Redistribution and use in source and binary forms, with or without
11
// modification, are permitted provided that the following conditions are
12
// met:
13
//
14
// 1. Redistributions of source code must retain the above copyright
15
// notice, this list of conditions and the following disclaimer.
16
//
17
// 2. Redistributions in binary form must reproduce the above copyright
18
// notice, this list of conditions and the following disclaimer in the
19
// documentation and/or other materials provided with the distribution.
20
//
21
// 3. Neither the name of the Corporation nor the names of the
22
// contributors may be used to endorse or promote products derived from
23
// this software without specific prior written permission.
24
//
25
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
26
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
29
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
30
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
31
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
32
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
34
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
35
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36
//
37
// Questions? Contact Michael A. Heroux (maherou@sandia.gov)
38
//
39
// ***********************************************************************
40
//@HEADER
41
42
#include <
EpetraExt_LPTrans_From_MatrixTrans.h
>
43
44
#include <
Epetra_Export.h
>
45
#include <
Epetra_Import.h
>
46
#include <
Epetra_LinearProblem.h
>
47
#include <
Epetra_CrsGraph.h
>
48
#include <
Epetra_CrsMatrix.h
>
49
#include <
Epetra_MultiVector.h
>
50
#include <
Epetra_Vector.h
>
51
#include <
Epetra_IntVector.h
>
52
#include <
Epetra_Map.h
>
53
#include <
Epetra_Comm.h
>
54
55
namespace
EpetraExt
{
56
57
LinearProblem_MatrixTrans::
58
~LinearProblem_MatrixTrans
()
59
{
60
if
(
Exporter_
)
delete
Exporter_
;
61
if
(
Importer_
)
delete
Importer_
;
62
63
if
(
NewProblem_
)
delete
NewProblem_
;
64
if
(
NewRHS_
)
delete
NewRHS_
;
65
if
(
NewLHS_
)
delete
NewLHS_
;
66
}
67
68
LinearProblem_MatrixTrans::NewTypeRef
69
LinearProblem_MatrixTrans::
70
operator()
(
OriginalTypeRef
orig )
71
{
72
OldProblem_
= &orig;
73
OldMatrix_
=
dynamic_cast<
Epetra_CrsMatrix
*
>
( orig.GetMatrix() );
74
OldRHS_
= orig.GetRHS();
75
OldLHS_
= orig.GetLHS();
76
OldRowMap_
=
const_cast<
Epetra_Map
*
>
(&
OldMatrix_
->RowMap());
77
78
int
ierr = 0;
79
(void) ierr;
// forestall "variable set but unused" warning
80
81
if
( !
OldMatrix_
) ierr = -2;
82
if
( !
OldRHS_
) ierr = -3;
83
if
( !
OldLHS_
) ierr = -4;
84
85
NewMatrix_
= &(
matrixTrans_
( *
OldMatrix_
));
86
87
Epetra_BlockMap
& NewRowMap =
const_cast<
Epetra_BlockMap
&
>
(
NewMatrix_
->Graph().RowMap());
88
89
NewRHS_
=
new
Epetra_MultiVector
( NewRowMap, 1 );
90
NewLHS_
=
new
Epetra_MultiVector
( NewRowMap, 1 );
91
92
Exporter_
=
new
Epetra_Export
( *
OldRowMap_
, NewRowMap );
93
Importer_
=
new
Epetra_Import
( NewRowMap, *
OldRowMap_
);
94
95
NewProblem_
=
new
Epetra_LinearProblem
(
NewMatrix_
,
NewLHS_
,
NewRHS_
);
96
97
return
*
NewProblem_
;
98
}
99
100
bool
101
LinearProblem_MatrixTrans::
102
fwd
()
103
{
104
NewLHS_
->Export( *
OldLHS_
, *
Exporter_
,
Insert
);
105
NewRHS_
->Export( *
OldRHS_
, *
Exporter_
,
Insert
);
106
NewMatrix_
->Export( *
OldMatrix_
, *
Exporter_
,
Insert
);
107
108
return
true
;
109
}
110
111
bool
112
LinearProblem_MatrixTrans::
113
rvs
()
114
{
115
OldLHS_
->Import( *
NewLHS_
, *
Exporter_
,
Insert
);
116
OldRHS_
->Import( *
NewRHS_
, *
Exporter_
,
Insert
);
117
OldMatrix_
->Import( *
NewMatrix_
, *
Exporter_
,
Insert
);
118
119
return
true
;
120
}
121
122
}
//namespace EpetraExt
123
EpetraExt_LPTrans_From_MatrixTrans.h
Insert
Insert
Epetra_Comm.h
Epetra_CrsGraph.h
Epetra_CrsMatrix.h
Epetra_Export.h
Epetra_Import.h
Epetra_IntVector.h
Epetra_LinearProblem.h
Epetra_Map.h
Epetra_MultiVector.h
Epetra_Vector.h
EpetraExt::LinearProblem_MatrixTrans::Importer_
Epetra_Import * Importer_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:62
EpetraExt::LinearProblem_MatrixTrans::matrixTrans_
SameTypeTransform< Epetra_CrsMatrix > & matrixTrans_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:60
EpetraExt::LinearProblem_MatrixTrans::OldLHS_
Epetra_MultiVector * OldLHS_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:67
EpetraExt::LinearProblem_MatrixTrans::fwd
bool fwd()
Forward Data Migration.
Definition
EpetraExt_LPTrans_From_MatrixTrans.cpp:102
EpetraExt::LinearProblem_MatrixTrans::NewLHS_
Epetra_MultiVector * NewLHS_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:73
EpetraExt::LinearProblem_MatrixTrans::~LinearProblem_MatrixTrans
~LinearProblem_MatrixTrans()
Destructor.
Definition
EpetraExt_LPTrans_From_MatrixTrans.cpp:58
EpetraExt::LinearProblem_MatrixTrans::OldProblem_
Epetra_LinearProblem * OldProblem_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:65
EpetraExt::LinearProblem_MatrixTrans::NewRHS_
Epetra_MultiVector * NewRHS_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:74
EpetraExt::LinearProblem_MatrixTrans::OldMatrix_
Epetra_CrsMatrix * OldMatrix_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:66
EpetraExt::LinearProblem_MatrixTrans::OldRowMap_
Epetra_Map * OldRowMap_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:69
EpetraExt::LinearProblem_MatrixTrans::OldRHS_
Epetra_MultiVector * OldRHS_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:68
EpetraExt::LinearProblem_MatrixTrans::operator()
NewTypeRef operator()(OriginalTypeRef orig)
Transform Operator.
Definition
EpetraExt_LPTrans_From_MatrixTrans.cpp:70
EpetraExt::LinearProblem_MatrixTrans::NewProblem_
Epetra_LinearProblem * NewProblem_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:71
EpetraExt::LinearProblem_MatrixTrans::NewMatrix_
Epetra_CrsMatrix * NewMatrix_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:72
EpetraExt::LinearProblem_MatrixTrans::rvs
bool rvs()
Reverse Data Migration.
Definition
EpetraExt_LPTrans_From_MatrixTrans.cpp:113
EpetraExt::LinearProblem_MatrixTrans::Exporter_
Epetra_Export * Exporter_
Definition
EpetraExt_LPTrans_From_MatrixTrans.h:63
EpetraExt::Transform< Epetra_LinearProblem, Epetra_LinearProblem >::OriginalTypeRef
Epetra_LinearProblem & OriginalTypeRef
Definition
EpetraExt_Transform.h:74
EpetraExt::Transform< Epetra_LinearProblem, Epetra_LinearProblem >::NewTypeRef
Epetra_LinearProblem & NewTypeRef
Definition
EpetraExt_Transform.h:79
Epetra_BlockMap
Epetra_CrsMatrix
Epetra_Export
Epetra_Import
Epetra_LinearProblem
Epetra_Map
Epetra_MultiVector
EpetraExt
EpetraExt::BlockCrsMatrix: A class for constructing a distributed block matrix.
Definition
EpetraExt_BlockCrsMatrix.cpp:46
Generated by
1.17.0