64 MPI_Comm_rank(gp.
_comm,&rank);
69 MPI_Barrier(gp.
_comm);
72 std::ostringstream Ostr;
73 Ostr <<
"Roctrail/Roctrail_debug_" << gp.
_id;
75 Ouf =
new std::ofstream;
76 Ouf->open(Ostr.str().c_str());
87 std::ostringstream Ostr;
88 Ostr << std::scientific << std::setprecision(5) << t*1e10;
89 std::string buf(Ostr.str());
90 std::string timestring(buf.substr(9)+
"."+buf.substr(0,1)+buf.substr(2,5));
97 std::string xp_s(ts.substr(0,2));
98 std::string num_s(ts.substr(3));
99 std::istringstream X_inst(ts);
103 double x =
pow(10,(
double)xp);
104 std::istringstream Num_inst(num_s);
113 std::string &rankstring)
115 std::string fname(filename.substr(0,filename.find_last_of(
".")));
116 std::string::size_type
x = fname.find_last_of(
"_");
117 std::string::size_type len = fname.length() -
x;
118 rankstring.assign(fname.substr(x+1,len-1));
119 fname = fname.substr(0,x);
120 x = fname.find_last_of(
"_");
121 len = fname.length() -
x;
122 timestring.assign(fname.substr(x+1,len-1));
123 wname = fname.substr(0,x);
130 const std::string &attribute_name,
132 std::vector<int> &pane_id)
134 std::vector<int> pane_ids;
137 std::vector<int>::iterator
pi = pane_ids.begin();
138 while(pi != pane_ids.end()){
140 COM_get_array((window_name+
"."+attribute_name).c_str(),*pi,&attptr);
141 if(*attptr == attribute_value)
142 pane_id.push_back(*pi);
150 const std::string &attribute_name,
151 const std::string &qual_name,
153 std::vector<int> &attvec)
155 std::vector<int> pane_ids;
158 std::vector<int>::iterator
pi = pane_ids.begin();
159 while(pi != pane_ids.end()){
161 COM_get_array((window_name+
"."+qual_name).c_str(),*pi,&attptr);
162 if(*attptr == qualval){
163 COM_get_array((window_name+
"."+attribute_name).c_str(),*pi,&attptr);
165 attvec.push_back(*attptr);
174 const std::string &attribute_name,
175 std::vector<int> &attvec)
177 std::vector<int> pane_ids;
180 std::vector<int>::iterator
pi = pane_ids.begin();
181 while(pi != pane_ids.end()){
183 COM_get_array((window_name+
"."+attribute_name).c_str(),*pi,&attptr);
185 attvec.push_back(*attptr);
192 MPI_Comm communicator)
195 MPI_Comm_size(communicator,&nprocs);
196 int nlocal_items = input_data.size();
197 std::vector<int> nitems_per_processor(nprocs);
198 MPI_Allgather(&nlocal_items,1,MPI_INT,&nitems_per_processor[0],1,MPI_INT,communicator);
199 std::vector<int> displacements(nprocs);
200 displacements[0] = 0;
201 int total_count = nitems_per_processor[0];
202 for(
int i = 1;
i < nprocs;
i++){
203 total_count += nitems_per_processor[
i];
204 displacements[
i] = nitems_per_processor[
i-1]+displacements[
i-1];
206 std::vector<int> all_items(total_count);
207 MPI_Allgatherv(&input_data[0],nlocal_items,MPI_INT,
208 &all_items[0],&nitems_per_processor[0],&displacements[0],
209 MPI_INT,communicator);
210 std::sort(all_items.begin(),all_items.end());
211 std::vector<int>::iterator ui = std::unique(all_items.begin(),all_items.end());
212 output_data.resize(ui - all_items.begin());
213 std::copy(all_items.begin(),ui,output_data.begin());
230 std::vector<std::vector<std::vector<int> > > &extent_pool,
231 std::vector<std::vector<std::vector<int> > > &neighbor_extent,
232 std::vector<int> &neighbors)
234 size_t pool_depth = extent_pool.size();
235 size_t nd = search_extent.size();
236 neighbor_extent.resize(0);
238 std::vector<std::vector<int> > extent(nd);
239 for(
size_t i = 0;
i < nd;
i++)
241 for(
size_t i = 0;
i < pool_depth;
i++){
243 for(
size_t j = 0;
j < nd;
j++){
244 if(!((search_extent[
j][0] >= extent_pool[
i][
j][0] &&
245 search_extent[
j][0] <= extent_pool[
i][
j][1]) ||
246 (search_extent[j][1] >= extent_pool[
i][j][0] &&
247 search_extent[j][1] <= extent_pool[
i][j][1])))
251 neighbors.push_back(
i);
252 for(
size_t j = 0;
j < nd;
j++){
253 extent[
j][0] =
std::max(search_extent[
j][0],extent_pool[
i][j][0]);
254 extent[
j][1] =
std::min(search_extent[j][1],extent_pool[
i][j][1]);
256 neighbor_extent.push_back(extent);
278 std::vector<std::vector<int> > &global_extent,
279 std::vector<std::vector<std::vector<int> > > &extent_pool,
280 std::vector<std::vector<int> > &ghost_extent,
281 std::vector<std::vector<std::vector<int> > > &neighbor_extent,
282 std::vector<int> &neighbors)
284 size_t pool_depth = extent_pool.size();
285 size_t nd = local_extent.size();
286 std::vector<std::vector<std::vector<int> > > pool_extents(pool_depth);
288 neighbor_extent.resize(0);
289 for(
size_t i = 0;
i < pool_depth;
i++){
290 pool_extents[
i].resize(nd);
291 for(
size_t j = 0;
j < nd;
j++)
292 pool_extents[
i][
j].resize(2,0);
294 ghost_extent = local_extent;
295 for(
size_t i = 0;
i < nd;
i++){
297 if(local_extent[
i][0] > global_extent[
i][0])
298 ghost_extent[
i][0] = local_extent[
i][0] - 1;
299 if(local_extent[i][1] < global_extent[i][1])
300 ghost_extent[
i][1] = local_extent[
i][1] + 1;
302 for(
size_t i = 0;
i < nd;
i++){
304 if(local_extent[
i][0] > global_extent[
i][0]){
305 std::vector<std::vector<int> > search_extent(ghost_extent);
306 search_extent[
i][1] = search_extent[
i][0];
308 std::vector<std::vector<std::vector<int> > > directional_extent;
309 std::vector<int> directional_neighbors;
311 directional_extent,directional_neighbors);
312 std::vector<int>::iterator dni = directional_neighbors.begin();
314 while(dni != directional_neighbors.end()){
315 int neighbor_index = *dni++;
316 for(
size_t j = 0;
j < nd;
j++){
317 if(pool_extents[neighbor_index][
j][0] > 0)
318 pool_extents[neighbor_index][
j][0] =
std::min(directional_extent[ncount][
j][0],
319 pool_extents[neighbor_index][j][0]);
321 pool_extents[neighbor_index][
j][0] = directional_extent[ncount][
j][0];
322 if(pool_extents[neighbor_index][j][1] > 0)
323 pool_extents[neighbor_index][
j][1] =
std::max(directional_extent[ncount][j][1],
324 pool_extents[neighbor_index][j][1]);
326 pool_extents[neighbor_index][
j][1] = directional_extent[ncount][
j][1];
334 if(local_extent[i][1] < global_extent[i][1]){
335 std::vector<std::vector<int> > search_extent(ghost_extent);
336 search_extent[
i][0] = search_extent[
i][1] = ghost_extent[
i][1];
337 std::vector<std::vector<std::vector<int> > > directional_extent;
338 std::vector<int> directional_neighbors;
340 directional_extent,directional_neighbors);
341 std::vector<int>::iterator dni = directional_neighbors.begin();
343 while(dni != directional_neighbors.end()){
344 int neighbor_index = *dni++;
345 for(
size_t j = 0;
j < nd;
j++){
346 if(pool_extents[neighbor_index][
j][0] > 0)
347 pool_extents[neighbor_index][
j][0] =
std::min(directional_extent[ncount][
j][0],
348 pool_extents[neighbor_index][j][0]);
350 pool_extents[neighbor_index][
j][0] = directional_extent[ncount][
j][0];
351 if(pool_extents[neighbor_index][j][1] > 0)
352 pool_extents[neighbor_index][
j][1] =
std::max(directional_extent[ncount][j][1],
353 pool_extents[neighbor_index][j][1]);
355 pool_extents[neighbor_index][
j][1] = directional_extent[ncount][
j][1];
363 for(
size_t i = 0;
i < pool_depth;
i++){
364 if(pool_extents[
i][0][0] > 0){
365 neighbors.push_back(
i);
366 neighbor_extent.push_back(pool_extents[
i]);
380 typename std::vector<T>::const_iterator ci = container.begin();
381 while(ci != container.end())
399 unsigned int asize = container.size();
404 typename std::vector<std::vector<T> >::const_iterator ci = container.begin();
405 while(ci != container.end()){
406 typename std::vector<T>::const_iterator vi = ci->begin();
407 while(vi != ci->end())
418 unsigned int number_of_nodes = coords.
Size();
419 COM_set_size((wname+
".nc").c_str(),pane_id,number_of_nodes);
423 std::memcpy(nc,coords[1],number_of_nodes*3*
sizeof(
double));
426 Mesh::Connectivity::iterator ci = conn.begin();
427 bool known_element_type =
false;
428 while(ci != conn.end()){
431 else if (ci->size() == 4)
434 assert(known_element_type);
436 unsigned int number_of_tris = tris.
Nelem();
437 unsigned int number_of_quads = quads.
Nelem();
438 int *con_array = NULL;
439 if(number_of_tris > 0){
440 COM_set_size((wname+
".:t3:real").c_str(),pane_id,number_of_tris);
442 COM_get_array((wname+
".:t3:real").c_str(),pane_id,&con_array);
444 while(ci != tris.end()){
445 unsigned int element_id = ci - tris.begin() + 1;
446 unsigned int element_index = element_id - 1;
447 con_array[3*element_index] = (*ci)[0];
448 con_array[3*element_index+1] = (*ci)[1];
449 con_array[3*element_index+2] = (*ci)[2];
453 if(number_of_quads > 0){
454 COM_set_size((wname+
".:q4:").c_str(),pane_id,number_of_quads);
458 while(ci != quads.end()){
459 unsigned int element_id = ci - quads.begin() + 1;
460 unsigned int element_index = element_id - 1;
461 con_array[4*element_index] = (*ci)[0];
462 con_array[4*element_index+1] = (*ci)[1];
463 con_array[4*element_index+2] = (*ci)[2];
464 con_array[4*element_index+3] = (*ci)[3];
476 std::vector<std::vector<double> > &soln_data,
491 unsigned int number_of_nodes = mesh.
nc.
Size();
493 COM_set_size((wname+
".nc").c_str(),pane_id,number_of_nodes);
497 std::memcpy(nc,mesh.
nc[1],number_of_nodes*3*
sizeof(
double));
500 Mesh::Connectivity::iterator ci = mesh.
con.begin();
502 bool known_element_type =
false;
503 while(ci != mesh.
con.end()){
506 else if (ci->size() == 8)
509 assert(known_element_type);
511 unsigned int number_of_tets = tets.
Nelem();
512 unsigned int number_of_bricks = bricks.
Nelem();
515 int *con_array = NULL;
516 if(number_of_tets > 0){
517 COM_set_size((wname+
".:T4:real").c_str(),pane_id,number_of_tets);
519 COM_get_array((wname+
".:T4:real").c_str(),pane_id,&con_array);
521 while(ci != tets.end()){
522 unsigned int element_id = ci - tets.begin() + 1;
523 unsigned int element_index = element_id - 1;
524 con_array[4*element_index] = (*ci)[0];
525 con_array[4*element_index+1] = (*ci)[1];
526 con_array[4*element_index+2] = (*ci)[2];
527 con_array[4*element_index+3] = (*ci)[3];
531 if(number_of_bricks > 0){
532 COM_set_size((wname+
".:B8:real").c_str(),pane_id,number_of_bricks);
534 COM_get_array((wname+
".:B8:real").c_str(),pane_id,&con_array);
536 while(ci != bricks.end()){
537 unsigned int element_id = ci - bricks.begin() + 1;
538 unsigned int element_index = element_id - 1;
539 con_array[8*element_index] = (*ci)[0];
540 con_array[8*element_index+1] = (*ci)[1];
541 con_array[8*element_index+2] = (*ci)[2];
542 con_array[8*element_index+3] = (*ci)[3];
543 con_array[8*element_index+4] = (*ci)[4];
544 con_array[8*element_index+5] = (*ci)[5];
545 con_array[8*element_index+6] = (*ci)[6];
546 con_array[8*element_index+7] = (*ci)[7];
568 MPI_Comm communicator = MPI_COMM_NULL;
570 IRAD::Comm::CommunicatorObject BaseComm(communicator);
571 int nprocs = BaseComm.Size();
572 int rank = BaseComm.Rank();
574 *ouf <<
"TRAIL_AddBlockStructuredGhostZone::Nprocs = " << nprocs << std::endl;
575 std::vector<int> pane_ids;
578 *ouf <<
"Number of panes: " << pane_ids.size() << std::endl;
580 std::vector<int> local_block_ids;
583 *ouf <<
"Local Block_ids: ";
584 IRAD::Util::DumpContents(*ouf,local_block_ids,
" ");
587 std::vector<int> global_blocks;
590 *ouf <<
"Global Block_ids: ";
591 IRAD::Util::DumpContents(*ouf,local_block_ids,
" ");
596 std::vector<int>::iterator bii = global_blocks.begin();
597 std::string wname2 = outwname;
598 bool window_created =
false;
610 window_created =
true;
617 while(bii != global_blocks.end()){
618 int block_id = *bii++;
619 std::vector<int>::iterator fi = std::find(local_block_ids.begin(),local_block_ids.end(),block_id);
621 if(fi != local_block_ids.end())
625 *ouf <<
"Splitting communicator for blocks." << std::endl;
626 IRAD::Comm::CommunicatorObject BlockComm;
627 BaseComm.Split(block_color,rank,BlockComm);
628 if(block_color == 1){
629 int block_nproc = BlockComm.Size();
630 int block_rank = BlockComm.Rank();
632 std::vector<int> local_patch_ids;
633 std::vector<int> panes;
635 std::vector<int>::iterator
pi = panes.begin();
636 while(pi != panes.end()){
640 local_patch_ids.push_back(*patch_id);
643 std::vector<int> all_patches(block_nproc);
646 std::vector<int>::iterator pii = all_patches.begin();
647 while(pii != all_patches.end()){
648 int patch_id = *pii++;
652 IRAD::Comm::CommunicatorObject PatchComm;
653 std::vector<int>::iterator fp = std::find(local_patch_ids.begin(),local_patch_ids.end(),patch_id);
654 if(fp != local_patch_ids.end())
657 *ouf <<
"Splitting communicator for patches." << std::endl;
658 BlockComm.Split(patch_color,block_rank,PatchComm);
659 if(patch_color == 1) {
660 int patch_nproc = PatchComm.Size();
661 int patch_rank = PatchComm.Rank();
662 std::vector<int> patch_pane;
664 int *global_patch_extent = NULL;
665 COM_get_array((wname+
".global_extent").c_str(),patch_pane[0],&global_patch_extent);
666 if(!global_patch_extent){
667 std::cerr <<
"ERROR: Window " << wname <<
" has no global_extent attribute." << std::endl;
670 int *local_patch_extent_ptr = NULL;
671 COM_get_array((wname+
".local_extent").c_str(),patch_pane[0],&local_patch_extent_ptr);
672 if(!local_patch_extent_ptr){
673 std::cerr <<
"ERROR: Window " << wname <<
" has no local_extent attribute." << std::endl;
676 std::vector<int> local_patch_extent;
677 for(
unsigned int aa = 0;aa < 6;aa++)
678 local_patch_extent.push_back(local_patch_extent_ptr[aa]);
680 *ouf <<
"Getting Local Coordinates." << std::endl;
681 double *LocalCoordinates = NULL;
682 COM_get_array((wname+
".nc").c_str(),patch_pane[0],&LocalCoordinates);
686 std::vector<int> all_patch_extents(6*patch_nproc);
687 PatchComm.AllGather(local_patch_extent,all_patch_extents,6,6);
688 std::vector<int> all_pane_ids(patch_nproc);
689 PatchComm.AllGather(patch_pane[0],all_pane_ids);
691 *ouf <<
"All patch extents communicated." << std::endl;
692 std::vector<std::vector<std::vector<int> > > extent_pool(patch_nproc);
693 std::vector<std::vector<int> > ghost_extent;
694 std::vector<std::vector<std::vector<int> > > neighbor_extent;
695 std::vector<int> neighbors;
696 std::vector<std::vector<int> > local_extent(3);
697 std::vector<std::vector<int> > global_extent(3);
698 for(
int dd = 0;dd < 3;dd++){
699 local_extent[dd].push_back(local_patch_extent[dd*2]);
700 local_extent[dd].push_back(local_patch_extent[dd*2+1]);
701 global_extent[dd].push_back(global_patch_extent[dd*2]);
702 global_extent[dd].push_back(global_patch_extent[dd*2+1]);
704 for(
int pp = 0;pp < patch_nproc;pp++){
705 extent_pool[pp].resize(3);
706 for(
int dd = 0;dd < 3;dd++){
707 extent_pool[pp][dd].push_back(all_patch_extents[pp*6+dd*2]);
708 extent_pool[pp][dd].push_back(all_patch_extents[pp*6+dd*2+1]);
712 *ouf <<
"Calling TRAIL_Get_Block_Structured_Neighbors." << std::endl;
721 *ouf <<
"Calling TRAIL_Get_Block_Structured_Neighbors done." << std::endl;
724 std::vector<int>::iterator
ni = neighbors.begin();
725 int number_of_neighbors = neighbors.size();
726 std::vector<std::vector<int> > RemoteNeighborExtent(number_of_neighbors);
727 std::vector<std::vector<double> > RemoteNodalCoordinates(number_of_neighbors);
728 std::vector<std::vector<double> > SendCoordinates(number_of_neighbors);
729 std::vector<std::vector<int> > FlattenedNeighborExtents(number_of_neighbors);
730 std::vector<int> RecvMsgID(number_of_neighbors);
733 *ouf <<
"All processors Doing ComLoop 1" << std::endl;
734 for(
int nc = 0;nc < number_of_neighbors;nc++){
736 if(nid != patch_rank){
737 RemoteNeighborExtent[nc].resize(6);
738 RecvMsgID[nc] = PatchComm.ARecv(RemoteNeighborExtent[nc],nid,1);
740 RemoteNodalCoordinates[nc].resize(3*bs_extent.
NNodes());
741 bs_extent.
Flatten(FlattenedNeighborExtents[nc]);
742 PatchComm.ASend(FlattenedNeighborExtents[nc],nid,1);
744 *ouf <<
"Sending the extents I request from " << nid <<
": ";
745 IRAD::Util::DumpContents(*ouf,FlattenedNeighborExtents[nc],
" ");
748 PatchComm.ARecv(RemoteNodalCoordinates[nc],nid,2);
753 ni = neighbors.begin();
756 *ouf <<
"Doing ComLoop 2." << std::endl;
757 for(
int nc = 0;nc < number_of_neighbors;nc++){
759 if(nid != patch_rank){
760 PatchComm.WaitRecv(RecvMsgID[nc]);
762 int nnodes = bs_extent.
NNodes();
764 *ouf <<
"Sending " << nnodes <<
" nodal coordinates to remote proc." << std::endl;
765 SendCoordinates[nc].resize(0);
766 std::vector<int> flat_indices;
769 std::vector<int>::iterator gii = flat_indices.begin();
770 while(gii != flat_indices.end()){
771 int nodeind = (*gii++ - 1)*3;
772 SendCoordinates[nc].push_back(LocalCoordinates[nodeind]);
773 SendCoordinates[nc].push_back(LocalCoordinates[nodeind + 1]);
774 SendCoordinates[nc].push_back(LocalCoordinates[nodeind + 2]);
777 *ouf <<
"SendCoordinates.size == " << SendCoordinates[nc].size() << std::endl;
778 PatchComm.ASend(SendCoordinates[nc],nid,2);
783 *ouf <<
"Waiting for all messages." << std::endl;
785 PatchComm.ClearRequests();
787 *ouf <<
"All messages received, requests cleared." << std::endl;
795 while(uei != uns_extent.end())
796 (*uei++)[1] = (*gei++)[1];
806 std::vector<int> flatunsextent;
807 uns_extent.
Flatten(flatunsextent);
811 std::vector<int> flatglobextent;
812 GlobalExtent.
Flatten(flatglobextent);
817 *ouf <<
"Patch ID = " << patch_id << std::endl;
825 std::vector<int> flatcon;
826 unsigned int nnodes_new = uns_extent.
NNodes();
827 std::vector<double> NewCoords(3*nnodes_new);
829 COM_set_size((wname2+
".nc").c_str(),patch_pane[0],nnodes_new);
836 COM_get_array((wname2+
".:q4:").c_str(),patch_pane[0],&conndat);
837 memcpy(conndat,&flatcon[0],
sizeof(
int)*4*conn.
Nelem());
838 std::vector<int> localind;
840 unsigned int nlocalnodes = LocalExtent.
NNodes();
842 for(
unsigned int a = 0;a < nlocalnodes;a++){
843 coords[(localind[a]-1)*3] = LocalCoordinates[a*3];
844 coords[(localind[a]-1)*3+1] = LocalCoordinates[a*3+1];
845 coords[(localind[a]-1)*3+2] = LocalCoordinates[a*3+2];
847 std::vector<int> send_panes;
848 std::vector<int> recv_panes;
849 std::vector< std::vector<int> > flat_recv_extents;
850 std::vector< std::vector<int> > flat_send_extents;
851 for(
int nc = 0;nc < number_of_neighbors;nc++){
852 int nid = neighbors[nc];
853 if(nid != patch_rank){
854 if(FlattenedNeighborExtents[nc][1] == LocalExtent[0][1]+1 ||
855 FlattenedNeighborExtents[nc][3] == LocalExtent[1][1]+1 ||
856 FlattenedNeighborExtents[nc][5] == LocalExtent[2][1]+1){
862 TrimmedNeighborExtent[0][0] =
std::max(TrimmedNeighborExtent[0][0],uns_extent[0][0]);
863 TrimmedNeighborExtent[1][0] =
std::max(TrimmedNeighborExtent[1][0],uns_extent[1][0]);
864 TrimmedNeighborExtent[2][0] =
std::max(TrimmedNeighborExtent[2][0],uns_extent[2][0]);
865 std::vector<int> flatrecvextent;
866 TrimmedNeighborExtent.
Flatten(flatrecvextent);
867 flat_recv_extents.push_back(flatrecvextent);
868 recv_panes.push_back(all_pane_ids[nid]);
873 std::vector<int> source_indices;
874 std::vector<int> dest_indices;
875 NeighborExtent.
GetFlatIndices(TrimmedNeighborExtent,source_indices);
877 unsigned int ncopynodes = source_indices.size();
878 for(
unsigned int a = 0;a < ncopynodes;a++){
879 unsigned int sind = (source_indices[a]-1)*3;
880 unsigned int dind = (dest_indices[a]-1)*3;
881 coords[dind] = RemoteNodalCoordinates[nc][sind];
882 coords[dind+1] = RemoteNodalCoordinates[nc][sind+1];
883 coords[dind+2] = RemoteNodalCoordinates[nc][sind+2];
886 if(FlattenedNeighborExtents[nc][1] == LocalExtent[0][0]-1 ||
887 FlattenedNeighborExtents[nc][3] == LocalExtent[1][0]-1 ||
888 FlattenedNeighborExtents[nc][5] == LocalExtent[2][0]-1){
890 *ouf <<
"Yeah, I send left to pane " << all_pane_ids[nid] << std::endl;
894 send_panes.push_back(all_pane_ids[nid]);
900 std::vector<int> flatsendextent;
901 NeighborExtent.
Flatten(flatsendextent);
903 *ouf <<
"Send extents: ";
904 IRAD::Util::DumpContents(*ouf,flatsendextent,
" ");
907 flat_send_extents.push_back(flatsendextent);
911 int nrecv = recv_panes.size();
912 int nsend = send_panes.size();
922 *ouf <<
"Number of panes I send to: " << nsend << std::endl
923 <<
"Number of panes I recv from: " << nrecv << std::endl
925 IRAD::Util::DumpContents(*ouf,send_panes,
" ");
928 IRAD::Util::DumpContents(*ouf,recv_panes,
" ");
930 <<
"Send Extents: " << std::endl;
931 for(
int o = 0;o < nsend;o++){
932 IRAD::Util::DumpContents(*ouf,flat_send_extents[o],
" ");
935 *ouf <<
"Recv Extents:" << std::endl;
936 for(
int o = 0;o < nrecv;o++){
937 IRAD::Util::DumpContents(*ouf,flat_recv_extents[o],
" ");
967 int total = ncomp*insize;
969 dest.push_back(ptr[count++]);
975 const std::string &attlist,MPI_Comm communicator,
978 std::vector<std::string> atts;
979 std::istringstream Istr(attlist);
982 *ouf <<
"FE2FD_Transfer: Enter" << std::endl;
985 while(Istr >> attstr)
986 atts.push_back(attstr);
990 IRAD::Comm::CommunicatorObject BaseComm(communicator);
991 int rank = BaseComm.Rank();
992 std::vector<std::string>::iterator atti = atts.begin();
994 *ouf <<
"FE2FD: Reducing attributes over shared nodes." << std::endl;
995 while(atti != atts.end()){
996 std::string attstr = fewin+
"."+*atti++;
998 *ouf <<
"FE2FD: Reducing " << attstr << std::endl;
1003 IRAD::Comm::CommunicatorObject AttComm;
1004 BaseComm.Split(att_color,rank,AttComm);
1014 *ouf <<
"FE2FD: Reduced " << attstr << std::endl;
1017 *ouf <<
"FE2FD: " << attstr <<
" did not exist." << std::endl;
1021 *ouf <<
"FE2FD: Waiting on all procs to finish reducing." << std::endl;
1024 *ouf <<
"FE2FD: All procs done reducing attributes." << std::endl;
1026 std::vector<int> pane_ids;
1029 *ouf <<
"FE2FD: Number of panes: " << pane_ids.size() << std::endl;
1031 std::vector<int> local_block_ids;
1034 *ouf <<
"FE2FD: Local Block_ids: ";
1035 IRAD::Util::DumpContents(*ouf,local_block_ids,
" ");
1038 std::vector<int> global_blocks;
1041 *ouf <<
"FE2FD: Global Block_ids: ";
1042 IRAD::Util::DumpContents(*ouf,local_block_ids,
" ");
1047 std::vector<int>::iterator bii = global_blocks.begin();
1048 while(bii != global_blocks.end()){
1049 int block_id = *bii++;
1050 std::vector<int>::iterator fi = std::find(local_block_ids.begin(),local_block_ids.end(),block_id);
1051 int block_color = 0;
1052 if(fi != local_block_ids.end())
1056 *ouf <<
"FE2FD: Splitting communicator for blocks." << std::endl;
1057 IRAD::Comm::CommunicatorObject BlockComm;
1058 BaseComm.Split(block_color,rank,BlockComm);
1059 if(block_color == 1){
1060 int block_nproc = BlockComm.Size();
1061 int block_rank = BlockComm.Rank();
1063 std::vector<int> local_patch_ids;
1064 std::vector<int> panes;
1066 std::vector<int>::iterator
pi = panes.begin();
1067 while(pi != panes.end()){
1071 local_patch_ids.push_back(*patch_id);
1074 std::vector<int> all_patches(block_nproc);
1077 std::vector<int>::iterator pii = all_patches.begin();
1078 while(pii != all_patches.end()){
1079 int patch_id = *pii++;
1082 int patch_color = 0;
1083 IRAD::Comm::CommunicatorObject PatchComm;
1084 std::vector<int>::iterator fp = std::find(local_patch_ids.begin(),local_patch_ids.end(),patch_id);
1085 if(fp != local_patch_ids.end())
1088 *ouf <<
"FE2FD: Splitting communicator for patches." << std::endl;
1089 BlockComm.Split(patch_color,block_rank,PatchComm);
1090 if(patch_color == 1) {
1093 std::vector<int> patch_pane;
1097 int pane_id = patch_pane[0];
1099 std::vector<int> flat_uns_extent;
1100 err =
TRAIL_Att2Vec(fewin+
".local_extent",pane_id,flat_uns_extent);
1101 std::vector<int> flat_fd_extent;
1102 err =
TRAIL_Att2Vec(fdwin+
".local_extent",pane_id,flat_fd_extent);
1106 std::vector<int> src_indices;
1108 std::vector<int> asizes(atts.size(),0);
1110 std::vector<std::string>::iterator atti = atts.begin();
1111 while(atti != atts.end()){
1112 std::string att = *atti++;
1121 *ouf <<
"FE2FD: All attributes sized up." << std::endl;
1123 atti = atts.begin();
1126 *ouf <<
"FE2FD: Copying buffers." << std::endl;
1127 while(atti != atts.end()){
1128 std::string attstr = fewin+
"."+*atti;
1129 std::string trgatt = fdwin+
"."+*atti++;
1130 char *srcptr = NULL;
1131 char *trgptr = NULL;
1134 std::vector<int>::iterator sii = src_indices.begin();
1136 while(sii != src_indices.end()){
1137 int src_index = *sii++ - 1;
1138 memcpy(&trgptr[count++*asizes[attindex]],&srcptr[src_index*asizes[attindex]],asizes[attindex]);
1147 *ouf <<
"FD2FE: Waiting at final barrier" << std::endl;
1150 *ouf <<
"FD2FE: Exit" << std::endl;
1157 const std::string &destwin,
1158 const std::vector<std::string> &atts)
1160 std::vector<std::string>::const_iterator ai = atts.begin();
1161 while(ai != atts.end()){
1162 std::string att = *ai++;
1163 std::string tatt = destwin+
"."+att;
1164 std::string satt = srcwin+
"."+att;
1184 const std::string &attlist,std::ostream *ouf)
1186 std::vector<std::string> atts;
1187 std::istringstream Istr(attlist);
1189 while(Istr >> attstr)
1190 atts.push_back(attstr);
1192 MPI_Comm communicator = MPI_COMM_NULL;
1194 IRAD::Comm::CommunicatorObject BaseComm(communicator);
1195 IRAD::Comm::CommunicatorObject BlockComm;
1196 IRAD::Comm::CommunicatorObject PatchComm;
1200 int rank = BaseComm.Rank();
1201 std::vector<int> pane_ids;
1204 *ouf <<
"TRAIL: Number of panes: " << pane_ids.size() << std::endl;
1206 std::vector<int> local_block_ids;
1209 *ouf <<
"TRAIL: Local Block_ids: ";
1210 IRAD::Util::DumpContents(*ouf,local_block_ids,
" ");
1213 std::vector<int> global_blocks;
1216 *ouf <<
"TRAIL: Global Block_ids: ";
1217 IRAD::Util::DumpContents(*ouf,local_block_ids,
" ");
1223 std::vector<int>::iterator bii = global_blocks.begin();
1224 while(bii != global_blocks.end()){
1225 int block_id = *bii++;
1226 std::vector<int>::iterator fi = std::find(local_block_ids.begin(),local_block_ids.end(),block_id);
1227 int block_color = 0;
1228 if(fi != local_block_ids.end())
1232 *ouf <<
"TRAIL: Splitting communicator for blocks." << std::endl;
1234 BaseComm.Split(block_color,rank,BlockComm);
1236 if(block_color == 1){
1237 int block_nproc = BlockComm.Size();
1238 int block_rank = BlockComm.Rank();
1240 std::vector<int> local_patch_ids;
1241 std::vector<int> panes;
1243 std::vector<int>::iterator
pi = panes.begin();
1244 while(pi != panes.end()){
1248 local_patch_ids.push_back(*patch_id);
1251 std::vector<int> all_patches(block_nproc);
1254 std::vector<int>::iterator pii = all_patches.begin();
1255 while(pii != all_patches.end()){
1256 int patch_id = *pii++;
1259 int patch_color = 0;
1261 std::vector<int>::iterator fp = std::find(local_patch_ids.begin(),local_patch_ids.end(),patch_id);
1262 if(fp != local_patch_ids.end())
1265 *ouf <<
"TRAIL: Splitting communicator for patches." << std::endl;
1266 BlockComm.Split(patch_color,block_rank,PatchComm);
1268 if(patch_color == 1) {
1269 int patch_nproc = PatchComm.Size();
1271 std::vector<int> patch_pane;
1275 int pane_id = patch_pane[0];
1276 std::vector<int> all_pane_ids(patch_nproc);
1277 PatchComm.AllGather(pane_id,all_pane_ids);
1279 std::vector<int> flat_uns_extent;
1280 err =
TRAIL_Att2Vec(destwin+
".local_extent",pane_id,flat_uns_extent);
1281 std::vector<int> flat_global_extent;
1282 err =
TRAIL_Att2Vec(destwin+
".global_extent",pane_id,flat_global_extent);
1283 std::vector<int> shared_panes;
1284 err =
TRAIL_Att2Vec(destwin+
".shared_panes",pane_id,shared_panes);
1285 std::vector<int> flat_shared_extents;
1286 err =
TRAIL_Att2Vec(destwin+
".shared_extents",pane_id,flat_shared_extents);
1287 std::vector<int> flat_fd_extent;
1288 err =
TRAIL_Att2Vec(srcwin+
".local_extent",pane_id,flat_fd_extent);
1292 *ouf <<
"fd_extent: (["
1293 << flat_fd_extent[0] <<
"," << flat_fd_extent[1] <<
"],["
1294 << flat_fd_extent[2] <<
"," << flat_fd_extent[3] <<
"],["
1295 << flat_fd_extent[4] <<
"," << flat_fd_extent[5] <<
"])"
1297 *ouf <<
"unstructured_extent: (["
1298 << flat_uns_extent[0] <<
"," << flat_uns_extent[1] <<
"],["
1299 << flat_uns_extent[2] <<
"," << flat_uns_extent[3] <<
"],["
1300 << flat_uns_extent[4] <<
"," << flat_uns_extent[5] <<
"])"
1302 *ouf <<
"global_extent: (["
1303 << flat_global_extent[0] <<
"," << flat_global_extent[1] <<
"],["
1304 << flat_global_extent[2] <<
"," << flat_global_extent[3] <<
"],["
1305 << flat_global_extent[4] <<
"," << flat_global_extent[5] <<
"])"
1307 for(
int iii = 0;iii < flat_shared_extents.size()/6;iii++){
1308 unsigned int index = iii*6;
1309 *ouf <<
"shared_extents (" << shared_panes[iii] <<
"): (["
1310 << flat_shared_extents[index+0] <<
"," << flat_shared_extents[index+1] <<
"],["
1311 << flat_shared_extents[index+2] <<
"," << flat_shared_extents[index+3] <<
"],["
1312 << flat_shared_extents[index+4] <<
"," << flat_shared_extents[index+5] <<
"])"
1317 std::vector<int> all_fd_extents(6*patch_nproc);
1319 PatchComm.AllGather(flat_fd_extent,all_fd_extents,6,6);
1321 *ouf <<
"TRAIL: All FD Extents communicated." << std::endl;
1330 std::vector<int> theflatindices;
1333 std::vector<Mesh::BSExtent<int> > AllFDExtents;
1334 std::vector<Mesh::BSExtent<int> > SharedExtents;
1335 std::vector<Mesh::BSExtent<int> > RecvExtents;
1336 std::vector<int> remote_ranks;
1338 std::vector<std::vector<char> > SendBuffers;
1339 std::vector<std::vector<char> > RecvBuffers;
1340 std::vector<std::vector<int> > FlatIndices;
1341 std::vector<int> recvranks;
1342 std::vector<int> sendranks;
1343 for(
int i = 0;
i < patch_nproc;
i++)
1349 std::vector<std::string>::iterator ai = atts.begin();
1350 std::vector<int> asizes(atts.size(),0);
1353 while(ai != atts.end()){
1354 std::string att = *ai++;
1360 *ouf <<
"TRAIL: Processing attribute " << att << std::endl;
1363 bsize += asizes[attindex++];
1366 *ouf <<
"TRAIL: All attributes sized up." << std::endl;
1367 std::vector<int>::iterator spi = shared_panes.begin();
1368 while(spi != shared_panes.end()){
1370 SharedExtents.push_back(SharedExtent);
1371 int rpane_id = *spi++;
1374 int remote_rank = std::find(all_pane_ids.begin(),all_pane_ids.end(),rpane_id) - all_pane_ids.begin();
1375 remote_ranks.push_back(remote_rank);
1377 FDExtent.
Overlap(SharedExtent,CommExtent);
1378 if(!CommExtent.empty()){
1380 sendranks.push_back(remote_rank);
1381 int nnodes = CommExtent.
NNodes();
1382 std::vector<std::string>::iterator ai = atts.begin();
1383 std::vector<int> indices;
1386 std::vector<char> sendbufv(nnodes*bsize,0);
1387 SendBuffers.push_back(sendbufv);
1388 std::vector<int>::iterator ii = indices.begin();
1389 size_t byte_offset = 0;
1390 while(ii != indices.end()){
1392 int index = *ii++ - 1;
1394 while(ai != atts.end()){
1395 std::string att = *ai++;
1396 char *data_ptr = NULL;
1399 memcpy(&SendBuffers[nsend][byte_offset],&data_ptr[index*asizes[attindex]],asizes[attindex]);
1401 byte_offset += asizes[attindex++];
1411 AllFDExtents[remote_rank].Overlap(SharedExtent,CommExtent);
1412 if(!CommExtent.empty()){
1413 RecvExtents.push_back(CommExtent);
1415 int nnodes = CommExtent.
NNodes();
1416 std::vector<char> recvbuf(nnodes*bsize,0);
1417 std::vector<std::string>::iterator ai = atts.begin();
1419 RecvBuffers.push_back(recvbuf);
1421 *ouf <<
"TRAIL: Receive buffer size for " << nnodes <<
" nodes is "
1422 << nnodes*bsize <<
"." << std::endl;
1423 recvranks.push_back(remote_rank);
1428 PatchComm.Barrier();
1429 std::vector<std::vector<char> >::iterator rbi = RecvBuffers.begin();
1430 std::vector<int>::iterator rri = recvranks.begin();
1432 while(rbi != RecvBuffers.end()){
1437 *ouf <<
"Receiving from " << *rri << std::endl;
1438 PatchComm.ARecv(*rbi,*rri);
1443 *ouf <<
"SendBuffers size = " << SendBuffers.size();
1444 std::vector<std::vector<char> >::iterator sbi = SendBuffers.begin();
1445 rri = sendranks.begin();
1447 while(sbi != SendBuffers.end()){
1452 *ouf <<
"Sending to " << *rri << std::endl;
1453 PatchComm.ASend(*sbi,*rri);
1457 PatchComm.WaitAll();
1458 PatchComm.Barrier();
1464 *ouf <<
"TRAIL: All communication are initiated." << std::endl;
1475 PatchComm.Barrier();
1477 *ouf <<
"TRAIL: Getting indices of fd nodes in unstructured representation." << std::endl;
1478 std::vector<int> uflat;
1479 std::vector<int> dflat;
1482 *ouf <<
"TRAIL: finding fd_extent: (["
1483 << dflat[0] <<
"," << dflat[1] <<
"],["
1484 << dflat[2] <<
"," << dflat[3] <<
"],["
1485 << dflat[4] <<
"," << dflat[5] <<
"])"
1487 *ouf <<
"TRAIL: in uns_extent: (["
1488 << uflat[0] <<
"," << uflat[1] <<
"],["
1489 << uflat[2] <<
"," << uflat[3] <<
"],["
1490 << uflat[4] <<
"," << uflat[5] <<
"])"
1502 PatchComm.Barrier();
1504 *ouf <<
"TRAIL: Ready to copy local FD data into FE arrays." << std::endl << std::flush;
1511 while(ai != atts.end()){
1512 std::string att = *ai++;
1513 std::string tatt = destwin+
"."+att;
1514 std::string satt = srcwin+
"."+att;
1519 *ouf <<
"TRAIL: " << tatt <<
" did not exist." << std::endl;
1529 *ouf <<
"TRAIL: Initializing buffer to 0." << std::endl;
1530 char *trg_ptr = NULL;
1534 for(
int acount = 0;acount < UnsExtent.
NNodes();acount++)
1535 for(
int ncomp = 0; ncomp < asizes[attindex];ncomp++)
1542 *ouf <<
"TRAIL: Attribute appeared to exist on target" << std::endl;
1545 *ouf <<
"TRAIL: Initializing buffer to 0." << std::endl;
1546 char *trg_ptr = NULL;
1548 assert(trg_ptr != NULL);
1551 for(
int acount = 0;acount < UnsExtent.
NNodes();acount++)
1552 for(
int ncomp = 0; ncomp < asizes[attindex];ncomp++)
1557 char *src_ptr = NULL;
1558 char *trg_ptr = NULL;
1560 assert(trg_ptr != NULL);
1562 assert(src_ptr != NULL);
1563 std::vector<int>::iterator fii = theflatindices.begin();
1565 while(fii != theflatindices.end()){
1567 memcpy(&trg_ptr[(index-1)*asizes[attindex]],&src_ptr[count++*asizes[attindex]],asizes[attindex]);
1572 PatchComm.Barrier();
1578 PatchComm.Barrier();
1580 *ouf <<
"TRAIL: Base copy completed." << std::endl << std::flush;
1584 std::vector<Mesh::BSExtent<int> >::iterator rei = RecvExtents.begin();
1586 while(rei != RecvExtents.end()){
1587 std::vector<int> flatindices;
1588 unsigned int nnodes = rei->NNodes();
1591 std::vector<int>::iterator fii = flatindices.begin();
1592 assert(nnodes == flatindices.size());
1593 for(
unsigned int i = 0;i < nnodes;i++){
1597 int byte_offset = 0;
1598 while(ai != atts.end()){
1599 std::string tatt = destwin+
"."+*ai;
1600 char *trg_ptr = NULL;
1602 assert(trg_ptr != NULL);
1604 memcpy(&trg_ptr[(index-1)*asizes[attindex]],
1605 &RecvBuffers[recvindex][i*bsize+byte_offset],asizes[attindex]);
1606 byte_offset += asizes[attindex++];
1616 PatchComm.Barrier();
1620 BlockComm.Barrier();
1625 *ouf <<
"TRAIL: All processors done with transfer." << std::endl;
1655 MPI_Comm communicator = MPI_COMM_NULL;
1657 IRAD::Comm::CommunicatorObject BaseComm(communicator);
1658 int nprocs = BaseComm.Size();
1659 int rank = BaseComm.Rank();
1661 *ouf <<
"TRAIL_AddBlockStructuredGhostZone::Nprocs = " << nprocs << std::endl;
1662 std::vector<int> pane_ids;
1665 *ouf <<
"Number of panes: " << pane_ids.size() << std::endl;
1667 std::vector<int> local_block_ids;
1670 *ouf <<
"Local Block_ids: ";
1671 IRAD::Util::DumpContents(*ouf,local_block_ids,
" ");
1674 std::vector<int> global_blocks;
1677 *ouf <<
"Global Block_ids: ";
1678 IRAD::Util::DumpContents(*ouf,global_blocks,
" ");
1684 std::string wname2 = outwname;
1705 std::vector<int>::iterator bii = global_blocks.begin();
1706 while(bii != global_blocks.end()){
1707 int block_id = *bii++;
1708 std::vector<int>::iterator fi = std::find(local_block_ids.begin(),local_block_ids.end(),block_id);
1709 int block_color = 0;
1710 if(fi != local_block_ids.end())
1714 *ouf <<
"Splitting communicator for blocks." << std::endl;
1715 IRAD::Comm::CommunicatorObject BlockComm;
1716 BaseComm.Split(block_color,rank,BlockComm);
1717 if(block_color == 1){
1718 int block_nproc = BlockComm.Size();
1719 int block_rank = BlockComm.Rank();
1721 *ouf <<
"Processor " << rank <<
" has block rank "
1722 << block_rank <<
"/" << block_nproc << std::endl;
1728 std::vector<int> local_patch_ids;
1729 std::vector<int> panes;
1732 *ouf <<
"Found " << panes.size() <<
" local panes: ";
1733 IRAD::Util::DumpContents(*ouf,panes,
" ");
1736 std::vector<int>::iterator
pi = panes.begin();
1737 while(pi != panes.end()){
1741 local_patch_ids.push_back(*patch_id);
1745 *ouf <<
"Found " << local_patch_ids.size() <<
" local patch_ids: ";
1746 IRAD::Util::DumpContents(*ouf,local_patch_ids,
" ");
1749 std::vector<int> all_patches(block_nproc);
1753 *ouf <<
"Found " << all_patches.size() <<
" global patch_ids: ";
1754 IRAD::Util::DumpContents(*ouf,all_patches,
" ");
1757 std::vector<int>::iterator pii = all_patches.begin();
1758 while(pii != all_patches.end()){
1759 int patch_id = *pii++;
1762 int patch_color = 0;
1763 IRAD::Comm::CommunicatorObject PatchComm;
1764 std::vector<int>::iterator fp = std::find(local_patch_ids.begin(),local_patch_ids.end(),patch_id);
1765 if(fp != local_patch_ids.end())
1768 *ouf <<
"Splitting communicator for patches." << std::endl;
1769 BlockComm.Split(patch_color,block_rank,PatchComm);
1770 if(patch_color == 1) {
1771 int patch_nproc = PatchComm.Size();
1772 int patch_rank = PatchComm.Rank();
1773 std::vector<int> patch_pane;
1775 int *global_patch_extent_ptr = NULL;
1776 COM_get_array((wname+
".global_extent").c_str(),patch_pane[0],&global_patch_extent_ptr);
1777 if(!global_patch_extent_ptr){
1779 *ouf <<
"ERROR: Window " << wname <<
" has no global_patch_extent attribute." << std::endl;
1780 std::cerr <<
"ERROR: Window " << wname <<
" has no global_patch_extent attribute." << std::endl;
1784 *ouf <<
"global_patch_extent: (["
1785 << global_patch_extent_ptr[0] <<
"," << global_patch_extent_ptr[1] <<
"],["
1786 << global_patch_extent_ptr[2] <<
"," << global_patch_extent_ptr[3] <<
"],["
1787 << global_patch_extent_ptr[4] <<
"," << global_patch_extent_ptr[5] <<
"])"
1790 int *local_patch_extent_ptr = NULL;
1791 COM_get_array((wname+
".local_extent").c_str(),patch_pane[0],&local_patch_extent_ptr);
1792 if(!local_patch_extent_ptr){
1794 *ouf <<
"ERROR: Window " << wname <<
" has no local_patch_extent attribute." << std::endl;
1795 std::cerr <<
"ERROR: Window " << wname <<
" has no local_patch_extent attribute." << std::endl;
1799 *ouf <<
"local_patch_extent: (["
1800 << local_patch_extent_ptr[0] <<
"," << local_patch_extent_ptr[1] <<
"],["
1801 << local_patch_extent_ptr[2] <<
"," << local_patch_extent_ptr[3] <<
"],["
1802 << local_patch_extent_ptr[4] <<
"," << local_patch_extent_ptr[5] <<
"])"
1805 std::vector<int> local_patch_extent;
1806 std::vector<int> flat_local_patch_extents(6*patch_nproc);
1807 IRAD::Util::CopyIntoContainer(local_patch_extent,local_patch_extent_ptr,6);
1809 std::vector<int> global_patch_extent;
1810 IRAD::Util::CopyIntoContainer(global_patch_extent,global_patch_extent_ptr,6);
1819 while(lpei != LocalPatchExtent.end()){
1820 if((*lpei)[1] < (*gpei)[1]){
1832 std::vector<int> extended_patch_extent;
1833 ExtendedPatchExtent.
Flatten(extended_patch_extent);
1834 std::vector<int> all_extended_patch_extents(6*patch_nproc);
1836 PatchComm.AllGather(extended_patch_extent,all_extended_patch_extents,6,6);
1838 std::vector<int> all_pane_ids(patch_nproc);
1840 PatchComm.AllGather(patch_pane[0],all_pane_ids);
1842 *ouf <<
"All extended patch extents communicated." << std::endl;
1846 std::vector<Mesh::BSExtent<int> > ExtentPool;
1847 for(
int pindex = 0;pindex < patch_nproc;pindex++){
1848 if(pindex != patch_rank){
1850 ExtentPool.push_back(swimmer);
1855 *ouf <<
"Search pool filled." << std::endl;
1857 std::vector<Mesh::BSExtent<int> > shared_extents;
1858 std::vector<int> neighborranks;
1859 std::vector<int> neighborpanes;
1861 std::vector<int> neighborindices;
1863 *ouf <<
"Finding shared nodes." << std::endl;
1864 ExtendedPatchExtent.
FindSharedNodes(ExtentPool,shared_extents,neighborindices);
1866 *ouf <<
"Shared nodes found." << std::endl
1867 <<
"Neighbor indices: ";
1868 IRAD::Util::DumpContents(*ouf,neighborindices,
" ");
1869 *ouf << std::endl <<
"Shared extents: " << std::endl;
1870 std::vector<Mesh::BSExtent<int> >::iterator bsmi = shared_extents.begin();
1871 while(bsmi != shared_extents.end()){
1872 unsigned int nid = bsmi - shared_extents.begin();
1873 *ouf <<
"Shared extent " << nid <<
":" << std::endl;
1874 std::vector<int> tempflat_extent;
1875 bsmi++->Flatten(tempflat_extent);
1876 *ouf <<
"shared_extent: (["
1877 << tempflat_extent[0] <<
"," << tempflat_extent[1] <<
"],["
1878 << tempflat_extent[2] <<
"," << tempflat_extent[3] <<
"],["
1879 << tempflat_extent[4] <<
"," << tempflat_extent[5] <<
"])"
1883 std::vector<int>::iterator nii = neighborindices.begin();
1884 while(nii != neighborindices.end()){
1886 if(nrank >= patch_rank)
1888 neighborranks.push_back(nrank);
1889 neighborpanes.push_back(all_pane_ids[nrank]);
1893 *ouf <<
"Neighbor ranks: ";
1894 IRAD::Util::DumpContents(*ouf,neighborranks,
" ");
1895 *ouf << std::endl <<
"Neighborpanes: ";
1896 IRAD::Util::DumpContents(*ouf,neighborpanes,
" ");
1901 *ouf <<
"Copying attributes." << std::endl;
1907 ExtendedPatchExtent.
Sync();
1909 *ouf <<
"Creating unstructured mesh." << std::endl;
1916 int *flip_ptr = NULL;
1917 COM_get_array((wname+
".flip").c_str(),patch_pane[0],&flip_ptr);
1918 if(flip_ptr != NULL)
1919 flip = (*flip_ptr > 0);
1923 *ouf <<
"Flipping unstructured surface." << std::endl;
1924 Mesh::Connectivity::iterator connit = conn.begin();
1925 while(connit != conn.end())
1941 *ouf <<
"Setting window data." << std::endl;
1942 std::vector<int> flatcon;
1943 unsigned int nnodes_new = ExtendedPatchExtent.
NNodes();
1945 COM_set_size((wname2+
".nc").c_str(),patch_pane[0],nnodes_new);
1949 COM_set_size((wname2+
".bcflag").c_str(),patch_pane[0],1);
1952 COM_get_array((wname2+
".bcflag").c_str(),patch_pane[0],&bcflag);
1956 COM_get_array((wname2+
".:q4:").c_str(),patch_pane[0],&conndat);
1957 memcpy(conndat,&flatcon[0],
sizeof(
int)*4*conn.
Nelem());
1958 std::vector<std::vector<int> > flattened_shared_extents;
1959 std::vector<Mesh::BSExtent<int> >::iterator sei = shared_extents.begin();
1960 while(sei != shared_extents.end()){
1961 std::vector<int> flatextent;
1962 sei++->Flatten(flatextent);
1963 flattened_shared_extents.push_back(flatextent);
1965 TRAIL_Copy2Attribute((wname2+
".shared_panes"),neighborpanes,patch_pane[0],neighborpanes.size());
1968 *ouf <<
"Building pconn." << std::endl;
1969 std::vector<int> pconn;
1970 pconn.push_back(neighborpanes.size());
1971 std::vector<int> sortedpanes(neighborpanes);
1972 std::sort(sortedpanes.begin(),sortedpanes.end());
1973 std::vector<int>::iterator spit = sortedpanes.begin();
1974 while(spit != sortedpanes.end()){
1975 int remote_pane_id = *spit++;
1976 pconn.push_back(remote_pane_id);
1977 int remote_pane_index = std::find(neighborpanes.begin(),neighborpanes.end(),remote_pane_id) - neighborpanes.begin();
1978 std::vector<int> sharednodes;
1979 ExtendedPatchExtent.
GetFlatIndices(shared_extents[remote_pane_index],sharednodes);
1980 pconn.push_back(sharednodes.size());
1981 std::vector<int>::iterator sni = sharednodes.begin();
1982 while(sni != sharednodes.end())
1983 pconn.push_back(*sni++);
1988 IRAD::Util::DumpContents(*ouf,pconn,
" ");
1992 PatchComm.Barrier();
1995 BlockComm.Barrier();
1998 *ouf <<
"window done, roccom finalizing it." << std::endl;
2001 *ouf <<
"window finalized." << std::endl;
2003 *ouf <<
"end barrier" << std::endl;
2006 *ouf <<
"all processors exiting." << std::endl;
2011 std::vector<SolnMetaData> &
smdv,
2012 std::vector<std::vector<std::vector<double> > > &soln_data,
2013 int verblevel,
bool no_ghost)
2015 std::vector<int> pane_ids;
2016 std::vector<std::vector<std::vector<double> > > temp_soln;
2019 soln_data.resize(temp_soln.size());
2020 meshes.resize(temp_soln.size());
2023 std::cout <<
"TRAIL_Window2UnstructuredMesh::Processing " << pane_ids.size()
2024 <<
" panes." << std::endl;
2025 std::vector<int>::iterator pii = pane_ids.begin();
2026 while(pii != pane_ids.end()){
2027 int pane_index = pii - pane_ids.begin();
2028 int pane_id = *pii++;
2029 const int *conn_ptr = NULL;
2030 double *coordinates_ptr = NULL;
2031 COM_get_array_const((wname+
".nc").c_str(),pane_id,(
const double **)&coordinates_ptr);
2034 COM_get_array_const((wname+
".:st3:").c_str(),pane_id,&conn_ptr);
2037 COM_get_size((wname+
".:st3:").c_str(),pane_id,&nreal,&nghost);
2039 std::cout <<
"Block Structured pane " << pane_id <<
": " << std::endl
2040 <<
"Coordinate array size (i,j,k): (" << conn_ptr[0]
2041 <<
"," << conn_ptr[1] <<
"," << conn_ptr[2] <<
")" << std::endl
2042 <<
"Ghost zone is " << nghost <<
" cells wide."
2046 nnodes = conn_ptr[0]*conn_ptr[1]*conn_ptr[2];
2047 meshes[pane_index].nc.init_copy(nnodes,coordinates_ptr);
2048 std::vector<Mesh::IndexType> extent;
2049 for(
int i = 0;
i < 3;
i++){
2050 extent.push_back(1);
2051 extent.push_back(conn_ptr[
i]);
2054 soln_data[pane_index].resize(temp_soln[pane_index].size());
2059 std::cout <<
"TRAIL_Window2UnstructuredMesh::Stripping ghosts from block structured Window"
2061 std::vector<Mesh::IndexType> real_extent;
2062 for(
int i = 0;
i < 3;
i++){
2063 real_extent.push_back(1+nghost);
2064 real_extent.push_back(conn_ptr[
i]-nghost);
2067 std::cout <<
"TRAIL_Window2UnstructuredMesh::Getting real node indices"
2070 std::vector<Mesh::IndexType> real_indices;
2072 unsigned int nreal_nodes = real_indices.size();
2073 std::vector<double> real_coordinates(nreal_nodes*3);
2074 std::vector<Mesh::IndexType>::iterator rii = real_indices.begin();
2077 std::cout <<
"TRAIL_Window2UnstructuredMesh::Extracting real coordinates"
2079 while(rii != real_indices.end()){
2081 double *crdptr = meshes[pane_index].nc[cindex];
2082 real_coordinates[rni++] = *crdptr++;
2083 real_coordinates[rni++] = *crdptr++;
2084 real_coordinates[rni++] = *crdptr;
2087 std::cout <<
"TRAIL_Window2UnstructuredMesh::Replacing coordinates with real"
2089 meshes[pane_index].nc.init_copy(nreal_nodes,&real_coordinates[0]);
2091 std::cout <<
"TRAIL_Window2UnstructuredMesh::Real nodal coordinates extracted."
2093 for(
int i = 0;
i < 3;
i++){
2094 real_extent[
i*2] = 1;
2095 real_extent[
i*2+1] -= nghost;
2099 std::cout <<
"TRAIL_Window2UnstructuredMesh::Creating mesh with real vertices/cells"
2102 meshes[pane_index].con.Sync();
2103 meshes[pane_index].con.SyncSizes();
2105 std::cout <<
"TRAIL_Window2UnstructuredMesh::Nodes: " << meshes[pane_index].nc.size()
2106 <<
", Cells: " << meshes[pane_index].con.Nelem() << std::endl
2107 <<
"TRAIL_Window2UnstructuredMesh::Extracting real cell indices."
2110 std::vector<Mesh::IndexType> cell_extent;
2111 for(
int i = 0;
i < 3;
i++){
2112 cell_extent.push_back(1);
2113 cell_extent.push_back(conn_ptr[
i]-1);
2116 std::vector<Mesh::IndexType> real_cell_extent;
2117 for(
int i = 0;
i < 3;
i++){
2118 real_cell_extent.push_back(1+nghost);
2119 real_cell_extent.push_back(conn_ptr[
i]-1-nghost);
2122 std::vector<Mesh::IndexType> real_cell_indices;
2126 std::cout <<
"TRAIL_Window2UnstructuredMesh::Extracting real solution data"
2128 std::vector<std::vector<double> >::iterator tsai = temp_soln[pane_index].begin();
2129 std::vector<std::vector<double> >::iterator sdai = soln_data[pane_index].begin();
2130 while(tsai != temp_soln[pane_index].end()){
2131 unsigned int att_index = tsai - temp_soln[pane_index].begin();
2132 unsigned int ncomp = smdv[att_index].ncomp;
2134 if(smdv[att_index].loc ==
'N' || smdv[att_index].loc ==
'n'){
2136 sdai->resize(real_indices.size()*ncomp);
2138 std::cout <<
"TRAIL_Window2UnstructuredMesh::Processing "
2139 << ncomp <<
" nodal components of "
2140 << smdv[att_index].name << std::endl;
2141 std::vector<double>::iterator sddi = sdai->begin();
2142 rii = real_indices.begin();
2143 while(rii != real_indices.end()){
2145 real_index *= ncomp;
2146 for(
unsigned int ncc = 0;ncc < ncomp;ncc++)
2147 *sddi++ = temp_soln[pane_index][att_index][real_index++];
2151 else if(smdv[att_index].loc ==
'E' || smdv[att_index].loc ==
'e'){
2153 sdai->resize(real_cell_indices.size()*ncomp);
2154 std::vector<double>::iterator sddi = sdai->begin();
2156 std::cout <<
"TRAIL_Window2UnstructuredMesh::Processing "
2157 << ncomp <<
" cellular components of "
2158 << smdv[att_index].name << std::endl;
2159 rii = real_cell_indices.begin();
2160 while(rii != real_cell_indices.end()){
2162 real_index *= ncomp;
2163 for(
unsigned int ncc = 0;ncc < ncomp;ncc++)
2164 *sddi++ = temp_soln[pane_index][att_index][real_index++];
2175 temp_soln[pane_index].resize(0);
2179 std::vector<std::vector<double> >::iterator tsai = temp_soln[pane_index].begin();
2180 std::vector<std::vector<double> >::iterator sdai = soln_data[pane_index].begin();
2181 while(tsai != temp_soln[pane_index].end()){
2184 sdai->resize(tsai->size());
2185 std::vector<double>::iterator sddi = sdai->begin();
2186 std::vector<double>::iterator tddi = tsai->begin();
2187 while(tddi != tsai->end())
2193 temp_soln[pane_index].resize(0);
2199 std::cout <<
"TRAIL_Window2UnstructuredMesh::Processing unstructured window" << std::endl;
2234 MPI_Comm comm_null = MPI_COMM_NULL;
2235 std::string bufwin(
"bufwin");
2237 std::cout <<
"Reading file " << fname <<
"..." << std::endl;
2240 std::cout <<
"Done reading file " << fname <<
"." << std::endl;
2246 std::cout <<
"Obtained temp window from file " << fname
2247 <<
", cloning.." << std::endl;
2255 std::cout <<
"Window " << wname <<
" created." << std::endl;
2267 std::istringstream Istr(atts);
2269 while(Istr >> aname) {
2270 std::string rstring(wname+
"."+aname);
2276 if( (loc ==
'E' || loc ==
'e' || loc ==
'n' || loc ==
'N') && ta ==
COM_DOUBLE)
2283 std::istringstream Istr(atts);
2285 while(Istr >> aname){
2286 std::string rstring(wname+
"."+aname);
2292 if( (loc ==
'E' || loc ==
'e' || loc ==
'n' || loc ==
'N') && ta ==
COM_DOUBLE) {
2294 smdv[count].loc = loc;
2295 smdv[count].name = aname;
2296 smdv[count].unit = unit;
2297 smdv[count].ncomp = ncomp;
2306 std::vector<std::vector<std::vector<double> > > &soln_data,
2307 std::vector<SolnMetaData> &
smdv,
int verblevel)
2314 std::cout <<
"Number of attributes: " << nAttrs << std::endl;
2315 std::cout <<
"Attribute string: " << attrStr << std::endl;
2317 std::vector<int> pane_ids;
2320 if( soln_data.size( ) != pane_ids.size( ) )
2321 soln_data.resize(pane_ids.size() );
2323 std::vector<int>::iterator pii = pane_ids.begin();
2324 while(pii != pane_ids.end()) {
2326 int pane_index = pii - pane_ids.begin();
2327 int pane_id = *pii++;
2330 std::cout <<
"TRAIL_GetWindowSolnData::Pane id: " << pane_id << std::endl
2331 <<
"TRAIL_GetWindowSolnData::Number of atts: "
2332 << smdv.size() << std::endl;
2335 soln_data[pane_index].resize(smdv.size());
2338 std::vector<SolnMetaData>::iterator smdi = smdv.begin();
2339 while(smdi != smdv.end()) {
2341 std::string name = wname +
"." + smdi ->name;
2343 unsigned int aindex = smdi - smdv.begin();
2348 std::cout << smdi->name <<
" size = " << array_size << std::endl;
2350 const double *solver_array = NULL;
2352 COM_get_array_const( name.c_str( ), pane_id, &solver_array);
2359 if( solver_array ) {
2362 std::cout <<
"TRAIL_GetWindowSolnData::Copying " << array_size*smdi->ncomp <<
" doubles into " << smdi->name <<
" array." << std::endl;
2364 soln_data[pane_index][aindex].resize(array_size*smdi->ncomp);
2365 std::memcpy(&soln_data[pane_index][aindex][0],solver_array,
sizeof(
double)*array_size*smdi->ncomp);
2366 std::vector<double>::iterator ai = soln_data[pane_index][aindex].begin();
2371 std::cout <<
"TRAIL_GetWindowSolnData::No " << smdi->name <<
" array found." << std::endl;
2373 soln_data[pane_index][aindex].resize(0);
2392 const std::string &wname,
2393 std::vector<int> &bcflags,
2406 std::string bufwin(
"bufwin");
2411 if(!bcflags.empty()){
2415 int npanes, *pane_ids;
2419 for (
int i=0;
i<npanes; ++
i) {
2425 std::vector<int>::iterator bcfi = bcflags.begin();
2426 while(bcfi != bcflags.end() && delite)
2427 if(*bcfi++ == *flag)
2464 (bufwin+
".all").c_str(), (with_ghost ? 1 : 0));
2467 (bufwin+
".mesh").c_str(), (with_ghost ? 1 : 0));
2477 const std::string &trgname,
2478 const std::string &path,
2479 double t,
unsigned int np,
2484 std::string filepre(srcname+
"_"+timestring+
"_");
2485 std::ostringstream Ofstr;
2486 unsigned int id = 0;
2488 *ouf <<
"TRAIL_MergeRocinFiles: Entry" << std::endl;
2491 *ouf <<
"Searching for files with prefix: " << filepre << std::endl;
2494 std::ostringstream Ostr;
2495 Ostr << filepre << std::setw(5) << std::setfill(
'0')
2497 std::string filename(Ostr.str()+
"_in.txt");
2498 Inf.open(filename.c_str());
2500 Ofstr << Inf.rdbuf() << std::endl;
2502 unlink(filename.c_str());
2506 Ouf.open((trgname+
"_in_"+timestring+
".txt").c_str());
2511 *ouf <<
"TRAIL_MergeRocinFiles: Exit" << std::endl;
2518 Ouf.open((path+
"/"+wname+
".fc").c_str());
2519 Ouf <<
"0.5 0.6 3 0.17365" << std::endl
2520 <<
"1.3962634 0.314159265 3" << std::endl
2521 <<
"0.0 0.5 3" << std::endl
2522 <<
"6 1 1 0" << std::endl
2523 <<
"2" << std::endl;
2530 Ouf.open((path+
"/"+wname+
".fc").c_str());
2531 Ouf <<
"0.76604444 0.98480775 3 0.98480775" << std::endl
2532 <<
"1.3962634 0.314159265 3" << std::endl
2533 <<
"0.17364818 0.96592583 3" << std::endl
2534 <<
"6 1 1 0" << std::endl
2535 <<
"2" << std::endl;
2545 const std::string &srcpath,
const std::string &trgpath,
2546 const std::string &destpath,
double t, MPI_Comm comm,
2550 std::string srcfile(src +
"_in_" + timestring +
".txt");
2551 std::string trgfile(trg +
"_in_" + timestring +
".txt");
2552 std::string trailwin(src+
"_trail");
2554 std::string format(
"HDF");
2555 std::string newpath;
2562 std::vector<int> bcflags(3);
2568 *ouf <<
"TRAIL_AutoSurfer:: homedir = " << homedir << std::endl
2569 <<
"TRAIL_AutoSurfer:: CWD = " <<
TRAIL_CWD() << std::endl
2570 <<
"TRAIL_AutoSurfer:: Creating common refinement." << std::endl
2571 <<
"TRAIL_AutoSurfer:: Reading in source surface from " << srcpath
2574 std::cout <<
"Roctrail> Reading in source surface from "
2575 << srcpath <<
"(test of patience)" << std::endl;
2577 newpath.assign(homedir+
"/"+trgpath);
2580 *ouf <<
"TRAIL_AutoSurfer: Reading target surface from " << newpath
2583 std::cout <<
"Roctrail> Reading target surface from " << newpath
2586 newpath.assign(homedir+
"/"+destpath);
2591 *ouf <<
"TRAIL_AutoSurfer: Calling Rocface Overlay...."
2593 std::cout <<
"Roctrail> Rocface performing overlay..." << std::endl;
2597 std::cout <<
"Roctrail> Overlay complete, writing overlay to " << newpath
2599 *ouf <<
"TRAIL_AutoSurfer: Writing overlay to " << newpath <<
"..."
2603 trailwin.c_str(), trg.c_str(), format.c_str());
2606 *ouf <<
"TRAIL_AutoSurfer: Done. CWD = " <<
TRAIL_CWD() << std::endl;
2615 const std::string &trgwin,
2616 std::ostream *ouf = NULL);
2621 const std::string &src,
2622 const std::string &trg,
2623 const std::string &dest,
2624 const std::string &srcpath,
2625 const std::string &trgpath,
2626 const std::string &destpath,
2627 const std::string &crpath,
2628 double t,
unsigned int id,
2633 std::string suffix(
"_in_"+timestring+
".txt");
2634 std::string srcfile(src + suffix);
2635 std::string trgfile(trg + suffix);
2636 std::string r_trg(dest);
2637 std::string trailwin(src+
"_trail");
2639 std::string format(
"HDF");
2640 std::string newpath;
2643 std::vector<int> bcflags(3);
2651 *ouf <<
"Reading source window (" << trailwin <<
") from "
2652 << srcpath <<
"/" << srcfile <<
"...";
2655 newpath.assign(homedir+
"/"+trgpath);
2658 *ouf <<
"done" << std::endl
2659 <<
"Reading target window from " << newpath
2660 <<
"/" << trgfile <<
"...";
2665 *ouf <<
"done" << std::endl
2666 <<
"Reading destination window " << r_trg <<
" from "
2667 << trgfile <<
"...";
2670 newpath.assign(homedir+
"/"+crpath);
2672 *ouf <<
"done" << std::endl
2673 <<
"Reading mesh overlay from " << newpath <<
"..." << std::endl;
2678 std::vector<int> pane_id;
2680 *ouf <<
"TRAIL_AutoSurfer: Reading mesh overlay for all surfaces."
2681 <<
"TRAIL_AutoSurfer: CR DIR: " <<
TRAIL_CWD() << std::endl;
2683 trailwin.c_str(),trg.c_str(),format.c_str());
2685 *ouf <<
"TRAIL_AutoSurfer: Beginning transfer for all surfaces."
2689 *ouf <<
"done" << std::endl
2690 <<
"Transferring data ..." << std::endl;
2698 std::istringstream Istr(names);
2699 for(
int i = 0;
i < num_attributes;
i++){
2703 if((loc ==
'e' || loc ==
'n') && comtype ==
COM_DOUBLE){
2706 std::cout <<
"Roctrail> Transferring attribute: " << aname <<
" on "
2707 << (loc ==
'e' ?
"elements" :
"nodes") <<
"."
2722 pane_id.resize(npanes);
2723 for(
int i = 0;
i < npanes;
i++)
2724 pane_id[
i] = srcpane_ids[
i];
2728 for(
int p = 0;p < npanes;p++){
2729 void *src_ptr = NULL;
2732 void *trg_ptr = NULL;
2736 &src_ptr,&src_std,&src_cap);
2738 &trg_ptr,&trg_std,&trg_cap);
2739 if(src_ptr && trg_ptr && (trg_std*trg_cap >= src_std*src_cap)){
2741 *ouf <<
"TRAIL_AutoSurfer: Transferred " << aname <<
"(" << src_std
2742 <<
"," << src_cap <<
") to " << aname <<
"(" << trg_std
2743 <<
"," << trg_cap <<
")" << std::endl;
2744 memcpy(trg_ptr,src_ptr,
sizeof(
double)*src_std*src_cap);
2748 *ouf <<
"TRAIL_AutoSurfer: WARNING: non matching sizes for "
2749 << aname <<
" on pane " << pane_id[p] <<
"."
2751 <<
"TRAIL_AutoSurfer: src(" << src_std <<
"," << src_cap
2752 <<
") trg(" << trg_std <<
"," << trg_cap <<
")"
2759 newpath.assign(homedir+
"/"+destpath);
2763 *ouf <<
"Transfer is complete, massaging and writing results to "
2764 << newpath <<
"/" << r_trg << std::endl;
2766 std::cout <<
"Roctrail> Transfer complete, writing new surface"
2783 *ouf <<
"Results written." << std::endl
2784 <<
"Surface data transfer is complete." << std::endl;
2786 std::cout <<
"Roctrail> New surface written" << std::endl;
2797 std::string controlfilename(pre +
"_in.txt");
2798 Ouf.open(controlfilename.c_str());
2799 Ouf <<
"@Proc: " << rank << std::endl
2800 <<
"@Files: " << pre <<
".hdf" << std::endl;
2803 std::vector<int>::iterator pii = pane_id.begin();
2804 while(pii != pane_id.end())
2805 Ouf << *pii++ <<
" ";
2812 const std::string &cntl_name,
const std::string &cntl_path,
2813 double t,
unsigned int id,MPI_Comm comm,std::ostream *ouf)
2820 if(comm != MPI_COMM_NULL){
2821 MPI_Comm_rank(comm,&rank);
2822 MPI_Comm_size(comm,&nproc);
2826 std::vector<int> pane_id;
2828 *ouf <<
"TRAIL_WriteWindow: Entry" << std::endl;
2830 pane_id.resize(npanes);
2831 for(
int i = 0;
i < npanes;
i++)
2832 pane_id[
i] = srcpane_ids[
i];
2838 std::string rankstr(
"0");
2844 std::ostringstream Ostr;
2845 Ostr << wname <<
"_" << timestring <<
"_" << std::setw(5)
2846 << std::setfill(
'0') <<
id;
2849 wname.c_str(),timestring.c_str());
2854 *ouf <<
"TRAIL_WriteWindow: Wrote window " << wname <<
" id("
2855 <<
id <<
") to " << Ostr.str() <<
".hdf" << std::endl
2856 <<
"TRAIL_WriteWindow: Merging Rocin control files."
2858 if(comm != MPI_COMM_NULL)
2864 if(comm != MPI_COMM_NULL)
2867 *ouf <<
"TRAIL_WriteWindow: Exit" << std::endl;
2875 const std::string &relpath)
2877 double targ_time = -1;
2879 Directory::iterator dfi = sd.begin();
2880 while(dfi != sd.end()){
2881 std::string cdir(*dfi++);
2882 std::string::size_type
x = cdir.find(dirpre);
2883 if(x != std::string::npos){
2885 if(tt < t && tt > targ_time)
2899 std::vector<int> pane_id;
2901 pane_id.resize(npanes);
2902 for(
int i = 0;
i < npanes;
i++)
2903 pane_id[
i] = srcpane_ids[
i];
2905 for(
int i = 0;
i < npanes;
i++){
2906 double *nc_t0 = NULL;
2908 double *mdot = NULL;
2915 &nc_t0,&stride1,&cap1);
2917 &nc,&stride2,&cap2);
2920 *ouf <<
"TRAIL_FixRocstarData: Fixing nc_t0 for pane(" << pane_id[
i]
2921 <<
")" << std::endl;
2922 for(
int c = 0;c < cap1;c++){
2923 unsigned int index = c*stride1;
2924 if(nc_t0[index] == 0.0 &&
2925 nc_t0[index+1] == 0.0 &&
2926 nc_t0[index+2] == 0.0){
2927 nc_t0[index] = nc[index];
2928 nc_t0[index+1] = nc[index+1];
2929 nc_t0[index+2] = nc[index+2];
2935 &bflag,&stride1,&cap1);
2937 &mdot,&stride2,&cap2);
2941 &bflag,&stride1,&cap1);
2945 *ouf <<
"TRAIL_FixRocstarData: Fixing bflag for pane(" << pane_id[
i]
2946 <<
")" << std::endl;
2947 for(
int c = 0;c < cap2;c++){
2958 const std::string &trgwin,
2963 (srcwin+
".mesh").c_str(),1);
2965 (srcwin+
".bcflag").c_str(),1);
2968 std::vector<int> pane_id;
2970 pane_id.resize(npanes);
2971 for(
int i = 0;
i < npanes;
i++)
2972 pane_id[
i] = srcpane_ids[
i];
2974 for(
int i = 0;
i < npanes;
i++){
2975 double *nc_t0 = NULL;
2982 &nc_t0,&stride1,&cap1);
2984 &nc,&stride2,&cap2);
2986 memcpy(nc,nc_t0,
sizeof(
double)*stride2*cap2);
2994 std::string wname(
"smooth_win");
2995 unsigned int nnodes = gp.
_nc.size()/3;
2997 *gp.
_out <<
"TRAIL_RocmopSmooth: This partition has " << nnodes
2998 <<
" nodes." << std::endl;
2999 MPI_Barrier(gp.
_comm);
3000 std::vector<double> disp(nnodes*3,0.0);
3002 *gp.
_out <<
"TRAIL_RocmopSmooth: Creating window." << std::endl;
3003 MPI_Barrier(gp.
_comm);
3011 MPI_Barrier(gp.
_comm);
3013 *gp.
_out <<
"TRAIL_RocmopSmooth: Loading Rocmop." << std::endl;
3014 MPI_Barrier(gp.
_comm);
3018 MPI_Barrier(gp.
_comm);
3020 *gp.
_out <<
"TRAIL_RocmopSmooth: Setting Rocmop options." << std::endl;
3021 MPI_Barrier(gp.
_comm);
3024 MPI_Barrier(gp.
_comm);
3025 unsigned int count = 0;
3026 while(count++ < niter){
3028 *gp.
_out <<
"TRAIL_RocmopSmooth: Calling Rocmop's smoothing function.."
3030 MPI_Barrier(gp.
_comm);
3032 MPI_Barrier(gp.
_comm);
3034 *gp.
_out <<
"TRAIL_RocmopSmooth: Smoothing done. Applying displacements."
3038 gp.
_nc[
n] += disp[
n];
3042 MPI_Barrier(gp.
_comm);
3044 *gp.
_out <<
"TRAIL_RocmopSmooth: Applying displacements done."
3046 MPI_Barrier(gp.
_comm);
3050 MPI_Barrier(gp.
_comm);
3052 *gp.
_out <<
"TRAIL_RocmopSmooth: All done." << std::endl;
3053 MPI_Barrier(gp.
_comm);
3058 unsigned int *ec,
unsigned int nel,
3059 unsigned int *cnstr_type,
3062 std::string wname(
"smooth_win");
3069 for(
unsigned int i = 0;
i < nel*3;
i++) ec[
i]++;
3070 std::vector<double> offsets;
3071 offsets.resize(nnodes*3);
3072 std::vector<double> speed;
3073 speed.resize(nel,0.0);
3093 std::ostringstream Ostr;
3094 Ostr << niter << std::ends;
3110 for(
unsigned int i = 0;
i < nnodes*3;
i++)
3111 nc[
i] += offsets[
i];
3115 for(
unsigned int i = 0;
i < nel*3;
i++) ec[
i]--;
std::vector< Mesh::UnstructuredMesh > meshes
The list of grids to write.
int COM_Type
Indices for derived data types.
void COM_get_communicator(const char *wname, MPI_Comm *comm)
void TRAIL_RocmopSmooth(GEM_Partition &gp, unsigned int niter)
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_WORLD
void TRAIL_GetWindowSolnMetaData(const std::string &wname, std::vector< SolnMetaData > &smdv, int verblevel=0)
void AddElement(const std::vector< IndexType > &elem)
General connectivity object.
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_COMM_SELF
void TRAIL_HDF2Window(const std::string &fname, const std::string &wname, int verb=0)
int TRAIL_FE2FD_Transfer(const std::string &fewin, const std::string &fdwin, const std::string &attlist, MPI_Comm communicator, std::ostream *ouf=NULL)
void COM_delete_window(const char *wname)
void CreateUnstructuredMesh(Connectivity &conn)
void COM_get_attribute(const std::string wa_str, char *loc, int *type, int *ncomp, std::string *unit)
int TRAIL_FD2FE_Transfer(const std::string &, const std::string &, const std::string &, std::ostream *ouf=NULL)
void FindSharedNodes(std::vector< BSExtent< T > > &extent_pool, std::vector< BSExtent< T > > &shared_extents, std::vector< T > &neighbors)
void Overlap(const BSExtent< T > &inextent, BSExtent< T > &outextent)
Vector_n max(const Array_n_const &v1, const Array_n_const &v2)
bool TRAIL_TransferSurfDataFILE(const std::string &src, const std::string &trg, const std::string &dest, const std::string &srcpath, const std::string &trgpath, const std::string &destpath, const std::string &crpath, double t, unsigned int id, MPI_Comm comm, std::ostream *=NULL)
void TRAIL_CreateRobustFC_old(const std::string &wname, const std::string &path)
void COM_set_size(const char *wa_str, int pane_id, int size, int ng=0)
Set sizes of for a specific attribute.
void COM_set_default_communicator(MPI_Comm comm)
This file contains the prototypes for Roccom API.
void TRAIL_CreateRobustFC(const std::string &wname, const std::string &path)
void TRAIL_AutoSurfer(const std::string &src, const std::string &trg, const std::string &srcpath=".", const std::string &trgpath=".", const std::string &destpath=".", double t=0, MPI_Comm comm=MPI_COMM_NULL, std::ostream *=NULL)
void COM_get_array(const char *wa_str, int pane_id, void **addr, int *strd, int *cap)
Get the address for an attribute on a specific pane.
A Roccom mesh optimization module.
int TRAIL_CD(const std::string &path, std::ostream *=NULL)
bool TRAIL_WriteWindow(const std::string &wname, const std::string &path, const std::string &twin, const std::string &tpath, double t, unsigned int id, MPI_Comm comm, std::ostream *=NULL)
int COM_get_attribute_handle(const char *waname)
void COM_delete_attribute(const char *wa_str)
Delete an existing attribute.
void ReOrient(std::vector< IndexType > &ec)
void TRAIL_SetAttribute(const std::string &aname, int pane_id, T &value)
int TRAIL_ExtractPanes(const std::string &window_name, const std::string &attribute_name, int attribute_value, std::vector< int > &pane_id)
void TRAIL_RocpropSmoothSurf(double *nc, unsigned int nnodes, unsigned int *ec, unsigned int nel, unsigned int *cnstr_type, unsigned int niter)
std::vector< SolnMetaData > smdv
The solution Metadata.
int TRAIL_FD2FE_WinCreate(const std::string &wname, const std::string &outwname, std::ostream *ouf=NULL)
Adds ghost zones for block structured meshes to close gaps in the interface surface mesh...
void TRAIL_Window2UnstructuredMesh(const std::string &wname, std::vector< Mesh::UnstructuredMesh > &meshes, std::vector< SolnMetaData > &smdv, std::vector< std::vector< std::vector< double > > > &soln_data, int verb=0, bool no_ghost=false)
std::string TRAIL_TimeString(double t)
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to ** copy
void TRAIL_FixRocstarData(const std::string &wname, std::ostream *ouf=NULL)
#define COM_UNLOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
void Flatten(std::vector< T > &output)
int TRAIL_UniqueAcrossProcs(std::vector< int > &input_data, std::vector< int > &output_data, MPI_Comm communicator)
void GetFlatIndices(const BSExtent< T > &extent, std::vector< T > &indices)
void COM_get_attributes(const char *wname, int *na, std::string &names)
std::string TRAIL_CWD(void)
void TRAIL_GetRocstarDumpStrings(const std::string &filename, std::string &wname, std::string ×tring, std::string &rankstring)
int TRAIL_Search_Block_Structured_Pool(std::vector< std::vector< int > > &search_extent, std::vector< std::vector< std::vector< int > > > &extent_pool, std::vector< std::vector< std::vector< int > > > &neighbor_extent, std::vector< int > &neighbors)
Given an array of ranges: search_extent[nd][2] and one array of array of ranges: partition_extent[num...
int TRAIL_Att2Vec(const std::string &att, int pane_id, std::vector< T > &dest)
void COM_window_init_done(const char *w_str, int pane_changed=true)
int TRAIL_UnstructuredMesh2Pane(const std::string &wname, int pane_id, Mesh::UnstructuredMesh &mesh, SolnMetaData &smdv, std::vector< std::vector< double > > &soln_data, int verblevel)
Creates a window from a Mesh object. (copies data)
void COM_get_size(const char *wa_str, int pane_id, int *size, int *ng=0)
Get the sizes of an attribute.
int COM_get_sizeof(const COM_Type type, int c)
void COM_clone_attribute(const char *wname, const char *attr, int wg=1, const char *ptnname=0, int val=0)
Clone the subset of panes of another window of which the given pane attribute has value val...
void COM_new_window(const char *wname, MPI_Comm c=MPI_COMM_NULL)
void COM_call_function(const int wf, int argc,...)
int TRAIL_SurfaceMesh2Window(const std::string &wname, int pane_id, Mesh::NodalCoordinates &, Mesh::Connectivity &)
Creates a window from a Mesh object. (copies data)
double TRAIL_FindSourceTime(const std::string &dirpre, double t, const std::string &relpath)
void TRAIL_File2Window(const std::string &fname, const std::string &wname, std::vector< int > &bcflags, MPI_Comm comm=MPI_COMM_NULL, bool apply_disp=false, bool all=false, bool with_ghost=false)
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 TRAIL_CreateDirectory(const std::string &fname)
void Flatten(std::vector< T > &outcon) const
Vector_n min(const Array_n_const &v1, const Array_n_const &v2)
int TRAIL_Get_Block_Structured_Neighbors(std::vector< std::vector< int > > &local_extent, std::vector< std::vector< int > > &global_extent, std::vector< std::vector< std::vector< int > > > &extent_pool, std::vector< std::vector< int > > &ghost_extent, std::vector< std::vector< std::vector< int > > > &neighbor_extent, std::vector< int > &neighbors)
Given two arrays of ranges: global_extent[nd][2] local_extent[nd][2] an extent pool: extent_pool[npoo...
int TRAIL_Add_Attributes(const std::string &srcwin, const std::string &destwin, const std::vector< std::string > &atts)
void COM_delete_pane(const char *str, int pid)
unsigned long id(const Leda_like_handle &x)
void TRAIL_MergeRocinFiles(const std::string &srcname, const std::string &trgname, const std::string &path="./", double t=0, unsigned int np=1, std::ostream *=NULL)
void TRAIL_Debug(GEM_Partition &gp)
bool PopulateVolumeWindow(const std::string &wname)
void int int REAL REAL REAL *z blockDim dim * ni
void COM_new_attribute(const char *wa_str, const char loc, const int type, int ncomp, const char *unit)
Registering an attribute type.
void COM_get_panes(const char *wname, std::vector< int > &pane_ids, int rank=-2)
void COM_free_buffer(int **buf)
void TRAIL_WriteRocinControl(std::vector< int > &pane_id, const std::string &pre, int rank)
IRAD::Primitive::IndexType IndexType
int TRAIL_GetPanelAttribute(const std::string &window_name, const std::string &attribute_name, const std::string &qual_name, int qualval, std::vector< int > &attvec)
std::vector< double > _nc
MPI_Comm COM_get_default_communicator()
void TRAIL_ExtractSurf0(const std::string &srcwin, const std::string &trgwin, std::ostream *ouf=NULL)
Simple Block Structured Mesh object.
double pow(double value, const Exponent &exp)
void TRAIL_Copy2Attribute(const std::string &aname, const std::vector< T > &container, int pane_id, int asize=1)
#define COM_LOAD_MODULE_STATIC_DYNAMIC(moduleName, windowString)
void COM_resize_array(const char *wa_str, int pane_id=0, void **addr=NULL, int strd=-1, int cap=0)
Resize an attribute on a specific pane and return the address by setting addr.
int COM_get_function_handle(const char *wfname)
int TRAIL_FD2FE_WinCreate2(const std::string &wname, const std::string &outwname, std::ostream *ouf=NULL)
Takes as input a block structured FD grid.
void TRAIL_GetWindowSolnData(const std::string &wname, std::vector< std::vector< std::vector< double > > > &soln_data, std::vector< SolnMetaData > &smdv, int verblevel=0)
#define COM_EXTERN_MODULE(moduleName)