62 unsigned int n_subdomains = 1;
63 unsigned int n_rsteps = 0;
64 double dist_fact = 0.;
67 bool convert_first_order =
false;
68 unsigned int convert_second_order = 0;
69 bool triangulate =
false;
70 bool do_quality =
false;
73 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
74 bool addinfelems =
false;
83 std::vector<std::string> names;
84 std::vector<std::string> var_names;
85 std::vector<Number> soln;
89 usage(std::string(argv[0]));
92 GetPot command_line (argc, argv);
95 if (command_line.search(2,
"-h",
"-?"))
99 if (command_line.search(1,
"-i"))
102 tmp = command_line.next(tmp);
104 names.push_back(tmp);
106 libmesh_error_msg(
"ERROR: Input name must precede output name!");
110 if (command_line.search(1,
"-o"))
113 tmp = command_line.next(tmp);
115 names.push_back(tmp);
117 libmesh_error_msg(
"ERROR: Input name must precede output name!");
121 if (command_line.search(1,
"-D"))
122 dist_fact = command_line.next(dist_fact);
125 if (command_line.search(1,
"-r"))
128 tmp = command_line.next(tmp);
129 n_rsteps = cast_int<unsigned int>(tmp);
133 if (command_line.search(1,
"-p"))
136 tmp = command_line.next(tmp);
137 n_subdomains = cast_int<unsigned int>(tmp);
141 if (command_line.search(1,
"-t"))
145 if (command_line.search(1,
"-q"))
149 tmp = command_line.next(tmp);
151 quality_type = Utility::string_to_enum<ElemQuality>(tmp);
155 if (command_line.search(1,
"-v"))
159 if (command_line.search(1,
"-b"))
163 if (command_line.search(1,
"-1"))
164 convert_first_order =
true;
167 if (command_line.search(1,
"-2"))
168 convert_second_order = 2;
171 if (command_line.search(1,
"-3"))
172 convert_second_order = 22;
174 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
177 if (command_line.search(1,
"-a"))
181 if (command_line.search(1,
"-x"))
183 origin_x.first =
true;
184 origin_x.second = command_line.next(origin_x.second);
188 if (command_line.search(1,
"-y"))
190 origin_y.first =
true;
191 origin_y.second = command_line.next(origin_y.second);
195 if (command_line.search(1,
"-z"))
197 origin_z.first =
true;
198 origin_z.second = command_line.next(origin_z.second);
202 if (command_line.search(1,
"-X"))
204 if (command_line.search(1,
"-Y"))
206 if (command_line.search(1,
"-Z"))
209 #endif // LIBMESH_ENABLE_INFINITE_ELEMENTS
232 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
236 if (names.size() == 3)
237 libmesh_error_msg(
"ERROR: Invalid combination: Building infinite elements\n"
238 <<
"not compatible with solution import.");
241 libmesh_error_msg(
"ERROR: Invalid combination: Building infinite elements\n"
242 <<
"not compatible with writing boundary conditions.");
246 if ((x_sym && !origin_x.first) ||
247 (y_sym && !origin_y.first) ||
248 (z_sym && !origin_z.first))
249 libmesh_error_msg(
"ERROR: When x-symmetry is requested using -X, then\n"
250 <<
"the option -x <coord> also has to be given.\n"
251 <<
"This holds obviously for y and z, too.");
267 else if ((origin_x.first || origin_y.first || origin_z.first) ||
268 (x_sym || y_sym || z_sym))
269 libmesh_error_msg(
"ERROR: -x/-y/-z/-X/-Y/-Z is only to be used when\n"
270 <<
"the option -a is also specified!");
294 libMesh::out <<
"Quality bounds for this element type are: ("
302 sv.push_back(elem->quality(quality_type));
304 const unsigned int n_bins = 10;
309 std::vector<dof_id_type> bad_elts = sv.
cut_below(0.8);
312 <<
" elements below the cutoff." << std::endl;
315 std::vector<dof_id_type> histogram;
318 const bool do_matlab =
true;
322 std::ofstream
out (
"histo.m");
324 out <<
"% This is a sample histogram plot for Matlab." << std::endl;
325 out <<
"bin_members = [" << std::endl;
326 for (
unsigned int i=0; i<n_bins; i++)
327 out << static_cast<Real>(histogram[i]) / static_cast<Real>(
mesh.
n_elem())
329 out <<
"];" << std::endl;
331 std::vector<Real> bin_coords(n_bins);
332 const Real max = *(std::max_element(sv.begin(), sv.end()));
333 const Real min = *(std::min_element(sv.begin(), sv.end()));
334 const Real delta = (max - min) / static_cast<Real>(n_bins);
335 for (
unsigned int i=0; i<n_bins; i++)
336 bin_coords[i] = min + (i * delta) + delta / 2.0 ;
338 out <<
"bin_coords = [" << std::endl;
339 for (
unsigned int i=0; i<n_bins; i++)
340 out << bin_coords[i] << std::endl;
341 out <<
"];" << std::endl;
343 out <<
"bar(bin_coords, bin_members, 1);" << std::endl;
344 out <<
"hold on" << std::endl;
345 out <<
"plot (bin_coords, 0, 'kx');" << std::endl;
346 out <<
"xlabel('Quality (0=Worst, 1=Best)');" << std::endl;
347 out <<
"ylabel('Percentage of elements in each bin');" << std::endl;
348 out <<
"axis([" << min <<
"," << max <<
",0, max(bin_members)]);" << std::endl;
357 if (convert_first_order)
360 libMesh::out <<
"Converting elements to first order counterparts\n";
372 if (convert_second_order > 0)
374 bool second_order_mode =
true;
375 std:: string message =
"Converting elements to second order counterparts";
376 if (convert_second_order == 2)
378 second_order_mode =
false;
379 message +=
", lower version: Quad4 -> Quad8, not Quad9";
382 else if (convert_second_order == 22)
384 second_order_mode =
true;
385 message +=
", highest version: Quad4 -> Quad9";
389 libmesh_error_msg(
"Invalid value, convert_second_order = " << convert_second_order);
404 #ifdef LIBMESH_ENABLE_AMR
411 << n_rsteps <<
" times"
415 mesh_refinement.uniformly_refine(n_rsteps);
440 if (n_subdomains > 1)
445 if (names.size() >= 2)
456 libMesh::out <<
" Mesh got refined, will write only _active_ elements." << std::endl;
466 if (names.size() == 2)
467 new_mesh.
write(names[1]);
468 else if (names.size() == 3)
469 new_mesh.write(names[1], soln, var_names);
471 libmesh_error_msg(
"Invalid names.size() = " << names.size());
475 if (names.size() == 2)
477 else if (names.size() == 3)
480 libmesh_error_msg(
"Invalid names.size() = " << names.size());
491 std::string boundary_name =
"bndry_";
492 boundary_name += names[1];
498 libmesh_error_msg(
"Invalid value write_bndry = " << write_bndry);
500 if (names.size() == 2)
501 boundary_mesh.write(boundary_name);
502 else if (names.size() == 3)
503 boundary_mesh.write(boundary_name, soln, var_names);