FEI Package Browser (Single Doxygen Collection)
Version of the Day
test_utils
feiDriver_main.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
9
//
10
// This is a simple program to exercise the FEI.
11
//
12
#include <
fei_macros.hpp
>
13
14
15
//Including the header fei_base.hpp gets us the declaration for
16
//most FEI classes.
17
18
#include <
fei_base.hpp
>
19
#include <
FEI_Implementation.hpp
>
20
21
#include <
fei_LibraryWrapper.hpp
>
22
#include <
test_utils/LibraryFactory.hpp
>
23
24
#include <
test_utils/Poisson_Elem.hpp
>
25
#include <
test_utils/PoissonData.hpp
>
26
27
#include <
test_utils/ElemBlock.hpp
>
28
#include <
test_utils/CRSet.hpp
>
29
#include <
test_utils/BCNodeSet.hpp
>
30
#include <
test_utils/CommNodeSet.hpp
>
31
#include <
test_utils/DataReader.hpp
>
32
#include <
test_utils/driverData.hpp
>
33
#include <
test_utils/fei_test_utils.hpp
>
34
#include <
test_utils/SolnCheck.hpp
>
35
36
#undef fei_file
37
#define fei_file "feiDriver.cpp"
38
#include <
fei_ErrMacros.hpp
>
39
40
//==============================================================================
41
//Here's the main...
42
//==============================================================================
43
int
feiDriver_main
(
int
argc,
char
** argv,
44
MPI_Comm
comm,
int
numProcs
,
int
localProc
){
45
46
std::vector<std::string> stdstrings;
47
CHK_ERR
(
fei_test_utils::get_filename_and_read_input
(argc, argv,
48
comm,
localProc
,
49
stdstrings) );
50
const
char
** params = NULL;
51
int
numParams = 0;
52
fei::utils::strings_to_char_ptrs
(stdstrings, numParams, params);
53
54
fei::ParameterSet
paramset;
55
fei::utils::parse_strings
(stdstrings,
" "
, paramset);
56
57
std::string solverName;
58
std::string inputFileName;
59
int
errcode = paramset.
getStringParamValue
(
"SOLVER_LIBRARY"
, solverName);
60
errcode += paramset.
getStringParamValue
(
"INPUT_FILE"
, inputFileName);
61
if
(errcode != 0) {
62
fei::console_out
() <<
"Expected to find both 'SOLVER_NAME' and 'INPUT_FILE' "
63
<<
"in input-file."
<<
FEI_ENDL
;
64
return
(-1);
65
}
66
67
//let's add the appropriate file-name extension to the file-name obtained from
68
//the input...
69
FEI_OSTRINGSTREAM
fullFileName;
70
fullFileName<< inputFileName<<
"."
<<
numProcs
<<
"."
<<
localProc
;
71
72
driverData
drv;
73
CHK_ERR
( drv.
readData
(fullFileName.str().c_str()) );
74
75
//ok, all the data is in the 'data' object, so we're ready to start
76
//handing it all over to an instantiation of the FEI.
77
78
//first, we have to instantiate a LibraryWrapper and an FEI...
79
80
fei::SharedPtr<LibraryWrapper>
wrapper;
81
try
{
82
wrapper =
fei::create_LibraryWrapper
(comm, solverName.c_str());
83
}
84
catch
(std::runtime_error& exc) {
85
fei::console_out
() << exc.what() <<
FEI_ENDL
;
86
ERReturn
(-1);
87
}
88
89
fei::SharedPtr<FEI>
fei
(
new
FEI_Implementation
(wrapper, comm));
90
91
const
char
* feiVersionString;
92
CHK_ERR
(
fei
->version(feiVersionString) );
93
94
FEI_COUT
<<
FEI_ENDL
<<
"FEI version: "
<< feiVersionString <<
FEI_ENDL
<<
FEI_ENDL
;
95
96
CHK_ERR
(
fei
->parameters(numParams, params) );
97
98
std::vector<const char*>& methodNames = drv.
get_methodNames
();
99
100
for
(
size_t
i=0; i<methodNames.size(); i++) {
101
if
(!strcmp(
"destructor"
, methodNames[i])) {
102
//In some cases the input file indicates that the FEI should be
103
//destroyed and then re-allocated before continuing. Note that we
104
//assume here that the solver-layer (linsyscore, wrapper or feData)
105
//should also be destroyed and re-allocated at the same time.
106
FEI_COUT
<<
"feiDriver: proc "
<<
localProc
<<
" destroying/reallocing FEI"
107
<<
FEI_ENDL
;
108
109
fei
.reset();
110
wrapper.
reset
();
111
try
{
112
wrapper =
fei::create_LibraryWrapper
(comm, solverName.c_str());
113
}
114
catch
(std::runtime_error& exc) {
115
fei::console_out
() << exc.what()<<
FEI_ENDL
;
116
ERReturn
(-1);
117
}
118
119
fei
.reset(
new
FEI_Implementation
(wrapper, comm));
120
121
CHK_ERR
(
fei
->parameters(numParams, params) );
122
123
continue
;
124
}
125
126
FEI_COUT
<<
"feiDriver: proc "
<<
localProc
<<
" calling FEI method: "
127
<< methodNames[i] <<
FEI_ENDL
;
128
int
feierror = drv.
call_fei_method
(methodNames[i],
fei
.get());
129
if
(feierror > 0)
continue
;
130
if
(feierror < 0) {
131
//for testing purposes, temporarily, don't bail out if an fei method
132
//returns an error.
133
continue
;
134
//return(-1);
135
}
136
}
137
138
MPI_Barrier
(comm);
139
140
if
(
localProc
== 0) {
141
FEI_COUT
<<
"feiDriver: TEST PASSED"
<<
FEI_ENDL
;
142
143
//This is something the SIERRA runtest tool looks for in test output...
144
FEI_COUT
<<
"SIERRA execution successful"
<<
FEI_ENDL
;
145
#ifdef SIERRA_BUILD_DATE
146
FEI_COUT
.setf(
IOS_FIXED
,
IOS_FLOATFIELD
);
147
FEI_COUT
<<
"Maximum CPU time: 0.0 seconds."
<<
FEI_ENDL
;
148
#endif
149
}
150
151
delete
[] params;
152
153
return
(0);
154
}
fei::create_LibraryWrapper
fei::SharedPtr< LibraryWrapper > create_LibraryWrapper(MPI_Comm comm, const char *libraryName)
Definition:
LibraryFactory.cpp:30
CommNodeSet.hpp
fei_base.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_Implementation.hpp
CHK_ERR
#define CHK_ERR(a)
Definition:
fei_ErrMacros.hpp:26
IOS_FLOATFIELD
#define IOS_FLOATFIELD
Definition:
fei_iostream.hpp:56
FEI_ENDL
#define FEI_ENDL
Definition:
fei_iostream.hpp:34
CRSet.hpp
feiDriver_main
int feiDriver_main(int argc, char **argv, MPI_Comm comm, int numProcs, int localProc)
Definition:
feiDriver_main.cpp:43
ElemBlock.hpp
IOS_FIXED
#define IOS_FIXED
Definition:
fei_iostream.hpp:57
MPI_Barrier
#define MPI_Barrier(a)
Definition:
fei_mpi.h:61
fei::SharedPtr< LibraryWrapper >
driverData
Definition:
driverData.hpp:161
fei_macros.hpp
DataReader.hpp
LibraryFactory.hpp
fei_test_utils.hpp
driverData::readData
int readData(const char *fileName)
Definition:
driverData.cpp:105
driverData::get_methodNames
std::vector< const char * > & get_methodNames()
Definition:
driverData.hpp:174
fei::ParameterSet
Definition:
fei_ParameterSet.hpp:46
SolnCheck.hpp
FEI_OSTRINGSTREAM
#define FEI_OSTRINGSTREAM
Definition:
fei_sstream.hpp:32
ERReturn
#define ERReturn(a)
Definition:
fei_ErrMacros.hpp:37
fei::ParameterSet::getStringParamValue
int getStringParamValue(const char *name, std::string ¶mValue) const
Definition:
fei_ParameterSet.cpp:57
driverData.hpp
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_test_utils::get_filename_and_read_input
int get_filename_and_read_input(int argc, char **argv, MPI_Comm comm, int localProc, std::vector< std::string > &stdstrings)
Definition:
fei_test_utils.cpp:174
FEI_Implementation
#define FEI_Implementation
Definition:
fei_version.h:66
fei
Definition:
fei_ArrayUtils.hpp:16
FEI_COUT
#define FEI_COUT
Definition:
fei_iostream.hpp:33
MPI_Comm
#define MPI_Comm
Definition:
fei_mpi.h:56
fei::localProc
int localProc(MPI_Comm comm)
Definition:
fei_CommUtils.cpp:13
fei_ErrMacros.hpp
BCNodeSet.hpp
fei::SharedPtr::reset
void reset(T *p=0)
Definition:
fei_SharedPtr.hpp:203
fei_LibraryWrapper.hpp
fei::numProcs
int numProcs(MPI_Comm comm)
Definition:
fei_CommUtils.cpp:25
fei::console_out
std::ostream & console_out()
Definition:
fei_console_ostream.cpp:26
driverData::call_fei_method
int call_fei_method(const char *method, FEI *fei)
Definition:
driverData.cpp:134
PoissonData.hpp
Poisson_Elem.hpp
Generated by
1.8.16