95int main(
int argc,
char** argv)
98 int numProcs = 1, localProc = 0;
106 std::vector<std::string> stdstrings;
115 std::string solverName;
125 fei::console_out() <<
"Failed to find one or more required parameters in input-file."
135 if (localProc == 0) {
136 int nodes = (L+1)*(L+1);
140 FEI_COUT <<
"\n========================================================\n";
142 FEI_COUT <<
"Square size L: " << L <<
" elements.\n";
143 FEI_COUT <<
"Global number of elements: " << L*L <<
"\n";
144 FEI_COUT <<
"Global number of nodes: " << nodes <<
"\n";
145 FEI_COUT <<
"Global number of equations: " << eqns <<
"\n";
146 FEI_COUT <<
"========================================================"
150 if (outputLevel == 1) {
151 if (localProc != 0) outputLevel = 0;
161 PoissonData poissonData(L, numProcs, localProc, outputLevel);
169 catch (std::runtime_error& exc) {
177 if (factory.
get() == NULL) {
185 factory->parameters(paramset);
188 factory->createVectorSpace(comm,
"poisson3");
192 factory->createMatrixGraph(nodeSpace, dummy,
"poisson3");
195 matrixGraph->setParameters(paramset);
204 nodeSpace->defineFields( numFields, fieldIDs, fieldSizes );
207 nodeSpace->defineIDTypes( 1, &nodeIDType );
217 CHK_ERR( matrixGraph->initComplete() );
235 linSys->setMatrix(mat);
236 linSys->setSolutionVector(solnVec);
237 linSys->setRHS(rhsVec);
239 CHK_ERR( linSys->parameters(paramset));
244 CHK_ERR( linSys->loadComplete() );
261 int err = solver->solve(linSys.
get(),
263 paramset, itersTaken, status);
268 if (localProc==0)
FEI_COUT <<
"solve returned err: " << err <<
", status: "
272 CHK_ERR( solnVec->scatterToOverlap() );
278 int numNodes = nodeSpace->getNumOwnedAndSharedIDs(nodeIDType);
282 int lenNodeIDs = numNodes;
284 double* soln =
new double[lenNodeIDs];
285 if (nodeIDs != NULL && soln != NULL) {
286 CHK_ERR( nodeSpace->getOwnedAndSharedIDs(nodeIDType, numNodes,
287 nodeIDs, lenNodeIDs) );
290 CHK_ERR( solnVec->copyOutFieldData(fieldID, nodeIDType,
291 numNodes, nodeIDs, soln));
293 for(
int i=0; i<numNodes; i++) {
294 int nID = (int)nodeIDs[i];
295 double x = (1.0* ((nID-1)%(L+1)))/L;
296 double y = (1.0* ((nID-1)/(L+1)))/L;
298 double exactSoln = x*x + y*y;
299 double error = std::abs(exactSoln - soln[i]);
300 if (maxErr < error) maxErr = error;
313 double globalMaxErr = 0.0;
314 MPI_Allreduce(&maxErr, &globalMaxErr, 1, MPI_DOUBLE, MPI_MAX, comm);
315 maxErr = globalMaxErr;
317 bool testPassed =
true;
318 if (maxErr > 1.e-6) testPassed =
false;
327 <<
" FEI initialize: " << fei_init_time <<
FEI_ENDL
328 <<
" FEI load: " << fei_load_time <<
FEI_ENDL
329 <<
" solve: " << solve_time <<
FEI_ENDL
330 <<
"Total program time: " << elapsed_cpu_time <<
FEI_ENDL;
333 if (testPassed && returnValue==0 && localProc == 0) {
335 FEI_COUT <<
"poisson: TEST PASSED, maxErr = " << maxErr <<
", iterations: "
339 if ((testPassed ==
false || returnValue != 0) && localProc == 0) {
340 FEI_COUT <<
"maxErr = " << maxErr <<
", TEST FAILED\n";
341 FEI_COUT <<
"(Test is deemed to have passed if the maximum difference"
342 <<
" between the exact and computed solutions is 1.e-6 or less, *AND*"
343 <<
" time-taken matches file-benchmark if available.)"
int init_elem_connectivities(FEI *fei, PoissonData &poissonData)
int load_elem_data(FEI *fei, PoissonData &poissonData)
int set_shared_nodes(FEI *fei, PoissonData &poissonData)
int load_BC_data(FEI *fei, PoissonData &poissonData)
int getIntParamValue(const char *name, int ¶mValue) const
int getStringParamValue(const char *name, std::string ¶mValue) const
void parse_strings(std::vector< std::string > &stdstrings, const char *separator_string, fei::ParameterSet ¶mset)
void print_args(int argc, char **argv)
int initialize_mpi(int argc, char **argv, int &localProc, int &numProcs)
int get_filename_and_read_input(int argc, char **argv, MPI_Comm comm, int localProc, std::vector< std::string > &stdstrings)
fei::SharedPtr< fei::Factory > create_fei_Factory(MPI_Comm comm, const char *libraryName)
std::ostream & console_out()
int main(int argc, char **argv)