libMesh
Loading...
Searching...
No Matches
meshtool.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18#include "libmesh/libmesh_config.h"
19
20// C++ includes
21#include <algorithm>
22#include <fstream>
23#include <iostream>
24#include <math.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <string>
29#include <vector>
30
31// Local Includes
32#include "libmesh/boundary_info.h"
33#include "libmesh/boundary_mesh.h"
34#include "libmesh/dof_map.h"
35#include "libmesh/elem.h"
36#include "libmesh/elem_quality.h"
37#include "libmesh/gmv_io.h"
38#include "libmesh/inf_elem_builder.h"
39#include "libmesh/libmesh.h"
40#include "libmesh/mesh.h"
41#include "libmesh/mesh_modification.h"
42#include "libmesh/mesh_refinement.h"
43#include "libmesh/mesh_netgen_interface.h"
44#include "libmesh/poly2tri_triangulator.h"
45#include "libmesh/simplex_refiner.h"
46#include "libmesh/statistics.h"
47#include "libmesh/string_to_enum.h"
48#include "libmesh/enum_elem_quality.h"
49#include "libmesh/getpot.h"
50#include <libmesh/mesh_smoother_vsmoother.h>
51
52using namespace libMesh;
53
54// convenient enum for the mode in which the boundary mesh
55// should be written
57
58// Print a usage message before exiting the program.
59void usage(const std::string & prog_name);
60
61int main (int argc, char ** argv)
62{
63 LibMeshInit init(argc, argv);
64
65 unsigned int n_subdomains = 1;
66 bool vsmooth = false;
67 unsigned int n_rsteps = 0;
68 Real simplex_refine = 0.;
69 double dist_fact = 0.;
70 bool verbose = false;
72 bool convert_first_order = false;
73 unsigned int convert_second_order = 0;
74 bool triangulate = false;
75 bool simplex_fill = false;
76 Real desired_measure = 1;
77 bool do_quality = false;
78 ElemQuality quality_type = DIAGONAL;
79
80#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
81 bool addinfelems = false;
82 InfElemBuilder::InfElemOriginValue origin_x(false, 0.);
83 InfElemBuilder::InfElemOriginValue origin_y(false, 0.);
84 InfElemBuilder::InfElemOriginValue origin_z(false, 0.);
85 bool x_sym=false;
86 bool y_sym=false;
87 bool z_sym=false;
88#endif
89
90 std::vector<std::string> names;
91 std::vector<std::string> output_names;
92
93 // Check for minimum number of command line args
94 if (argc < 3)
95 usage(std::string(argv[0]));
96
97 // Create a GetPot object to parse the command line
98 GetPot command_line (argc, argv);
99
100 // Print usage and exit immediately if user asked for help.
101 if (command_line.search(2, "-h", "-?"))
102 usage(argv[0]);
103
104 // Input file name(s)
105 command_line.disable_loop();
106 while (command_line.search(1, "-i"))
107 {
108 std::string tmp;
109 tmp = command_line.next(tmp);
110 names.push_back(tmp);
111 }
112 command_line.reset_cursor();
113
114 // Output file name
115 while (command_line.search(1, "-o"))
116 {
117 std::string tmp;
118 tmp = command_line.next(tmp);
119 output_names.push_back(tmp);
120 }
121 command_line.enable_loop();
122
123 // Get the mesh distortion factor
124 if (command_line.search(1, "-D"))
125 dist_fact = command_line.next(dist_fact);
126
127 // Number of refinements
128 if (command_line.search(1, "-r"))
129 {
130 int tmp = 0;
131 tmp = command_line.next(tmp);
132 n_rsteps = cast_int<unsigned int>(tmp);
133 }
134
135 // Split edges to reach specified element volume
136 if (command_line.search(1, "-s"))
137 simplex_refine = command_line.next(simplex_refine);
138
139 // Number of subdomains for partitioning
140 if (command_line.search(1, "-p"))
141 {
142 int tmp = 0;
143 tmp = command_line.next(tmp);
144 n_subdomains = cast_int<unsigned int>(tmp);
145 }
146
147 // Whether to apply variational smoother
148 if (command_line.search(1, "-V"))
149 vsmooth = true;
150
151 // Should we call all_tri()?
152 if (command_line.search(1, "-t"))
153 triangulate = true;
154
155 // Should we triangulate/tetrahedralize a boundary interior?
156 if (command_line.search(1, "-T"))
157 {
158 simplex_fill = true;
159 desired_measure = command_line.next(desired_measure);
160 }
161
162 // Should we calculate element quality?
163 if (command_line.search(1, "-q"))
164 {
165 do_quality = true;
166 std::string tmp;
167 tmp = command_line.next(tmp);
168 if (tmp != "")
169 quality_type = Utility::string_to_enum<ElemQuality>(tmp);
170 }
171
172 // Should we be verbose?
173 if (command_line.search(1, "-v"))
174 verbose = true;
175
176 // Should we write the boundary?
177 if (command_line.search(1, "-b"))
178 write_bndry = BM_MESH_ONLY;
179
180 // Should we convert all elements to 1st order?
181 if (command_line.search(1, "-1"))
182 convert_first_order = true;
183
184 // Should we convert all elements to 2nd order?
185 if (command_line.search(1, "-2"))
186 convert_second_order = 2;
187
188 // Should we convert all elements to "full" 2nd order?
189 if (command_line.search(1, "-3"))
190 convert_second_order = 22;
191
192#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
193
194 // Add infinite elements
195 if (command_line.search(1, "-a"))
196 addinfelems = true;
197
198 // Specify origin x coordinate
199 if (command_line.search(1, "-x"))
200 {
201 origin_x.first = true;
202 origin_x.second = command_line.next(origin_x.second);
203 }
204
205 // Specify origin y coordinate
206 if (command_line.search(1, "-y"))
207 {
208 origin_y.first = true;
209 origin_y.second = command_line.next(origin_y.second);
210 }
211
212 // Specify origin z coordinate
213 if (command_line.search(1, "-z"))
214 {
215 origin_z.first = true;
216 origin_z.second = command_line.next(origin_z.second);
217 }
218
219 // Symmetries
220 if (command_line.search(1, "-X"))
221 x_sym = true;
222 if (command_line.search(1, "-Y"))
223 y_sym = true;
224 if (command_line.search(1, "-Z"))
225 z_sym = true;
226
227#endif // LIBMESH_ENABLE_INFINITE_ELEMENTS
228
229 // Read the input mesh
230 Mesh mesh(init.comm());
231 if (!names.empty())
232 {
233 mesh.read(names[0]);
234
235 if (verbose)
236 {
237 libMesh::out << "Mesh " << names[0] << ":" << std::endl;
240 }
241
242 for (unsigned int i=1; i < names.size(); ++i)
243 {
244 Mesh extra_mesh(init.comm());
245 extra_mesh.read(names[i]);
246
247 if (verbose)
248 {
249 libMesh::out << "Mesh " << names[i] << ":" << std::endl;
250 extra_mesh.print_info();
251 extra_mesh.get_boundary_info().print_summary();
252 }
253
254 unique_id_type max_uid = 0;
255#ifdef LIBMESH_ENABLE_UNIQUE_ID
256 max_uid = mesh.parallel_max_unique_id();
257#endif
258
259 mesh.copy_nodes_and_elements(extra_mesh, false,
262 max_uid);
264
265 if (verbose)
266 {
267 libMesh::out << "Combined Mesh:" << std::endl;
270 }
271 }
272 }
273
274 else
275 {
276 libMesh::out << "No input specified." << std::endl;
277 return 1;
278 }
279
280
281
282#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
283
284 if (addinfelems)
285 {
286 libmesh_error_msg_if(write_bndry != BM_DISABLED,
287 "ERROR: Invalid combination: Building infinite elements\n"
288 "not compatible with writing boundary conditions.");
289
290 // Sanity checks: -X/Y/Z can only be used, when the
291 // corresponding coordinate is also given (using -x/y/z)
292 libmesh_error_msg_if((x_sym && !origin_x.first) || // claim x-symmetry, but x-coordinate of origin not given!
293 (y_sym && !origin_y.first) || // the same for y
294 (z_sym && !origin_z.first), // the same for z
295 "ERROR: When x-symmetry is requested using -X, then\n"
296 "the option -x <coord> also has to be given.\n"
297 "This holds obviously for y and z, too.");
298
299 // build infinite elements
300 InfElemBuilder(mesh).build_inf_elem(origin_x, origin_y, origin_z,
301 x_sym, y_sym, z_sym,
302 verbose);
303
304 if (verbose)
305 {
308 }
309 }
310
311 // sanity check
312 else
313 libmesh_error_msg_if((origin_x.first || origin_y.first || origin_z.first) ||
314 (x_sym || y_sym || z_sym),
315 "ERROR: -x/-y/-z/-X/-Y/-Z is only to be used when\n"
316 "the option -a is also specified!");
317
318#endif
319
320
321 // Maybe convert non-simplex elements into simplices
322 if (triangulate)
323 {
324 if (verbose)
325 libMesh::out << "...Converting to all simplices...\n";
326
328 }
329
330 // Maybe fill an interior mesh specified by an input boundary mesh
331 if (simplex_fill)
332 {
333 if (mesh.mesh_dimension() == 2)
334 {
335#ifdef LIBMESH_HAVE_NETGEN
337 ngint.desired_volume() = desired_measure;
338 ngint.triangulate();
339#else
340 libmesh_error_msg("Requested triangulation of a 2D boundary without Poly2Tri enabled");
341#endif
342 }
343 else if (mesh.mesh_dimension() == 1)
344 {
345#ifdef LIBMESH_HAVE_POLY2TRI
346 Poly2TriTriangulator poly2tri(mesh);
348 poly2tri.desired_area() = desired_measure;
349 poly2tri.minimum_angle() = 0;
350 poly2tri.triangulate();
351#else
352 libmesh_error_msg("Requested triangulation of a 1D boundary without Poly2Tri enabled");
353#endif
354 }
355 }
356
357 // Compute Shape quality metrics
358 if (do_quality)
359 {
361 sv.reserve(mesh.n_elem());
362
363 libMesh::out << "Quality type is: " << Quality::name(quality_type) << std::endl;
364
365 // What are the quality bounds for this element?
366 std::pair<Real, Real> bounds = mesh.elem_ref(0).qual_bounds(quality_type);
367 libMesh::out << "Quality bounds for this element type are: ("
368 << bounds.first
369 << ", "
370 << bounds.second
371 << ") "
372 << std::endl;
373
374 for (const auto & elem : mesh.active_element_ptr_range())
375 sv.push_back(elem->quality(quality_type));
376
377 const unsigned int n_bins = 10;
378 libMesh::out << "Avg. shape quality: " << sv.mean() << std::endl;
379
380 // Find element indices below the specified cutoff.
381 // These might be considered "bad" elements which need refinement.
382 std::vector<dof_id_type> bad_elts = sv.cut_below(0.8);
383 libMesh::out << "Found " << bad_elts.size()
384 << " of " << mesh.n_elem()
385 << " elements below the cutoff." << std::endl;
386
387 // Compute the histogram for this distribution
388 std::vector<dof_id_type> histogram;
389 sv.histogram(histogram, n_bins);
390
391 const bool do_matlab = true;
392
393 if (do_matlab)
394 {
395 std::ofstream out ("histo.m");
396
397 out << "% This is a sample histogram plot for Matlab." << std::endl;
398 out << "bin_members = [" << std::endl;
399 for (unsigned int i=0; i<n_bins; i++)
400 out << static_cast<Real>(histogram[i]) / static_cast<Real>(mesh.n_elem())
401 << std::endl;
402 out << "];" << std::endl;
403
404 std::vector<Real> bin_coords(n_bins);
405 const Real max = *(std::max_element(sv.begin(), sv.end()));
406 const Real min = *(std::min_element(sv.begin(), sv.end()));
407 const Real delta = (max - min) / static_cast<Real>(n_bins);
408 for (unsigned int i=0; i<n_bins; i++)
409 bin_coords[i] = min + (i * delta) + delta / 2.0 ;
410
411 out << "bin_coords = [" << std::endl;
412 for (unsigned int i=0; i<n_bins; i++)
413 out << bin_coords[i] << std::endl;
414 out << "];" << std::endl;
415
416 out << "bar(bin_coords, bin_members, 1);" << std::endl;
417 out << "hold on" << std::endl;
418 out << "plot (bin_coords, 0, 'kx');" << std::endl;
419 out << "xlabel('Quality (0=Worst, 1=Best)');" << std::endl;
420 out << "ylabel('Percentage of elements in each bin');" << std::endl;
421 out << "axis([" << min << "," << max << ",0, max(bin_members)]);" << std::endl;
422
423 out << "title('" << Quality::name(quality_type) << "');" << std::endl;
424
425 }
426 }
427
428 // Possibly convert higher-order elements into first-order
429 // counterparts
430 if (convert_first_order)
431 {
432 if (verbose)
433 libMesh::out << "Converting elements to first order counterparts\n";
434
436
437 if (verbose)
438 {
441 }
442 }
443
444 // Possibly convert all linear elements into second-order counterparts
445 if (convert_second_order > 0)
446 {
447 bool second_order_mode = true;
448 std:: string message = "Converting elements to second order counterparts";
449 if (convert_second_order == 2)
450 {
451 second_order_mode = false;
452 message += ", lower version: Quad4 -> Quad8, not Quad9";
453 }
454
455 else if (convert_second_order == 22)
456 {
457 second_order_mode = true;
458 message += ", highest version: Quad4 -> Quad9";
459 }
460
461 else
462 libmesh_error_msg("Invalid value, convert_second_order = " << convert_second_order);
463
464 if (verbose)
465 libMesh::out << message << std::endl;
466
467 mesh.all_second_order(second_order_mode);
468
469 if (verbose)
470 {
473 }
474 }
475
476 if (simplex_refine)
477 {
478 SimplexRefiner simplex_refiner (mesh);
479 simplex_refiner.desired_volume() = simplex_refine;
480 simplex_refiner.refine_elements();
481 }
482
483#ifdef LIBMESH_ENABLE_AMR
484
485 // Possibly refine the mesh
486 if (n_rsteps > 0)
487 {
488 if (verbose)
489 libMesh::out << "Refining the mesh "
490 << n_rsteps << " times"
491 << std::endl;
492
493 MeshRefinement mesh_refinement (mesh);
494 mesh_refinement.uniformly_refine(n_rsteps);
495
496 if (verbose)
497 {
500 }
501 }
502
503
504 // Possibly distort the mesh
505 if (dist_fact > 0.)
506 {
507 libMesh::out << "Distorting the mesh by a factor of "
508 << dist_fact
509 << std::endl;
510
512 }
513
514#endif
515
516
517
518 // Possibly partition the mesh
519 if (n_subdomains > 1)
520 mesh.partition(n_subdomains);
521
522 // Possibly smooth the mesh
523 if (vsmooth)
524 {
525 VariationalMeshSmoother vsmoother(mesh, 0.5, true, TOLERANCE * TOLERANCE, TOLERANCE * TOLERANCE, 20);
526 vsmoother.smooth();
527 }
528
529 // Possibly write the mesh
530 if (output_names.size())
531 {
532 // When the mesh got refined, it is likely that
533 // the user does _not_ want to write also
534 // the coarse elements, but only the active ones.
535 // Use Mesh::create_submesh() to create a mesh
536 // of only active elements, and then write _this_
537 // new mesh.
538 if (n_rsteps > 0)
539 {
540 if (verbose)
541 libMesh::out << " Mesh got refined, will write only _active_ elements." << std::endl;
542
543 Mesh new_mesh (init.comm(), cast_int<unsigned char>(mesh.mesh_dimension()));
544
545 mesh.create_submesh
546 (new_mesh,
547 mesh.active_elements_begin(),
548 mesh.active_elements_end());
549
550 // now write the new_mesh in as many formats as requested
551 for (auto & output_name : output_names)
552 new_mesh.write(output_name);
553 }
554 else
555 {
556 // Write the new_mesh in as many formats as requested
557 for (auto & output_name : output_names)
558 mesh.write(output_name);
559 }
560
561
562
563 // Possibly write the BCs
564 if (write_bndry != BM_DISABLED)
565 {
566 BoundaryMesh boundary_mesh
567 (mesh.comm(), cast_int<unsigned char>(mesh.mesh_dimension()-1));
568
569 if (write_bndry == BM_MESH_ONLY)
570 mesh.get_boundary_info().sync(boundary_mesh);
571
572 else
573 libmesh_error_msg("Invalid value write_bndry = " << write_bndry);
574
575 // Write the mesh in as many formats as requested
576 for (auto boundary_name : output_names)
577 {
578 boundary_name = "bndry_" + boundary_name;
579 boundary_mesh.write(boundary_name);
580 }
581 }
582 }
583
584 return 0;
585}
586
587
588void usage(const std::string & prog_name)
589{
590 std::ostringstream helpList;
591 helpList << "usage:\n"
592 << " "
593 << prog_name
594 << " [options] ...\n"
595 << "\n"
596 << "options:\n"
597 << " -i <string> Input file name, one option per file\n"
598 << " Multiple files get concatenated"
599 << " -o <string> Output file name, one option per file\n"
600 << "\n -b Write the boundary conditions\n"
601 << " -D <factor> Randomly move interior nodes by D*hmin\n"
602 << " -h Print help menu\n"
603 << " -p <count> Partition into <count> subdomains\n"
604 << " -V Apply the variational mesh smoother\n"
605#ifdef LIBMESH_ENABLE_AMR
606 << " -r <count> Uniformly refine <count> times\n"
607#endif
608 << " -s <volume> Split-edge refine elements exceeding <volume>\n"
609 << " -t Convert all elements to triangles/tets\n"
610 << " -T <desired elem area/vol> Triangulate/Tetrahedralize the interior\n"
611 << " -v Verbose\n"
612 << " -q <metric> Evaluates the named element quality metric\n"
613 << " -1 Converts a mesh of higher order elements\n"
614 << " to their first-order counterparts:\n"
615 << " Quad8 -> Quad4, Tet10 -> Tet4 etc\n"
616 << " -2 Converts a mesh of linear elements\n"
617 << " to their second-order counterparts:\n"
618 << " Quad4 -> Quad8, Tet4 -> Tet10 etc\n"
619 << " -3 Same, but to the highest possible:\n"
620 << " Quad4 -> Quad9, Hex8 -> Hex27 etc\n"
621#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
622 << "\n -a Add infinite elements\n"
623 << " -x <coord> Specify infinite element origin\n"
624 << " -y <coord> coordinates. If none given, origin\n"
625 << " -z <coord> is determined automatically.\n"
626 << " -X When building infinite elements \n"
627 << " -Y treat mesh as x/y/z-symmetric.\n"
628 << " -Z When -X is given, -x <coord> also\n"
629 << " has to be given. Similar for y,z.\n"
630#endif
631 << "\n"
632 << "\n"
633 << " This program is used to convert and partition from/to a variety of\n"
634 << " formats. File types are inferred from file extensions. For example,\n"
635 << " the command:\n"
636 << "\n"
637 << " ./meshtool -i in.e -o out.plt\n"
638 << "\n"
639 << " will read a mesh in the ExodusII format (from Cubit, for example)\n"
640 << " from the file in.e. It will then write the mesh in the Tecplot\n"
641 << " binary format to out.plt.\n"
642 << "\n"
643 << " and\n"
644 << "\n"
645 << " ./meshtool -i cylinder.msh -i square.xda -o out.e -2\n"
646 << "\n"
647 << " will read the Gmsh formatted mesh file cylinder.msh, concatenate\n"
648 << " the elements and nodes (with shifted id numbers) from the libMesh\n"
649 << " mesh file square.xda, convert all first-order elements from both\n"
650 << " to second-order, and write the combined mesh in Exodus format to\n"
651 << " out.e.\n"
652#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
653 << "\n"
654 << " and\n"
655 << "\n"
656 << " ./meshtool -i dry.unv -o packed.gmv -a -x 30.5 -y -10.5 -X\n"
657 << "\n"
658 << " will read a Universal file, determine the z-coordinate of the origin\n"
659 << " automatically, e.g. z_origin = 3., build infinite elements with the\n"
660 << " origin (30.5, -10.5, 3.) on top of volume elements, while preserving\n"
661 << " a symmetry plane through (30.5, -10.5, 3.) perpendicular to x.\n"
662 << " It is imperative that the origin lies _inside_ the given volume mesh.\n"
663 << " If not, infinite elements are not correctly built!\n"
664#endif
665 << "\n"
666 << " This program supports the I/O formats:\n"
667 << "\n"
668 << " *.cpa -- libMesh ASCII checkpoint format\n"
669 << " *.cpr -- libMesh binary checkpoint format,\n"
670 << " *.e -- Sandia's ExodusII format\n"
671 << " *.exo -- Sandia's ExodusII format\n"
672 << " *.gmv -- LANL's GMV (General Mesh Viewer) format\n"
673 << " *.mesh -- MEdit mesh format\n"
674 << " *.msh -- GMSH ASCII file\n"
675 << " *.n -- Sandia's Nemesis format\n"
676 << " *.nem -- Sandia's Nemesis format\n"
677 << " *.plt -- Tecplot binary file\n"
678 << " *.poly -- TetGen ASCII file\n"
679 << " *.ucd -- AVS's ASCII UCD format\n"
680 << " *.ugrid -- Kelly's DIVA ASCII format\n"
681 << " *.unv -- I-deas Universal format\n"
682 << " *.vtu -- VTK (paraview-readable) format\n"
683 << " *.xda -- libMesh ASCII format\n"
684 << " *.xdr -- libMesh binary format,\n"
685 << "\n As well as for input only:\n\n" \
686 << " *.bext -- Bezier files in DYNA format\n" \
687 << " *.bxt -- Bezier files in DYNA format\n" \
688 << " *.inp -- Abaqus .inp format\n" \
689 << " *.mat -- Matlab triangular ASCII file\n" \
690 << " *.off -- OOGL OFF surface format\n" \
691 << " *.ogl -- OOGL OFF surface format\n" \
692 << " *.oogl -- OOGL OFF surface format\n" \
693 << "\n As well as for output only:\n\n" \
694 << " *.dat -- Tecplot ASCII file\n"
695 << " *.fro -- ACDL's surface triangulation file\n"
696 << " *.poly -- TetGen ASCII file\n"
697 << "\n";
698
699 libMesh::out << helpList.str();
700 exit(0);
701}
void sync(UnstructuredMesh &boundary_mesh)
Generates boundary_mesh data structures corresponding to the mesh data structures.
void print_summary(std::ostream &out_stream=libMesh::out) const
Prints a summary of the boundary information.
The BoundaryMesh is a Mesh in its own right, but it contains a description of the boundary of some ot...
virtual std::pair< Real, Real > qual_bounds(const ElemQuality) const
Definition elem.h:1109
This class is used to build infinite elements on top of an existing mesh.
const Point build_inf_elem(const bool be_verbose=false)
Build infinite elements atop a volume-based mesh, determine origin automatically.
std::pair< bool, double > InfElemOriginValue
Useful typedef.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition libmesh.h:92
const BoundaryInfo & get_boundary_info() const
The information about boundary ids on the mesh.
Definition mesh_base.h:170
unsigned int mesh_dimension() const
Definition mesh_base.C:430
virtual dof_id_type n_elem() const =0
virtual void all_first_order()=0
Converts a mesh with higher-order elements into a mesh with linear elements.
void all_second_order(const bool full_ordered=true)
Calls the range-based version of this function with a range consisting of all elements in the mesh.
Definition mesh_base.C:1803
void prepare_for_use(const bool skip_renumber_nodes_and_elements, const bool skip_find_neighbors)
Prepare a newly created (or read) mesh for use.
Definition mesh_base.C:824
virtual void write(const std::string &name) const =0
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
virtual dof_id_type max_node_id() const =0
virtual dof_id_type max_elem_id() const =0
virtual const Elem & elem_ref(const dof_id_type i) const
Definition mesh_base.h:788
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition mesh_base.C:1755
virtual void partition(const unsigned int n_parts)
Call the default partitioner (currently metis_partition()).
Definition mesh_base.C:1769
virtual unique_id_type parallel_max_unique_id() const =0
Implements (adaptive) mesh refinement algorithms for a MeshBase.
void uniformly_refine(unsigned int n=1)
Uniformly refines the mesh n times.
Real & desired_volume()
Sets and/or gets the desired tetrahedron volume.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
Class NetGenMeshInterface provides an interface for tetrahedralization of meshes using the NetGen lib...
virtual void triangulate() override
Method invokes NetGen library to compute a tetrahedralization.
const Parallel::Communicator & comm() const
A C++ interface between LibMesh and the poly2tri library, with custom code for Steiner point insertio...
virtual void triangulate() override
Internally, this calls the poly2tri triangulation code in a loop, inserting our owner Steiner points ...
A C++ class to refine a simplicial mesh via splitting edges that exceed a given metric.
bool refine_elements()
Finds elements which exceed the requested metric and refines them via subdivision into new simplices ...
Real & desired_volume()
Sets and/or gets the desired element volume.
The StatisticsVector class is derived from the std::vector<> and therefore has all of its useful feat...
Definition statistics.h:68
virtual Real mean() const
Definition statistics.C:75
virtual std::vector< dof_id_type > cut_below(Real cut) const
Definition statistics.C:340
virtual void histogram(std::vector< dof_id_type > &bin_members, unsigned int n_bins=10)
Definition statistics.C:179
Real & minimum_angle()
Sets and/or gets the minimum desired angle.
TriangulationType & triangulation_type()
Sets and/or gets the desired triangulation type.
@ PSLG
Triangulate the interior of a Planar Straight Line Graph, which is defined implicitly by the order of...
Real & desired_area()
Sets and/or gets the desired triangle area.
virtual void write(const std::string &name) const override
Write the file specified by name.
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false) override
Reads the file specified by name.
This is an implementation of Larisa Branets' smoothing algorithms.
virtual void smooth() override
Redefinition of the smooth function from the base class.
MeshBase & mesh
void usage(const std::string &prog_name)
Definition meshtool.C:588
BoundaryMeshWriteMode
Definition meshtool.C:56
@ BM_DISABLED
Definition meshtool.C:56
@ BM_MESH_ONLY
Definition meshtool.C:56
void all_tri(MeshBase &mesh)
Subdivides any non-simplex elements in a Mesh to produce simplex (triangular in 2D,...
void distort(MeshBase &mesh, const Real factor, const bool perturb_boundary=false)
Randomly perturb the nodal locations.
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
The libMesh namespace provides an interface to certain functionality in the library.
uint8_t unique_id_type
Definition id_types.h:86
OStreamProxy out
ElemQuality
Defines an enum for element quality metrics.
static constexpr Real TOLERANCE
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
int main()