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) {
122 if (localProc != 0) outputLevel = 0;
128 PoissonData poissonData(L, numProcs, localProc, outputLevel);
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;
216 err = fei->
solve(status);
221 double iTime, lTime, sTime, rTime;
226 if (localProc == 0) {
227 FEI_COUT <<
"FEI cpu-times:" << FEI_ENDL
228 <<
" init. phase: " << iTime << FEI_ENDL
229 <<
" load phase: " << lTime << FEI_ENDL
230 <<
" solve time: " << sTime <<
FEI_ENDL;
236 if (localProc == 0) {
252 int lenNodeIDs = numNodes;
254 double* soln =
new double[lenNodeIDs];
255 if (nodeIDs != NULL && soln != NULL) {
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;
288 if (testPassed && localProc == 0) {
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.)"
306 FEI_COUT <<
"Proc0 cpu times (seconds):" << FEI_ENDL
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)
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 poisson_main(int argc, char **argv, MPI_Comm comm, int numProcs, int localProc)
virtual int getNodalFieldSolution(int fieldID, int numNodes, const GlobalID *nodeIDs, double *results)=0
#define FEI_Implementation
int whichArg(int argc, const char *const *argv, const char *findarg)
virtual int getNumLocalNodes(int &numNodes)=0
virtual int version(const char *&versionString)=0
int init_elem_connectivities(FEI *fei, HexBeam &hexcube)
#define FEI_SINGLE_SYSTEM
int load_elem_data(FEI *fei, HexBeam &hexcube)
int getStringParamValue(const char *name, std::string ¶mValue) const
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)
virtual int initFields(int numFields, const int *fieldSizes, const int *fieldIDs, const int *fieldTypes=NULL)=0
virtual int setSolveType(int solveType)=0
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 localProc(MPI_Comm comm)
virtual int residualNorm(int whichNorm, int numFields, int *fieldIDs, double *norms)=0
virtual int iterations(int &itersTaken) const =0
virtual fei::SharedPtr< FEI > createFEI(fei::SharedPtr< LibraryWrapper > wrapper, MPI_Comm comm)
virtual int getLocalNodeIDList(int &numNodes, GlobalID *nodeIDs, int lenNodeIDs)=0
fei::SharedPtr< LibraryWrapper > create_LibraryWrapper(MPI_Comm comm, const char *libraryName)
virtual int cumulative_cpu_times(double &initPhase, double &loadPhase, double &solve, double &solnReturn)=0
int numProcs(MPI_Comm comm)
int getIntParamValue(const char *name, int ¶mValue) const