14 #include <fei_macros.hpp>
21 #include <fei_base.hpp>
22 #include <FEI_Implementation.hpp>
27 #include <test_utils/LibraryFactory.hpp>
32 #include <test_utils/HexBeam.hpp>
33 #include <test_utils/HexBeamCR.hpp>
35 #include <test_utils/fei_test_utils.hpp>
36 #include <snl_fei_Utils.hpp>
39 #define fei_file "cube_main.cpp"
40 #include <fei_ErrMacros.hpp>
45 int beam_oldfei_main(
int argc,
char** argv,
46 MPI_Comm comm,
int numProcs,
int localProc){
48 std::vector<std::string> stdstrings;
53 const char** params = NULL;
61 std::string solverName;
62 std::string datasource;
76 fei::console_out() <<
"Failed to find one or more required parameters in input-file."
77 << FEI_ENDL <<
"Required parameters:"<<FEI_ENDL
78 <<
"SOLVER_LIBRARY" << FEI_ENDL
79 <<
"DATA_SOURCE" << FEI_ENDL
80 <<
"CONSTRAINT_FORM" << FEI_ENDL
81 <<
"W" << FEI_ENDL <<
"D" << FEI_ENDL <<
"DofPerNode" << FEI_ENDL;
86 if (datasource ==
"HexBeam") {
87 hexcubeptr =
new HexBeam(W, D, DofPerNode,
88 HexBeam::OneD, numProcs, localProc);
91 hexcubeptr =
new HexBeamCR(W, D, DofPerNode,
92 HexBeam::OneD, numProcs, localProc);
98 int numCRs = (W+1)*(W+1)*(numProcs*2)-1;
99 if (hexcube.getNumCRs() < 1) numCRs = 0;
100 FEI_COUT << FEI_ENDL;
101 FEI_COUT <<
"========================================================"
103 FEI_COUT <<
"Size W: " << W <<
" (num-elements-along-side-of-cube)"<<FEI_ENDL;
104 FEI_COUT <<
"Size D: " << D <<
" (num-elements-along-depth-of-cube)"<<FEI_ENDL;
105 FEI_COUT <<
"DOF per node: " << DofPerNode <<FEI_ENDL;
106 FEI_COUT <<
"Num local elements: " << hexcube.localNumElems_ << FEI_ENDL;
107 FEI_COUT <<
"Num global elements: " << hexcube.totalNumElems_ << FEI_ENDL;
108 FEI_COUT <<
"Num local DOF: " << hexcube.numLocalDOF_ << FEI_ENDL;
109 FEI_COUT <<
"Num global DOF: " << hexcube.numGlobalDOF_ << FEI_ENDL;
110 FEI_COUT <<
"Num global CRs: " << numCRs << FEI_ENDL;
111 FEI_COUT <<
"========================================================"
123 if (whichFEI ==
"OLDFEI") {
127 catch (std::runtime_error& exc) {
133 else if (whichFEI ==
"fei::FEI_Impl") {
137 catch (std::runtime_error& exc) {
144 fei::console_out() <<
"cube ERROR, value of 'WHICH_FEI' must be 'OLDFEI' or 'fei::FEI_Impl'"<< FEI_ENDL;
149 CHK_ERR( fei->
parameters(numParams, params) );
156 int fieldSize = hexcube.numDofPerNode();
158 CHK_ERR( fei->
initFields( 1, &fieldSize, &fieldID ) );
160 CHK_ERR( HexBeam_Functions::init_elem_connectivities( fei.
get(), hexcube ) );
162 CHK_ERR( HexBeam_Functions::init_shared_nodes( fei.
get(), hexcube ) );
165 CHK_ERR( HexBeam_Functions::
166 init_constraints( fei.
get(), hexcube, firstLocalCRID) );
172 if (localProc == 0) {
173 FEI_COUT.setf(IOS_FIXED, IOS_FLOATFIELD);
174 FEI_COUT <<
"Initialization time: " << fei_init_time << FEI_ENDL;
184 CHK_ERR( HexBeam_Functions::load_elem_data(fei.
get(), hexcube) );
186 CHK_ERR( HexBeam_Functions::load_constraints(fei.
get(), hexcube, firstLocalCRID) );
197 if (localProc == 0) {
199 FEI_COUT.setf(IOS_FIXED, IOS_FLOATFIELD);
200 FEI_COUT <<
"Coef. loading time: " << fei_load_time << FEI_ENDL;
201 FEI_COUT <<
"Total assembly time: " << fei_init_time + fei_load_time << FEI_ENDL;
213 err = fei->
solve(status);
216 if (localProc==0) FEI_COUT <<
"solve returned status: " << status << FEI_ENDL;
221 if (localProc == 0) {
222 FEI_COUT <<
"Solver time: " << solve_time << FEI_ENDL;
226 if (localProc == 0) {
227 #if defined(FEI_PLATFORM) && defined(FEI_OPT_LEVEL)
228 double benchmark = fei_init_time;
230 FEI_OSTRINGSTREAM testname_init;
231 testname_init <<
"cube_"<<whichFEI<<
"_init_"<<W<<
"_"<<D<<
"_"<<DofPerNode<<
"_"
232 <<solverName<<
"_np"<<numProcs<<
"_"
233 <<FEI_PLATFORM<<
"_"<<FEI_OPT_LEVEL;
235 FEI_OSTRINGSTREAM testname_load;
236 testname_load <<
"cube_"<<whichFEI<<
"_load_"<<W<<
"_"<<D<<
"_"<<DofPerNode<<
"_"
237 <<solverName<<
"_np"<<numProcs<<
"_"
238 <<FEI_PLATFORM<<
"_"<<FEI_OPT_LEVEL;
240 double file_init, file_load;
241 bool file_benchmarks_available =
true;
244 testname_init.str().c_str());
246 testname_load.str().c_str());
248 catch (std::runtime_error& exc) {
249 file_benchmarks_available =
false;
252 if (file_benchmarks_available) {
254 bool init_test_passed =
255 fei_test_utils::check_and_cout_test_result(testname_init.str(), benchmark,
258 benchmark = fei_load_time;
259 bool load_test_passed =
260 fei_test_utils::check_and_cout_test_result(testname_load.str(), benchmark,
263 returnValue = init_test_passed&&load_test_passed ? 0 : 1;
268 bool testPassed = returnValue==0;
269 if (testPassed && localProc == 0) {
271 FEI_COUT <<
"cube execution successful" << FEI_ENDL;
void strings_to_char_ptrs(std::vector< std::string > &stdstrings, int &numStrings, const char **&charPtrs)
virtual int parameters(int numParams, const char *const *paramStrings)=0
virtual int initComplete()=0
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
virtual int solve(int &status)=0
int getStringParamValue(const char *name, std::string ¶mValue) const
double get_file_benchmark(const char *filename, const char *testname)
int get_filename_and_read_input(int argc, char **argv, MPI_Comm comm, int localProc, std::vector< std::string > &stdstrings)
virtual int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)=0
virtual int setSolveType(int solveType)=0
std::ostream & console_out()
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
virtual int loadComplete(bool applyBCs=true, bool globalAssemble=true)=0
virtual fei::SharedPtr< FEI > createFEI(fei::SharedPtr< LibraryWrapper > wrapper, MPI_Comm comm)
fei::SharedPtr< LibraryWrapper > create_LibraryWrapper(MPI_Comm comm, const char *libraryName)
int getIntParamValue(const char *name, int ¶mValue) const