FEI Package Browser (Single Doxygen Collection)
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
base
snl_fei_Factory.cpp
Go to the documentation of this file.
1
/*--------------------------------------------------------------------*/
2
/* Copyright 2005 Sandia Corporation. */
3
/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4
/* non-exclusive license for use of this work by or on behalf */
5
/* of the U.S. Government. Export of this program may require */
6
/* a license from the United States Government. */
7
/*--------------------------------------------------------------------*/
8
#ifndef _snl_fei_Factory_cpp_
9
#define _snl_fei_Factory_cpp_
10
11
#include <
fei_macros.hpp
>
12
13
#include <
snl_fei_Factory.hpp
>
14
15
//----------------------------------------------------------------------------
16
snl_fei::Factory::Factory
(
MPI_Comm
comm,
17
fei::SharedPtr<LibraryWrapper>
wrapper)
18
:
fei
::
Factory
(comm),
19
comm_
(comm),
20
broker_
(),
21
matrixGraph_
(),
22
nodeIDType_
(0),
23
lsc_
(),
24
feData_
(),
25
wrapper_
(wrapper),
26
outputLevel_
(0),
27
blockMatrix_
(false)
28
{
29
if
(
wrapper_
.get() != NULL) {
30
lsc_ = wrapper->getLinearSystemCore();
31
feData_ = wrapper->getFiniteElementData();
32
}
33
}
34
35
//----------------------------------------------------------------------------
36
snl_fei::Factory::Factory
(
MPI_Comm
comm,
37
fei::SharedPtr<LinearSystemCore>
lsc)
38
:
fei
::
Factory
(comm),
39
comm_
(comm),
40
broker_
(),
41
matrixGraph_
(),
42
nodeIDType_
(0),
43
lsc_
(lsc),
44
feData_
(),
45
wrapper_
(),
46
outputLevel_
(0),
47
blockMatrix_
(false)
48
{
49
}
50
51
//----------------------------------------------------------------------------
52
snl_fei::Factory::Factory
(
MPI_Comm
comm,
53
fei::SharedPtr<FiniteElementData>
feData,
int
nodeIDType)
54
:
fei
::
Factory
(comm),
55
comm_
(comm),
56
broker_
(),
57
matrixGraph_
(),
58
nodeIDType_
(nodeIDType),
59
lsc_
(),
60
feData_
(feData),
61
wrapper_
(NULL),
62
outputLevel_
(0),
63
blockMatrix_
(false)
64
{
65
}
66
67
//----------------------------------------------------------------------------
68
snl_fei::Factory::~Factory
()
69
{
70
}
71
72
//----------------------------------------------------------------------------
73
fei::SharedPtr<fei::Factory>
74
snl_fei::Factory::clone
()
const
75
{
76
fei::SharedPtr<fei::Factory>
factory;
77
if
(
wrapper_
.get() != NULL) {
78
factory.
reset
(
new
snl_fei::Factory
(
comm_
,
wrapper_
));
79
}
80
else
if
(
lsc_
.get() != NULL) {
81
factory.
reset
(
new
snl_fei::Factory
(
comm_
,
lsc_
));
82
}
83
else
if
(
feData_
.get() != NULL) {
84
factory.
reset
(
new
snl_fei::Factory
(
comm_
,
feData_
,
nodeIDType_
));
85
}
86
87
return
(factory);
88
}
89
90
//----------------------------------------------------------------------------
91
void
92
snl_fei::Factory::parameters
(
const
fei::ParameterSet
& parameterset)
93
{
94
fei::Factory::parameters
(parameterset);
95
96
int
err = 0;
97
if
(
lsc_
.get() != NULL ||
feData_
.get() != NULL) {
98
int
numParams = 0;
99
const
char
** paramStrings = NULL;
100
std::vector<std::string> stdstrings;
101
fei::utils::convert_ParameterSet_to_strings
(¶meterset, stdstrings);
102
fei::utils::strings_to_char_ptrs
(stdstrings, numParams, paramStrings);
103
char
** nc_paramStrings =
const_cast<
char
**
>
(paramStrings);
104
if
(
lsc_
.get() != NULL) {
105
err +=
lsc_
->parameters(numParams, nc_paramStrings);
106
}
107
if
(
feData_
.get() != NULL) {
108
err +=
feData_
->parameters(numParams, nc_paramStrings);
109
}
110
111
delete
[] paramStrings;
112
113
if
(err != 0) {
114
FEI_OSTRINGSTREAM
osstr;
115
osstr <<
"snl_fei::Factory::parameters received err="
<<err
116
<<
" from either feiData_->parameters or lsc_->parameters."
;
117
throw
std::runtime_error(osstr.str());
118
}
119
}
120
121
parameterset.
getIntParamValue
(
"outputLevel"
,
outputLevel_
);
122
123
const
fei::Param
* param = 0;
124
fei::Param::ParamType
ptype =
fei::Param::BAD_TYPE
;
125
126
param = parameterset.
get
(
"BLOCK_GRAPH"
);
127
ptype = param != NULL ? param->
getType
() :
fei::Param::BAD_TYPE
;
128
if
(ptype !=
fei::Param::BAD_TYPE
) {
129
blockMatrix_
=
true
;
130
}
131
132
param = parameterset.
get
(
"BLOCK_MATRIX"
);
133
ptype = param != NULL ? param->
getType
() :
fei::Param::BAD_TYPE
;
134
if
(ptype !=
fei::Param::BAD_TYPE
) {
135
if
(ptype ==
fei::Param::BOOL
) {
136
blockMatrix_
= param->
getBoolValue
();
137
}
138
else
{
139
blockMatrix_
=
true
;
140
}
141
}
142
143
param = parameterset.
get
(
"AZ_matrix_type"
);
144
ptype = param != NULL ? param->
getType
() :
fei::Param::BAD_TYPE
;
145
if
(ptype !=
fei::Param::BAD_TYPE
) {
146
if
(ptype ==
fei::Param::STRING
) {
147
if
(param->
getStringValue
() ==
"AZ_VBR_MATRIX"
) {
148
blockMatrix_
=
true
;
149
}
150
}
151
}
152
}
153
154
//----------------------------------------------------------------------------
155
fei::SharedPtr<fei::MatrixGraph>
156
snl_fei::Factory::createMatrixGraph
(
fei::SharedPtr<fei::VectorSpace>
rowSpace,
157
fei::SharedPtr<fei::VectorSpace>
columnSpace,
158
const
char
* name)
159
{
160
static
fei::MatrixGraph_Impl2::Factory
factory;
161
matrixGraph_
= factory.
createMatrixGraph
(rowSpace, columnSpace, name);
162
return
(
matrixGraph_
);
163
}
164
165
//----------------------------------------------------------------------------
166
fei::SharedPtr<fei::Vector>
167
snl_fei::Factory::createVector
(
fei::SharedPtr<fei::VectorSpace>
vecSpace,
168
int
numVectors)
169
{
170
(void)vecSpace;
171
fei::SharedPtr<fei::Vector>
dummy;
172
if
(
matrixGraph_
.get() == NULL) {
173
fei::console_out
() <<
"snl_fei::Factory ERROR: when using LinearSystemCore or FiniteElementData"
174
<<
", you must create a MatrixGraph before you can create vectors"
<<
FEI_ENDL
;
175
return
(dummy);
176
}
177
178
if
(
matrixGraph_
->getGlobalNumSlaveConstraints() > 0 &&
179
reducer_
.get() == NULL) {
180
reducer_
=
matrixGraph_
->getReducer();
181
}
182
183
createBroker
(
matrixGraph_
);
184
185
return
(
broker_
->createVector() );
186
}
187
188
//----------------------------------------------------------------------------
189
fei::SharedPtr<fei::Vector>
190
snl_fei::Factory::createVector
(
fei::SharedPtr<fei::VectorSpace>
vecSpace,
191
bool
isSolutionVector,
192
int
numVectors)
193
{
194
fei::SharedPtr<fei::Vector>
dummy;
195
(void)vecSpace;
196
if
(
matrixGraph_
.get() == NULL) {
197
fei::console_out
() <<
"snl_fei::Factory ERROR: when using LinearSystemCore"
198
<<
", you must create a MatrixGraph before you can create vectors"
<<
FEI_ENDL
;
199
return
(dummy);
200
}
201
202
if
(
matrixGraph_
->getGlobalNumSlaveConstraints() > 0 &&
203
reducer_
.get() == NULL) {
204
reducer_
=
matrixGraph_
->getReducer();
205
}
206
207
createBroker
(
matrixGraph_
);
208
209
return
(
broker_
->createVector(isSolutionVector) );
210
}
211
212
//----------------------------------------------------------------------------
213
fei::SharedPtr<fei::Vector>
214
snl_fei::Factory::createVector
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph,
215
int
numVectors)
216
{
217
matrixGraph_
= matrixGraph;
218
219
if
(
matrixGraph_
->getGlobalNumSlaveConstraints() > 0 &&
220
reducer_
.get() == NULL) {
221
reducer_
=
matrixGraph_
->getReducer();
222
}
223
224
createBroker
(
matrixGraph_
);
225
226
return
(
broker_
->createVector() );
227
}
228
229
//----------------------------------------------------------------------------
230
fei::SharedPtr<fei::Vector>
231
snl_fei::Factory::createVector
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph,
232
bool
isSolutionVector,
233
int
numVectors)
234
{
235
matrixGraph_
= matrixGraph;
236
237
if
(
matrixGraph_
->getGlobalNumSlaveConstraints() > 0 &&
238
reducer_
.get() == NULL) {
239
reducer_
=
matrixGraph_
->getReducer();
240
}
241
242
createBroker
(
matrixGraph_
);
243
244
return
(
broker_
->createVector(isSolutionVector) );
245
}
246
247
//----------------------------------------------------------------------------
248
fei::SharedPtr<fei::Matrix>
249
snl_fei::Factory::createMatrix
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph)
250
{
251
matrixGraph_
= matrixGraph;
252
fei::SharedPtr<fei::Matrix>
mptr;
253
254
if
(
matrixGraph_
.get() == NULL) {
255
fei::console_out
() <<
"snl_fei::Factory ERROR: when using LinearSystemCore"
256
<<
", you must create a MatrixGraph before you can create matrices"
<<
FEI_ENDL
;
257
return
(mptr);
258
}
259
260
if
(
matrixGraph_
->getGlobalNumSlaveConstraints() > 0 &&
261
reducer_
.get() == NULL) {
262
reducer_
=
matrixGraph_
->getReducer();
263
}
264
265
createBroker
(
matrixGraph_
);
266
267
broker_
->setMatrixGraph(matrixGraph);
268
269
return
(
broker_
->createMatrix());
270
}
271
272
//----------------------------------------------------------------------------
273
fei::SharedPtr<fei::LinearSystem>
274
snl_fei::Factory::createLinearSystem
(
fei::SharedPtr<fei::MatrixGraph>
& matrixGraph)
275
{
276
matrixGraph_
= matrixGraph;
277
278
if
(
matrixGraph_
.get() == NULL) {
279
fei::console_out
() <<
"snl_fei::Factory ERROR: you may not create a LinearSystem with "
280
<<
"a NULL MatrixGraph object."
<<
FEI_ENDL
;
281
fei::SharedPtr<fei::LinearSystem>
linsys;
282
return
(linsys);
283
}
284
285
if
(
matrixGraph_
->getGlobalNumSlaveConstraints() > 0 &&
286
reducer_
.get() == NULL) {
287
reducer_
=
matrixGraph_
->getReducer();
288
}
289
290
createBroker
(
matrixGraph_
);
291
292
broker_
->setMatrixGraph(matrixGraph);
293
294
return
(
broker_
->createLinearSystem() );
295
}
296
297
//----------------------------------------------------------------------------
298
fei::SharedPtr<fei::Solver>
299
snl_fei::Factory::createSolver
(
const
char
* name)
300
{
301
fei::SharedPtr<fei::Solver>
solver(
new
fei::Solver
);
302
return
(solver);
303
}
304
305
//----------------------------------------------------------------------------
306
fei::SharedPtr<LibraryWrapper>
307
snl_fei::Factory::get_LibraryWrapper
()
const
308
{
309
return
(
wrapper_
);
310
}
311
312
//----------------------------------------------------------------------------
313
int
snl_fei::Factory::getOutputLevel
()
const
314
{
315
return
(
outputLevel_
);
316
}
317
318
//----------------------------------------------------------------------------
319
int
320
snl_fei::Factory::createBroker
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph)
321
{
322
int
err = -1;
323
if
(
lsc_
.get() != NULL) {
324
err =
createBroker_LinSysCore
(matrixGraph,
lsc_
);
325
}
326
if
(
feData_
.get() != NULL) {
327
err =
createBroker_FEData
(matrixGraph,
feData_
);
328
}
329
330
return
(err);
331
}
332
333
//----------------------------------------------------------------------------
334
int
335
snl_fei::Factory::createBroker_LinSysCore
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph,
336
fei::SharedPtr<LinearSystemCore>
lsc)
337
{
338
if
(
broker_
.get() == NULL) {
339
fei::SharedPtr<snl_fei::Broker>
brokerptr(
new
snl_fei::Broker_LinSysCore
(lsc, matrixGraph,
reducer_
,
blockMatrix_
));
340
broker_
= brokerptr;
341
}
342
343
return
(0);
344
}
345
346
//----------------------------------------------------------------------------
347
int
348
snl_fei::Factory::createBroker_FEData
(
fei::SharedPtr<fei::MatrixGraph>
matrixGraph,
349
fei::SharedPtr<FiniteElementData>
feData)
350
{
351
if
(
broker_
.get() == NULL) {
352
fei::SharedPtr<snl_fei::Broker>
353
brokerptr(
new
snl_fei::Broker_FEData
(feData, matrixGraph,
354
nodeIDType_
));
355
broker_
= brokerptr;
356
}
357
358
return
(0);
359
}
360
361
362
#endif
363
fei::Factory::Factory
Factory()
fei::Factory::parameters
virtual void parameters(const fei::ParameterSet ¶mset)
Definition
fei_Factory.cpp:38
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::Param
Definition
fei_Param.hpp:23
fei::Param::getStringValue
const std::string & getStringValue() const
Definition
fei_Param.hpp:104
fei::Param::ParamType
ParamType
Definition
fei_Param.hpp:26
fei::Param::BAD_TYPE
@ BAD_TYPE
Definition
fei_Param.hpp:32
fei::Param::STRING
@ STRING
Definition
fei_Param.hpp:27
fei::Param::BOOL
@ BOOL
Definition
fei_Param.hpp:30
fei::Param::getType
ParamType getType() const
Definition
fei_Param.hpp:98
fei::Param::getBoolValue
bool getBoolValue() const
Definition
fei_Param.hpp:122
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::get
const Param * get(const char *name) const
Definition
fei_ParameterSet.hpp:260
fei::SharedPtr
Definition
fei_SharedPtr.hpp:65
fei::SharedPtr::reset
void reset(T *p=0)
Definition
fei_SharedPtr.hpp:203
fei::Solver
Definition
fei_Solver.hpp:22
snl_fei::Broker_FEData
Definition
snl_fei_Broker_FEData.hpp:34
snl_fei::Broker_LinSysCore
Definition
snl_fei_Broker_LinSysCore.hpp:37
snl_fei::Factory
Definition
snl_fei_Factory.hpp:35
snl_fei::Factory::get_LibraryWrapper
fei::SharedPtr< LibraryWrapper > get_LibraryWrapper() const
Definition
snl_fei_Factory.cpp:307
snl_fei::Factory::createSolver
virtual fei::SharedPtr< fei::Solver > createSolver(const char *name=0)
Definition
snl_fei_Factory.cpp:299
snl_fei::Factory::createBroker_LinSysCore
int createBroker_LinSysCore(fei::SharedPtr< fei::MatrixGraph > matrixGraph, fei::SharedPtr< LinearSystemCore > lsc)
Definition
snl_fei_Factory.cpp:335
snl_fei::Factory::outputLevel_
int outputLevel_
Definition
snl_fei_Factory.hpp:120
snl_fei::Factory::createVector
virtual fei::SharedPtr< fei::Vector > createVector(fei::SharedPtr< fei::VectorSpace > vecSpace, int numVectors=1)
Definition
snl_fei_Factory.cpp:167
snl_fei::Factory::Factory
Factory(MPI_Comm comm, fei::SharedPtr< LibraryWrapper > wrapper)
Definition
snl_fei_Factory.cpp:16
snl_fei::Factory::~Factory
virtual ~Factory()
Definition
snl_fei_Factory.cpp:68
snl_fei::Factory::createMatrixGraph
virtual fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > columnSpace, const char *name)
Definition
snl_fei_Factory.cpp:156
snl_fei::Factory::reducer_
fei::SharedPtr< fei::Reducer > reducer_
Definition
snl_fei_Factory.hpp:113
snl_fei::Factory::createLinearSystem
virtual fei::SharedPtr< fei::LinearSystem > createLinearSystem(fei::SharedPtr< fei::MatrixGraph > &matrixGraph)
Definition
snl_fei_Factory.cpp:274
snl_fei::Factory::lsc_
fei::SharedPtr< LinearSystemCore > lsc_
Definition
snl_fei_Factory.hpp:117
snl_fei::Factory::createMatrix
virtual fei::SharedPtr< fei::Matrix > createMatrix(fei::SharedPtr< fei::MatrixGraph > matrixGraph)
Definition
snl_fei_Factory.cpp:249
snl_fei::Factory::createBroker
int createBroker(fei::SharedPtr< fei::MatrixGraph > matrixGraph)
Definition
snl_fei_Factory.cpp:320
snl_fei::Factory::createBroker_FEData
int createBroker_FEData(fei::SharedPtr< fei::MatrixGraph > matrixGraph, fei::SharedPtr< FiniteElementData > feData)
Definition
snl_fei_Factory.cpp:348
snl_fei::Factory::matrixGraph_
fei::SharedPtr< fei::MatrixGraph > matrixGraph_
Definition
snl_fei_Factory.hpp:112
snl_fei::Factory::clone
fei::SharedPtr< fei::Factory > clone() const
Definition
snl_fei_Factory.cpp:74
snl_fei::Factory::wrapper_
fei::SharedPtr< LibraryWrapper > wrapper_
Definition
snl_fei_Factory.hpp:119
snl_fei::Factory::comm_
MPI_Comm comm_
Definition
snl_fei_Factory.hpp:110
snl_fei::Factory::getOutputLevel
int getOutputLevel() const
Definition
snl_fei_Factory.cpp:313
snl_fei::Factory::nodeIDType_
int nodeIDType_
Definition
snl_fei_Factory.hpp:115
snl_fei::Factory::broker_
fei::SharedPtr< snl_fei::Broker > broker_
Definition
snl_fei_Factory.hpp:111
snl_fei::Factory::feData_
fei::SharedPtr< FiniteElementData > feData_
Definition
snl_fei_Factory.hpp:118
snl_fei::Factory::blockMatrix_
bool blockMatrix_
Definition
snl_fei_Factory.hpp:121
snl_fei::Factory::parameters
virtual void parameters(const fei::ParameterSet ¶meterset)
Definition
snl_fei_Factory.cpp:92
FEI_ENDL
#define FEI_ENDL
Definition
fei_iostream.hpp:34
fei_macros.hpp
MPI_Comm
#define MPI_Comm
Definition
fei_mpi.h:56
FEI_OSTRINGSTREAM
#define FEI_OSTRINGSTREAM
Definition
fei_sstream.hpp:32
fei::utils::convert_ParameterSet_to_strings
void convert_ParameterSet_to_strings(const fei::ParameterSet *paramset, std::vector< std::string > ¶mStrings)
Definition
fei_utils.cpp:270
fei::utils::strings_to_char_ptrs
void strings_to_char_ptrs(std::vector< std::string > &stdstrings, int &numStrings, const char **&charPtrs)
Definition
fei_utils.cpp:178
fei
Definition
fei_ArrayUtils.hpp:16
fei::console_out
std::ostream & console_out()
Definition
fei_console_ostream.cpp:26
snl_fei_Factory.hpp
Generated by
1.17.0