68 std::vector<std::string> stdstrings;
72 const char** params = NULL;
79 std::string solverName;
89 fei::console_out() <<
"Failed to find one or more required parameters in input-file."
97 int nodes = (L+1)*(L+1);
100 FEI_COUT <<
"========================================================"
107 FEI_COUT <<
"========================================================"
111 if ((masterProc == localProc)&&(outputLevel>0)) {
115 if (outputLevel == 1) {
116 if (localProc != 0) outputLevel = 0;
122 PoissonData poissonData(L, numProcs, localProc, outputLevel);
135 if (factory.
get() == NULL) {
159 nodeSpace->
defineFields( numFields, fieldIDs, fieldSizes );
216 int err = solver->
solve(linSys.
get(),
218 paramset, itersTaken, status);
223 if (localProc==0)
FEI_COUT <<
"solve returned err: " << err <<
", status: "
237 int lenNodeIDs = numNodes;
239 double* soln =
new double[lenNodeIDs];
240 if (nodeIDs != NULL && soln != NULL) {
242 nodeIDs, lenNodeIDs) );
246 numNodes, nodeIDs, soln));
248 for(
int i=0; i<numNodes; i++) {
249 int nID = (int)nodeIDs[i];
250 double x = (1.0* ((nID-1)%(L+1)))/L;
251 double y = (1.0* ((nID-1)/(L+1)))/L;
253 double exactSoln = x*x + y*y;
254 double error = std::abs(exactSoln - soln[i]);
255 if (maxErr < error) maxErr = error;
268 double globalMaxErr = 0.0;
269 MPI_Allreduce(&maxErr, &globalMaxErr, 1, MPI_DOUBLE, MPI_MAX, comm);
270 maxErr = globalMaxErr;
272 bool testPassed =
true;
273 if (maxErr > 1.e-6) testPassed =
false;
281 FEI_COUT <<
"Proc0 cpu times (seconds):" << FEI_ENDL
282 <<
" FEI initialize: " << fei_init_time << FEI_ENDL
283 <<
" FEI load: " << fei_load_time << FEI_ENDL
284 <<
" solve: " << solve_time << FEI_ENDL
285 <<
"Total program time: " << elapsed_cpu_time <<
FEI_ENDL;
287 #if defined(FEI_PLATFORM) && defined(FEI_OPT_LEVEL)
288 double benchmark = fei_init_time+fei_load_time;
290 testname <<
"poisson3_"<<L<<
"_"<<solverName<<
"_np"<<numProcs<<
"_"
291 <<FEI_PLATFORM<<
"_"<<FEI_OPT_LEVEL;
293 double file_value = 0.0;
294 bool file_value_available =
true;
297 testname.str().c_str());
299 catch(std::runtime_error& exc) {
300 file_value_available =
false;
303 if (file_value_available) {
307 returnValue = test_passed ? 0 : 1;
313 if (testPassed && returnValue==0 && localProc == 0) {
315 FEI_COUT <<
"poisson: TEST PASSED, maxErr = " << maxErr <<
", iterations: "
320 if ((testPassed ==
false || returnValue != 0) && localProc == 0) {
321 if (testPassed==
true) {
322 FEI_COUT <<
"maxErr = " << maxErr <<
", but time-taken outside margin. TEST FAILED" <<
FEI_ENDL;
327 FEI_COUT <<
"(Test is deemed to have passed if the maximum difference"
328 <<
" between the exact and computed solutions is 1.e-6 or less, *AND*"
329 <<
" time-taken matches file-benchmark if available.)"
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
void strings_to_char_ptrs(std::vector< std::string > &stdstrings, int &numStrings, const char **&charPtrs)
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 int copyOutFieldData(int fieldID, int idType, int numIDs, const int *IDs, double *data, int vectorIndex=0)=0
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
int poisson3_main(int argc, char **argv, MPI_Comm comm, int numProcs, int localProc)
virtual fei::SharedPtr< VectorSpace > createVectorSpace(MPI_Comm, const char *name)
int init_elem_connectivities(FEI *fei, HexBeam &hexcube)
int load_elem_data(FEI *fei, HexBeam &hexcube)
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
int set_shared_nodes(FEI *fei, PoissonData &poissonData)
int getOwnedAndSharedIDs(int idtype, int lenList, int *IDs, int &numOwnedAndSharedIDs)
void defineIDTypes(int numIDTypes, const int *idTypes)
virtual fei::SharedPtr< fei::Vector > createVector(fei::SharedPtr< fei::VectorSpace > vecSpace, int numVectors=1)=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 getNumOwnedAndSharedIDs(int idType)
int localProc(MPI_Comm comm)
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
#define FEI_OSTRINGSTREAM
int numProcs(MPI_Comm comm)
int getIntParamValue(const char *name, int ¶mValue) const
bool check_and_cout_test_result(std::string testname, double value, double file_value, unsigned margin)