33 #ifndef OOMPH_LINE_VISUALISER_HEADER 34 #define OOMPH_LINE_VISUALISER_HEADER 38 #include <oomph-lib-config.h> 69 const double& max_search_radius=DBL_MAX) :
71 Comm_pt(mesh_pt->communicator_pt())
74 setup(mesh_pt,coord_vec);
83 const double &scale = 1.0) :
85 Comm_pt(mesh_pt->communicator_pt())
101 const std::string file_name,
const double &scale = 1.0) :
103 Comm_pt(mesh_pt->communicator_pt())
125 unsigned n=data[
i].size();
128 for (
unsigned j=0;j<n;j++)
130 outfile << data[
i][j] <<
" ";
134 outfile << std::endl;
160 int my_rank=
Comm_pt->my_rank();
209 unsigned ndata=vec[
i].size();
213 size_values.push_back(ndata);
216 tmp_proc_point_found_plus_one[
i]=my_rank+1;
219 for (
unsigned j=0;j<ndata;j++)
221 local_values.push_back(vec[
i][j]);
230 MPI_Reduce(&tmp_proc_point_found_plus_one[0],
231 &proc_point_found_plus_one[0],
232 Nplot_points, MPI_UNSIGNED, MPI_MAX, 0,
246 for (
int i=1;
i<nproc;
i++)
249 MPI_Recv(&buff_size, 1, MPI_UNSIGNED,
i,
250 tag,
Comm_pt->mpi_comm(), &stat);
251 received_size[
i-1].resize(std::max(
unsigned(1),buff_size));
252 MPI_Recv(&received_size[
i-1][0], buff_size, MPI_UNSIGNED,
i,
253 tag,
Comm_pt->mpi_comm(), &stat);
256 MPI_Recv(&buff_size, 1, MPI_UNSIGNED,
i,
257 tag,
Comm_pt->mpi_comm(), &stat);
258 received_data[
i-1].resize(std::max(
unsigned(1),buff_size));
259 MPI_Recv(&received_data[
i-1][0], buff_size, MPI_DOUBLE,
i,
260 tag,
Comm_pt->mpi_comm(), &stat);
267 if (proc_point_found_plus_one[
i] != 0)
270 if (proc_point_found_plus_one[
i] == 1)
278 unsigned line_i=proc_point_found_plus_one[
i]-2;
281 data[
i].resize(received_size[line_i][counter_s[line_i] ]);
284 for (
unsigned j=0;j<received_size[line_i][counter_s[line_i] ];
287 data[
i][j]=received_data[line_i][counter_d[line_i]+j];
291 counter_d[line_i]+=received_size[line_i][counter_s[line_i] ];
302 buff_size = size_values.size();
303 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
307 if (buff_size==0) size_values.resize(1);
308 MPI_Send(&size_values[0], buff_size, MPI_UNSIGNED, 0, tag,
312 buff_size = local_values.size();
313 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
317 if (buff_size==0) local_values.resize(1);
318 MPI_Send(&local_values[0], buff_size, MPI_DOUBLE, 0, tag,
322 #endif // Serial version 367 int my_rank=
Comm_pt->my_rank();
386 for (
unsigned j=0; j<dim; j++)
417 unsigned ndata=vec[
i].size();
421 size_values.push_back(ndata);
424 tmp_proc_point_found_plus_one[
i]=my_rank+1;
428 for (
unsigned j=0;j<ndata;j++)
430 local_values.push_back(vec[
i][j]);
439 MPI_Reduce(&tmp_proc_point_found_plus_one[0],
440 &proc_point_found_plus_one[0],
441 Nplot_points, MPI_UNSIGNED, MPI_MAX, 0,
454 for (
int i=1;
i<nproc;
i++)
457 MPI_Recv(&buff_size, 1, MPI_UNSIGNED,
i,
458 tag,
Comm_pt->mpi_comm(), &stat);
459 received_size[
i-1].resize(std::max(
unsigned(1),buff_size));
460 MPI_Recv(&received_size[
i-1][0], buff_size, MPI_UNSIGNED,
i,
461 tag,
Comm_pt->mpi_comm(), &stat);
464 MPI_Recv(&buff_size, 1, MPI_UNSIGNED,
i,
465 tag,
Comm_pt->mpi_comm(), &stat);
466 received_data[
i-1].resize(std::max(
unsigned(1),buff_size));
467 MPI_Recv(&received_data[
i-1][0], buff_size, MPI_DOUBLE,
i,
468 tag,
Comm_pt->mpi_comm(), &stat);
475 if (proc_point_found_plus_one[
i] != 0)
478 if (proc_point_found_plus_one[
i] == 1)
486 unsigned line_i=proc_point_found_plus_one[
i]-2;
489 coord_vec[
i].resize(received_size[line_i][counter_s[line_i] ]);
492 for (
unsigned j=0;j<received_size[line_i][counter_s[line_i] ];
495 coord_vec[
i][j]=received_data[line_i][counter_d[line_i]+j];
499 counter_d[line_i]+=received_size[line_i][counter_s[line_i] ];
510 buff_size = size_values.size();
511 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
515 if (buff_size==0) size_values.resize(1);
516 MPI_Send(&size_values[0], buff_size, MPI_UNSIGNED, 0, tag,
520 buff_size = local_values.size();
521 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
525 if (buff_size==0) local_values.resize(1);
526 MPI_Send(&local_values[0], buff_size, MPI_DOUBLE, 0, tag,
530 #endif // Serial version 557 std::ifstream file_input(file_name.c_str(),std::ios_base::in);
560 std::ostringstream error_message;
561 error_message <<
"Cannot open file " << file_name <<
"\n";
563 OOMPH_CURRENT_FUNCTION,
564 OOMPH_EXCEPTION_LOCATION);
566 if (!file_input.is_open())
568 std::ostringstream error_message;
569 error_message <<
"Cannot open file " << file_name <<
"\n";
571 OOMPH_CURRENT_FUNCTION,
572 OOMPH_EXCEPTION_LOCATION);
580 while(getline(file_input,line))
584 if (isdigit(line[0]))
590 int n=sscanf(line.c_str(),
"%lf %lf %lf",&tmp[0],&tmp[1],&tmp[2]);
595 for (
unsigned i=0;
i<3;
i++)
601 coord_vec_tmp.push_back(tmp);
611 setup(mesh_pt,coord_vec_tmp);
625 unsigned count_not_found_local=0;
628 unsigned dim=coord_vec[0].size();
659 count_not_found_local++;
672 Plot_point[
i]=std::pair<FiniteElement*,Vector<double> >(fe_pt,
s);
676 oomph_info <<
"Number of points not found locally: " 677 << count_not_found_local << std::endl;
680 unsigned count_not_found=count_not_found_local;
686 int nproc=Comm_pt->nproc();
693 int my_rank=Comm_pt->my_rank();
706 tmp_proc_point_found_plus_one[
i]=my_rank+1;
714 MPI_Reduce(&tmp_proc_point_found_plus_one[0],
715 &proc_point_found_plus_one[0],
716 Nplot_points, MPI_UNSIGNED, MPI_MAX, 0,
717 Comm_pt->mpi_comm());
728 if (proc_point_found_plus_one[
i] == 0)
736 MPI_Bcast(&count_not_found,1,MPI_UNSIGNED,0,
737 Comm_pt->mpi_comm());
744 <<
"Total time for location of plot points in LineVisualiser: " 745 << tt_end-tt_start <<
" [" << count_not_found
746 <<
" plot points were not found (with max search radius=" 747 << Max_search_radius <<
")]\n";
762 for (
unsigned j=0; j<dim; j++)
void setup_from_file(Mesh *mesh_pt, const std::string file_name, const double &scale)
Helper function to setup from file.
SamplePointContainer * sample_point_container_pt() const
Pointer to the sample point container.
unsigned Nplot_points
Number of plot points.
LineVisualiser(Mesh *mesh_pt, const double &max_search_radius, const std::string file_name, const double &scale=1.0)
Constructor reading centerline file.
A general Finite Element class.
double Max_search_radius
Max radius beyond which we stop searching the bin. Initialised to DBL_MAX so keep going until the poi...
void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s, const bool &use_coordinate_as_initial_guess=false)
Find the sub geometric object and local coordinate therein that corresponds to the intrinsic coordina...
void update_plot_points_coordinates(Vector< Vector< double > > &coord_vec)
Update plot points coordinates (in preparation of remesh, say).
Class to aid visualisation of the values on a set of points. NOTE: in a distributed problem...
void get_output_data(Vector< Vector< double > > &data)
Output data function: store data associated with each plot point in data array.
void get_local_plot_points_coordinates(Vector< Vector< double > > &data)
LineVisualiser(Mesh *mesh_pt, const std::string file_name, const double &scale=1.0)
Constructor reading centerline file.
double timer()
returns the time in seconds after some point in past
void setup(Mesh *mesh_pt, const Vector< Vector< double > > &coord_vec)
Helper function to setup the output structures.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
OomphCommunicator * Comm_pt
Pointer to communicator – allows us to collect data on processor 0 if the mesh is distributed...
Vector< std::pair< FiniteElement *, Vector< double > > > Plot_point
Vector of pairs containing points to finite elements and local coordinates.
double & max_search_radius()
Set maximum search radius for locate zeta. This is initialised do DBL_MAX so we brutally search throu...
void output(std::ostream &outfile)
Output function: output each plot point. NOTE: in a distributed problem, output is only done on proce...
LineVisualiser(Mesh *mesh_pt, const Vector< Vector< double > > &coord_vec, const double &max_search_radius=DBL_MAX)
Constructor: Pass pointer to mesh and coordinates of desired plot points: coord_vec[j][i] is the i-th...
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...