39 std::string solnName = name +
".soln";
42 std::string compName = name +
".comp";
48 std::vector<int> &
elmts,
50 int rank,
int nproc,
int type,
51 int &nnodes,
int &nelem) {
62 int row=rank/proc_col, col=rank%proc_col;
64 const double width=100.,
length=100.;
66 std::cout <<
"type = " << type << std::endl;
69 nnodes = (nrow*ncol + (nrow-1)*(ncol-1));
70 nelem = 4*(nrow-1)*(ncol-1);
71 elmts.resize(nelem*3);
74 nelem = 2*(nrow-1)*(ncol-1);
75 elmts.resize(nelem*3);
78 nelem = (nrow-1)*(ncol-1);
79 elmts.resize(nelem*4);
81 coors.resize(nnodes*3);
86 coors[3*(
i*ncol+
j) + 1]=row*width+width/(nrow-1)*
i;
87 coors[3*(
i*ncol+
j) + 2]=0;
93 if(ncol > 1) xSpacing = width/(ncol-1);
95 if(nrow > 1) ySpacing =
length/(nrow-1);
98 for(
int i=0;
i < nrow-1; ++
i){
99 for(
int j=0;
j < ncol-1; ++
j){
100 int count = nrow*
ncol;
101 int elmidx = 4*(
i*(ncol-1)+
j);
103 coors[3*(count+
i*(ncol-1)+
j) + 0] = xSpacing*
j + xSpacing/2 + col*
length;
104 coors[3*(count+
i*(ncol-1)+
j) + 1] = ySpacing*
i + ySpacing/2 + row*width;
105 coors[3*(count+
i*(ncol-1)+
j) + 2] = 0;
108 elmts[3*(elmidx) + 0]=
i*ncol+
j+1;
109 elmts[3*(elmidx) + 1]=
i*(ncol-1)+
j+count+1;
110 elmts[3*(elmidx) + 2]=
i*ncol+
j+2;
113 elmts[3*(elmidx+1) + 0]=
i*ncol+
j+ncol+1;
114 elmts[3*(elmidx+1) + 1]=
i*ncol+
j+ncol+2;
115 elmts[3*(elmidx+1) + 2]=
i*(ncol-1)+
j+count+1;
118 elmts[3*(elmidx+2) + 0]=
i*ncol+
j+1;
119 elmts[3*(elmidx+2) + 1]=
i*ncol+
j+ncol+1;
120 elmts[3*(elmidx+2) + 2]=
i*(ncol-1)+
j+count+1;
123 elmts[3*(elmidx+3) + 0]=
i*ncol+
j+2;
124 elmts[3*(elmidx+3) + 1]=
i*(ncol-1)+
j+count+1;
125 elmts[3*(elmidx+3) + 2]=
i*ncol+
j+ncol+2;
132 for(
int i=0;
i < nrow-1; ++
i){
133 for(
int j=0;
j < ncol-1; ++
j){
134 int elmidx = 2*(
i*(ncol-1)+
j);
137 elmts[3*(elmidx) + 0]=
i*ncol+
j+1;
138 elmts[3*(elmidx) + 1]=
i*ncol+
j+ncol+1;
139 elmts[3*(elmidx) + 2]=
i*ncol+
j+2;
142 elmts[3*(elmidx+1) + 0]=
i*ncol+
j+ncol+1;
143 elmts[3*(elmidx+1) + 1]=
i*ncol+
j+ncol+2;
144 elmts[3*(elmidx+1) + 2]=
i*ncol+
j+2;
151 for (
int i=0;
i<nrow-1; ++
i) {
152 for (
int j=0;
j<ncol-1; ++
j) {
153 int elmidx =
i*(ncol-1)+
j;
155 elmts[4*elmidx + 0]=
i*ncol+
j+1;
156 elmts[4*elmidx + 1]=
i*ncol+j+ncol+1;
157 elmts[4*elmidx + 2]=
i*ncol+j+ncol+2;
158 elmts[4*elmidx + 3]=
i*ncol+j+2;
164 int main(
int argc,
char *argv[]){
171 std::vector<std::string> windowNames(nwindows);
172 std::vector< std::vector< std::vector<double> > > coords(nwindows);
173 std::vector< std::vector< std::vector<int> > > elements(nwindows);
174 std::vector< std::vector< std::vector<double> > > soln(nwindows);
175 std::vector< std::vector< std::vector<double> > > comp(nwindows);
178 std::cout <<
"Initializing Roccom and Rocface" << std::endl;
196 for(
int i=0;
i < nwindows;
i++)
198 std::stringstream ss;
200 ss >> windowNames[
i];
202 std::cout <<
"Creating window " << ss.str() << std::endl;
206 for(
int i=0;
i < nwindows;
i++){
207 std::string &windowName(windowNames[
i]);
216 std::cout << windowName <<
":" << std::endl;
217 std::cout << nrow <<
" by " << ncol << std::endl;
219 coords[
i].resize(npanes);
220 elements[
i].resize(npanes);
221 soln[
i].resize(npanes);
222 comp[
i].resize(npanes);
224 for(
int j=0;
j < npanes;
j++){
229 nrow,ncol,j,npanes,meshType,
234 soln[
i][
j].resize( coords[i][j].size() );
235 comp[
i][
j].resize( coords[i][j].size() );
237 for(
int k=0;
k < soln[
i][
j].size();
k++){
238 soln[
i][
j][
k] = coords[
i][
j][
k];
239 comp[
i][
j][
k] = -1.0;
245 COM_set_array( (windowName+
".nc"), pane_id, &coords[i][j][0]);
247 std::string connectivityName;
248 connectivityName = ((meshType < 2) ? (windowName+
".:t3:") :
249 (windowName+
".:q4:"));
251 COM_set_array(connectivityName, pane_id, &elements[i][j][0]);
253 COM_set_array((windowName+
".soln"), pane_id, &soln[i][j][0]);
254 COM_set_array((windowName+
".comp"), pane_id, &comp[i][j][0]);
313 const char *format =
"HDF";
317 std::cout <<
"Overlaying meshes..." << std::endl;
328 COM_call_function( RFC_write, &tri0_mesh, &quad_mesh,
"tri02",
"quad20", format);
332 COM_call_function( RFC_write, &tri1_mesh, &quad_mesh,
"tri12",
"quad21", format);
349 COM_call_function( RFC_read, &tri0_mesh, &tri1_mesh, NULL,
"tri01",
"tri10", format);
353 std::vector<std::vector< double > >::iterator paneIt = comp[check_id].begin();
354 std::vector<std::vector< double > >::iterator paneIt2 = coords[check_id].begin();
356 double compTol = 1e-5;
357 while(paneIt != comp[check_id].end()){
358 std::vector<double> &paneComp(*paneIt++);
359 std::vector<double> &paneCoords(*paneIt2++);
360 std::vector<double>::iterator pcIt = paneComp.begin();
361 std::vector<double>::iterator pcIt2 = paneCoords.begin();
362 while(pcIt != paneComp.end()){
363 double solnDiff = std::fabs(*pcIt - *pcIt2);
364 if(solnDiff > compTol){
366 std::cout << *pcIt <<
" != " << *pcIt2
367 <<
" (" << solnDiff <<
")" << std::endl;
373 std::cout <<
"Nodal transfer from Triangles 1 to Triangles 0 "
374 << (pass ?
"passed" :
"failed") <<
"." << std::endl;
378 paneIt = comp[check_id].begin();
379 paneIt2 = coords[check_id].begin();
381 while(paneIt != comp[check_id].end()){
382 std::vector<double> &paneComp(*paneIt++);
383 std::vector<double> &paneCoords(*paneIt2++);
384 std::vector<double>::iterator pcIt = paneComp.begin();
385 std::vector<double>::iterator pcIt2 = paneCoords.begin();
386 while(pcIt != paneComp.end()){
387 double solnDiff = std::fabs(*pcIt - *pcIt2);
388 if(solnDiff > compTol){
390 std::cout << *pcIt <<
" != " << *pcIt2
391 <<
" (" << solnDiff <<
")" << std::endl;
397 std::cout <<
"Nodal transfer from Triangles 0 to Triangles 1 "
398 << (pass ?
"passed" :
"failed") <<
"." << std::endl;
402 COM_call_function( RFC_read, &tri0_mesh, &quad_mesh, NULL,
"tri02",
"quad20", format);
405 paneIt = comp[check_id].begin();
406 paneIt2 = coords[check_id].begin();
408 while(paneIt != comp[check_id].end()){
409 std::vector<double> &paneComp(*paneIt++);
410 std::vector<double> &paneCoords(*paneIt2++);
411 std::vector<double>::iterator pcIt = paneComp.begin();
412 std::vector<double>::iterator pcIt2 = paneCoords.begin();
413 while(pcIt != paneComp.end()){
414 double solnDiff = std::fabs(*pcIt - *pcIt2);
415 if(solnDiff > compTol){
417 std::cout << *pcIt <<
" != " << *pcIt2
418 <<
" (" << solnDiff <<
")" << std::endl;
424 std::cout <<
"Nodal transfer from Triangles 0 to Quads "
425 << (pass ?
"passed" :
"failed") <<
"." << std::endl;
429 paneIt = comp[check_id].begin();
430 paneIt2 = coords[check_id].begin();
432 while(paneIt != comp[check_id].end()){
433 std::vector<double> &paneComp(*paneIt++);
434 std::vector<double> &paneCoords(*paneIt2++);
435 std::vector<double>::iterator pcIt = paneComp.begin();
436 std::vector<double>::iterator pcIt2 = paneCoords.begin();
437 while(pcIt != paneComp.end()){
438 double solnDiff = std::fabs(*pcIt - *pcIt2);
439 if(solnDiff > compTol){
441 std::cout << *pcIt <<
" != " << *pcIt2
442 <<
" (" << solnDiff <<
")" << std::endl;
448 std::cout <<
"Nodal transfer from Quads to Triangles 0 "
449 << (pass ?
"passed" :
"failed") <<
"." << std::endl;
453 COM_call_function( RFC_read, &tri1_mesh, &quad_mesh, NULL,
"tri12",
"quad21", format);
456 paneIt = comp[check_id].begin();
457 paneIt2 = coords[check_id].begin();
459 while(paneIt != comp[check_id].end()){
460 std::vector<double> &paneComp(*paneIt++);
461 std::vector<double> &paneCoords(*paneIt2++);
462 std::vector<double>::iterator pcIt = paneComp.begin();
463 std::vector<double>::iterator pcIt2 = paneCoords.begin();
464 while(pcIt != paneComp.end()){
465 double solnDiff = std::fabs(*pcIt - *pcIt2);
466 if(solnDiff > compTol){
468 std::cout << *pcIt <<
" != " << *pcIt2
469 <<
" (" << solnDiff <<
")" << std::endl;
475 std::cout <<
"Nodal transfer from Triangles 1 to Quads "
476 << (pass ?
"passed" :
"failed") <<
"." << std::endl;
480 paneIt = comp[check_id].begin();
481 paneIt2 = coords[check_id].begin();
483 while(paneIt != comp[check_id].end()){
484 std::vector<double> &paneComp(*paneIt++);
485 std::vector<double> &paneCoords(*paneIt2++);
486 std::vector<double>::iterator pcIt = paneComp.begin();
487 std::vector<double>::iterator pcIt2 = paneCoords.begin();
488 while(pcIt != paneComp.end()){
489 double solnDiff = std::fabs(*pcIt - *pcIt2);
490 if(solnDiff > compTol){
492 std::cout << *pcIt <<
" != " << *pcIt2
493 <<
" (" << solnDiff <<
")" << std::endl;
499 std::cout <<
"Nodal transfer from Quads to Triangles 1 "
500 << (pass ?
"passed" :
"failed") <<
"." << std::endl;
504 for(
int i=0;
i < nwindows;
i++){
void initUnstructuredMesh(std::vector< double > &coors, std::vector< int > &elmts, int nrow, int ncol, int rank, int nproc, int type, int &nnodes, int &nelem)
void COM_delete_window(const char *wname)
void makeWindow(std::string name)
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
This file contains the prototypes for Roccom API.
int COM_get_attribute_handle(const char *waname)
double length(Vector3D *const v, int n)
int elmts[total_npanes][num_elmts][4]
void COM_window_init_done(const char *w_str, int pane_changed=true)
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void COM_set_profiling(int i)
void COM_call_function(const int wf, int argc,...)
void COM_set_array(const char *wa_str, int pane_id, void *addr, int strd=0, int cap=0)
Associates an array with an attribute for a specific pane.
int main(int argc, char *argv[])
void COM_init(int *argc, char ***argv)
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
int COM_get_function_handle(const char *wfname)
#define COM_EXTERN_MODULE(moduleName)