2 #include "femparameters.h" 4 #include "libmesh/parsed_function.h" 5 #include "libmesh/zero_function.h" 8 #include <unordered_set> 12 #define GETPOT_INPUT(A) { A = input(#A, A); \ 13 variable_names.insert(#A); \ 14 const std::string stringval = input(#A, std::string()); \ 15 variable_assignments.push_back(std::string(#A "=") + stringval); } 16 #define GETPOT_INT_INPUT(A) { A = input(#A, (int)A); \ 17 variable_names.insert(#A); \ 18 const std::string stringval = input(#A, std::string()); \ 19 variable_assignments.push_back(std::string(#A "=") + stringval); } 21 #define GETPOT_REGISTER(A) { \ 22 variable_names.insert(#A); \ 23 std::string stringval = input(#A, std::string()); \ 24 variable_assignments.push_back(std::string(#A "=") + stringval); } 28 initial_timestep(0), n_timesteps(100),
31 timesolver_core(
"euler"),
32 solution_history_type(
"memory"),
33 end_time(
std::numeric_limits<
Real>::max()),
34 deltat(0.0001), timesolver_theta(0.5),
35 timesolver_maxgrowth(0.), timesolver_tolerance(0.),
36 timesolver_upper_tolerance(0.),
37 steadystate_tolerance(0.),
38 timesolver_norm(0,
L2),
41 domaintype(
"square"), domainfile(
"mesh.xda"), elementtype(
"quad"),
43 domain_xmin(0.0), domain_ymin(0.0), domain_zmin(0.0),
44 domain_edge_width(1.0), domain_edge_length(1.0), domain_edge_height(1.0),
45 coarsegridx(1), coarsegridy(1), coarsegridz(1),
46 coarserefinements(0), extrarefinements(0),
47 mesh_redistribute_func(
"0"),
49 mesh_partitioner_type(
"Default"),
51 nelem_target(8000), global_tolerance(0.0),
52 refine_fraction(0.3), coarsen_fraction(0.3), coarsen_threshold(10),
54 initial_adaptivesteps(0),
57 write_gmv_error(false), write_tecplot_error(false),
58 write_exodus_error(false),
59 output_xda(false), output_xdr(false),
60 output_bz2(true), output_gz(true),
61 output_gmv(false), output_tecplot(false),
62 output_exodus(false), output_nemesis(false),
66 #ifdef LIBMESH_ENABLE_PERIODIC
67 periodic_boundaries(0),
70 run_simulation(true), run_postprocess(false),
72 fe_family(1,
"LAGRANGE"), fe_order(1, 1),
73 extra_quadrature_order(0),
75 analytic_jacobians(true), verify_analytic_jacobians(0.0),
77 print_solution_norms(false), print_solutions(false),
78 print_residual_norms(false), print_residuals(false),
79 print_jacobian_norms(false), print_jacobians(false),
80 print_element_solutions(false),
81 print_element_residuals(false),
82 print_element_jacobians(false),
84 constrain_in_solver(true),
85 use_petsc_snes(false),
86 time_solver_quiet(true), solver_quiet(true), solver_verbose(false),
87 reuse_preconditioner(true),
88 require_residual_reduction(true),
89 min_step_length(1e-5),
90 max_linear_iterations(200000), max_nonlinear_iterations(20),
91 relative_step_tolerance(1.e-7), relative_residual_tolerance(1.e-10),
92 absolute_residual_tolerance(1.e-10),
94 linear_tolerance_multiplier(1.e-3),
96 initial_sobolev_order(1),
97 initial_extra_quadrature(0),
98 refine_uniformly(false),
99 indicator_type(
"kelly"), patch_reuse(true), sobolev_order(1)
126 j = i->second.begin(); j != i->second.end();
136 j = i->second.begin(); j != i->second.end();
143 const std::string & func_value)
145 if (func_type ==
"parsed")
146 return std::make_unique<ParsedFunction<Number>>(func_value);
147 else if (func_type ==
"zero")
148 return std::make_unique<ZeroFunction<Number>>();
150 libmesh_not_implemented();
152 return std::unique_ptr<FunctionBase<Number>>();
157 const std::vector<std::string> * other_variable_names)
159 std::vector<std::string> variable_assignments;
160 std::unordered_set<std::string> variable_names;
161 if (other_variable_names)
162 for (std::size_t i=0; i != other_variable_names->size(); ++i)
164 const std::string &
name = (*other_variable_names)[i];
165 const std::string stringval = input(
name, std::string());
166 variable_assignments.push_back(
name +
"=" + stringval);
171 GETPOT_INPUT(
transient);
184 const unsigned int n_timesolver_norm = input.vector_variable_size(
"timesolver_norm");
186 for (
unsigned int i=0; i != n_timesolver_norm; ++i)
188 int current_norm = 0;
193 current_norm = input(
"timesolver_norm", current_norm, i);
194 if (current_norm == 0)
196 else if (current_norm == 1)
198 else if (current_norm == 2)
240 #ifndef LIBMESH_HAVE_GZSTREAM 244 #ifndef LIBMESH_HAVE_BZ2 249 #ifndef LIBMESH_HAVE_GMV 255 #ifndef LIBMESH_HAVE_TECPLOT_API 261 #ifndef LIBMESH_HAVE_EXODUS_API 266 #ifndef LIBMESH_HAVE_NEMESIS_API 272 const unsigned int n_system_types =
273 input.vector_variable_size(
"system_types");
277 for (
unsigned int i=0; i != n_system_types; ++i)
284 #ifdef LIBMESH_ENABLE_PERIODIC 286 const unsigned int n_periodic_bcs =
287 input.vector_variable_size(
"periodic_boundaries");
296 libMesh::out <<
"Periodic boundaries need rectilinear domains" << std::endl;;
299 for (
unsigned int i=0; i != n_periodic_bcs; ++i)
301 const unsigned int myboundary =
302 input(
"periodic_boundaries", -1, i);
318 myboundary << std::endl;;
338 myboundary << std::endl;;
346 #endif // LIBMESH_ENABLE_PERIODIC 350 std::string zero_string =
"zero";
351 std::string empty_string =
"";
353 GETPOT_REGISTER(dirichlet_condition_types);
354 GETPOT_REGISTER(dirichlet_condition_values);
355 GETPOT_REGISTER(dirichlet_condition_boundaries);
358 const unsigned int n_dirichlet_conditions=
359 input.vector_variable_size(
"dirichlet_condition_types");
361 if (n_dirichlet_conditions !=
362 input.vector_variable_size(
"dirichlet_condition_values"))
365 <<
" Dirichlet condition types does not match " 366 << input.vector_variable_size(
"dirichlet_condition_values")
367 <<
" Dirichlet condition values." << std::endl;
372 if (n_dirichlet_conditions !=
373 input.vector_variable_size(
"dirichlet_condition_boundaries"))
376 <<
" Dirichlet condition types does not match " 377 << input.vector_variable_size(
"dirichlet_condition_boundaries")
378 <<
" Dirichlet condition boundaries." << std::endl;
383 if (n_dirichlet_conditions !=
384 input.vector_variable_size(
"dirichlet_condition_variables"))
387 <<
" Dirichlet condition types does not match " 388 << input.vector_variable_size(
"dirichlet_condition_variables")
389 <<
" Dirichlet condition variables sets." << std::endl;
394 for (
unsigned int dc=0; dc != n_dirichlet_conditions; ++dc)
396 const std::string func_type =
397 input(
"dirichlet_condition_types", zero_string, dc);
399 const std::string func_value =
400 input(
"dirichlet_condition_values", empty_string, dc);
408 const std::string variable_set =
409 input(
"dirichlet_condition_variables", empty_string, dc);
411 for (
unsigned int i=0; i != variable_set.size(); ++i)
413 if (variable_set[i] ==
'1')
415 else if (variable_set[i] !=
'0')
417 libMesh::out <<
"Unable to understand Dirichlet variable set" 418 << variable_set << std::endl;
424 GETPOT_REGISTER(neumann_condition_types);
425 GETPOT_REGISTER(neumann_condition_values);
426 GETPOT_REGISTER(neumann_condition_boundaries);
429 const unsigned int n_neumann_conditions=
430 input.vector_variable_size(
"neumann_condition_types");
432 if (n_neumann_conditions !=
433 input.vector_variable_size(
"neumann_condition_values"))
436 <<
" Neumann condition types does not match " 437 << input.vector_variable_size(
"neumann_condition_values")
438 <<
" Neumann condition values." << std::endl;
443 if (n_neumann_conditions !=
444 input.vector_variable_size(
"neumann_condition_boundaries"))
447 <<
" Neumann condition types does not match " 448 << input.vector_variable_size(
"neumann_condition_boundaries")
449 <<
" Neumann condition boundaries." << std::endl;
454 if (n_neumann_conditions !=
455 input.vector_variable_size(
"neumann_condition_variables"))
458 <<
" Neumann condition types does not match " 459 << input.vector_variable_size(
"neumann_condition_variables")
460 <<
" Neumann condition variables sets." << std::endl;
465 for (
unsigned int nc=0; nc != n_neumann_conditions; ++nc)
467 const std::string func_type =
468 input(
"neumann_condition_types", zero_string, nc);
470 const std::string func_value =
471 input(
"neumann_condition_values", empty_string, nc);
479 const std::string variable_set =
480 input(
"neumann_condition_variables", empty_string, nc);
482 for (
unsigned int i=0; i != variable_set.size(); ++i)
484 if (variable_set[i] ==
'1')
486 else if (variable_set[i] !=
'0')
488 libMesh::out <<
"Unable to understand Neumann variable set" 489 << variable_set << std::endl;
495 GETPOT_REGISTER(initial_condition_types);
496 GETPOT_REGISTER(initial_condition_values);
497 GETPOT_REGISTER(initial_condition_subdomains);
499 const unsigned int n_initial_conditions=
500 input.vector_variable_size(
"initial_condition_types");
502 if (n_initial_conditions !=
503 input.vector_variable_size(
"initial_condition_values"))
506 <<
" initial condition types does not match " 507 << input.vector_variable_size(
"initial_condition_values")
508 <<
" initial condition values." << std::endl;
513 if (n_initial_conditions !=
514 input.vector_variable_size(
"initial_condition_subdomains"))
517 <<
" initial condition types does not match " 518 << input.vector_variable_size(
"initial_condition_subdomains")
519 <<
" initial condition subdomains." << std::endl;
524 for (
unsigned int i=0; i != n_initial_conditions; ++i)
526 const std::string func_type =
527 input(
"initial_condition_types", zero_string, i);
529 const std::string func_value =
530 input(
"initial_condition_values", empty_string, i);
539 GETPOT_REGISTER(other_interior_function_types);
540 GETPOT_REGISTER(other_interior_function_values);
541 GETPOT_REGISTER(other_interior_function_subdomains);
542 GETPOT_REGISTER(other_interior_function_ids);
544 const unsigned int n_other_interior_functions =
545 input.vector_variable_size(
"other_interior_function_types");
547 if (n_other_interior_functions !=
548 input.vector_variable_size(
"other_interior_function_values"))
551 <<
" other interior function types does not match " 552 << input.vector_variable_size(
"other_interior_function_values")
553 <<
" other interior function values." << std::endl;
558 if (n_other_interior_functions !=
559 input.vector_variable_size(
"other_interior_function_subdomains"))
562 <<
" other interior function types does not match " 563 << input.vector_variable_size(
"other_interior_function_subdomains")
564 <<
" other interior function subdomains." << std::endl;
569 if (n_other_interior_functions !=
570 input.vector_variable_size(
"other_interior_function_ids"))
573 <<
" other interior function types does not match " 574 << input.vector_variable_size(
"other_interior_function_ids")
575 <<
" other interior function ids." << std::endl;
580 for (
unsigned int i=0; i != n_other_interior_functions; ++i)
582 const std::string func_type =
583 input(
"other_interior_function_types", zero_string, i);
585 const std::string func_value =
586 input(
"other_interior_function_values", empty_string, i);
592 input(
"other_interior_condition_ids",
int(0), i);
598 GETPOT_REGISTER(other_boundary_function_types);
599 GETPOT_REGISTER(other_boundary_function_values);
600 GETPOT_REGISTER(other_boundary_function_boundaries);
601 GETPOT_REGISTER(other_boundary_function_ids);
603 const unsigned int n_other_boundary_functions =
604 input.vector_variable_size(
"other_boundary_function_types");
606 if (n_other_boundary_functions !=
607 input.vector_variable_size(
"other_boundary_function_values"))
610 <<
" other boundary function types does not match " 611 << input.vector_variable_size(
"other_boundary_function_values")
612 <<
" other boundary function values." << std::endl;
617 if (n_other_boundary_functions !=
618 input.vector_variable_size(
"other_boundary_function_boundaries"))
621 <<
" other boundary function types does not match " 622 << input.vector_variable_size(
"other_boundary_function_boundaries")
623 <<
" other boundary function boundaries." << std::endl;
628 if (n_other_boundary_functions !=
629 input.vector_variable_size(
"other_boundary_function_ids"))
632 <<
" other boundary function types does not match " 633 << input.vector_variable_size(
"other_boundary_function_ids")
634 <<
" other boundary function ids." << std::endl;
639 for (
unsigned int i=0; i != n_other_boundary_functions; ++i)
641 const std::string func_type =
642 input(
"other_boundary_function_types", zero_string, i);
644 const std::string func_value =
645 input(
"other_boundary_function_values", empty_string, i);
651 input(
"other_boundary_function_ids",
int(0), i);
662 const unsigned int n_fe_family =
663 std::max(1u, input.vector_variable_size(
"fe_family"));
664 fe_family.resize(n_fe_family,
"LAGRANGE");
665 for (
unsigned int i=0; i != n_fe_family; ++i)
668 const unsigned int n_fe_order =
669 input.vector_variable_size(
"fe_order");
671 for (
unsigned int i=0; i != n_fe_order; ++i)
717 std::vector<std::string> bad_variables =
718 input.unidentified_arguments(variable_assignments);
723 std::vector<std::string> actually_bad_variables;
724 for (std::size_t i = 0; i < bad_variables.size(); ++i)
728 if (bad_variables[i].empty() || bad_variables[i][0] !=
'-')
730 std::string bad_variable_name =
731 bad_variables[i].substr(0, bad_variables[i].find(
'='));
732 if (!variable_names.count(bad_variable_name))
733 actually_bad_variables.push_back(bad_variables[i]);
739 if (bad_variables.size() > (i+1) &&
740 !bad_variables[i+1].empty() &&
741 bad_variables[i+1][0] !=
'-')
745 if (this->
comm().
rank() == 0 && !actually_bad_variables.empty())
747 libMesh::err <<
"ERROR: Unrecognized variables:" << std::endl;
748 for (
auto var : actually_bad_variables)
750 libMesh::err <<
"Not found among recognized variables:" << std::endl;
751 for (std::size_t i = 0; i != variable_names.size(); ++i)
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
unsigned int nelem_target
libMesh::Real timesolver_upper_tolerance
libMesh::Real domain_ymin
bool print_solution_norms
unsigned int initial_timestep
bool print_element_residuals
unsigned int coarserefinements
std::string solution_history_type
bool reuse_preconditioner
libMesh::Real timesolver_tolerance
libMesh::Real elementorder
std::string mesh_partitioner_type
VectorValue< Real > RealVectorValue
Useful typedefs to allow transparent switching between Real and Complex data types.
static constexpr Real TOLERANCE
TestClass subdomain_id_type
Based on the 4-byte comment warning above, this probably doesn't work with exodusII at all...
libMesh::Real domain_edge_length
std::string timesolver_core
std::string system_config_file
bool require_residual_reduction
libMesh::Real domain_zmin
bool print_residual_norms
libMesh::Real timesolver_maxgrowth
processor_id_type rank() const
std::map< libMesh::boundary_id_type, libMesh::FunctionBase< libMesh::Number > * > neumann_conditions
const Parallel::Communicator & comm() const
libMesh::Real relative_step_tolerance
std::string indicator_type
The libMesh namespace provides an interface to certain functionality in the library.
The definition of a periodic boundary.
libMesh::Real refine_fraction
libMesh::Real domain_edge_height
unsigned int initial_extra_quadrature
std::unique_ptr< FunctionBase< Number > > new_function_base(const std::string &func_type, const std::string &func_value)
std::vector< unsigned int > fe_order
std::string mesh_redistribute_func
libMesh::Real coarsen_threshold
unsigned int max_linear_iterations
double minimum_linear_tolerance
std::map< int, std::map< libMesh::subdomain_id_type, libMesh::FunctionBase< libMesh::Number > * > > other_interior_functions
std::map< libMesh::subdomain_id_type, libMesh::FunctionBase< libMesh::Number > * > initial_conditions
std::vector< libMesh::PeriodicBoundary > periodic_boundaries
std::vector< std::string > fe_family
std::map< int, std::map< libMesh::boundary_id_type, libMesh::FunctionBase< libMesh::Number > * > > other_boundary_functions
libMesh::Real verify_analytic_jacobians
unsigned int write_interval
unsigned int max_adaptivesteps
double initial_linear_tolerance
std::map< libMesh::boundary_id_type, std::vector< unsigned int > > neumann_condition_variables
int extra_quadrature_order
libMesh::Real global_tolerance
void read(GetPot &input, const std::vector< std::string > *other_variable_names=nullptr)
libMesh::Real absolute_residual_tolerance
An object whose state is distributed along a set of processors.
libMesh::Real relative_residual_tolerance
bool print_element_solutions
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
bool print_jacobian_norms
unsigned int extrarefinements
libMesh::Real min_step_length
libMesh::Real timesolver_theta
bool print_element_jacobians
unsigned int max_nonlinear_iterations
double linear_tolerance_multiplier
std::map< libMesh::boundary_id_type, std::vector< unsigned int > > dirichlet_condition_variables
unsigned int initial_adaptivesteps
unsigned int initial_sobolev_order
libMesh::Real numerical_jacobian_h
std::map< libMesh::boundary_id_type, libMesh::FunctionBase< libMesh::Number > * > dirichlet_conditions
std::vector< libMesh::FEMNormType > timesolver_norm
unsigned int sobolev_order
std::vector< std::string > system_types
FEMParameters(const libMesh::Parallel::Communicator &comm_in)
libMesh::Real domain_edge_width
libMesh::Real coarsen_fraction
libMesh::Real steadystate_tolerance
libMesh::Real domain_xmin
unsigned int deltat_reductions