EpetraExt
Development
Toggle main menu visibility
Loading...
Searching...
No Matches
src
transform
EpetraExt_LPTrans_From_GraphTrans.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_GraphTrans.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_GraphTrans::
58
~LinearProblem_GraphTrans
()
59
{
60
if
( MatExporter_ )
delete
MatExporter_;
61
if
( VecExporter_ )
delete
VecExporter_;
62
if
( Importer_ )
delete
Importer_;
63
64
if
( NewProblem_ )
delete
NewProblem_;
65
if
( NewRHS_ )
delete
NewRHS_;
66
if
( NewLHS_ )
delete
NewLHS_;
67
if
( NewMatrix_ )
delete
NewMatrix_;
68
}
69
70
LinearProblem_GraphTrans::NewTypeRef
71
LinearProblem_GraphTrans::
72
operator()
(
OriginalTypeRef
orig )
73
{
74
OldProblem_ = &orig;
75
OldMatrix_ =
dynamic_cast<
Epetra_CrsMatrix
*
>
( orig.GetMatrix() );
76
OldGraph_ =
const_cast<
Epetra_CrsGraph
*
>
(&OldMatrix_->Graph());
77
OldRHS_ = orig.GetRHS();
78
OldLHS_ = orig.GetLHS();
79
OldRowMap_ =
const_cast<
Epetra_Map
*
>
(&OldMatrix_->RowMap());
80
81
int
ierr = 0;
82
(void) ierr;
// silence "set but not used" warning
83
84
if
( !OldMatrix_ ) ierr = -2;
85
if
( !OldRHS_ ) ierr = -3;
86
if
( !OldLHS_ ) ierr = -4;
87
88
Epetra_CrsGraph
& NewGraph = graphTrans_( *OldGraph_ );
89
NewMatrix_ =
new
Epetra_CrsMatrix
(
Copy
, NewGraph );
90
91
Epetra_BlockMap
& NewRowMap =
const_cast<
Epetra_BlockMap
&
>
(NewGraph.
RowMap
());
92
93
NewRHS_ =
new
Epetra_MultiVector
( NewRowMap, 1 );
94
NewLHS_ =
new
Epetra_MultiVector
( NewRowMap, 1 );
95
96
MatExporter_ =
new
Epetra_Export
( *OldRowMap_, NewRowMap );
97
VecExporter_ =
new
Epetra_Export
( *OldRowMap_, NewRowMap );
98
Importer_ =
new
Epetra_Import
( *OldRowMap_, NewRowMap );
99
100
NewProblem_ =
new
Epetra_LinearProblem
( NewMatrix_, NewLHS_, NewRHS_ );
101
102
return
*NewProblem_;
103
}
104
105
bool
106
LinearProblem_GraphTrans::
107
fwd
()
108
{
109
NewLHS_->Export( *OldLHS_, *VecExporter_,
Insert
);
110
NewRHS_->Export( *OldRHS_, *VecExporter_,
Insert
);
111
NewMatrix_->Export( *OldMatrix_, *MatExporter_,
Insert
);
112
113
return
true
;
114
}
115
116
bool
117
LinearProblem_GraphTrans::
118
rvs
()
119
{
120
OldLHS_->Import( *NewLHS_, *Importer_,
Insert
);
121
// OldRHS_->Import( *NewRHS_, *Importer_, Insert );
122
// OldMatrix_->Import( *NewMatrix_, *Importer_, Insert );
123
124
return
true
;
125
}
126
127
}
//namespace EpetraExt
128
EpetraExt_LPTrans_From_GraphTrans.h
Insert
Insert
Copy
Copy
EpetraExt::LinearProblem_GraphTrans::~LinearProblem_GraphTrans
~LinearProblem_GraphTrans()
EpetraExt::LinearProblem_GraphTrans Destructor.
Definition
EpetraExt_LPTrans_From_GraphTrans.cpp:58
EpetraExt::LinearProblem_GraphTrans::rvs
bool rvs()
Reverse migration of data from transformed to original object.
Definition
EpetraExt_LPTrans_From_GraphTrans.cpp:118
EpetraExt::LinearProblem_GraphTrans::fwd
bool fwd()
Forward migration of data from original to transformed object.
Definition
EpetraExt_LPTrans_From_GraphTrans.cpp:107
EpetraExt::LinearProblem_GraphTrans::operator()
NewTypeRef operator()(OriginalTypeRef orig)
Constructs an Epetra_LinearProblem from the original using the same row transformation given by the E...
Definition
EpetraExt_LPTrans_From_GraphTrans.cpp:72
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_CrsGraph
Epetra_CrsGraph::RowMap
const Epetra_BlockMap & RowMap() const
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