29 #ifndef OOMPH_LINE_VISUALISER_HEADER
30 #define OOMPH_LINE_VISUALISER_HEADER
34 #include <oomph-lib-config.h>
62 const double& max_search_radius = DBL_MAX)
64 Comm_pt(mesh_pt->communicator_pt())
67 setup(mesh_pt, coord_vec);
77 const double& scale = 1.0)
94 const double& max_search_radius,
96 const double& scale = 1.0)
98 Comm_pt(mesh_pt->communicator_pt())
118 unsigned n = data[
i].size();
121 for (
unsigned j = 0; j < n; j++)
123 outfile << data[
i][j] <<
" ";
127 outfile << std::endl;
152 int my_rank =
Comm_pt->my_rank();
201 unsigned ndata = vec[
i].size();
205 size_values.push_back(ndata);
208 tmp_proc_point_found_plus_one[
i] = my_rank + 1;
211 for (
unsigned j = 0; j < ndata; j++)
213 local_values.push_back(vec[
i][j]);
222 MPI_Reduce(&tmp_proc_point_found_plus_one[0],
223 &proc_point_found_plus_one[0],
241 for (
int i = 1;
i < nproc;
i++)
251 received_size[
i - 1].resize(std::max(
unsigned(1), buff_size));
252 MPI_Recv(&received_size[
i - 1][0],
268 received_data[
i - 1].resize(std::max(
unsigned(1), buff_size));
269 MPI_Recv(&received_data[
i - 1][0],
282 if (proc_point_found_plus_one[
i] != 0)
285 if (proc_point_found_plus_one[
i] == 1)
293 unsigned line_i = proc_point_found_plus_one[
i] - 2;
296 data[
i].resize(received_size[line_i][counter_s[line_i]]);
300 j < received_size[line_i][counter_s[line_i]];
303 data[
i][j] = received_data[line_i][counter_d[line_i] + j];
307 counter_d[line_i] += received_size[line_i][counter_s[line_i]];
318 buff_size = size_values.size();
319 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
Comm_pt->mpi_comm());
322 if (buff_size == 0) size_values.resize(1);
323 MPI_Send(&size_values[0],
331 buff_size = local_values.size();
332 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
Comm_pt->mpi_comm());
335 if (buff_size == 0) local_values.resize(1);
336 MPI_Send(&local_values[0],
387 int my_rank =
Comm_pt->my_rank();
406 for (
unsigned j = 0; j < dim; j++)
437 unsigned ndata = vec[
i].size();
441 size_values.push_back(ndata);
444 tmp_proc_point_found_plus_one[
i] = my_rank + 1;
448 for (
unsigned j = 0; j < ndata; j++)
450 local_values.push_back(vec[
i][j]);
459 MPI_Reduce(&tmp_proc_point_found_plus_one[0],
460 &proc_point_found_plus_one[0],
477 for (
int i = 1;
i < nproc;
i++)
487 received_size[
i - 1].resize(std::max(
unsigned(1), buff_size));
488 MPI_Recv(&received_size[
i - 1][0],
504 received_data[
i - 1].resize(std::max(
unsigned(1), buff_size));
505 MPI_Recv(&received_data[
i - 1][0],
518 if (proc_point_found_plus_one[
i] != 0)
521 if (proc_point_found_plus_one[
i] == 1)
524 coord_vec[
i] = vec[
i];
529 unsigned line_i = proc_point_found_plus_one[
i] - 2;
532 coord_vec[
i].resize(received_size[line_i][counter_s[line_i]]);
536 j < received_size[line_i][counter_s[line_i]];
540 received_data[line_i][counter_d[line_i] + j];
544 counter_d[line_i] += received_size[line_i][counter_s[line_i]];
555 buff_size = size_values.size();
556 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
Comm_pt->mpi_comm());
559 if (buff_size == 0) size_values.resize(1);
560 MPI_Send(&size_values[0],
568 buff_size = local_values.size();
569 MPI_Send(&buff_size, 1, MPI_UNSIGNED, 0, tag,
Comm_pt->mpi_comm());
572 if (buff_size == 0) local_values.resize(1);
573 MPI_Send(&local_values[0],
608 std::ifstream file_input(file_name.c_str(), std::ios_base::in);
611 std::ostringstream error_message;
612 error_message <<
"Cannot open file " << file_name <<
"\n";
614 OOMPH_CURRENT_FUNCTION,
615 OOMPH_EXCEPTION_LOCATION);
617 if (!file_input.is_open())
619 std::ostringstream error_message;
620 error_message <<
"Cannot open file " << file_name <<
"\n";
622 OOMPH_CURRENT_FUNCTION,
623 OOMPH_EXCEPTION_LOCATION);
631 while (getline(file_input, line) )
635 if (isdigit(line[0]))
642 sscanf(line.c_str(),
"%lf %lf %lf", &tmp[0], &tmp[1], &tmp[2]);
647 for (
unsigned i = 0;
i < 3;
i++)
653 coord_vec_tmp.push_back(tmp);
663 setup(mesh_pt, coord_vec_tmp);
676 unsigned count_not_found_local = 0;
679 unsigned dim = coord_vec[0].size();
710 count_not_found_local++;
723 Plot_point[
i] = std::pair<FiniteElement*, Vector<double>>(fe_pt,
s);
727 oomph_info <<
"Number of points not found locally: "
728 << count_not_found_local << std::endl;
731 unsigned count_not_found = count_not_found_local;
743 int my_rank =
Comm_pt->my_rank();
756 tmp_proc_point_found_plus_one[
i] = my_rank + 1;
764 MPI_Reduce(&tmp_proc_point_found_plus_one[0],
765 &proc_point_found_plus_one[0],
781 if (proc_point_found_plus_one[
i] == 0)
789 MPI_Bcast(&count_not_found, 1, MPI_UNSIGNED, 0,
Comm_pt->mpi_comm());
794 oomph_info <<
"Number of plot points not found (with max search radius="
796 <<
"\nTotal time for LineVisualiser setup [sec]: "
812 for (
unsigned j = 0; j < dim; j++)
double & max_search_radius()
Set maximum search radius for locate zeta. This is initialised do DBL_MAX so we brutally search throu...
A general Finite Element class.
/////////////////////////////////////////////////////////////////////
Class to aid visualisation of the values on a set of points. NOTE: in a distributed problem,...
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.
LineVisualiser(Mesh *mesh_pt, const std::string file_name, const double &scale=1.0)
Constructor reading centerline file.
void update_plot_points_coordinates(Vector< Vector< double >> &coord_vec)
Update plot points coordinates (in preparation of remesh, say).
unsigned Nplot_points
Number of plot points.
void setup(Mesh *mesh_pt, const Vector< Vector< double >> &coord_vec)
Helper function to setup the output structures.
void get_output_data(Vector< Vector< double >> &data)
Output data function: store data associated with each plot point in data array.
LineVisualiser(Mesh *mesh_pt, const double &max_search_radius, const std::string file_name, const double &scale=1.0)
Constructor reading centerline file.
double Max_search_radius
Max radius beyond which we stop searching the bin. Initialised to DBL_MAX so keep going until the poi...
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...
void get_local_plot_points_coordinates(Vector< Vector< double >> &data)
void output(std::ostream &outfile)
Output function: output each plot point. NOTE: in a distributed problem, output is only done on proce...
void setup_from_file(Mesh *mesh_pt, const std::string file_name, const double &scale)
Helper function to setup from file.
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
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...
SamplePointContainer * sample_point_container_pt() const
Pointer to the sample point container.
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
An OomphLibError object which should be thrown when an run-time error is encountered....
A slight extension to the standard template vector class so that we can include "graceful" array rang...
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
double timer()
returns the time in seconds after some point in past
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...