57 #define fei_file "poisson_main.cpp" 66 int masterProc = 0, err = 0;
70 std::vector<std::string> stdstrings;
74 const char** params = NULL;
81 std::string which_fei;
82 std::string solverName;
91 fei::console_out() <<
"Failed to find one or more required parameters in input-file." 100 int nodes = (L+1)*(L+1);
103 FEI_COUT <<
"========================================================" 109 FEI_COUT <<
"========================================================" 114 if (outputLevel >= 0) outputLevel = 1;
115 if (outputLevel < 0) outputLevel = 0;
117 if ((masterProc ==
localProc)&&(outputLevel>0)) {
121 if (outputLevel == 1) {
136 if (which_fei ==
"OLDFEI") {
140 catch (std::runtime_error& exc) {
146 else if (which_fei ==
"fei::FEI_Impl") {
150 catch (std::runtime_error& exc) {
161 const char* feiVersionString;
167 CHK_ERR(
fei->parameters( numParams, params ) );
180 CHK_ERR(
fei->initFields( numFields, fieldSizes, fieldIDs ) );
216 err =
fei->solve(status);
221 double iTime, lTime, sTime, rTime;
222 CHK_ERR(
fei->cumulative_cpu_times(iTime, lTime, sTime, rTime) );
228 <<
" init. phase: " << iTime <<
FEI_ENDL 229 <<
" load phase: " << lTime <<
FEI_ENDL 230 <<
" solve time: " << sTime <<
FEI_ENDL;
235 CHK_ERR(
fei->residualNorm(1, 1, &fieldIDs[0], &norm) );
252 int lenNodeIDs = numNodes;
254 double* soln =
new double[lenNodeIDs];
255 if (nodeIDs != NULL && soln != NULL) {
256 CHK_ERR(
fei->getLocalNodeIDList(numNodes, nodeIDs, lenNodeIDs) );
259 CHK_ERR(
fei->getNodalFieldSolution(fieldID, numNodes, nodeIDs, soln));
261 for(
int i=0; i<numNodes; i++) {
262 int nID = (int)nodeIDs[i];
263 double x = (1.0* ((nID-1)%(L+1)))/L;
264 double y = (1.0* ((nID-1)/(L+1)))/L;
266 double exactSoln = x*x + y*y;
267 double error = std::abs(exactSoln - soln[i]);
268 if (maxErr < error) maxErr = error;
281 double globalMaxErr = 0.0;
282 MPI_Allreduce(&maxErr, &globalMaxErr, 1, MPI_DOUBLE, MPI_MAX, comm);
283 maxErr = globalMaxErr;
285 bool testPassed =
true;
286 if (maxErr > 1.e-6) testPassed =
false;
289 FEI_COUT <<
"poisson: TEST PASSED, maxErr = " << maxErr <<
", iterations: " 294 if (testPassed ==
false &&
localProc == 0) {
296 FEI_COUT <<
"(Test is deemed to have passed if the maximum difference" 297 <<
" between the exact and computed solutions is 1.e-6 or less.)" 307 <<
" FEI initialize: " << fei_init_time <<
FEI_ENDL 308 <<
" FEI load: " << fei_load_time <<
FEI_ENDL 309 <<
" solve: " << solve_time <<
FEI_ENDL 310 <<
"Total program time: " << elapsed_cpu_time <<
FEI_ENDL;
void strings_to_char_ptrs(std::vector< std::string > &stdstrings, int &numStrings, const char **&charPtrs)
int poisson_main(int argc, char **argv, MPI_Comm comm, int numProcs, int localProc)
int getStringParamValue(const char *name, std::string ¶mValue) const
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
#define FEI_Implementation
int whichArg(int argc, const char *const *argv, const char *findarg)
int init_elem_connectivities(FEI *fei, HexBeam &hexcube)
#define FEI_SINGLE_SYSTEM
int load_elem_data(FEI *fei, HexBeam &hexcube)
int get_filename_and_read_input(int argc, char **argv, MPI_Comm comm, int localProc, std::vector< std::string > &stdstrings)
int set_shared_nodes(FEI *fei, PoissonData &poissonData)
void print_args(int argc, char **argv)
std::ostream & console_out()
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
int load_BC_data(FEI *fei, HexBeam &hexcube)
int getIntParamValue(const char *name, int ¶mValue) const
int localProc(MPI_Comm comm)
virtual fei::SharedPtr< FEI > createFEI(fei::SharedPtr< LibraryWrapper > wrapper, MPI_Comm comm)
fei::SharedPtr< LibraryWrapper > create_LibraryWrapper(MPI_Comm comm, const char *libraryName)
int numProcs(MPI_Comm comm)