sample_point_container.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2024 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 #ifndef OOMPH_SAMPLE_POINT_CONTAINER_HEADER
27 #define OOMPH_SAMPLE_POINT_CONTAINER_HEADER
28 
29 #ifdef OOMPH_HAS_CGAL
30 
31 #include <CGAL/Cartesian_d.h>
32 #include <CGAL/Search_traits_d.h>
33 #include <CGAL/Search_traits_adapter.h>
34 #include <boost/iterator/zip_iterator.hpp>
35 #include <CGAL/Orthogonal_k_neighbor_search.h>
36 
37 #endif
38 
39 // oomph-lib includes
41 #include "sparse_vector.h"
42 
43 /// /////////////////////////////////////////////////////////////////
44 /// /////////////////////////////////////////////////////////////////
45 /// /////////////////////////////////////////////////////////////////
46 
47 
48 //=============================================================================
49 /// Class for containing sample points: Number of finite element in
50 /// its mesh and index of sample point within that element.
51 //=============================================================================
53 {
54 public:
55  /// Construct SamplePoint object from number of finite element
56  /// in its mesh, and index of sample point within that element
58  const unsigned& sample_point_index_in_element)
61  {
62  }
63 
64  /// Broken copy constructor.
65  SamplePoint(const SamplePoint& data) = delete;
66 
67  /// Broken assignment operator.
68  void operator=(const SamplePoint&) = delete;
69 
70  /// Access function to the index of finite element in its mesh
71  unsigned element_index_in_mesh() const
72  {
73  return Element_index_in_mesh;
74  }
75 
76  /// Index of sample point within element
78  {
80  }
81 
82 
83 private:
84  /// Index of finite element in its mesh
86 
87  /// Index of the sample point within element
89 };
90 
91 
92 /// /////////////////////////////////////////////////////////////////
93 /// /////////////////////////////////////////////////////////////////
94 /// /////////////////////////////////////////////////////////////////
95 
96 
97 // Forward declaration of the RefineableBinArray class.
98 class RefineableBinArray;
99 
100 
101 //==============================================================================
102 /// RefineableBin class. Contains sample points and is embedded in a
103 /// RefineableBinArray. May itself be represented by a RefineableBinArray to
104 /// make it recursive.
105 //==============================================================================
107 {
108 public:
109  /// Constructor. Pass pointer to bin array that
110  /// contains this bin and the index of the newly created bin in that
111  /// RefineableBinArray
113  const unsigned& bin_index_in_bin_array)
114  : Sample_point_pt(0),
115  Sub_bin_array_pt(0),
116  Bin_array_pt(bin_array_pt),
117  Bin_index_in_bin_array(bin_index_in_bin_array)
118  {
119  }
120 
121 
122  /// Broken copy constructor.
123  RefineableBin(const RefineableBin& data) = delete;
124 
125  /// Broken assignment operator.
126  void operator=(const RefineableBin&) = delete;
127 
128  /// Destructor
129  ~RefineableBin();
130 
131  /// Compute total number of sample points recursively
133 
134  /// Add a new sample point to RefineableBin
135  void add_sample_point(SamplePoint* new_sample_point_pt,
136  const Vector<double>& zeta_coordinates);
137 
138  /// Find sub-GeomObject (finite element) and the local coordinate
139  /// s within it that contains point with global coordinate zeta.
140  /// sub_geom_object_pt=0 if point can't be found.
141  void locate_zeta(const Vector<double>& zeta,
142  GeomObject*& sub_geom_object_pt,
143  Vector<double>& s);
144 
145  /// Output bin; x,[y,[z]],n_sample_points
146  void output(std::ofstream& outfile, const bool& don_t_recurse = false);
147 
148  /// Output bin vertices (allowing display of bins as zones).
149  void output_bins(std::ofstream& outfile);
150 
151  /// Output bin vertices (allowing display of bins as zones).
152  void output_bin_vertices(std::ofstream& outfile);
153 
154  /// Number of sample points stored in bin
156  {
157  if (Sample_point_pt == 0)
158  {
159  return 0;
160  }
161  else
162  {
163  return Sample_point_pt->size();
164  }
165  }
166 
167 protected:
168  /// Container of SamplePoints. Pointer to vector because it's shorter
169  /// than an empty vector! (Not all RefineableBins have sample
170  /// points -- the ones that are subdivided don't!)
171  Vector<SamplePoint*>* Sample_point_pt;
172 
173  /// Pointer to a possible sub-BinArray. Null by default
175 
176  /// Pointer to the bin array which "owns" this RefineableBin.
178 
179  /// Index of bin in its bin array
181 
182  /// Method for building a new subbin_array (called when the Bin size
183  /// is greater than the Max_number_of_sample_point_per_bin (and the Bin is
184  /// recursive). Pass in the extremal coordinates of the bin which is
185  /// being subdivided. Redistributes all existing sample points to
186  /// newly made sub-bin-array and empties its own storage. Pass
187  /// Max./min. coordinates of new bin array for efficiency.
188  void make_sub_bin_array(
189  const Vector<std::pair<double, double>>& min_and_max_coordinates);
190 
191  /// Boundaries of bin in each coordinate direction.
192  /// *.first = min; *.second = max
193  void get_bin_boundaries(
194  Vector<std::pair<double, double>>& min_and_max_coordinates);
195 };
196 
197 
198 /// /////////////////////////////////////////////////////////////////////
199 /// /////////////////////////////////////////////////////////////////////
200 /// /////////////////////////////////////////////////////////////////////
201 
202 //=========================================================================
203 /// Base class for all sample point containers
204 //=========================================================================
206 {
207 public:
208  /// Constructor
210  Mesh* mesh_pt,
211  const Vector<std::pair<double, double>>& min_and_max_coordinates,
214  const unsigned& nsample_points_generated_per_element)
215  : Mesh_pt(mesh_pt),
219 #ifdef OOMPH_HAS_MPI
222 #endif
226  {
227  // Don't limit max. search radius
228  Max_search_radius = DBL_MAX;
229  }
230 
231  /// Broken default constructor; needed for broken
232  /// copy constructors. Don't call. It will die.
234  {
235  // Throw the error
236  throw OomphLibError("Broken default constructor. Don't call this!",
237  OOMPH_CURRENT_FUNCTION,
238  OOMPH_EXCEPTION_LOCATION);
239  }
240 
241  /// Broken copy constructor.
243 
244  /// Broken assignment operator.
245  void operator=(const SamplePointContainer&) = delete;
246 
247  /// Virtual destructor
249 
250  /// Find sub-GeomObject (finite element) and the local coordinate
251  /// s within it that contains point with global coordinate zeta.
252  /// sub_geom_object_pt=0 if point can't be found.
253  virtual void locate_zeta(const Vector<double>& zeta,
254  GeomObject*& sub_geom_object_pt,
255  Vector<double>& s) = 0;
256 
257 
258  /// Counter to keep track of how many sample points we've
259  /// visited during top level call to locate_zeta. Virtual so it can be
260  /// overloaded for different versions.
262  {
264  }
265 
266  /// Total number of sample points in sample point container, possibly
267  /// computed recursively.
269  const = 0;
270 
271  /// Dimension of the zeta ( = dim of local coordinate of elements)
272  virtual unsigned ndim_zeta() const = 0;
273 
274  /// Pointer to mesh from whose FiniteElements sample points are created
275  Mesh* mesh_pt() const
276  {
277  return Mesh_pt;
278  }
279 
280  /// Pair of doubles for min and maximum coordinates in i-th direction:
281  /// min (first) and max. (second) coordinates
282  const std::pair<double, double>& min_and_max_coordinates(
283  const unsigned& i) const
284  {
285  return Min_and_max_coordinates[i];
286  }
287 
288  /// Vector of pair of doubles for min and maximum coordinates.
289  /// min (first) and max. (second) coordinates
290  const Vector<std::pair<double, double>>& min_and_max_coordinates() const
291  {
293  }
294 
295 
296 #ifdef OOMPH_HAS_MPI
297 
298  /// Ignore halo elements?
300  {
302  }
303 
304 #endif
305 
306  /// Use Eulerian coordinates (i.e. interpolated_x) rather than
307  /// zeta itself (i.e. interpolated_zeta) to identify point.
309  {
311  }
312 
313  /// "Measure of" number of sample points generated in each element
315  {
317  }
318 
319  /// Set maximum search radius for locate zeta. This is initialised
320  /// do DBL_MAX so we brutally search through the entire bin structure,
321  /// no matter how big it is until we've found the required point (or
322  /// failed to do so. This can be VERY costly with fine meshes.
323  /// Here the user takes full responsibility and states that we have
324  /// no chance in hell to find the required point in
325  /// a bin whose closest vertex is further than the specified
326  /// max search radius.
328  {
329  return Max_search_radius;
330  }
331 
332 
333  /// File to record sequence of visited sample points in. Used for debugging/
334  /// illustration of search procedures.
335  static std::ofstream Visited_sample_points_file;
336 
337  /// Boolean flag to make to make locate zeta fail. Used for debugging/
338  /// illustration of search procedures.
340 
341  /// Use equally spaced sample points? (otherwise vertices are sampled
342  /// repeatedly
344 
345  /// Time setup?
347 
348  /// Offset of sample point container boundaries beyond max/min coords
349  static double Percentage_offset;
350 
351 protected:
352  /// Helper function to compute the min and max coordinates for the
353  /// mesh, in each dimension
355 
356  /// Pointer to mesh from whose FiniteElements sample points are created
357  Mesh* Mesh_pt;
358 
359  /// Vector of pairs of doubles for min and maximum coordinates.
360  /// Call: Min_and_max_coordinates[j] gives me the
361  /// pair of min (first) and max. (second) coordinates in the j-th
362  /// coordinate direction.
363  Vector<std::pair<double, double>> Min_and_max_coordinates;
364 
365  /// Use Eulerian coordinates (i.e. interpolated_x) rather than
366  /// zeta itself (i.e. interpolated_zeta) to identify point.
368 
369 #ifdef OOMPH_HAS_MPI
370 
371  /// Ignore halo elements?
373 
374 #endif
375 
376  /// "Measure of" number of sample points generated in each element
378 
379  /// Counter to keep track of how many sample points we've
380  /// visited during top level call to locate_zeta
381  unsigned
383 
384  /// Max radius beyond which we stop searching the bin. Initialised
385  /// to DBL_MAX so keep going until the point is found or until
386  /// we've searched every single bin. Overwriting this means we won't search
387  /// in bins whose closest vertex is at a distance greater than
388  /// Max_search_radius from the point to be located.
390 };
391 
392 
393 /// /////////////////////////////////////////////////////////////////////
394 /// /////////////////////////////////////////////////////////////////////
395 /// /////////////////////////////////////////////////////////////////////
396 
397 
398 //=========================================================================
399 /// Base class for all bin arrays
400 //=========================================================================
401 class BinArray : public virtual SamplePointContainer
402 {
403 public:
404  /// Constructor
406  const Vector<std::pair<double, double>>& min_and_max_coordinates,
407  const Vector<unsigned>& dimensions_of_bin_array,
410  const unsigned& nsample_points_generated_per_element)
417  {
418  // Note: Resizing of Dimensions_of_bin_array if no sizes are specified
419  // is delayed to derived class since refineable and nonrefineable
420  // bin arrays have different defaults.
421  }
422 
423  /// Broken default constructor; needed for broken
424  /// copy constructors. Don't call. It will die.
426  {
427  // Throw the error
428  throw OomphLibError("Broken default constructor. Don't call this!",
429  OOMPH_CURRENT_FUNCTION,
430  OOMPH_EXCEPTION_LOCATION);
431  }
432 
433  /// Broken copy constructor.
434  BinArray(const BinArray& data) = delete;
435 
436  /// Broken assignment operator.
437  void operator=(const BinArray&) = delete;
438 
439  /// Virtual destructor
440  virtual ~BinArray() {}
441 
442  /// Helper function for computing the bin indices of neighbouring bins
443  /// at a given "radius" of the specified bin. Final, optional boolean
444  /// (default: true) chooses to use the old version which appears to be
445  /// faster than Louis' new one after all (in the few cases where this
446  /// functionality is still used -- not all if we have cgal!)
447  void get_neighbouring_bins_helper(const unsigned& bin_index,
448  const unsigned& radius,
449  Vector<unsigned>& neighbouring_bin_index,
450  const bool& use_old_version = true);
451 
452  /// Profiling function to compare performance of two different
453  /// versions of the get_neighbouring_bins_helper(...) function
455 
456 
457  /// Get (linearly enumerated) bin index of bin that
458  /// contains specified zeta
459  unsigned coords_to_bin_index(const Vector<double>& zeta);
460 
461 
462  /// Get "coordinates" of bin that contains specified zeta
463  void coords_to_vectorial_bin_index(const Vector<double>& zeta,
464  Vector<unsigned>& bin_index);
465 
466  /// Output bins (boundaries and number of sample points in them)
467  virtual void output_bins(std::ofstream& outfile) = 0;
468 
469  /// Output bin vertices (allowing display of bin boundaries as zones).
470  virtual void output_bin_vertices(std::ofstream& outfile) = 0;
471 
472  /// Number of bins (not taking recursion into account for refineable
473  /// versions)
474  virtual unsigned nbin() const = 0;
475 
476  /// Max. bin dimension (number of bins in coordinate directions)
477  unsigned max_bin_dimension() const;
478 
479  /// Dimension of the zeta ( = dim of local coordinate of elements)
480  unsigned ndim_zeta() const
481  {
482  return Dimensions_of_bin_array.size();
483  }
484 
485  /// Number of bins in coordinate direction i
486  unsigned dimension_of_bin_array(const unsigned& i) const
487  {
488  return Dimensions_of_bin_array[i];
489  }
490 
491 
492  /// Number of bins in coordinate directions. Const vector-based
493  /// version
494  Vector<unsigned> dimensions_of_bin_array() const
495  {
497  }
498 
499 
500  /// Number of bins in specified coordinate direction
501  unsigned dimensions_of_bin_array(const unsigned& i) const
502  {
503  return Dimensions_of_bin_array[i];
504  }
505 
506 protected:
507  /// Number of bins in each coordinate direction
508  Vector<unsigned> Dimensions_of_bin_array;
509 };
510 
511 
512 /// /////////////////////////////////////////////////////////////////////
513 /// /////////////////////////////////////////////////////////////////////
514 /// /////////////////////////////////////////////////////////////////////
515 
516 
517 //==============================================================================
518 /// RefineableBinArray class.
519 //==============================================================================
520 class RefineableBinArray : public virtual BinArray
521 {
522 public:
523  /// Constructor
524  RefineableBinArray(SamplePointContainerParameters* bin_array_parameters_pt);
525 
526  /// Broken copy constructor.
527  RefineableBinArray(const RefineableBinArray& data) = delete;
528 
529  /// Broken assignment operator.
530  void operator=(const RefineableBinArray&) = delete;
531 
532  /// Destructor
534  {
535  unsigned n = Bin_pt.size();
536  for (unsigned i = 0; i < n; i++)
537  {
538  if (Bin_pt[i] != 0)
539  {
540  delete Bin_pt[i];
541  Bin_pt[i] = 0;
542  }
543  }
544  }
545 
546  /// Root bin array
548  {
549  return Root_bin_array_pt;
550  }
551 
552  /// Pointer to i-th bin; can be null if bin is empty
553  RefineableBin* bin_pt(const unsigned& i) const
554  {
555  return Bin_pt[i];
556  }
557 
558  /// Number of bins (not taking recursion into account)
559  unsigned nbin() const
560  {
561  return Bin_pt.size();
562  }
563 
564  /// Default number of bins (in each coordinate direction)
565  /// (Note: don't move this into a common base class because
566  /// each derived class has its own value; we'll want far fewer
567  /// in the refineable version!)
568  static unsigned Default_n_bin_1d;
569 
570  /// Compute total number of sample points recursively
572 
573  /// Fill the bin array with specified SamplePoints
574  void fill_bin_array(const Vector<SamplePoint*>& sample_point_pt)
575  {
576  unsigned n_dim = ndim_zeta();
577 
578  unsigned n = sample_point_pt.size();
579  for (unsigned i = 0; i < n; i++)
580  {
581  // Coordinates of this point
582  Vector<double> zeta(n_dim);
583 
584  // Which element is the point in?
585  unsigned e = sample_point_pt[i]->element_index_in_mesh();
586  FiniteElement* el_pt = Mesh_pt->finite_element_pt(e);
587 
588  // Which sample point is it at?
589  unsigned j = sample_point_pt[i]->sample_point_index_in_element();
590  Vector<double> s(n_dim);
591  bool use_equally_spaced_interior_sample_points =
593  el_pt->get_s_plot(j,
595  s,
596  use_equally_spaced_interior_sample_points);
598  {
599  el_pt->interpolated_x(s, zeta);
600  }
601  else
602  {
603  el_pt->interpolated_zeta(s, zeta);
604  }
605 
606  // Add it
607  add_sample_point(sample_point_pt[i], zeta);
608  }
609  }
610 
611  /// Add specified SamplePoint to RefineableBinArray
612  void add_sample_point(SamplePoint* new_sample_point_pt,
613  const Vector<double>& zeta)
614  {
615  // Find the correct bin
616  unsigned bin_index = coords_to_bin_index(zeta);
617 
618  // if the bin is not yet created, create it...
619  if (Bin_pt[bin_index] == 0)
620  {
621  Bin_pt[bin_index] = new RefineableBin(this, bin_index);
622  }
623  // Then add the SamplePoint
624  Bin_pt[bin_index]->add_sample_point(new_sample_point_pt, zeta);
625  }
626 
627  /// Find sub-GeomObject (finite element) and the local coordinate
628  /// s within it that contains point with global coordinate zeta.
629  /// sub_geom_object_pt=0 if point can't be found.
630  void locate_zeta(const Vector<double>& zeta,
631  GeomObject*& sub_geom_object_pt,
632  Vector<double>& s);
633 
634  /// Boundaries of specified bin in each coordinate direction.
635  /// *.first = min; *.second = max.
636  void get_bin_boundaries(
637  const unsigned& bin_index,
638  Vector<std::pair<double, double>>& min_and_max_coordinates);
639 
640  /// Depth of the hierarchical bin_array.
641  unsigned depth() const
642  {
643  return Depth;
644  }
645 
646  /// Max depth of the hierarchical bin_array; const version
647  unsigned max_depth() const
648  {
649  return Max_depth;
650  }
651 
652  /// Max depth of the hierarchical bin_array
653  unsigned& max_depth()
654  {
655  return Max_depth;
656  }
657 
658  /// Is the BinArray recursive?
660  {
661  return Bin_array_is_recursive;
662  }
663 
664  /// Maximum number of sample points in bin (before its subdivided
665  /// recursively)
667  {
669  }
670 
671  /// Output bins
672  void output_bins(std::ofstream& outfile)
673  {
674  /// Loop over bins
675  unsigned n_bin = Bin_pt.size();
676  for (unsigned i = 0; i < n_bin; i++)
677  {
678  if (Bin_pt[i] != 0)
679  {
680  Bin_pt[i]->output(outfile);
681  }
682  }
683  }
684 
685  /// Output bin vertices (allowing display of bins as zones).
686  void output_bin_vertices(std::ofstream& outfile);
687 
688  /// Output neighbouring bins at given "radius" of the specified bin
689  void output_neighbouring_bins(const unsigned& bin_index,
690  const unsigned& radius,
691  std::ofstream& outfile);
692 
693 
694  /// Counter to keep track of how many sample points we've
695  /// visited during top level call to locate_zeta
697  {
698  if (Depth == 0)
699  {
701  }
702  else
703  {
704  return Root_bin_array_pt
706  }
707  }
708 
709  /// When searching through sample points recursively from the top
710  /// level RefineableBinArray (in deterministic order!) only actually do the
711  /// locate_zeta calls when when the counter exceeds this value.
713  {
715  }
716 
717  /// When searching through sample points recursively from the top
718  /// level RefineableBinArray (in deterministic order!) only actually do the
719  /// locate_zeta calls when when the counter is less than this value.
721  {
723  }
724 
725  /// Every time we've completed a "spiral", visiting a finite
726  /// number of sample points in a deterministic order, use this
727  /// multiplier to increase the max. number of sample points to be visited.
728  /// Using a multiplier rather than a constant increment increases
729  /// the amount of (more and more unlikely to yield anything!) work
730  /// done locally before doing another costly mpi round trip
731  /// when we're already far from the point we're trying to find.
733  {
735  }
736 
737  /// When searching through sample points recursively from the top
738  /// level RefineableBinArray (in deterministic order!) only actually do the
739  /// locate_zeta calls when when the counter exceeds this value.
740  /// This is the initial value when starting the spiral based search.
742  {
744  }
745 
746 
747 private:
748  /// Fill the bin array with sample points from FiniteElements stored in mesh
749  void fill_bin_array();
750 
751  /// Loop over all sample points in the element specified via the
752  /// pointer and create a SamplePoint for each. Also specify the index of the
753  /// element in its mesh.
754  void create_sample_points_from_element(FiniteElement* const element_pt,
755  const unsigned& n_element);
756 
757 
758  /// Vector of pointers to constituent RefineableBins.
759  Vector<RefineableBin*> Bin_pt;
760 
761  /// Variable which stores if the RefineableBinArray is
762  /// recursive or not.
764 
765  /// Variable which stores the Depth value of the bin_array. Useful for
766  /// debugging and for preventing "infinite" recursion in case if there is
767  /// a problem.
768  unsigned Depth;
769 
770  /// Max depth of the hierarchical bin_array
771  unsigned Max_depth;
772 
773  /// Maximum number of sample points in bin (before it's subdivided
774  /// recursively)
776 
777  /// Pointer to root bin array
779 
780  // hierher only used in root
781 
782  /// When searching through sample points recursively from the top
783  /// level RefineableBinArray (in deterministic order!) only actually do the
784  /// locate_zeta calls when when the counter exceeds this value.
786 
787  /// When searching through sample points recursively from the top
788  /// level RefineableBinArray (in deterministic order!) only actually do the
789  /// locate_zeta calls when when the counter is less than this value.
791 
792  /// Every time we've completed a "spiral", visiting a finite
793  /// number of sample points in a deterministic order, use this
794  /// multiplier to increase the max. number of sample points to be visited.
795  /// Using a multiplier rather than a constant increment increases
796  /// the amount of (more and more unlikely to yield anything!) work
797  /// done locally before doing another costly mpi round trip
798  /// when we're already far from the point we're trying to find.
799  unsigned
801 
802  /// When searching through sample points recursively from the top
803  /// level RefineableBinArray (in deterministic order!) only actually do the
804  /// locate_zeta calls when when the counter exceeds this value.
805  /// This is the initial value when starting the spiral based search.
807 };
808 
809 
810 /// /////////////////////////////////////////////////////////////////////////////
811 /// /////////////////////////////////////////////////////////////////////////////
812 /// /////////////////////////////////////////////////////////////////////////////
813 
814 
815 //==============================================================================
816 /// NonRefineableBinArray class.
817 //==============================================================================
818 class NonRefineableBinArray : public virtual BinArray
819 {
820 public:
821  /// Constructor
823  SamplePointContainerParameters* bin_array_parameters_pt);
824 
825  /// Destructor:
827  {
829  }
830 
831  /// Broken copy constructor.
833 
834  /// Broken assignment operator.
835  void operator=(const NonRefineableBinArray&) = delete;
836 
837  /// Find sub-GeomObject (finite element) and the local coordinate
838  /// s within it that contains point with global coordinate zeta.
839  /// sub_geom_object_pt=0 if point can't be found.
840  void locate_zeta(const Vector<double>& zeta,
841  GeomObject*& sub_geom_object_pt,
842  Vector<double>& s);
843 
844  /// Total number of bins (empty or not)
845  unsigned nbin() const
846  {
847  const unsigned n_lagrangian = ndim_zeta();
848  unsigned ntotalbin = Dimensions_of_bin_array[0];
849  for (unsigned i = 1; i < n_lagrangian; i++)
850  {
851  ntotalbin *= Dimensions_of_bin_array[i];
852  }
853  return ntotalbin;
854  }
855 
856  /// Default number of bins (in each coordinate direction).
857  /// (Note: don't move this into a common base class because
858  /// each derived class has its own value; nonrefineable bin
859  /// wants a much larger value than the refineable one!)
860  static unsigned Default_n_bin_1d;
861 
862  /// Compute total number of sample points recursively
864 
865  /// Number of spirals to be searched in one go const version
866  unsigned n_spiral_chunk() const
867  {
868  return Nspiral_chunk;
869  }
870 
871  /// Number of spirals to be searched in one go
872  unsigned& n_spiral_chunk()
873  {
874  return Nspiral_chunk;
875  }
876 
877  /// Access function to max. spiral level during straight locate_zeta
878  /// search (for efficiency; similar to max_search_radius())
879  unsigned& max_spiral_level()
880  {
881  return Max_spiral_level;
882  }
883 
884  /// Access function to current min. spiral level
886  {
888  }
889 
890  /// Access function to current max. spiral level
892  {
894  }
895 
896  /// Provide some stats on the fill level of the associated bin
897  void get_fill_stats(unsigned& n_bin,
898  unsigned& max_n_entry,
899  unsigned& min_n_entry,
900  unsigned& tot_n_entry,
901  unsigned& n_empty) const;
902 
903  /// Compute the minimum distance of any vertex in the specified bin
904  /// from the specified Lagrangian coordinate zeta
905  double min_distance(const unsigned& i_bin, const Vector<double>& zeta);
906 
907  /// Output bin vertices (allowing display of bins as zones).
908  void output_bin_vertices(std::ofstream& outfile);
909 
910  /// Get vector of vectors containing the coordinates of the
911  /// vertices of the i_bin-th bin: bin_vertex[j][i] contains the
912  /// i-th coordinate of the j-th vertex.
913  void get_bin_vertices(const unsigned& i_bin,
914  Vector<Vector<double>>& bin_vertex);
915 
916  /// Get the number of the bin containing the specified coordinate.
917  /// Bin number is negative if the coordinate is outside
918  /// the bin structure.
919  void get_bin(const Vector<double>& zeta, int& bin_number);
920 
921  /// Get the number of the bin containing the specified coordinate; also
922  /// return the contents of that bin. Bin number is negative if the
923  /// coordinate is outside the bin structure.
924  void get_bin(
925  const Vector<double>& zeta,
926  int& bin_number,
927  Vector<std::pair<FiniteElement*, Vector<double>>>& sample_point_pairs);
928 
929  /// Get the contents of all bins in vector
930  Vector<Vector<std::pair<FiniteElement*, Vector<double>>>> bin_content() const
931  {
932  Vector<Vector<std::pair<FiniteElement*, Vector<double>>>> all_vals;
933  Bin_object_coord_pairs.get_all_values(all_vals);
934  return all_vals;
935  }
936 
937  /// Get the contents of all bins in vector
938  const std::map<unsigned, Vector<std::pair<FiniteElement*, Vector<double>>>>* get_all_bins_content()
939  const
940  {
941  // Return the content of the bins
942  return Bin_object_coord_pairs.map_pt();
943  }
944 
945  /// Fill bin by diffusion, populating each empty bin with the
946  /// same content as the first non-empty bin found during a spiral-based search
947  /// up to the specified "radius" (default 1)
948  void fill_bin_by_diffusion(const unsigned& bin_diffusion_radius = 1);
949 
950 
951  /// Output bins
952  void output_bins(std::ofstream& outfile);
953 
954  /// Output bins
955  void output_bins(std::string& filename)
956  {
957  std::ofstream outfile;
958  outfile.open(filename.c_str());
959  output_bins(outfile);
960  outfile.close();
961  }
962 
963  /// Counter for overall number of bins allocated -- used to
964  /// issue warning if this exceeds a threshhold. (Default assignment
965  /// of 100^DIM bins per MeshAsGeomObject can be a killer if there
966  /// are huge numbers of sub-meshes (e.g. in unstructured FSI).
967  static unsigned long Total_nbin_cells_counter;
968 
969  /// Total number of bins above which warning is issued.
970  /// (Default assignment of 100^DIM bins per MeshAsGeomObject can
971  /// be a killer if there are huge numbers of sub-meshes (e.g. in
972  /// unstructured FSI).
974 
975  /// Boolean to supppress warnings about large number of bins
977 
978  /// Boolean flag to make sure that warning about large number
979  /// of bin cells only gets triggered once.
981 
982  /// Fraction of elements/bin that triggers warning. Too many
983  /// elements per bin can lead to very slow computations
985 
986  /// Boolean to supppress warnings about small number of bins
988 
989  /// Boolean flag to make sure that warning about small number
990  /// of bin cells only gets triggered once.
992 
993 private:
994  /// Fill the bin array with sample points from FiniteElements stored in mesh
995  void fill_bin_array();
996 
997  /// Initialise and populate the "bin" structure for locating coordinates
998  /// and increment counter for total number of bins in active use by any
999  /// MeshAsGeomObject)
1001 
1002  /// Flush the storage for the binning method (and decrement counter
1003  /// for total number of bins in active use by any MeshAsGeomObject)
1005  {
1007  Bin_object_coord_pairs.clear();
1008  }
1009 
1010  /// Storage for paired objects and coords in each bin
1011  SparseVector<Vector<std::pair<FiniteElement*, Vector<double>>>>
1013 
1014  /// Max. spiralling level (for efficiency; effect similar to
1015  /// max_search_radius)
1017 
1018  /// Current min. spiralling level
1020 
1021  /// Current max. spiralling level
1023 
1024  /// Number of spirals to be searched in one go
1025  unsigned Nspiral_chunk;
1026 };
1027 
1028 
1029 /// /////////////////////////////////////////////////////////////////////
1030 /// /////////////////////////////////////////////////////////////////////
1031 /// /////////////////////////////////////////////////////////////////////
1032 
1033 #ifdef OOMPH_HAS_CGAL
1034 
1035 
1036 //====================================================================
1037 /// CGAL-based SamplePointContainer
1038 //====================================================================
1040 {
1041 public:
1042  /// Constructor
1044  SamplePointContainerParameters* sample_point_container_parameters_pt);
1045 
1046  /// Broken copy constructor.
1048 
1049  /// Broken assignment operator.
1050  void operator=(const CGALSamplePointContainer&) = delete;
1051 
1052  /// Virtual destructor
1054  {
1055  unsigned n = Sample_point_pt.size();
1056  for (unsigned i = 0; i < n; i++)
1057  {
1058  delete Sample_point_pt[i];
1059  Sample_point_pt[i] = 0;
1060  }
1061  delete CGAL_tree_d_pt;
1062  CGAL_tree_d_pt = 0;
1063  }
1064 
1065  /// When searching through sample points only actually do the
1066  /// locate_zeta calls when when the counter exceeds this value.
1068  {
1070  }
1071 
1072  /// When searching through sample points only actually do the
1073  /// locate_zeta calls when when the counter is less than this value.
1075  {
1077  }
1078 
1079 
1080  /// Every time we've completed a "spiral", visiting a finite
1081  /// number of sample points in a deterministic order, use this
1082  /// multiplier to increase the max. number of sample points to be visited.
1083  /// Using a multiplier rather than a constant increment increases
1084  /// the amount of (more and more unlikely to yield anything!) work
1085  /// done locally before doing another costly mpi round trip
1086  /// when we're already far from the point we're trying to find.
1088  {
1090  }
1091 
1092  /// When searching through sample points only actually do the
1093  /// locate_zeta calls when when the counter exceeds this value.
1094  /// This is the initial value when starting the spiral based search.
1096  {
1098  }
1099 
1100 
1101  /// Find sub-GeomObject (finite element) and the local coordinate
1102  /// s within it that contains point with global coordinate zeta.
1103  /// sub_geom_object_pt=0 if point can't be found.
1104  void locate_zeta(const Vector<double>& zeta,
1105  GeomObject*& sub_geom_object_pt,
1106  Vector<double>& s);
1107 
1108 
1109  /// Find the sub geometric object and local coordinate therein that
1110  /// corresponds to the intrinsic coordinate zeta, using up to the specified
1111  /// number of sample points as initial guess for the Newton-based search.
1112  /// If this fails, return the nearest sample point.
1113  void limited_locate_zeta(
1114  const Vector<double>& zeta,
1115  const unsigned& max_sample_points_for_newton_based_search,
1116  GeomObject*& sub_geom_object_pt,
1117  Vector<double>& s);
1118 
1119 
1120  /// Dimension of the zeta ( = dim of local coordinate of elements)
1121  unsigned ndim_zeta() const
1122  {
1123  return Ndim_zeta;
1124  }
1125 
1126  /// Compute total number of sample points in sample point container
1128 
1129 private:
1130  /// Get the sample points; return time for setup of CGAL tree.
1131  double get_sample_points();
1132 
1133  /// Dimension of the zeta ( = dim of local coordinate of elements)
1134  unsigned Ndim_zeta;
1135 
1136  /// typedefs for cgal stuff
1137  typedef CGAL::Cartesian_d<double> Kernel_d;
1138  typedef Kernel_d::Point_d Point_d;
1139  typedef boost::tuple<Point_d, SamplePoint*> Point_d_and_pointer;
1140  typedef CGAL::Search_traits_d<Kernel_d> Traits_base_d;
1141  typedef CGAL::Search_traits_adapter<
1143  CGAL::Nth_of_tuple_property_map<0, Point_d_and_pointer>,
1144  Traits_base_d>
1146  typedef CGAL::Orthogonal_k_neighbor_search<Traits_d> K_neighbor_search_d;
1147 
1148  /// Vector containing sample point coordinates
1149  Vector<Point_d> CGAL_sample_point_zeta_d;
1150 
1151  /// Pointer to tree-based representation of sample points
1152  K_neighbor_search_d::Tree* CGAL_tree_d_pt;
1153 
1154  /// Vector storing pointers to sample point objects (which represent
1155  /// sample point in terms of number of element
1156  /// in its mesh and number of sample point)
1157  Vector<SamplePoint*> Sample_point_pt;
1158 
1159  /// When searching through sample points only actually do the
1160  /// locate_zeta calls when when the counter exceeds this value.
1162 
1163  /// When searching through sample points only actually do the
1164  /// locate_zeta calls when when the counter is less than this value.
1166 
1167  /// Every time we've completed a "spiral", visiting a finite
1168  /// number of sample points in a deterministic order, use this
1169  /// multiplier to increase the max. number of sample points to be visited.
1170  /// Using a multiplier rather than a constant increment increases
1171  /// the amount of (more and more unlikely to yield anything!) work
1172  /// done locally before doing another costly mpi round trip
1173  /// when we're already far from the point we're trying to find.
1174  unsigned
1176 
1177  /// When searching through sample points only actually do the
1178  /// locate_zeta calls when when the counter exceeds this value.
1179  /// This is the initial value when starting the "spiral based" search.
1181 };
1182 
1183 #endif // endif oomph has cgal
1184 
1185 /// /////////////////////////////////////////////////////////////////////
1186 /// /////////////////////////////////////////////////////////////////////
1187 /// /////////////////////////////////////////////////////////////////////
1188 
1189 
1190 } // end of namespace extension
1191 
1192 #endif
e
Definition: cfortran.h:571
static char t char * s
Definition: cfortran.h:568
cstr elem_len * i
Definition: cfortran.h:603
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
unsigned dimension_of_bin_array(const unsigned &i) const
Number of bins in coordinate direction i.
unsigned max_bin_dimension() const
Max. bin dimension (number of bins in coordinate directions)
Vector< unsigned > dimensions_of_bin_array() const
Number of bins in coordinate directions. Const vector-based version.
virtual void output_bins(std::ofstream &outfile)=0
Output bins (boundaries and number of sample points in them)
void get_neighbouring_bins_helper(const unsigned &bin_index, const unsigned &radius, Vector< unsigned > &neighbouring_bin_index, const bool &use_old_version=true)
Helper function for computing the bin indices of neighbouring bins at a given "radius" of the specifi...
unsigned dimensions_of_bin_array(const unsigned &i) const
Number of bins in specified coordinate direction.
unsigned ndim_zeta() const
Dimension of the zeta ( = dim of local coordinate of elements)
Vector< unsigned > Dimensions_of_bin_array
Number of bins in each coordinate direction.
virtual unsigned nbin() const =0
Number of bins (not taking recursion into account for refineable versions)
virtual ~BinArray()
Virtual destructor.
BinArray(const BinArray &data)=delete
Broken copy constructor.
BinArray()
Broken default constructor; needed for broken copy constructors. Don't call. It will die.
unsigned coords_to_bin_index(const Vector< double > &zeta)
Get (linearly enumerated) bin index of bin that contains specified zeta.
void profile_get_neighbouring_bins_helper()
Profiling function to compare performance of two different versions of the get_neighbouring_bins_help...
BinArray(Mesh *mesh_pt, const Vector< std::pair< double, double >> &min_and_max_coordinates, const Vector< unsigned > &dimensions_of_bin_array, const bool &use_eulerian_coordinates_during_setup, const bool &ignore_halo_elements_during_locate_zeta_search, const unsigned &nsample_points_generated_per_element)
Constructor.
void operator=(const BinArray &)=delete
Broken assignment operator.
void coords_to_vectorial_bin_index(const Vector< double > &zeta, Vector< unsigned > &bin_index)
Get "coordinates" of bin that contains specified zeta.
virtual void output_bin_vertices(std::ofstream &outfile)=0
Output bin vertices (allowing display of bin boundaries as zones).
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s)
Find sub-GeomObject (finite element) and the local coordinate s within it that contains point with gl...
unsigned ndim_zeta() const
Dimension of the zeta ( = dim of local coordinate of elements)
CGALSamplePointContainer(const CGALSamplePointContainer &data)=delete
Broken copy constructor.
CGAL::Orthogonal_k_neighbor_search< Traits_d > K_neighbor_search_d
CGALSamplePointContainer(SamplePointContainerParameters *sample_point_container_parameters_pt)
Constructor.
unsigned & multiplier_for_max_sample_point_to_actually_lookup_during_locate_zeta()
Every time we've completed a "spiral", visiting a finite number of sample points in a deterministic o...
unsigned & last_sample_point_to_actually_lookup_during_locate_zeta()
When searching through sample points only actually do the locate_zeta calls when when the counter is ...
void limited_locate_zeta(const Vector< double > &zeta, const unsigned &max_sample_points_for_newton_based_search, GeomObject *&sub_geom_object_pt, Vector< double > &s)
Find the sub geometric object and local coordinate therein that corresponds to the intrinsic coordina...
unsigned Multiplier_for_max_sample_point_to_actually_lookup_during_locate_zeta
Every time we've completed a "spiral", visiting a finite number of sample points in a deterministic o...
unsigned & initial_last_sample_point_to_actually_lookup_during_locate_zeta()
When searching through sample points only actually do the locate_zeta calls when when the counter exc...
unsigned Last_sample_point_to_actually_lookup_during_locate_zeta
When searching through sample points only actually do the locate_zeta calls when when the counter is ...
Vector< SamplePoint * > Sample_point_pt
Vector storing pointers to sample point objects (which represent sample point in terms of number of e...
virtual ~CGALSamplePointContainer()
Virtual destructor.
double get_sample_points()
Get the sample points; return time for setup of CGAL tree.
unsigned Initial_last_sample_point_to_actually_lookup_during_locate_zeta
When searching through sample points only actually do the locate_zeta calls when when the counter exc...
CGAL::Cartesian_d< double > Kernel_d
typedefs for cgal stuff
unsigned First_sample_point_to_actually_lookup_during_locate_zeta
When searching through sample points only actually do the locate_zeta calls when when the counter exc...
Vector< Point_d > CGAL_sample_point_zeta_d
Vector containing sample point coordinates.
K_neighbor_search_d::Tree * CGAL_tree_d_pt
Pointer to tree-based representation of sample points.
unsigned Ndim_zeta
Dimension of the zeta ( = dim of local coordinate of elements)
unsigned & first_sample_point_to_actually_lookup_during_locate_zeta()
When searching through sample points only actually do the locate_zeta calls when when the counter exc...
boost::tuple< Point_d, SamplePoint * > Point_d_and_pointer
CGAL::Search_traits_d< Kernel_d > Traits_base_d
unsigned total_number_of_sample_points_computed_recursively() const
Compute total number of sample points in sample point container.
void operator=(const CGALSamplePointContainer &)=delete
Broken assignment operator.
CGAL::Search_traits_adapter< Point_d_and_pointer, CGAL::Nth_of_tuple_property_map< 0, Point_d_and_pointer >, Traits_base_d > Traits_d
///////////////////////////////////////////////////////////////////////////// ///////////////////////...
static bool Already_warned_about_small_number_of_bin_cells
Boolean flag to make sure that warning about small number of bin cells only gets triggered once.
void get_bin(const Vector< double > &zeta, int &bin_number)
Get the number of the bin containing the specified coordinate. Bin number is negative if the coordina...
void get_bin(const Vector< double > &zeta, int &bin_number, Vector< std::pair< FiniteElement *, Vector< double >>> &sample_point_pairs)
Get the number of the bin containing the specified coordinate; also return the contents of that bin....
static bool Suppress_warning_about_large_total_number_of_bins
Boolean to supppress warnings about large number of bins.
void fill_bin_array()
Fill the bin array with sample points from FiniteElements stored in mesh.
void create_bins_of_objects()
Initialise and populate the "bin" structure for locating coordinates and increment counter for total ...
unsigned n_spiral_chunk() const
Number of spirals to be searched in one go const version.
const std::map< unsigned, Vector< std::pair< FiniteElement *, Vector< double > > > > * get_all_bins_content() const
Get the contents of all bins in vector.
unsigned Nspiral_chunk
Number of spirals to be searched in one go.
unsigned Max_spiral_level
Max. spiralling level (for efficiency; effect similar to max_search_radius)
static unsigned long Total_nbin_cells_counter
Counter for overall number of bins allocated – used to issue warning if this exceeds a threshhold....
void operator=(const NonRefineableBinArray &)=delete
Broken assignment operator.
void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s)
Find sub-GeomObject (finite element) and the local coordinate s within it that contains point with gl...
static unsigned Threshold_for_elements_per_bin_warning
Fraction of elements/bin that triggers warning. Too many elements per bin can lead to very slow compu...
unsigned Current_min_spiral_level
Current min. spiralling level.
void get_bin_vertices(const unsigned &i_bin, Vector< Vector< double >> &bin_vertex)
Get vector of vectors containing the coordinates of the vertices of the i_bin-th bin: bin_vertex[j][i...
unsigned Current_max_spiral_level
Current max. spiralling level.
static bool Suppress_warning_about_small_number_of_bins
Boolean to supppress warnings about small number of bins.
void fill_bin_by_diffusion(const unsigned &bin_diffusion_radius=1)
Fill bin by diffusion, populating each empty bin with the same content as the first non-empty bin fou...
void output_bins(std::string &filename)
Output bins.
unsigned total_number_of_sample_points_computed_recursively() const
Compute total number of sample points recursively.
NonRefineableBinArray(const NonRefineableBinArray &data)=delete
Broken copy constructor.
void output_bin_vertices(std::ofstream &outfile)
Output bin vertices (allowing display of bins as zones).
static bool Already_warned_about_large_number_of_bin_cells
Boolean flag to make sure that warning about large number of bin cells only gets triggered once.
SparseVector< Vector< std::pair< FiniteElement *, Vector< double > > > > Bin_object_coord_pairs
Storage for paired objects and coords in each bin.
void output_bins(std::ofstream &outfile)
Output bins.
Vector< Vector< std::pair< FiniteElement *, Vector< double > > > > bin_content() const
Get the contents of all bins in vector.
static unsigned Default_n_bin_1d
Default number of bins (in each coordinate direction). (Note: don't move this into a common base clas...
unsigned & max_spiral_level()
Access function to max. spiral level during straight locate_zeta search (for efficiency; similar to m...
unsigned & current_max_spiral_level()
Access function to current max. spiral level.
unsigned & n_spiral_chunk()
Number of spirals to be searched in one go.
void get_fill_stats(unsigned &n_bin, unsigned &max_n_entry, unsigned &min_n_entry, unsigned &tot_n_entry, unsigned &n_empty) const
Provide some stats on the fill level of the associated bin.
void flush_bins_of_objects()
Flush the storage for the binning method (and decrement counter for total number of bins in active us...
static unsigned long Threshold_for_total_bin_cell_number_warning
Total number of bins above which warning is issued. (Default assignment of 100^DIM bins per MeshAsGeo...
NonRefineableBinArray(SamplePointContainerParameters *bin_array_parameters_pt)
Constructor.
unsigned & current_min_spiral_level()
Access function to current min. spiral level.
double min_distance(const unsigned &i_bin, const Vector< double > &zeta)
Compute the minimum distance of any vertex in the specified bin from the specified Lagrangian coordin...
unsigned nbin() const
Total number of bins (empty or not)
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
unsigned Multiplier_for_max_sample_point_to_actually_lookup_during_locate_zeta
Every time we've completed a "spiral", visiting a finite number of sample points in a deterministic o...
unsigned depth() const
Depth of the hierarchical bin_array.
unsigned & max_depth()
Max depth of the hierarchical bin_array.
Vector< RefineableBin * > Bin_pt
Vector of pointers to constituent RefineableBins.
unsigned max_depth() const
Max depth of the hierarchical bin_array; const version.
unsigned Max_depth
Max depth of the hierarchical bin_array.
unsigned total_number_of_sample_points_computed_recursively() const
Compute total number of sample points recursively.
unsigned First_sample_point_to_actually_lookup_during_locate_zeta
When searching through sample points recursively from the top level RefineableBinArray (in determinis...
void fill_bin_array(const Vector< SamplePoint * > &sample_point_pt)
Fill the bin array with specified SamplePoints.
bool bin_array_is_recursive() const
Is the BinArray recursive?
static unsigned Default_n_bin_1d
Default number of bins (in each coordinate direction) (Note: don't move this into a common base class...
void operator=(const RefineableBinArray &)=delete
Broken assignment operator.
void add_sample_point(SamplePoint *new_sample_point_pt, const Vector< double > &zeta)
Add specified SamplePoint to RefineableBinArray.
void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s)
Find sub-GeomObject (finite element) and the local coordinate s within it that contains point with gl...
unsigned & initial_last_sample_point_to_actually_lookup_during_locate_zeta()
When searching through sample points recursively from the top level RefineableBinArray (in determinis...
unsigned & total_number_of_sample_points_visited_during_locate_zeta_from_top_level()
Counter to keep track of how many sample points we've visited during top level call to locate_zeta.
unsigned nbin() const
Number of bins (not taking recursion into account)
RefineableBinArray * Root_bin_array_pt
Pointer to root bin array.
unsigned Depth
Variable which stores the Depth value of the bin_array. Useful for debugging and for preventing "infi...
unsigned Max_number_of_sample_point_per_bin
Maximum number of sample points in bin (before it's subdivided recursively)
RefineableBinArray * root_bin_array_pt() const
Root bin array.
void fill_bin_array()
Fill the bin array with sample points from FiniteElements stored in mesh.
void output_bin_vertices(std::ofstream &outfile)
Output bin vertices (allowing display of bins as zones).
void output_neighbouring_bins(const unsigned &bin_index, const unsigned &radius, std::ofstream &outfile)
Output neighbouring bins at given "radius" of the specified bin.
unsigned Last_sample_point_to_actually_lookup_during_locate_zeta
When searching through sample points recursively from the top level RefineableBinArray (in determinis...
unsigned & first_sample_point_to_actually_lookup_during_locate_zeta()
When searching through sample points recursively from the top level RefineableBinArray (in determinis...
void output_bins(std::ofstream &outfile)
Output bins.
void get_bin_boundaries(const unsigned &bin_index, Vector< std::pair< double, double >> &min_and_max_coordinates)
Boundaries of specified bin in each coordinate direction. *.first = min; *.second = max.
void create_sample_points_from_element(FiniteElement *const element_pt, const unsigned &n_element)
Loop over all sample points in the element specified via the pointer and create a SamplePoint for eac...
unsigned Initial_last_sample_point_to_actually_lookup_during_locate_zeta
When searching through sample points recursively from the top level RefineableBinArray (in determinis...
RefineableBin * bin_pt(const unsigned &i) const
Pointer to i-th bin; can be null if bin is empty.
unsigned & last_sample_point_to_actually_lookup_during_locate_zeta()
When searching through sample points recursively from the top level RefineableBinArray (in determinis...
unsigned & multiplier_for_max_sample_point_to_actually_lookup_during_locate_zeta()
Every time we've completed a "spiral", visiting a finite number of sample points in a deterministic o...
RefineableBinArray(SamplePointContainerParameters *bin_array_parameters_pt)
Constructor.
unsigned max_number_of_sample_point_per_bin() const
Maximum number of sample points in bin (before its subdivided recursively)
RefineableBinArray(const RefineableBinArray &data)=delete
Broken copy constructor.
bool Bin_array_is_recursive
Variable which stores if the RefineableBinArray is recursive or not.
RefineableBin class. Contains sample points and is embedded in a RefineableBinArray....
void output_bins(std::ofstream &outfile)
Output bin vertices (allowing display of bins as zones).
unsigned nsample_points_in_bin()
Number of sample points stored in bin.
void output(std::ofstream &outfile, const bool &don_t_recurse=false)
Output bin; x,[y,[z]],n_sample_points.
void add_sample_point(SamplePoint *new_sample_point_pt, const Vector< double > &zeta_coordinates)
Add a new sample point to RefineableBin.
void get_bin_boundaries(Vector< std::pair< double, double >> &min_and_max_coordinates)
Boundaries of bin in each coordinate direction. *.first = min; *.second = max.
RefineableBinArray * Sub_bin_array_pt
Pointer to a possible sub-BinArray. Null by default.
void output_bin_vertices(std::ofstream &outfile)
Output bin vertices (allowing display of bins as zones).
unsigned total_number_of_sample_points_computed_recursively() const
Compute total number of sample points recursively.
unsigned Bin_index_in_bin_array
Index of bin in its bin array.
~RefineableBin()
Destructor.
void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s)
Find sub-GeomObject (finite element) and the local coordinate s within it that contains point with gl...
Vector< SamplePoint * > * Sample_point_pt
Container of SamplePoints. Pointer to vector because it's shorter than an empty vector!...
void operator=(const RefineableBin &)=delete
Broken assignment operator.
RefineableBin(RefineableBinArray *bin_array_pt, const unsigned &bin_index_in_bin_array)
Constructor. Pass pointer to bin array that contains this bin and the index of the newly created bin ...
void make_sub_bin_array(const Vector< std::pair< double, double >> &min_and_max_coordinates)
Method for building a new subbin_array (called when the Bin size is greater than the Max_number_of_sa...
RefineableBinArray * Bin_array_pt
Pointer to the bin array which "owns" this RefineableBin.
RefineableBin(const RefineableBin &data)=delete
Broken copy constructor.
///////////////////////////////////////////////////////////////////// ///////////////////////////////...
static bool Always_fail_elemental_locate_zeta
Boolean flag to make to make locate zeta fail. Used for debugging/ illustration of search procedures.
static double Percentage_offset
Offset of sample point container boundaries beyond max/min coords.
Vector< std::pair< double, double > > Min_and_max_coordinates
Vector of pairs of doubles for min and maximum coordinates. Call: Min_and_max_coordinates[j] gives me...
static bool Enable_timing_of_setup
Time setup?
bool ignore_halo_elements_during_locate_zeta_search() const
Ignore halo elements?
unsigned & nsample_points_generated_per_element()
"Measure of" number of sample points generated in each element
bool Ignore_halo_elements_during_locate_zeta_search
Ignore halo elements?
const std::pair< double, double > & min_and_max_coordinates(const unsigned &i) const
Pair of doubles for min and maximum coordinates in i-th direction: min (first) and max....
SamplePointContainer()
Broken default constructor; needed for broken copy constructors. Don't call. It will die.
const Vector< std::pair< double, double > > & min_and_max_coordinates() const
Vector of pair of doubles for min and maximum coordinates. min (first) and max. (second) coordinates.
bool use_eulerian_coordinates_during_setup() const
Use Eulerian coordinates (i.e. interpolated_x) rather than zeta itself (i.e. interpolated_zeta) to id...
SamplePointContainer(const SamplePointContainer &data)=delete
Broken copy constructor.
virtual ~SamplePointContainer()
Virtual destructor.
unsigned Nsample_points_generated_per_element
"Measure of" number of sample points generated in each element
unsigned Total_number_of_sample_points_visited_during_locate_zeta_from_top_level
Counter to keep track of how many sample points we've visited during top level call to locate_zeta.
bool Use_eulerian_coordinates_during_setup
Use Eulerian coordinates (i.e. interpolated_x) rather than zeta itself (i.e. interpolated_zeta) to id...
Mesh * Mesh_pt
Pointer to mesh from whose FiniteElements sample points are created.
double Max_search_radius
Max radius beyond which we stop searching the bin. Initialised to DBL_MAX so keep going until the poi...
SamplePointContainer(Mesh *mesh_pt, const Vector< std::pair< double, double >> &min_and_max_coordinates, const bool &use_eulerian_coordinates_during_setup, const bool &ignore_halo_elements_during_locate_zeta_search, const unsigned &nsample_points_generated_per_element)
Constructor.
virtual unsigned total_number_of_sample_points_computed_recursively() const =0
Total number of sample points in sample point container, possibly computed recursively.
virtual void locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s)=0
Find sub-GeomObject (finite element) and the local coordinate s within it that contains point with gl...
static std::ofstream Visited_sample_points_file
File to record sequence of visited sample points in. Used for debugging/ illustration of search proce...
double & max_search_radius()
Set maximum search radius for locate zeta. This is initialised do DBL_MAX so we brutally search throu...
Mesh * mesh_pt() const
Pointer to mesh from whose FiniteElements sample points are created.
void operator=(const SamplePointContainer &)=delete
Broken assignment operator.
virtual unsigned & total_number_of_sample_points_visited_during_locate_zeta_from_top_level()
Counter to keep track of how many sample points we've visited during top level call to locate_zeta....
virtual unsigned ndim_zeta() const =0
Dimension of the zeta ( = dim of local coordinate of elements)
void setup_min_and_max_coordinates()
Helper function to compute the min and max coordinates for the mesh, in each dimension.
static bool Use_equally_spaced_interior_sample_points
Use equally spaced sample points? (otherwise vertices are sampled repeatedly.
///////////////////////////////////////////////////////////////// ///////////////////////////////////...
SamplePoint(const unsigned &element_index_in_mesh, const unsigned &sample_point_index_in_element)
Construct SamplePoint object from number of finite element in its mesh, and index of sample point wit...
void operator=(const SamplePoint &)=delete
Broken assignment operator.
SamplePoint(const SamplePoint &data)=delete
Broken copy constructor.
unsigned element_index_in_mesh() const
Access function to the index of finite element in its mesh.
unsigned Sample_point_index_in_element
Index of the sample point within element.
unsigned Element_index_in_mesh
Index of finite element in its mesh.
unsigned sample_point_index_in_element() const
Index of sample point within element.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.