triangle_mesh.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$
7 //LIC//
8 //LIC// $LastChangedDate$
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 // Common base class for all Triangle Meshes
31 #ifndef OOMPH_TRIMESH_HEADER
32 #define OOMPH_TRIMESH_HEADER
33 
34 // Config header generated by autoconfig
35 #ifdef HAVE_CONFIG_H
36 #include <oomph-lib-config.h>
37 #endif
38 
39 // Oomph-lib includes
40 #include "Vector.h"
41 #include "nodes.h"
42 #include "matrices.h"
43 #include "mesh.h"
45 
46 namespace oomph
47 {
48 
49 //================================================================
50 /// Base class for triangle meshes (meshes made of 2D triangle elements).
51 /// Note: we choose to template TriangleMeshBase here because certain
52 /// functions in UnstructuredTwoDMeshGeometryBase need template parameters
53 /// and it's much cleaner simply to template the entire class
54 //================================================================
56  public virtual Mesh
57 {
58 
59 public:
60 
61  /// Constructor
63  {
64 #ifdef OOMPH_HAS_TRIANGLE_LIB
65  //Initialise the TriangulateIO Data structure
67 
68  // Enable triangulateio specific parts for dump/restart by default.
70 #endif
71  }
72 
73  /// Broken copy constructor
75  {
76  BrokenCopy::broken_copy("TriangleMeshBase");
77  }
78 
79  /// Broken assignment operator
80 //Commented out broken assignment operator because this can lead to a conflict warning
81 //when used in the virtual inheritence hierarchy. Essentially the compiler doesn't
82 //realise that two separate implementations of the broken function are the same and so,
83 //quite rightly, it shouts.
84  /*void operator=(const TriangleMeshBase&)
85  {
86  BrokenCopy::broken_assign("TriangleMeshBase");
87  }*/
88 
89  /// Destructor (empty)
91  {
92 #ifdef OOMPH_HAS_TRIANGLE_LIB
93  // Clear the triangulate data structure
95 #endif
96  }
97 
98  /// Setup lookup schemes which establish whic elements are located
99  /// next to mesh's boundaries (wrapper to suppress doc).
101  {
102  std::ofstream outfile;
104  }
105 
106  /// \short Setup lookup schemes which establish which elements are located
107  /// next to mesh's boundaries. Doc in outfile (if it's open).
108  void setup_boundary_element_info(std::ostream &outfile);
109 
110 #ifdef OOMPH_HAS_TRIANGLE_LIB
111  /// \short const access for Use_triangulateio_restart.
113 
114  /// \short write access for Use_triangulateio_restart.
116 
117  /// \short write access for Use_triangulateio_restart.
119 
120  /// Access to the triangulateio representation of the mesh
122 
123  /// \short Helper function. Write a TriangulateIO object file with all the
124  /// triangulateio fields. String s is add to assign a different value for
125  /// the input and/or output structure
126  void write_triangulateio(TriangulateIO& triangulate_io, std::string& s);
127 
128  /// \short Helper function. Clean up the memory associated with the
129  /// TriangulateIO object. This should really only be used to save
130  /// memory in extremely tight situations.
133 
134  /// \short Dump the triangulateio structure to a dump file and
135  /// record boundary coordinates of boundary nodes
136  void dump_triangulateio(std::ostream &dump_file);
137 
138 #ifdef OOMPH_HAS_MPI
139  /// Virtual function that is used to dump info. related with
140  /// distributed triangle meshes
141  virtual void dump_distributed_info_for_restart(std::ostream &dump_file)
142  {
143  std::ostringstream error_stream;
144  error_stream << "Empty default dump disributed info. method called.\n";
145  error_stream << "This should be overloaded in a specific TriangleMesh\n";
146  throw OomphLibError(error_stream.str(),
147  "TriangleMeshBase::dump_distributed_info_for_restart()",
148  OOMPH_EXCEPTION_LOCATION);
149  }
150 
151  /// Virtual function that is used to dump info. related with
152  /// distributed triangle meshes
153  virtual void dump_info_to_reset_halo_haloed_scheme(std::ostream &dump_file)
154  {
155  std::ostringstream error_stream;
156  error_stream << "Empty default dump info. to reset halo haloed scheme.\n";
157  error_stream << "This should be overloaded in a specific TriangleMesh\n";
158  throw OomphLibError(error_stream.str(),
159  "TriangleMeshBase::dump_info_to_reset_halo_haloed_scheme()",
160  OOMPH_EXCEPTION_LOCATION);
161  }
162 
163  /// Virtual function that is used to read info. related with
164  /// distributed triangle meshes
165  virtual void read_distributed_info_for_restart(std::istream &restart_file)
166  {
167  std::ostringstream error_stream;
168  error_stream << "Empty default read disributed info. method called.\n";
169  error_stream << "This should be overloaded in a specific TriangleMesh\n";
170  throw OomphLibError(error_stream.str(),
171  "TriangleMeshBase::read_distributed_info_for_restart()",
172  OOMPH_EXCEPTION_LOCATION);
173  }
174 
175  /// Virtual function used to re-establish any additional info. related with
176  /// the distribution after a re-starting for triangle meshes
178  OomphCommunicator* comm_pt, std::istream &restart_file)
179  {
180  std::ostringstream error_stream;
181  error_stream << "Empty default reestablish disributed info method "
182  << "called.\n";
183  error_stream << "This should be overloaded in a specific "
184  << "RefineableTriangleMesh\n";
185  throw OomphLibError(error_stream.str(),
186  "TriangleMeshBase::reestablish_distribution_info_for_restart()",
187  OOMPH_EXCEPTION_LOCATION);
188  }
189 #endif
190 
191  /// Virtual function used to update the polylines representation after
192  /// restart
194  {
195  std::ostringstream error_stream;
196  error_stream << "Empty default update polylines representation from "
197  << "restart method called.\n";
198  error_stream << "This should be overloaded in a specific "
199  << "RefineableTriangleMesh\n";
200  throw OomphLibError(error_stream.str(),
201  "TriangleMeshBase::update_polyline_representation_from_restart()",
202  OOMPH_EXCEPTION_LOCATION);
203  }
204 
205  /// \short Regenerate the mesh from a dumped triangulateio file
206  /// and dumped boundary coordinates of boundary nodes
207  void remesh_from_triangulateio(std::istream &restart_file);
208 
209  ///Virtual function that is used for specific remeshing from the triangulateio
211  {
212  std::ostringstream error_stream;
213  error_stream << "Empty default remesh function called.\n";
214  error_stream << "This should be overloaded in a specific TriangleMesh\n";
215  throw OomphLibError(error_stream.str(),
216  OOMPH_CURRENT_FUNCTION,
217  OOMPH_EXCEPTION_LOCATION);
218  }
219 
220 #endif // #ifdef OOMPH_HAS_TRIANGLE_LIB
221 
222  /// Virtual function to perform the load balance rutines
223  virtual void load_balance(const Vector<unsigned>&
224  target_domain_for_local_non_halo_element)
225  {
226  std::ostringstream error_stream;
227  error_stream << "Empty default load balancing function called.\n";
228  error_stream << "This should be overloaded in a specific TriangleMesh\n";
229  throw OomphLibError(error_stream.str(),
230  "TriangleMeshBase::load_balance()",
231  OOMPH_EXCEPTION_LOCATION);
232  }
233 
234  /// Virtual function to perform the reset boundary elements info rutines
236  Vector<unsigned> &ntmp_boundary_elements,
237  Vector<Vector<unsigned> > &ntmp_boundary_elements_in_region,
238  Vector<FiniteElement*> &deleted_elements)
239  {
240  std::ostringstream error_stream;
241  error_stream << "Empty default reset boundary element info function"
242  << "called.\n";
243  error_stream << "This should be overloaded in a specific "
244  << "TriangleMesh\n";
245  throw OomphLibError(error_stream.str(),
246  "TriangleMeshBase::reset_boundary_element_info()",
247  OOMPH_EXCEPTION_LOCATION);
248  }
249 
250  protected:
251 
252 #ifdef OOMPH_HAS_TRIANGLE_LIB
253 
254  ///\short TriangulateIO representation of the mesh
256 
257  /// Should we use triangulateio specific parts for dump/restart? (Doesn't
258  /// work with some elements and isn't needed if not using adaptivity).
260 
261 #endif // OOMPH_HAS_TRIANGLE
262 
263 };
264 
265 }
266 
267 #endif
268 
TriangulateIO Triangulateio
TriangulateIO representation of the mesh.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
TriangleMeshBase()
Constructor.
Definition: triangle_mesh.h:62
TriangulateIO & triangulateio_representation()
Access to the triangulateio representation of the mesh.
void enable_triangulateio_restart()
write access for Use_triangulateio_restart.
virtual void read_distributed_info_for_restart(std::istream &restart_file)
virtual void dump_distributed_info_for_restart(std::ostream &dump_file)
virtual void update_polyline_representation_from_restart()
void clear_triangulateio(TriangulateIO &triangulate_io, const bool &clear_hole_data)
Clear TriangulateIO structure.
virtual void dump_info_to_reset_halo_haloed_scheme(std::ostream &dump_file)
static char t char * s
Definition: cfortran.h:572
void remesh_from_triangulateio(std::istream &restart_file)
Regenerate the mesh from a dumped triangulateio file and dumped boundary coordinates of boundary node...
virtual void load_balance(const Vector< unsigned > &target_domain_for_local_non_halo_element)
Virtual function to perform the load balance rutines.
virtual void reestablish_distribution_info_for_restart(OomphCommunicator *comm_pt, std::istream &restart_file)
TriangleMeshBase(const TriangleMeshBase &node)
Broken copy constructor.
Definition: triangle_mesh.h:74
void initialise_triangulateio(TriangulateIO &triangle_io)
Initialise TriangulateIO structure.
void clear_triangulateio()
Helper function. Clean up the memory associated with the TriangulateIO object. This should really onl...
virtual ~TriangleMeshBase()
Broken assignment operator.
Definition: triangle_mesh.h:90
virtual void reset_boundary_element_info(Vector< unsigned > &ntmp_boundary_elements, Vector< Vector< unsigned > > &ntmp_boundary_elements_in_region, Vector< FiniteElement *> &deleted_elements)
Virtual function to perform the reset boundary elements info rutines.
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn&#39;t been defined.
void write_triangulateio(TriangulateIO &triangulate_io, std::string &s)
Helper function. Write a TriangulateIO object file with all the triangulateio fields. String s is add to assign a different value for the input and/or output structure.
void disable_triangulateio_restart()
write access for Use_triangulateio_restart.
virtual void remesh_from_internal_triangulateio()
Virtual function that is used for specific remeshing from the triangulateio.
bool use_triangulateio_restart() const
const access for Use_triangulateio_restart.
void dump_triangulateio(std::ostream &dump_file)
Dump the triangulateio structure to a dump file and record boundary coordinates of boundary nodes...
A general mesh class.
Definition: mesh.h:74
An oomph-lib wrapper to the MPI_Comm communicator object. Just contains an MPI_Comm object (which is ...
Definition: communicator.h:57