FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
support-Trilinos
fei_Factory_Aztec.cpp
Go to the documentation of this file.
1
/*
2
// @HEADER
3
// ************************************************************************
4
// FEI: Finite Element Interface to Linear Solvers
5
// Copyright (2005) Sandia Corporation.
6
//
7
// Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
8
// 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 Alan Williams (william@sandia.gov)
38
//
39
// ************************************************************************
40
// @HEADER
41
*/
42
43
44
#include "
fei_trilinos_macros.hpp
"
45
46
#include <
fei_Factory_Aztec.hpp
>
47
48
#include <
fei_VectorReducer.hpp
>
49
#include <
fei_MatrixReducer.hpp
>
50
51
Factory_Aztec::Factory_Aztec
(
MPI_Comm
comm)
52
:
fei
::
Factory
(comm),
53
comm_
(comm),
54
reducer_
(),
55
blockEntryMatrix_
(false),
56
outputLevel_
(0)
57
{
58
}
59
60
Factory_Aztec::~Factory_Aztec
()
61
{
62
}
63
64
int
Factory_Aztec::parameters
(
int
numParams,
65
const
char
*
const
* paramStrings)
66
{
67
std::vector<std::string> stdstrings;
68
fei::utils::char_ptrs_to_strings
(numParams, paramStrings, stdstrings);
69
70
fei::ParameterSet
paramset;
71
fei::utils::parse_strings
(stdstrings,
" "
, paramset);
72
73
parameters
(paramset);
74
return
(0);
75
}
76
77
void
Factory_Aztec::parameters
(
const
fei::ParameterSet
& parameterset)
78
{
79
fei::Factory::parameters
(parameterset);
80
81
parameterset.
getIntParamValue
(
"outputLevel"
,
outputLevel_
);
82
83
bool
blkGraph =
false
;
84
bool
blkMatrix =
false
;
85
86
parameterset.
getBoolParamValue
(
"BLOCK_GRAPH"
, blkGraph);
87
parameterset.
getBoolParamValue
(
"BLOCK_MATRIX"
, blkMatrix);
88
89
blockEntryMatrix_
= (blkGraph || blkMatrix);
90
}
91
92
fei::SharedPtr<fei::MatrixGraph>
93
Factory_Aztec::createMatrixGraph
(
fei::SharedPtr<fei::VectorSpace>
rowSpace,
94
fei::SharedPtr<fei::VectorSpace>
colSpace,
95
const
char
* name)
96
{
97
static
fei::MatrixGraph_Impl2::Factory
factory2;
98
return
factory2.
createMatrixGraph
(rowSpace, colSpace, name);
99
}
100
101
fei::SharedPtr<fei::Vector>
102
Factory_Aztec::createVector
(
fei::SharedPtr<fei::VectorSpace>
vecSpace,
103
bool
isSolutionVector,
104
int
numVectors)
105
{
106
std::vector<int> indices;
107
int
err = 0, localSize = 0;
108
if
(
reducer_
.get() != NULL) {
109
indices =
reducer_
->getLocalReducedEqns();
110
localSize = indices.size();
111
}
112
else
{
113
if
(
blockEntryMatrix_
) {
114
localSize = vecSpace->getNumBlkIndices_Owned();
115
indices.resize(localSize*2);
116
err = vecSpace->getBlkIndices_Owned(localSize, &indices[0], &indices[localSize], localSize);
117
}
118
else
{
119
localSize = vecSpace->getNumIndices_Owned();
120
err = vecSpace->getIndices_Owned(indices);
121
}
122
}
123
if
(err != 0) {
124
throw
std::runtime_error(
"fei::Factory_Aztec: error in vecSpace->getIndices_Owned"
);
125
}
126
127
fei::SharedPtr<fei::Vector>
feivec, tmpvec;
128
129
if
(
reducer_
.get() != NULL) {
130
feivec.
reset
(
new
fei::VectorReducer
(
reducer_
,
131
tmpvec, isSolutionVector));
132
}
133
else
{
134
feivec = tmpvec;
135
}
136
137
return
(feivec);
138
}
139
140
fei::SharedPtr<fei::Vector>
141
Factory_Aztec::createVector
(
fei::SharedPtr<fei::VectorSpace>
vecSpace,
142
int
numVectors)
143
{
144
bool
isSolnVector =
false
;
145
return
(
createVector
(vecSpace, isSolnVector, numVectors));
146
}
147
148
fei::SharedPtr<fei::Vector>
149
Factory_Aztec::createVector
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph,
150
int
numVectors)
151
{
152
bool
isSolnVector =
false
;
153
return
(
createVector
(matrixGraph, isSolnVector, numVectors));
154
}
155
156
fei::SharedPtr<fei::Vector>
157
Factory_Aztec::createVector
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph,
158
bool
isSolutionVector,
159
int
numVectors)
160
{
161
int
globalNumSlaves = matrixGraph->getGlobalNumSlaveConstraints();
162
163
if
(globalNumSlaves > 0 &&
reducer_
.get()==NULL) {
164
reducer_
= matrixGraph->getReducer();
165
}
166
167
fei::SharedPtr<fei::Vector>
feivec, tmpvec;
168
169
std::vector<int> indices;
170
int
err = 0, localSize;
171
fei::SharedPtr<fei::VectorSpace>
vecSpace = matrixGraph->getRowSpace();
172
if
(
reducer_
.get() != NULL) {
173
indices =
reducer_
->getLocalReducedEqns();
174
localSize = indices.size();
175
}
176
else
{
177
localSize = vecSpace->getNumIndices_Owned();
178
indices.resize(localSize);
179
err = vecSpace->getIndices_Owned(indices);
180
}
181
if
(err != 0) {
182
throw
std::runtime_error(
"error in vecSpace->getIndices_Owned"
);
183
}
184
185
if
(
reducer_
.get() != NULL) {
186
feivec.
reset
(
new
fei::VectorReducer
(
reducer_
, tmpvec, isSolutionVector));
187
}
188
else
{
189
feivec = tmpvec;
190
}
191
192
return
(feivec);
193
}
194
195
fei::SharedPtr<fei::Matrix>
196
Factory_Aztec::createMatrix
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph)
197
{
198
fei::SharedPtr<fei::Matrix>
feimat;
199
int
globalNumSlaves = matrixGraph->getGlobalNumSlaveConstraints();
200
201
if
(globalNumSlaves > 0 &&
reducer_
.get()==NULL) {
202
reducer_
= matrixGraph->getReducer();
203
}
204
205
return
feimat;
206
}
207
208
fei::SharedPtr<fei::Solver>
209
Factory_Aztec::createSolver
(
const
char
* name)
210
{
211
fei::SharedPtr<fei::Solver>
solver;
212
return
(solver);
213
}
214
Factory_Aztec::parameters
int parameters(int numParams, const char *const *paramStrings)
Definition
fei_Factory_Aztec.cpp:64
Factory_Aztec::createSolver
fei::SharedPtr< fei::Solver > createSolver(const char *name=0)
Definition
fei_Factory_Aztec.cpp:209
Factory_Aztec::outputLevel_
int outputLevel_
Definition
fei_Factory_Aztec.hpp:128
Factory_Aztec::createVector
fei::SharedPtr< fei::Vector > createVector(fei::SharedPtr< fei::VectorSpace > vecSpace, int numVectors=1)
Definition
fei_Factory_Aztec.cpp:141
Factory_Aztec::blockEntryMatrix_
bool blockEntryMatrix_
Definition
fei_Factory_Aztec.hpp:126
Factory_Aztec::createMatrix
fei::SharedPtr< fei::Matrix > createMatrix(fei::SharedPtr< fei::MatrixGraph > matrixGraph)
Definition
fei_Factory_Aztec.cpp:196
Factory_Aztec::comm_
MPI_Comm comm_
Definition
fei_Factory_Aztec.hpp:123
Factory_Aztec::Factory_Aztec
Factory_Aztec(MPI_Comm comm)
Definition
fei_Factory_Aztec.cpp:51
Factory_Aztec::createMatrixGraph
fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > colSpace, const char *name=NULL)
Definition
fei_Factory_Aztec.cpp:93
Factory_Aztec::reducer_
fei::SharedPtr< fei::Reducer > reducer_
Definition
fei_Factory_Aztec.hpp:125
Factory_Aztec::~Factory_Aztec
virtual ~Factory_Aztec()
Definition
fei_Factory_Aztec.cpp:60
fei::Factory::parameters
virtual void parameters(const fei::ParameterSet ¶mset)
Definition
fei_Factory.cpp:38
fei::Factory::Factory
Factory(MPI_Comm comm)
Definition
fei_Factory.cpp:20
fei::MatrixGraph_Impl2::Factory
Definition
fei_MatrixGraph_Impl2.hpp:36
fei::MatrixGraph_Impl2::Factory::createMatrixGraph
virtual fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > columnSpace, const char *name)
Definition
fei_MatrixGraph_Impl2.cpp:81
fei::ParameterSet
Definition
fei_ParameterSet.hpp:46
fei::ParameterSet::getIntParamValue
int getIntParamValue(const char *name, int ¶mValue) const
Definition
fei_ParameterSet.cpp:28
fei::ParameterSet::getBoolParamValue
int getBoolParamValue(const char *name, bool ¶mValue) const
Definition
fei_ParameterSet.cpp:69
fei::SharedPtr
Definition
fei_SharedPtr.hpp:65
fei::SharedPtr::reset
void reset(T *p=0)
Definition
fei_SharedPtr.hpp:203
fei::VectorReducer
Definition
fei_VectorReducer.hpp:24
fei_Factory_Aztec.hpp
fei_MatrixReducer.hpp
fei_VectorReducer.hpp
MPI_Comm
#define MPI_Comm
Definition
fei_mpi.h:56
fei_trilinos_macros.hpp
fei::utils::parse_strings
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
Definition
fei_utils.cpp:191
fei::utils::char_ptrs_to_strings
void char_ptrs_to_strings(int numStrings, const char *const *charstrings, std::vector< std::string > &stdstrings)
Definition
fei_utils.cpp:164
fei
Definition
fei_ArrayUtils.hpp:16
Generated by
1.17.0