generic/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// Copyright (C) 2006-2022 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 // Common base class for all Triangle Meshes
27 #ifndef OOMPH_GENERIC_TRIANGLE_MESH_HEADER
28 #define OOMPH_GENERIC_TRIANGLE_MESH_HEADER
29 
30 // Config header generated by autoconfig
31 #ifdef HAVE_CONFIG_H
32 #include <oomph-lib-config.h>
33 #endif
34 
35 // Oomph-lib includes
36 #include "Vector.h"
37 #include "nodes.h"
38 #include "matrices.h"
39 #include "mesh.h"
41 
42 namespace oomph
43 {
44  //================================================================
49  //================================================================
51  public virtual Mesh
52  {
53  public:
56  {
57 #ifdef OOMPH_HAS_TRIANGLE_LIB
58  // Initialise the TriangulateIO Data structure
59  TriangleHelper::initialise_triangulateio(Triangulateio);
60 
61  // Enable triangulateio specific parts for dump/restart by default.
62  Use_triangulateio_restart = true;
63 #endif
64  }
65 
67  TriangleMeshBase(const TriangleMeshBase& node) = delete;
68 
70  // Commented out broken assignment operator because this can lead to a
71  // conflict warning when used in the virtual inheritence hierarchy.
72  // Essentially the compiler doesn't realise that two separate
73  // implementations of the broken function are the same and so, quite
74  // rightly, it shouts.
75  /*void operator=(const TriangleMeshBase&) = delete;*/
76 
79  {
80 #ifdef OOMPH_HAS_TRIANGLE_LIB
81  // Clear the triangulate data structure
82  TriangleHelper::clear_triangulateio(Triangulateio);
83 #endif
84  }
85 
89  {
90  std::ofstream outfile;
92  }
93 
96  void setup_boundary_element_info(std::ostream& outfile);
97 
98 #ifdef OOMPH_HAS_TRIANGLE_LIB
100  bool use_triangulateio_restart() const
101  {
102  return Use_triangulateio_restart;
103  }
104 
106  void enable_triangulateio_restart()
107  {
108  Use_triangulateio_restart = true;
109  }
110 
112  void disable_triangulateio_restart()
113  {
114  Use_triangulateio_restart = false;
115  }
116 
118  TriangulateIO& triangulateio_representation()
119  {
120  return Triangulateio;
121  }
122 
126  void write_triangulateio(TriangulateIO& triangulate_io, std::string& s);
127 
131  void clear_triangulateio()
132  {
133  TriangleHelper::clear_triangulateio(Triangulateio);
134  }
135 
138  void dump_triangulateio(std::ostream& dump_file);
139 
140 #ifdef OOMPH_HAS_MPI
143  virtual void dump_distributed_info_for_restart(std::ostream& dump_file)
144  {
145  std::ostringstream error_stream;
146  error_stream << "Empty default dump disributed info. method called.\n";
147  error_stream << "This should be overloaded in a specific TriangleMesh\n";
148  throw OomphLibError(
149  error_stream.str(),
150  "TriangleMeshBase::dump_distributed_info_for_restart()",
152  }
153 
156  virtual void dump_info_to_reset_halo_haloed_scheme(std::ostream& dump_file)
157  {
158  std::ostringstream error_stream;
159  error_stream << "Empty default dump info. to reset halo haloed scheme.\n";
160  error_stream << "This should be overloaded in a specific TriangleMesh\n";
161  throw OomphLibError(
162  error_stream.str(),
163  "TriangleMeshBase::dump_info_to_reset_halo_haloed_scheme()",
165  }
166 
169  virtual void read_distributed_info_for_restart(std::istream& restart_file)
170  {
171  std::ostringstream error_stream;
172  error_stream << "Empty default read disributed info. method called.\n";
173  error_stream << "This should be overloaded in a specific TriangleMesh\n";
174  throw OomphLibError(
175  error_stream.str(),
176  "TriangleMeshBase::read_distributed_info_for_restart()",
178  }
179 
182  virtual void reestablish_distribution_info_for_restart(
183  OomphCommunicator* comm_pt, std::istream& restart_file)
184  {
185  std::ostringstream error_stream;
186  error_stream << "Empty default reestablish disributed info method "
187  << "called.\n";
188  error_stream << "This should be overloaded in a specific "
189  << "RefineableTriangleMesh\n";
190  throw OomphLibError(
191  error_stream.str(),
192  "TriangleMeshBase::reestablish_distribution_info_for_restart()",
194  }
195 #endif
196 
199  virtual void update_polyline_representation_from_restart()
200  {
201  std::ostringstream error_stream;
202  error_stream << "Empty default update polylines representation from "
203  << "restart method called.\n";
204  error_stream << "This should be overloaded in a specific "
205  << "RefineableTriangleMesh\n";
206  throw OomphLibError(
207  error_stream.str(),
208  "TriangleMeshBase::update_polyline_representation_from_restart()",
210  }
211 
214  void remesh_from_triangulateio(std::istream& restart_file);
215 
218  virtual void remesh_from_internal_triangulateio()
219  {
220  std::ostringstream error_stream;
221  error_stream << "Empty default remesh function called.\n";
222  error_stream << "This should be overloaded in a specific TriangleMesh\n";
223  throw OomphLibError(
224  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
225  }
226 
227 #endif // #ifdef OOMPH_HAS_TRIANGLE_LIB
228 
230  virtual void load_balance(
231  const Vector<unsigned>& target_domain_for_local_non_halo_element)
232  {
233  std::ostringstream error_stream;
234  error_stream << "Empty default load balancing function called.\n";
235  error_stream << "This should be overloaded in a specific TriangleMesh\n";
236  throw OomphLibError(error_stream.str(),
237  "TriangleMeshBase::load_balance()",
239  }
240 
243  Vector<unsigned>& ntmp_boundary_elements,
244  Vector<Vector<unsigned>>& ntmp_boundary_elements_in_region,
245  Vector<FiniteElement*>& deleted_elements)
246  {
247  std::ostringstream error_stream;
248  error_stream << "Empty default reset boundary element info function"
249  << "called.\n";
250  error_stream << "This should be overloaded in a specific "
251  << "TriangleMesh\n";
252  throw OomphLibError(error_stream.str(),
253  "TriangleMeshBase::reset_boundary_element_info()",
255  }
256 
257  protected:
258 #ifdef OOMPH_HAS_TRIANGLE_LIB
259 
261  TriangulateIO Triangulateio;
262 
265  bool Use_triangulateio_restart;
266 
267 #endif // OOMPH_HAS_TRIANGLE
268  };
269 
270 } // namespace oomph
271 
272 #endif
Definition: mesh.h:67
Definition: oomph_definitions.h:222
Definition: generic/triangle_mesh.h:52
TriangleMeshBase(const TriangleMeshBase &node)=delete
Broken copy constructor.
void setup_boundary_element_info()
Definition: generic/triangle_mesh.h:88
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.
Definition: generic/triangle_mesh.h:242
virtual void load_balance(const Vector< unsigned > &target_domain_for_local_non_halo_element)
Virtual function to perform the load balance rutines.
Definition: generic/triangle_mesh.h:230
virtual ~TriangleMeshBase()
Broken assignment operator.
Definition: generic/triangle_mesh.h:78
TriangleMeshBase()
Constructor.
Definition: generic/triangle_mesh.h:55
Definition: unstructured_two_d_mesh_geometry_base.h:1738
RealScalar s
Definition: level1_cplx_impl.h:130
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86