mesh_as_geometric_object.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// Version 1.0; svn revision $LastChangedRevision: 1282 $
7 //LIC//
8 //LIC// $LastChangedDate: 2017-01-16 08:27:53 +0000 (Mon, 16 Jan 2017) $
9 //LIC//
10 //LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11 //LIC//
12 //LIC// This library is free software; you can redistribute it and/or
13 //LIC// modify it under the terms of the GNU Lesser General Public
14 //LIC// License as published by the Free Software Foundation; either
15 //LIC// version 2.1 of the License, or (at your option) any later version.
16 //LIC//
17 //LIC// This library is distributed in the hope that it will be useful,
18 //LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 //LIC// Lesser General Public License for more details.
21 //LIC//
22 //LIC// You should have received a copy of the GNU Lesser General Public
23 //LIC// License along with this library; if not, write to the Free Software
24 //LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 //LIC// 02110-1301 USA.
26 //LIC//
27 //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28 //LIC//
29 //LIC//====================================================================
30 //Header file for a class that is used to represent a mesh
31 //as a geometric object
32 
33 //Include guards to prevent multiple inclusion of the header
34 #ifndef OOMPH_MESH_AS_GEOMETRIC_OBJECT_HEADER
35 #define OOMPH_MESH_AS_GEOMETRIC_OBJECT_HEADER
36 
37 // Config header generated by autoconfig
38 #ifdef HAVE_CONFIG_H
39  #include <oomph-lib-config.h>
40 #endif
41 
42 #include<limits.h>
43 #include<float.h>
44 
45 //Include the geometric object header file
46 #include "geom_objects.h"
47 
48 namespace oomph
49 {
50 
51 
52 ////////////////////////////////////////////////////////////////////////
53 ////////////////////////////////////////////////////////////////////////
54 ////////////////////////////////////////////////////////////////////////
55 
56 // hierher move this into vector.h or its own file at some point
57 
58 
59 //========================================================================
60 /// Sparse vector -- wrapper for map (but avoids filling map during
61 /// reads of zero/empty entries). Square bracket operator is read-only.
62 //========================================================================
63 template<class T>
65 {
66 
67 public:
68 
69  /// Constructor
71  {
72  // Empty instance
73  Empty_pt=new T(0);
74  }
75 
76  /// Destructor
78  {
79  // Delete empty instance
80  delete Empty_pt;
81  }
82 
83  // Initialise the bin (only called by the create_bins_of_objects()
84  // method)
85  void initialise(const unsigned &size)
86  {
87  // Create a "large" bool vector indicating all entries are empty
88  Has_entry.resize(size,false);
89  }
90 
91  /// Wipe storage
92  void clear()
93  {
94  Data.clear();
95 
96  // Get current size and reset all entries
97  const unsigned size = Has_entry.size();
98  Has_entry.resize(size,false);
99  }
100 
101  /// Square bracket access (const version)
102  const T& operator[](const unsigned& i) const
103  {
104  typedef typename std::map<unsigned,T>::const_iterator IT;
105  IT it=Data.find(i);
106  if (it==Data.end())
107  {
108  return *Empty_pt;
109  }
110  return (*it).second;
111  }
112 
113  /// Set value of i-th entry
114  void set_value(const unsigned& i, const T& value)
115  {
116  Data[i]=value;
117  //Mark as having entry
118  Has_entry[i]=true;
119  }
120 
121 
122  /// \short Number of nonzero entries stored in here (specifying the
123  /// size of the vector (as a mathematical object)
124  /// doesn't really make sense -- the thing could be infinitely
125  /// big and we wouldn't know or care)
126  unsigned nnz() const
127  {
128  return Data.size();
129  }
130 
131  /// Read-only access to underlying map
132  const std::map<unsigned,T>* map_pt() const
133  {
134  return &Data;
135  }
136 
137  /// Read/write access to underlying map -- dangerous!
138  std::map<unsigned,T>* map_pt()
139  {
140  return &Data;
141  }
142 
143  /// \short Check if the bin has entries
144  bool has_entry(const unsigned &nbin)
145  {
146  return Has_entry[nbin];
147  }
148 
149  /// \short Return vector containing all values
150  /// (without reference to their specific indices)
151  /// for fast direct access
152  void get_all_values(Vector<T>& all_values) const
153  {
154  all_values.clear();
155  all_values.resize(nnz());
156  typedef typename std::map<unsigned,T>::const_iterator IT;
157  unsigned count=0;
158  for (IT it=Data.begin();it!=Data.end();it++)
159  {
160  all_values[count++]=(*it).second;
161  }
162  }
163 
164 private:
165 
166  /// Internal storage in map.
167  std::map<unsigned,T> Data;
168 
169  /// Empty instance
170  const T* Empty_pt;
171 
172  /// Keep track of the filled and empty bins
173  std::vector<bool> Has_entry;
174 
175 };
176 
177 
178 
179 
180 
181 ////////////////////////////////////////////////////////////////////////
182 ////////////////////////////////////////////////////////////////////////
183 ////////////////////////////////////////////////////////////////////////
184 
185 
186 
187 
188 
189 //========================================================================
190 /// This class provides a GeomObject representation of a given
191 /// finite element mesh. The Lagrangian coordinate is taken to be the
192 /// dimension of the (first) element in the mesh and the Eulerian
193 /// coordinate is taken to be the dimension of the (first) node in
194 /// the mesh. If there are no elements or nodes the appropriate dimensions
195 /// will be set to zero.
196 /// The consitituent elements of the mesh must have their own
197 /// GeomObject representations, so they must be FiniteElements,
198 /// and they become sub-objects
199 /// in this compound GeomObject.
200 //========================================================================
202 {
203 
204 private:
205 
206  /// \short Helper function for constructor: pass the pointer to the mesh,
207  /// and boolean
208  /// to specify whether to calculate coordinate extrema or not.
209  void construct_it(Mesh* const &mesh_pt,
210  const bool& compute_extreme_bin_coords);
211 
212  /// \short Sort the sampling points in the specified bin by distance from
213  /// sampling point
214  void sort_the_bin(const Vector<double>& zeta,
215  Vector<std::pair<FiniteElement*,Vector<double> > >&
216  sample_point_pairs);
217 
218  /// \short Vector of pointers to Data items that affects the object's shape
220 
221  ///Internal storage for the elements that constitute the object
223 
224  ///Storage for paired objects and coords in each bin
227 
228  /// \short In parallel computation, suppress synchronisation of bins
229  /// Default is false. If set to true, each processor will create
230  /// its own bin structure, spanning only its own elements
232 
233  /// \short Max radius beyond which we stop searching the bin. Initialised
234  /// to DBL_MAX so keep going until the point is found or until
235  /// we've searched every single bin. Overwriting this means we won't search
236  /// in bins whose closest vertex is at a distance greater than
237  /// Max_search_radius from the point to be located.
239 
240  /// Max. spiralling level (for efficiency; effect similar to max_search_radius)
242 
243  ///Storage for min coordinates in the mesh
245 
246  ///Storage for max coordinates in the mesh
248 
249  ///Number of bins in x direction
250  unsigned Nbin_x;
251 
252  ///Number of bins in y direction
253  unsigned Nbin_y;
254 
255  ///Number of bins in z direction
256  unsigned Nbin_z;
257 
258  ///Current min. spiralling level
260 
261  ///Current max. spiralling level
263 
264 #ifdef OOMPH_HAS_MPI
265 
266  ///Communicator
268 
269 #endif
270 
271  /// \short Flag to indicate that MeshAsGeomObject has used
272  /// Eulerian coordinates when setting up bin.
274 
275 public:
276 
277  ///\short Constructor, pass the pointer to the mesh.
278  /// Final flag (default 0) allows
279  /// the suppression of synchronisation of bin boundaries on multiple
280  /// processors so if set to 1 each processor only creates a bin
281  /// structure that contains its own elements, rather than a bin
282  /// bin structure that is identical for each processor. Obviously
283  /// only relevant for distributed problems.
284  MeshAsGeomObject(Mesh* const &mesh_pt,
285  const unsigned& suppress_synchronisation_of_bins_flag=0)
286  : GeomObject()
287  {
288  Max_search_radius=DBL_MAX;
289  Max_spiral_level=UINT_MAX;
291  if (suppress_synchronisation_of_bins_flag==1)
292  {
294  }
295  bool compute_extreme_bin_coords=true;
296  this->construct_it(mesh_pt,compute_extreme_bin_coords);
297  }
298 
299  ///\short Constructor, pass the pointer to the mesh and communicator.
300  /// Final flag (default 0) allows
301  /// the suppression of synchronisation of bin boundaries on multiple
302  /// processors so if set to 1 each processor only creates a bin
303  /// structure that contains its own elements, rather than a bin
304  /// bin structure that is identical for each processor. Obviously
305  /// only relevant for distributed problems.
306  MeshAsGeomObject(Mesh* const &mesh_pt,
307  OomphCommunicator* comm_pt,
308  const unsigned& suppress_synchronisation_of_bins_flag=0)
309  : GeomObject()
310  {
311  Max_search_radius=DBL_MAX;
312  Max_spiral_level=UINT_MAX;
314  if (suppress_synchronisation_of_bins_flag==1)
315  {
317  }
318  bool compute_extreme_bin_coords=true;
319  this->construct_it(mesh_pt,compute_extreme_bin_coords);
320  }
321 
322  ///\short Constructor, pass the pointer to the mesh and
323  /// boolean to bypass the computation of the extreme coordinates
324  ///of the bin used in the locate_zeta method. Final flag (default 0) allows
325  /// the suppression of synchronisation of bin boundaries on multiple
326  /// processors so if set to 1 each processor only creates a bin
327  /// structure that contains its own elements, rather than a bin
328  /// bin structure that is identical for each processor. Obviously
329  /// only relevant for distributed problems.
330  MeshAsGeomObject(Mesh* const &mesh_pt,
331  const bool& compute_extreme_bin_coords,
332  const unsigned& suppress_synchronisation_of_bins_flag=0) :
333  GeomObject()
334  {
335  Max_search_radius=DBL_MAX;
336  Max_spiral_level=UINT_MAX;
338  if (suppress_synchronisation_of_bins_flag==1)
339  {
341  }
342  this->construct_it(mesh_pt,compute_extreme_bin_coords);
343  }
344 
345 
346  /// \short Constructor, pass the pointer to the mesh, communicator, and
347  /// boolean to bypass the computation of the extreme coordinates
348  /// of the bin used in the locate_zeta method. Final flag (default 0) allows
349  /// the suppression of synchronisation of bin boundaries on multiple
350  /// processors so if set to 1 each processor only creates a bin
351  /// structure that contains its own elements, rather than a bin
352  /// bin structure that is identical for each processor. Obviously
353  /// only relevant for distributed problems.
354  MeshAsGeomObject(Mesh* const &mesh_pt,
355  OomphCommunicator* comm_pt,
356  const bool& compute_extreme_bin_coords,
357  const unsigned& suppress_synchronisation_of_bins_flag=0) :
358  GeomObject()
359  {
360  Max_search_radius=DBL_MAX;
361  Max_spiral_level=UINT_MAX;
362  if (suppress_synchronisation_of_bins_flag==1)
363  {
365  }
367  this->construct_it(mesh_pt,compute_extreme_bin_coords);
368  }
369 
370  /// Empty Constructor
372 
373  /// Destructor
375  {
376  // Flush bin (mainly to decrement counter for number of
377  // active bins)
379  }
380 
381  /// Broken copy constructor
383  {
384  BrokenCopy::broken_copy("MeshAsGeomObject");
385  }
386 
387  /// Broken assignment operator
389  {
390  BrokenCopy::broken_assign("MeshAsGeomObject");
391  }
392 
393 
394  /// Total number of bins (empty or not)
395  unsigned total_nbin() const
396  {
397  const unsigned n_lagrangian = this->nlagrangian();
398  unsigned Nbin[3] ={Nbin_x, Nbin_y, Nbin_z};
399  unsigned ntotalbin=Nbin[0];
400  for(unsigned i=1;i<n_lagrangian;i++) {ntotalbin *= Nbin[i];}
401  return ntotalbin;
402  }
403 
404  /// How many items of Data does the shape of the object depend on?
405  unsigned ngeom_data() const {return Geom_data_pt.size();}
406 
407  /// \short Return pointer to the j-th Data item that the object's
408  /// shape depends on
409  Data* geom_data_pt(const unsigned& j) {return Geom_data_pt[j];}
410 
411  /// \short Find the sub geometric object and local coordinate therein that
412  /// corresponds to the intrinsic coordinate zeta. If sub_geom_object_pt=0
413  /// on return from this function, none of the constituent sub-objects
414  /// contain the required coordinate. Following from the general
415  /// interface to this function in GeomObjects,
416  /// setting the optional bool argument to true means that each
417  /// time the sub-object's locate_zeta function is called, the coordinate
418  /// argument "s" is used as the initial guess. However, this doesn't
419  /// make sense here and the argument is ignored (though a warning
420  /// is issued when the code is compiled in PARANOID setting)
421  void locate_zeta(const Vector<double>& zeta,
422  GeomObject*& sub_geom_object_pt,
423  Vector<double>& s,
424  const bool& use_coordinate_as_initial_guess=false)
425  {
426 #ifdef PARANOID
427  if (use_coordinate_as_initial_guess)
428  {
430  "Ignoring the use_coordinate_as_initial_guess argument.",
431  "MeshAsGeomObject::locate_zeta()",
432  OOMPH_EXCEPTION_LOCATION);
433  }
434 #endif
435 
436  // Call locate zeta with spiraling switched off
437  bool called_within_spiral=false;
438  spiraling_locate_zeta(zeta,sub_geom_object_pt,s,called_within_spiral);
439  }
440 
441  /// \short Find the sub geometric object and local coordinate therein that
442  /// corresponds to the intrinsic coordinate zeta. If sub_geom_object_pt=0
443  /// on return from this function, none of the constituent sub-objects
444  /// contain the required coordinate.
445  /// Setting the final bool argument to true means that we only search
446  /// for matching element within a a certain number of "spirals" within
447  /// the bin structure.
448  void spiraling_locate_zeta(const Vector<double>& zeta,
449  GeomObject*& sub_geom_object_pt,
450  Vector<double>& s,
451  const bool &called_within_spiral);
452 
453  /// \short Version of spiraling locate zeta used for the projection
454  /// during the unstructured mesh adaptation
455  void my_spiraling_locate_zeta(const Vector<double>& zeta,
456  GeomObject*& sub_geom_object_pt,
457  Vector<double>& s,
458  const bool &called_within_spiral);
459 
460  /// \short Return the position as a function of the intrinsic coordinate zeta.
461  /// This provides an (expensive!) default implementation in which
462  /// we loop over all the constituent sub-objects and check if they
463  /// contain zeta and then evaluate their position() function.
464  void position(const Vector<double> &zeta, Vector<double> &r) const
465  {
466  // Call position function at current timestep:
467  unsigned t=0;
468  position(t,zeta,r);
469  }
470 
471 
472  /// \short Parametrised position on object: r(zeta). Evaluated at
473  /// previous timestep. t=0: current time; t>0: previous
474  /// timestep. This provides an (expensive!) default implementation in which
475  /// we loop over all the constituent sub-objects and check if they
476  /// contain zeta and then evaluate their position() function.
477  void position(const unsigned& t, const Vector<double>& zeta,
478  Vector<double>& r) const
479  {
480  // Storage for the GeomObject that contains the zeta coordinate
481  // and the intrinsic coordinate within it.
482  GeomObject* sub_geom_object_pt;
483  const unsigned n_lagrangian = this->nlagrangian();
484  Vector<double> s(n_lagrangian);
485 
486  //Find the sub object containing zeta, and the local intrinsic coordinate
487  //within it
488  const_cast<MeshAsGeomObject*>(this)->locate_zeta(zeta,sub_geom_object_pt,s);
489  if(sub_geom_object_pt == 0)
490  {
491  std::ostringstream error_message;
492  error_message << "Cannot locate zeta ";
493  for(unsigned i=0;i<n_lagrangian;i++)
494  {
495  error_message << zeta[i] << " ";
496  }
497  error_message << std::endl;
498  throw OomphLibError(error_message.str(),
499  OOMPH_CURRENT_FUNCTION,
500  OOMPH_EXCEPTION_LOCATION);
501  }
502  //Call that sub-object's position function
503  sub_geom_object_pt->position(t,s,r);
504 
505  } // end of position
506 
507  ///Return the derivative of the position
508  void dposition(const Vector<double> &xi, DenseMatrix<double> &drdxi) const
509  {
510  throw OomphLibError("dposition() not implemented",
511  OOMPH_CURRENT_FUNCTION,
512  OOMPH_EXCEPTION_LOCATION);
513  }
514 
515 
516  /// \short Set maximum search radius for locate zeta. This is initialised
517  /// do DBL_MAX so we brutally search through the entire bin structure,
518  /// no matter how big it is until we've found the required point (or
519  /// failed to do so. This can be VERY costly with fine meshes.
520  /// Here the user takes full responsibility and states that we have
521  /// no chance in hell to find the required point in
522  /// a bin whose closest vertex is further than the specified
523  /// max search radius.
525 
526  /// \short Access function to max. spiral level during straight locate_zeta
527  /// search (for efficiency; similar to max_search_radius())
528  unsigned& max_spiral_level() {return Max_spiral_level;}
529 
530  ///Access function to current min. spiral level
532 
533  ///Access function to current max. spiral level
535 
536  ///Access function for min coordinate in x direction
537  double& x_min() {return Min_coords[0];}
538 
539  ///Access function for max coordinate in x direction
540  double& x_max() {return Max_coords[0];}
541 
542  ///Access function for min coordinate in y direction
543  double& y_min() {return Min_coords[1];}
544 
545  ///Access function for max coordinate in y direction
546  double& y_max() {return Max_coords[1];}
547 
548  ///Access function for min coordinate in z direction
549  double& z_min() {return Min_coords[2];}
550 
551  ///Access function for max coordinate in z direction
552  double& z_max() {return Max_coords[2];}
553 
554  ///Get the min and max coordinates for the mesh, in each dimension
555  void get_min_and_max_coordinates(Mesh* const &mesh_pt);
556 
557  ///Number of bins in x direction
558  unsigned nbin_x(){return Nbin_x;}
559 
560  ///Number of bins in y direction
561  unsigned nbin_y(){return Nbin_y;}
562 
563  ///Number of bins in z direction
564  unsigned nbin_z(){return Nbin_z;}
565 
566  /// Provide some stats on the fill level of the associated bin
567  void get_fill_stats(unsigned& n_bin,
568  unsigned& max_n_entry,
569  unsigned& min_n_entry,
570  unsigned& tot_n_entry,
571  unsigned& n_empty) const;
572 
573  /// \short Compute the minimum distance of any vertex in the specified bin
574  /// from the specified Lagrangian coordinate zeta
575  double min_distance(const unsigned& i_bin,
576  const Vector<double>& zeta);
577 
578 
579  /// \short Output bin vertices (allowing display of bins as zones).
580  /// Final argument specifies the coordinates of a point
581  /// and output includes the minimum distance of any of
582  /// the bin vertices to this point.
583  void output_bin_vertices(std::ostream& outfile,
584  const Vector<double>& zeta);
585 
586 
587  /// \short Output bin vertices (allowing display of bins as zones).
588  void output_bin_vertices(std::ostream& outfile)
589  {
590  Vector<double> zeta( this->nlagrangian(),0.0);
591  output_bin_vertices(outfile,zeta);
592  }
593 
594 
595  /// \short Output bin vertices of specified bin (allowing display
596  /// of bins as zones).
597  /// Final argument specifies the coordinates of a point
598  /// and output includes the minimum distance of any of
599  /// the bin vertices to this point.
600  void output_bin_vertices(std::ostream& outfile,
601  const unsigned& i_bin,
602  const Vector<double>& zeta);
603 
604  /// Output bin vertices of specified bin (allowing display of bins as zones).
605  void output_bin_vertices(std::ostream& outfile,
606  const unsigned& i_bin)
607  {
608  Vector<double> zeta( this->nlagrangian(),0.0);
609  output_bin_vertices(outfile,i_bin,zeta);
610  }
611 
612 
613 
614  /// \short Get vector of vectors containing the coordinates of the
615  /// vertices of the i_bin-th bin: bin_vertex[j][i] contains the
616  /// i-th coordinate of the j-th vertex.
617  void get_bin_vertices(const unsigned& i_bin,
618  Vector<Vector<double> >& bin_vertex);
619 
620  /// Initialise and populate the "bin" structure for locating coordinates
621  /// and increment counter for total number of bins in active use by any
622  /// MeshAsGeomObject)
623  /// Note that the number of elements in the mesh is passed in only
624  /// for a warning message about small numbers of bins.
625  void create_bins_of_objects(const unsigned long &n_mesh_element);
626 
627  /// \short Flush the storage for the binning method (and decrement counter
628  /// for total number of bins in active use by any MeshAsGeomObject)
630  {
632  Bin_object_coord_pairs.clear();
633  }
634 
635  /// \short Get the number of the bin containing the specified coordinate.
636  /// Bin number is negative if the coordinate is outside
637  /// the bin structure.
638  void get_bin(const Vector<double>& zeta, int& bin_number);
639 
640  /// \short Get the number of the bin containing the specified coordinate; also
641  /// return the contents of that bin. Bin number is negative if the
642  /// coordinate is outside the bin structure.
643  void get_bin(const Vector<double>& zeta, int& bin_number,
644  Vector<std::pair<FiniteElement*,
645  Vector<double> > >& sample_point_pairs);
646 
647  /// Get the contents of all bins in vector
649  {
651  Bin_object_coord_pairs.get_all_values(all_vals);
652  return all_vals;
653  }
654 
655  /// Get the contents of all bins in vector
656  const std::map<unsigned,Vector<std::pair<FiniteElement*,Vector<double> > > > *
658  {
659  // Return the content of the bins
660  return Bin_object_coord_pairs.map_pt();
661  }
662 
663  ///Calculate the bin numbers of all the neighbours to "bin" given the level
664  void get_neighbouring_bins_helper(const unsigned& bin_number,
665  const unsigned& level,
666  Vector<unsigned>& neighbour_bin,
667  const bool &only_use_filled_bins=false);
668 
669  /// \short Fill bin by diffusion, populating each empty bin with the
670  /// same content as the first non-empty bin found during a spiral-based search
671  /// up to the specified "radius" (default 1)
672  void fill_bin_by_diffusion(const unsigned& bin_diffusion_radius=1);
673 
674  /// Output bins
675  void output_bins(std::ofstream& outfile);
676 
677  /// Output bins
678  void output_bins(std::string& filename)
679  {
680  std::ofstream outfile;
681  outfile.open(filename.c_str());
682  output_bins(outfile);
683  outfile.close();
684  }
685 
686  /// \short Globally set-able (sorry!) flag to indicate that MeshAsGeomObject
687  /// is to use Eulerian coordinates when setting up bin.
689 
690  /// \short Counter for overall number of bins allocated -- used to
691  /// issue warning if this exceeds a threshhold. (Default assignment
692  /// of 100^DIM bins per MeshAsGeomObject can be a killer if there
693  /// are huge numbers of sub-meshes (e.g. in unstructured FSI).
694  static unsigned long Total_nbin_cells_counter;
695 
696  /// \short Total number of bins above which warning is issued.
697  /// (Default assignment of 100^DIM bins per MeshAsGeomObject can
698  /// be a killer if there are huge numbers of sub-meshes (e.g. in
699  /// unstructured FSI).
701 
702  /// \short Boolean to supppress warnings about large number of bins
704 
705  /// \short Boolean flag to make sure that warning about large number
706  /// of bin cells only gets triggered once.
708 
709  /// \short Fraction of elements/bin that triggers warning. Too many
710  /// elements per bin can lead to very slow computations
712 
713  /// \short Boolean to supppress warnings about small number of bins
715 
716  /// \short Boolean flag to make sure that warning about small number
717  /// of bin cells only gets triggered once.
719 
720 
721 
722 };
723 
724 }
725 
726 #endif
bool has_entry(const unsigned &nbin)
Check if the bin has entries.
unsigned nbin_z()
Number of bins in z direction.
unsigned nnz() const
Number of nonzero entries stored in here (specifying the size of the vector (as a mathematical object...
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
unsigned total_nbin() const
Total number of bins (empty or not)
unsigned nbin_y()
Number of bins in y direction.
void get_all_values(Vector< T > &all_values) const
Return vector containing all values (without reference to their specific indices) for fast direct acc...
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...
Vector< Vector< std::pair< FiniteElement *, Vector< double > > > > bin_content() const
Get the contents of all bins in vector.
double & z_min()
Access function for min coordinate in z direction.
MeshAsGeomObject(Mesh *const &mesh_pt, const unsigned &suppress_synchronisation_of_bins_flag=0)
Constructor, pass the pointer to the mesh. Final flag (default 0) allows the suppression of synchroni...
unsigned & current_min_spiral_level()
Access function to current min. spiral level.
cstr elem_len * i
Definition: cfortran.h:607
void output_bin_vertices(std::ostream &outfile)
Output bin vertices (allowing display of bins as zones).
unsigned nbin_x()
Number of bins in x direction.
void operator=(const MeshAsGeomObject &)
Broken assignment operator.
Vector< double > Max_coords
Storage for max coordinates in the mesh.
A general Finite Element class.
Definition: elements.h:1271
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.
char t
Definition: cfortran.h:572
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...
unsigned Current_min_spiral_level
Current min. spiralling level.
virtual void position(const Vector< double > &zeta, Vector< double > &r) const =0
Parametrised position on object at current time: r(zeta).
std::map< unsigned, T > * map_pt()
Read/write access to underlying map – dangerous!
MeshAsGeomObject(const MeshAsGeomObject &)
Broken copy constructor.
void position(const unsigned &t, const Vector< double > &zeta, Vector< double > &r) const
Parametrised position on object: r(zeta). Evaluated at previous timestep. t=0: current time; t>0: pre...
static bool Use_eulerian_coordinates_during_setup
Globally set-able (sorry!) flag to indicate that MeshAsGeomObject is to use Eulerian coordinates when...
double Max_search_radius
Max radius beyond which we stop searching the bin. Initialised to DBL_MAX so keep going until the poi...
void output_bins(std::ofstream &outfile)
Output bins.
bool Have_used_eulerian_coordinates_during_setup
Flag to indicate that MeshAsGeomObject has used Eulerian coordinates when setting up bin...
double & x_max()
Access function for max coordinate in x direction.
std::map< unsigned, T > Data
Internal storage in map.
std::vector< bool > Has_entry
Keep track of the filled and empty bins.
MeshAsGeomObject(Mesh *const &mesh_pt, OomphCommunicator *comm_pt, const bool &compute_extreme_bin_coords, const unsigned &suppress_synchronisation_of_bins_flag=0)
Constructor, pass the pointer to the mesh, communicator, and boolean to bypass the computation of the...
unsigned ngeom_data() const
How many items of Data does the shape of the object depend on?
unsigned & max_spiral_level()
Access function to max. spiral level during straight locate_zeta search (for efficiency; similar to m...
MeshAsGeomObject()
Empty Constructor.
double & z_max()
Access function for max coordinate in z direction.
MeshAsGeomObject(Mesh *const &mesh_pt, OomphCommunicator *comm_pt, const unsigned &suppress_synchronisation_of_bins_flag=0)
Constructor, pass the pointer to the mesh and communicator. Final flag (default 0) allows the suppres...
void dposition(const Vector< double > &xi, DenseMatrix< double > &drdxi) const
Return the derivative of the position.
void spiraling_locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s, const bool &called_within_spiral)
Find the sub geometric object and local coordinate therein that corresponds to the intrinsic coordina...
OomphCommunicator * Communicator_pt
Communicator.
unsigned nlagrangian() const
Access function to # of Lagrangian coordinates.
Definition: geom_objects.h:182
unsigned Nbin_y
Number of bins in y direction.
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 output_bins(std::string &filename)
Output bins.
const std::map< unsigned, T > * map_pt() const
Read-only access to underlying map.
const T & operator[](const unsigned &i) const
Square bracket access (const version)
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 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 get_min_and_max_coordinates(Mesh *const &mesh_pt)
Get the min and max coordinates for the mesh, in each dimension.
Vector< double > Min_coords
Storage for min coordinates in the mesh.
unsigned & current_max_spiral_level()
Access function to current max. spiral level.
static char t char * s
Definition: cfortran.h:572
void output_bin_vertices(std::ostream &outfile, const unsigned &i_bin)
Output bin vertices of specified bin (allowing display of bins as zones).
Data * geom_data_pt(const unsigned &j)
Return pointer to the j-th Data item that the object's shape depends on.
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...
void position(const Vector< double > &zeta, Vector< double > &r) const
Return the position as a function of the intrinsic coordinate zeta. This provides an (expensive!) def...
void my_spiraling_locate_zeta(const Vector< double > &zeta, GeomObject *&sub_geom_object_pt, Vector< double > &s, const bool &called_within_spiral)
Version of spiraling locate zeta used for the projection during the unstructured mesh adaptation...
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...
void create_bins_of_objects(const unsigned long &n_mesh_element)
A class that represents a collection of data; each Data object may contain many different individual ...
Definition: nodes.h:89
double & x_min()
Access function for min coordinate in x direction.
static unsigned long Total_nbin_cells_counter
Counter for overall number of bins allocated – used to issue warning if this exceeds a threshhold...
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...
Vector< Data * > Geom_data_pt
Vector of pointers to Data items that affects the object's shape.
static bool Suppress_warning_about_large_total_number_of_bins
Boolean to supppress warnings about large number of bins.
void get_neighbouring_bins_helper(const unsigned &bin_number, const unsigned &level, Vector< unsigned > &neighbour_bin, const bool &only_use_filled_bins=false)
Calculate the bin numbers of all the neighbours to "bin" given the level.
MeshAsGeomObject(Mesh *const &mesh_pt, const bool &compute_extreme_bin_coords, const unsigned &suppress_synchronisation_of_bins_flag=0)
Constructor, pass the pointer to the mesh and boolean to bypass the computation of the extreme coordi...
double & y_min()
Access function for min coordinate in y direction.
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...
double & max_search_radius()
Set maximum search radius for locate zeta. This is initialised do DBL_MAX so we brutally search throu...
static bool Suppress_warning_about_small_number_of_bins
Boolean to supppress warnings about small number of bins.
double & y_max()
Access function for max coordinate in y direction.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
Vector< FiniteElement * > Sub_geom_object_pt
Internal storage for the elements that constitute the object.
unsigned Current_max_spiral_level
Current max. spiralling level.
unsigned Max_spiral_level
Max. spiralling level (for efficiency; effect similar to max_search_radius)
void clear()
Wipe storage.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
unsigned Nbin_z
Number of bins in z direction.
void initialise(const unsigned &size)
void sort_the_bin(const Vector< double > &zeta, Vector< std::pair< FiniteElement *, Vector< double > > > &sample_point_pairs)
Sort the sampling points in the specified bin by distance from sampling point.
unsigned Nbin_x
Number of bins in x direction.
bool Suppress_synchronisation_of_bins
In parallel computation, suppress synchronisation of bins Default is false. If set to true...
void flush_bins_of_objects()
Flush the storage for the binning method (and decrement counter for total number of bins in active us...
const T * Empty_pt
Empty instance.
void construct_it(Mesh *const &mesh_pt, const bool &compute_extreme_bin_coords)
Helper function for constructor: pass the pointer to the mesh, and boolean to specify whether to calc...
const std::map< unsigned, Vector< std::pair< FiniteElement *, Vector< double > > > > * get_all_bins_content() const
Get the contents of all bins in vector.
A general mesh class.
Definition: mesh.h:74
void set_value(const unsigned &i, const T &value)
Set value of i-th entry.
void output_bin_vertices(std::ostream &outfile, const Vector< double > &zeta)
Output bin vertices (allowing display of bins as zones). Final argument specifies the coordinates of ...
SparseVector< Vector< std::pair< FiniteElement *, Vector< double > > > > Bin_object_coord_pairs
Storage for paired objects and coords in each bin.
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
Definition: communicator.h:57