14 #include <fei_macros.hpp>
19 #include <fei_base.hpp>
24 #include <test_utils/LibraryFactory.hpp>
29 #include <test_utils/HexBeam.hpp>
30 #include <test_utils/HexBeamCR.hpp>
31 #include <snl_fei_Utils.hpp>
32 #include <test_utils/fei_test_utils.hpp>
37 #define fei_file "cube3.cpp"
38 #include <fei_ErrMacros.hpp>
43 int beam_main(
int argc,
char** argv,
44 MPI_Comm comm,
int numProcs,
int localProc){
48 std::vector<std::string> stdstrings;
55 std::string solverName;
56 std::string datasource;
57 std::string constraintform;
70 fei::console_out() <<
"Failed to find one or more required parameters in input-file."
71 << FEI_ENDL <<
"Required parameters:"<<FEI_ENDL
72 <<
"SOLVER_LIBRARY" << FEI_ENDL
73 <<
"DATA_SOURCE" << FEI_ENDL
74 <<
"CONSTRAINT_FORM" << FEI_ENDL
75 <<
"W" << FEI_ENDL <<
"D" << FEI_ENDL <<
"DofPerNode" << FEI_ENDL;
81 bool slave_constraints =
false;
82 if (
"slaves" == constraintform) {
83 slave_constraints =
true;
87 if (datasource ==
"HexBeam") {
88 hexcubeptr =
new HexBeam(W, D, DofPerNode,
89 HexBeam::OneD, numProcs, localProc);
92 hexcubeptr =
new HexBeamCR(W, D, DofPerNode,
93 HexBeam::OneD, numProcs, localProc);
99 int numCRs = (W+1)*(W+1)* ((numProcs*2)-1);
100 if (hexcube.getNumCRs() < 1) numCRs = 0;
101 FEI_COUT << FEI_ENDL;
102 FEI_COUT <<
"========================================================"
105 FEI_COUT <<
"--------------------------------------------------------"<<FEI_ENDL;
106 FEI_COUT <<
"Size W: " << W <<
" (num-elements-along-side-of-cube)"<<FEI_ENDL;
107 FEI_COUT <<
"Size D: " << D <<
" (num-elements-along-depth-of-cube)"<<FEI_ENDL;
108 FEI_COUT <<
"DOF per node: " << DofPerNode <<FEI_ENDL;
109 FEI_COUT <<
"Num local elements: " << hexcube.localNumElems_ << FEI_ENDL;
110 FEI_COUT <<
"Num global elements: " << hexcube.totalNumElems_ << FEI_ENDL;
111 FEI_COUT <<
"Num local DOF: " << hexcube.numLocalDOF_ << FEI_ENDL;
112 FEI_COUT <<
"Num global DOF: " << hexcube.numGlobalDOF_ << FEI_ENDL;
113 FEI_COUT <<
"Num global CRs: " << numCRs << FEI_ENDL;
114 FEI_COUT <<
"========================================================"
125 FEI_COUT <<
"library " << solverName <<
" not available."<<FEI_ENDL;
128 if (factory.
get() == NULL) {
129 FEI_COUT <<
"snl_fei::Factory allocation failed." << FEI_ENDL;
147 int fieldSize = hexcube.numDofPerNode();
155 CHK_ERR( HexBeam_Functions::
156 init_elem_connectivities( matrixGraph.
get(), hexcube ) );
158 CHK_ERR( HexBeam_Functions::
159 init_shared_nodes( matrixGraph.
get(), hexcube ) );
161 int firstLocalCRID = 0;
162 if (slave_constraints) {
163 CHK_ERR( HexBeam_Functions::
164 init_slave_constraints( matrixGraph.
get(), hexcube) );
167 CHK_ERR( HexBeam_Functions::
168 init_constraints( matrixGraph.
get(), hexcube, localProc, firstLocalCRID) );
175 if (localProc == 0) {
176 FEI_COUT.setf(IOS_FIXED, IOS_FLOATFIELD);
177 FEI_COUT <<
"Initialization cpu time: " << fei_init_time << FEI_ENDL;
190 if (localProc == 0) {
191 FEI_COUT.setf(IOS_FIXED, IOS_FLOATFIELD);
192 FEI_COUT <<
"Create-Matrix cpu time: " << fei_creatematrix_time << FEI_ENDL;
208 CHK_ERR( HexBeam_Functions::
209 load_elem_data(matrixGraph.
get(), mat.
get(), rhsVec.
get(), hexcube) );
214 if (!slave_constraints) {
215 CHK_ERR( HexBeam_Functions::
216 load_constraints(linSys.
get(), hexcube, firstLocalCRID) );
223 if (localProc == 0) {
225 FEI_COUT.setf(IOS_FIXED, IOS_FLOATFIELD);
226 FEI_COUT <<
"Coef. loading cpu time: " << fei_load_time << FEI_ENDL;
227 FEI_COUT <<
"Total assembly wall time: "
228 << fei_init_time + fei_creatematrix_time + fei_load_time << FEI_ENDL;
241 std::string solver_name_value;
244 const char* charptr_solvername =
245 solver_name_value.empty() ? 0 : solver_name_value.c_str();
252 if (localProc==0) FEI_COUT <<
"solve..." << FEI_ENDL;
255 int err = solver->
solve(linSys.
get(),
264 if (localProc==0) FEI_COUT <<
"solve returned err: " << err <<
", status: "
265 << status << FEI_ENDL;
269 FEI_COUT <<
" cpu-time in solve: " << solve_time << FEI_ENDL;
280 FEI_COUT.setf(IOS_FIXED, IOS_FLOATFIELD);
282 FEI_COUT <<
"Proc0 cpu times (seconds):" << FEI_ENDL
283 <<
" FEI initialize: " << fei_init_time << FEI_ENDL
284 <<
" FEI create-matrix: " << fei_creatematrix_time << FEI_ENDL
285 <<
" FEI load: " << fei_load_time << FEI_ENDL
286 <<
" solve: " << solve_time << FEI_ENDL
287 <<
"Total program time: " << elapsed_cpu_time << FEI_ENDL;
289 #if defined(FEI_PLATFORM) && defined(FEI_OPT_LEVEL)
290 double benchmark = fei_init_time;
292 std::string slavestr;
293 if (!constraintform.empty()) {
294 slavestr = constraintform;
296 if (slavestr.size() > 0) slavestr +=
"_";
298 FEI_OSTRINGSTREAM testname_init;
299 testname_init <<
"cube3_init_"<<slavestr<<W<<
"_"<<D<<
"_"<<DofPerNode<<
"_"
300 <<solverName<<
"_np"<<numProcs<<
"_"
301 <<FEI_PLATFORM<<
"_"<<FEI_OPT_LEVEL;
302 FEI_OSTRINGSTREAM testname_create;
303 testname_create <<
"cube3_creatematrix_"<<slavestr<<W<<
"_"<<D<<
"_"<<DofPerNode
304 <<
"_"<<solverName<<
"_np"<<numProcs<<
"_"
305 <<FEI_PLATFORM<<
"_"<<FEI_OPT_LEVEL;
306 FEI_OSTRINGSTREAM testname_load;
307 testname_load <<
"cube3_load_"<<slavestr<<W<<
"_"<<D<<
"_"<<DofPerNode<<
"_"
308 <<solverName<<
"_np"<<numProcs<<
"_"
309 <<FEI_PLATFORM<<
"_"<<FEI_OPT_LEVEL;
311 double file_init, file_create, file_load;
312 bool file_benchmarks_available =
true;
315 testname_init.str().c_str());
317 testname_create.str().c_str());
319 testname_load.str().c_str());
321 catch (std::runtime_error& exc) {
322 file_benchmarks_available =
false;
325 if (file_benchmarks_available) {
327 bool init_test_passed =
328 fei_test_utils::check_and_cout_test_result(testname_init.str(), benchmark,
331 benchmark = fei_creatematrix_time;
332 bool create_test_passed =
333 fei_test_utils::check_and_cout_test_result(testname_create.str(), benchmark,
336 benchmark = fei_load_time;
337 bool load_test_passed =
338 fei_test_utils::check_and_cout_test_result(testname_load.str(), benchmark,
341 returnValue = init_test_passed&&create_test_passed&&load_test_passed ? 0 : 1;
347 bool testPassed = returnValue==0;
348 if (testPassed && localProc == 0) {
350 FEI_COUT <<
"FEI test successful" << FEI_ENDL;
virtual void setMatrix(fei::SharedPtr< fei::Matrix > &matrix)
virtual fei::SharedPtr< fei::Solver > createSolver(const char *name=0)=0
virtual void setParameters(const fei::ParameterSet ¶ms)=0
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
virtual int parameters(int numParams, const char *const *paramStrings)=0
virtual void parameters(const fei::ParameterSet ¶mset)
virtual void setSolutionVector(fei::SharedPtr< fei::Vector > &soln)
virtual fei::SharedPtr< fei::LinearSystem > createLinearSystem(fei::SharedPtr< fei::MatrixGraph > &matrixGraph)
void defineFields(int numFields, const int *fieldIDs, const int *fieldSizes, const int *fieldTypes=NULL)
virtual void setRHS(fei::SharedPtr< fei::Vector > &rhs)
virtual int scatterToOverlap()=0
virtual int loadComplete(bool applyBCs=true, bool globalAssemble=true)=0
void setParameters(const fei::ParameterSet ¶mset)
virtual fei::SharedPtr< VectorSpace > createVectorSpace(MPI_Comm, const char *name)
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 initComplete()=0
void defineIDTypes(int numIDTypes, const int *idTypes)
virtual fei::SharedPtr< fei::Vector > createVector(fei::SharedPtr< fei::VectorSpace > vecSpace, int numVectors=1)=0
std::ostream & console_out()
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
virtual int solve(fei::LinearSystem *linearSystem, fei::Matrix *preconditioningMatrix, const fei::ParameterSet ¶meterSet, int &iterationsTaken, int &status)
virtual fei::SharedPtr< fei::Matrix > createMatrix(fei::SharedPtr< fei::MatrixGraph > matrixGraph)=0
virtual fei::SharedPtr< fei::MatrixGraph > createMatrixGraph(fei::SharedPtr< fei::VectorSpace > rowSpace, fei::SharedPtr< fei::VectorSpace > columnSpace, const char *name)=0
int getIntParamValue(const char *name, int ¶mValue) const