33 #ifndef OOMPH_REFINEABLE_MESH_TEMPLATE_CC 34 #define OOMPH_REFINEABLE_MESH_TEMPLATE_CC 38 #include <oomph-lib-config.h> 59 template<
class ELEMENT>
64 if(is_additional_synchronisation_of_hanging_nodes_disabled()==
true)
71 using namespace Missing_masters_functions;
83 int n_proc=Comm_pt->nproc();
84 int my_rank=Comm_pt->my_rank();
94 for(
int d=0; d<n_proc; d++)
99 if(nexternal_haloed_node(d)!=0)
102 oomph_info <<
"Processor " << my_rank <<
"'s external haloed nodes with processor " << d <<
" are:" << std::endl;
103 for(
unsigned i=0;
i<nexternal_haloed_node(d);
i++)
105 oomph_info <<
"external_haloed_node_pt("<<d<<
","<<
i<<
") = " << external_haloed_node_pt(d,
i) << std::endl;
106 oomph_info <<
"x = ( " << external_haloed_node_pt(d,
i)->x(0) <<
" , " << external_haloed_node_pt(d,
i)->x(1) <<
" )" << std::endl;
111 for(
int d=0; d<n_proc; d++)
116 if(nexternal_halo_node(d)!=0)
119 oomph_info <<
"Processor " << my_rank <<
"'s external halo nodes with processor " << d <<
" are:" << std::endl;
120 for(
unsigned i=0;
i<nexternal_halo_node(d);
i++)
122 oomph_info <<
"external_halo_node_pt("<<d<<
","<<
i<<
") = " << external_halo_node_pt(d,
i) << std::endl;
123 oomph_info <<
"x = ( " << external_halo_node_pt(d,
i)->x(0) <<
" , " << external_halo_node_pt(d,
i)->x(1) <<
" )" << std::endl;
130 std::ostringstream err_stream;
131 err_stream <<
"There are already some nodes in the external storage" 133 <<
"for this mesh. This bit assumes that nothing else" 135 <<
"uses this storage (for now).";
138 OOMPH_CURRENT_FUNCTION,
139 OOMPH_EXCEPTION_LOCATION);
154 haloed_hanging_node_with_discrepancy_pt(n_proc);
162 int ncont_inter_values=ncont_interpolated_values;
166 for (
int d=0; d<n_proc; d++)
175 unsigned nh=nhaloed_node(d);
176 for (
unsigned j=0;j<nh;j++)
179 Node* nod_pt=haloed_node_pt(d,j);
183 for (
int icont=-1; icont<ncont_inter_values; icont++)
189 haloed_hanging[d].push_back(n_master);
193 haloed_hanging[d].push_back(0);
199 unsigned count_haloed=haloed_hanging[d].size();
204 MPI_Recv(&tmp,1,MPI_UNSIGNED,d,0,Comm_pt->mpi_comm(),&status);
205 if (tmp!=count_haloed)
207 std::ostringstream error_stream;
208 error_stream <<
"Number of halo data, " << tmp
209 <<
", does not match number of haloed data, " 210 << count_haloed << std::endl;
213 OOMPH_CURRENT_FUNCTION,
214 OOMPH_EXCEPTION_LOCATION);
221 halo_hanging[d].resize(count_haloed);
222 MPI_Recv(&halo_hanging[d][0],count_haloed,MPI_INT,d,0,
223 Comm_pt->mpi_comm(),&status);
230 for (
int dd=0; dd<n_proc; dd++)
240 unsigned nh=nhalo_node(dd);
241 for (
unsigned j=0;j<nh;j++)
244 Node* nod_pt=halo_node_pt(dd,j);
248 for (
int icont=-1; icont<ncont_inter_values; icont++)
254 local_halo_hanging.push_back(n_master);
258 local_halo_hanging.push_back(0);
265 unsigned count_halo=local_halo_hanging.size();
269 MPI_Send(&count_halo,1,MPI_UNSIGNED,dd,0,Comm_pt->mpi_comm());
275 MPI_Send(&local_halo_hanging[0],count_halo,MPI_INT,
276 dd,0,Comm_pt->mpi_comm());
286 oomph_info <<
"Time for first all-to-all in additional_synchronise_hanging_nodes(): " 287 << t_end-t_start << std::endl;
302 for (
int d=0; d<n_proc; d++)
311 unsigned nh=nhaloed_node(d);
312 for (
unsigned j=0;j<nh;j++)
315 Node* nod_pt=haloed_node_pt(d,j);
319 for (
int icont=-1; icont<ncont_inter_values; icont++)
326 if ((haloed_hanging[d][count]>0)&&
327 (haloed_hanging[d][count]!=halo_hanging[d][count]))
330 haloed_hanging_node_with_discrepancy_pt[d].insert(
331 std::pair<Node*,unsigned>(nod_pt,d));
348 for (
int d=0; d<n_proc; d++)
361 unsigned nhaloed_nonmaster_nodes_processed = 0;
365 std::map<Node*,unsigned>::iterator j;
366 for(j=haloed_hanging_node_with_discrepancy_pt[d].begin(); j!=haloed_hanging_node_with_discrepancy_pt[d].end(); j++)
368 Node* nod_pt = (*j).first;
372 std::vector<Node*>::iterator it
373 = std::find(Shared_node_pt[d].begin(),
374 Shared_node_pt[d].end(),
376 if(it != Shared_node_pt[d].end())
380 nhaloed_nonmaster_nodes_processed++;
384 unsigned index = it - Shared_node_pt[d].begin();
385 haloed_nonmaster_node_index.push_back(index);
391 (d, nod_pt,
this, ncont_inter_values,
392 send_unsigneds, send_doubles);
397 "Haloed node not found in haloed node storage",
398 OOMPH_CURRENT_FUNCTION,
399 OOMPH_EXCEPTION_LOCATION);
404 unsigned send_unsigneds_count = send_unsigneds.size();
405 unsigned send_doubles_count = send_doubles.size();
408 MPI_Send(&send_unsigneds_count,1,MPI_UNSIGNED,d,0,Comm_pt->mpi_comm());
409 MPI_Send(&send_doubles_count,1,MPI_UNSIGNED,d,1,Comm_pt->mpi_comm());
412 MPI_Send(&nhaloed_nonmaster_nodes_processed,1,MPI_UNSIGNED,d,2,
413 Comm_pt->mpi_comm());
414 if(nhaloed_nonmaster_nodes_processed>0)
416 MPI_Send(&haloed_nonmaster_node_index[0],
417 nhaloed_nonmaster_nodes_processed,MPI_UNSIGNED,d,3,
418 Comm_pt->mpi_comm());
422 if(send_unsigneds_count>0)
425 MPI_Send(&send_unsigneds[0],send_unsigneds_count,MPI_UNSIGNED,d,4,
426 Comm_pt->mpi_comm());
428 if(send_doubles_count>0)
431 MPI_Send(&send_doubles[0],send_doubles_count,MPI_DOUBLE,d,5,
432 Comm_pt->mpi_comm());
442 for(
int dd=0; dd<n_proc; dd++)
448 unsigned nrecv_unsigneds = 0;
449 unsigned nrecv_doubles = 0;
450 MPI_Recv(&nrecv_unsigneds,1,MPI_UNSIGNED,dd,0,
451 Comm_pt->mpi_comm(),&status);
452 MPI_Recv(&nrecv_doubles,1,MPI_UNSIGNED,dd,1,
453 Comm_pt->mpi_comm(),&status);
456 unsigned nhalo_nonmaster_nodes_to_process = 0;
457 MPI_Recv(&nhalo_nonmaster_nodes_to_process,1,MPI_UNSIGNED,dd,2,
458 Comm_pt->mpi_comm(),&status);
460 nhalo_nonmaster_nodes_to_process);
461 if (nhalo_nonmaster_nodes_to_process!=0)
463 MPI_Recv(&halo_nonmaster_node_index[0],
464 nhalo_nonmaster_nodes_to_process,MPI_UNSIGNED,dd,3,
465 Comm_pt->mpi_comm(),&status);
473 if(nrecv_unsigneds>0)
476 MPI_Recv(&recv_unsigneds[0],nrecv_unsigneds,MPI_UNSIGNED,dd,4,
477 Comm_pt->mpi_comm(),&status);
482 MPI_Recv(&recv_doubles[0],nrecv_doubles,MPI_DOUBLE,dd,5,
483 Comm_pt->mpi_comm(),&status);
487 unsigned recv_unsigneds_count = 0;
488 unsigned recv_doubles_count = 0;
491 for(
unsigned j=0; j<nhalo_nonmaster_nodes_to_process; j++)
495 Node* nod_pt = shared_node_pt(dd,halo_nonmaster_node_index[j]);
499 if(dynamic_cast<MacroElementNodeUpdateNode*>(nod_pt))
507 std::ostringstream err_stream;
508 err_stream <<
"This currently doesn't work for" 510 <<
"MacroElementNodeUpdateNodes because these require" 512 <<
"MacroElementNodeUpdateElements to be created for" 514 <<
"the missing halo nodes which will be added" 517 OOMPH_CURRENT_FUNCTION,
518 OOMPH_EXCEPTION_LOCATION);
526 unsigned loc_p = (unsigned) dd;
528 recursively_add_masters_of_external_halo_node_to_storage<ELEMENT>
529 (nod_pt,
this, loc_p, node_index, ncont_inter_values,
530 recv_unsigneds_count, recv_unsigneds,
531 recv_doubles_count, recv_doubles);
544 <<
"Time for second all-to-all in additional_synchronise_hanging_nodes() " 545 << t_end-t_start << std::endl;
553 unsigned external_halo_count=0;
554 unsigned external_haloed_count=0;
560 bool duplicate_haloed_node_exists =
false;
563 for (
int d=0;d<n_proc;d++)
568 std::map<Node*,bool> node_shared;
576 unsigned nexternal_halo_nod=nexternal_halo_node(d);
577 for (
unsigned j=0;j<nexternal_halo_nod;j++)
579 Node* nod_pt=external_halo_node_pt(d,j);
582 if (!node_shared[nod_pt])
584 this->add_shared_node_pt(d,nod_pt);
585 node_shared[nod_pt]=
true;
586 external_halo_count++;
592 unsigned nexternal_haloed_nod=nexternal_haloed_node(d);
593 for (
unsigned j=0;j<nexternal_haloed_nod;j++)
595 Node* nod_pt=external_haloed_node_pt(d,j);
598 if (!node_shared[nod_pt])
600 this->add_shared_node_pt(d,nod_pt);
601 node_shared[nod_pt]=
true;
602 external_haloed_count++;
606 duplicate_haloed_node_exists =
true;
619 unsigned nexternal_haloed_nod=nexternal_haloed_node(d);
620 for (
unsigned j=0;j<nexternal_haloed_nod;j++)
622 Node* nod_pt=external_haloed_node_pt(d,j);
625 if (!node_shared[nod_pt])
627 this->add_shared_node_pt(d,nod_pt);
628 node_shared[nod_pt]=
true;
629 external_haloed_count++;
633 duplicate_haloed_node_exists =
true;
639 unsigned nexternal_halo_nod=nexternal_halo_node(d);
640 for (
unsigned j=0;j<nexternal_halo_nod;j++)
642 Node* nod_pt=external_halo_node_pt(d,j);
645 if (!node_shared[nod_pt])
647 this->add_shared_node_pt(d,nod_pt);
648 node_shared[nod_pt]=
true;
649 external_halo_count++;
661 <<
" external halo nodes and" 663 oomph_info <<
"INFO: " << external_haloed_count
664 <<
" external haloed nodes were added to the shared node scheme" 668 if(duplicate_haloed_node_exists)
683 std::ostringstream err_stream;
684 err_stream <<
"Duplicate halo nodes exist on another processor!" 686 <<
"(See source code for more detailed explanation)" 691 OOMPH_CURRENT_FUNCTION,
692 OOMPH_EXCEPTION_LOCATION);
700 <<
"Time for identification of shared nodes in additional_synchronise_hanging_nodes(): " 701 << t_end-t_start << std::endl;
HangInfo *const & hanging_pt() const
Return pointer to hanging node data (this refers to the geometric hanging node status) (const version...
void recursively_add_masters_of_external_haloed_node(int &iproc, Node *nod_pt, Mesh *const &mesh_pt, int &n_cont_inter_values, Vector< unsigned > &send_unsigneds, Vector< double > &send_doubles)
Recursively add any master nodes (and their master nodes etc) of external haloed nodes.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
unsigned nmaster() const
Return the number of master nodes.
bool is_hanging() const
Test whether the node is geometrically hanging.
bool Doc_comprehensive_timings
Global boolean to switch on comprehensive timing – can probably be declared const false when develop...
void additional_synchronise_hanging_nodes(const unsigned &ncont_interpolated_values)
double timer()
returns the time in seconds after some point in past