libMesh
Functions
adjoints_ex1.C File Reference

Go to the source code of this file.

Functions

void write_output (EquationSystems &es, unsigned int a_step, std::string solution_type, FEMParameters &param)
 
void set_system_parameters (LaplaceSystem &system, FEMParameters &param)
 
std::unique_ptr< MeshRefinementbuild_mesh_refinement (MeshBase &mesh, FEMParameters &param)
 
std::unique_ptr< ErrorEstimatorbuild_error_estimator (FEMParameters &param, QoISet &qois)
 
int main (int argc, char **argv)
 

Function Documentation

◆ build_error_estimator()

std::unique_ptr<ErrorEstimator> build_error_estimator ( FEMParameters param,
QoISet qois 
)

Definition at line 239 of file adjoints_ex1.C.

241 {
242  if (param.indicator_type == "kelly")
243  {
244  libMesh::out << "Using Kelly Error Estimator" << std::endl;
245 
246  return libmesh_make_unique<KellyErrorEstimator>();
247  }
248  else if (param.indicator_type == "adjoint_residual")
249  {
250  libMesh::out << "Using Adjoint Residual Error Estimator with Patch Recovery Weights" << std::endl;
251 
252  AdjointResidualErrorEstimator * adjoint_residual_estimator = new AdjointResidualErrorEstimator;
253 
254  adjoint_residual_estimator->qoi_set() = qois;
255 
256  adjoint_residual_estimator->error_plot_suffix = "error.gmv";
257 
259  adjoint_residual_estimator->primal_error_estimator().reset(p1);
260 
262  adjoint_residual_estimator->dual_error_estimator().reset(p2);
263 
264  adjoint_residual_estimator->primal_error_estimator()->error_norm.set_type(0, H1_SEMINORM);
265  p1->set_patch_reuse(param.patch_reuse);
266 
267  adjoint_residual_estimator->dual_error_estimator()->error_norm.set_type(0, H1_SEMINORM);
268  p2->set_patch_reuse(param.patch_reuse);
269 
270  return std::unique_ptr<ErrorEstimator>(adjoint_residual_estimator);
271  }
272  else
273  libmesh_error_msg("Unknown indicator_type = " << param.indicator_type);
274 }

References libMesh::AdjointResidualErrorEstimator::dual_error_estimator(), libMesh::AdjointResidualErrorEstimator::error_plot_suffix, libMesh::H1_SEMINORM, FEMParameters::indicator_type, libMesh::out, FEMParameters::patch_reuse, libMesh::AdjointResidualErrorEstimator::primal_error_estimator(), libMesh::AdjointResidualErrorEstimator::qoi_set(), and libMesh::PatchRecoveryErrorEstimator::set_patch_reuse().

Referenced by main().

◆ build_mesh_refinement()

std::unique_ptr<MeshRefinement> build_mesh_refinement ( MeshBase mesh,
FEMParameters param 
)

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 277 of file adjoints_ex1.C.

278 {
279  // Initialize libMesh.
280  LibMeshInit init (argc, argv);
281 
282  // This example requires a linear solver package.
283  libmesh_example_requires(libMesh::default_solver_package() != INVALID_SOLVER_PACKAGE,
284  "--enable-petsc, --enable-trilinos, or --enable-eigen");
285 
286  // This example relies on exceptions to control which Partitioner gets built.
287 #ifndef LIBMESH_ENABLE_EXCEPTIONS
288  libmesh_example_requires(false, "--enable-exceptions");
289 #endif
290 
291  // Skip adaptive examples on a non-adaptive libMesh build
292 #ifndef LIBMESH_ENABLE_AMR
293  libmesh_example_requires(false, "--enable-amr");
294 #else
295 
296  libMesh::out << "Started " << argv[0] << std::endl;
297 
298  // Make sure the general input file exists, and parse it
299  {
300  std::ifstream i("general.in");
301  if (!i)
302  libmesh_error_msg('[' << init.comm().rank() << "] Can't find general.in; exiting early.");
303  }
304 
305  // Read in parameters from the input file
306  GetPot infile("general.in");
307 
308  // But allow the command line to override it.
309  infile.parse_command_line(argc, argv);
310 
311  FEMParameters param(init.comm());
312  param.read(infile);
313 
314  // Skip this default-2D example if libMesh was compiled as 1D-only.
315  libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
316 
317  // Create a mesh, with dimension to be overridden later, distributed
318  // across the default MPI communicator.
319  Mesh mesh(init.comm());
320 
321  // Give the mesh a non-default partitioner if we can try to do so
322  // safely
323  if (param.mesh_partitioner_type != "Default")
324  {
325 #ifndef LIBMESH_HAVE_RTTI
326  libmesh_example_requires(false, "RTTI support");
327 #else
328  // Factory failures are *verbose* in parallel; let's silence
329  // cerr temporarily.
330  auto oldbuf = libMesh::err.rdbuf();
331  libMesh::err.rdbuf(nullptr);
332  try
333  {
334  // Many partitioners won't work on a distributed Mesh, and
335  // even a currently serialized DistributedMesh won't stay
336  // that way through AMR/C
337  if (!mesh.is_replicated() &&
338  (param.mesh_partitioner_type == "Centroid" ||
339  param.mesh_partitioner_type == "Hilbert" ||
340  param.mesh_partitioner_type == "Morton" ||
341  param.mesh_partitioner_type == "SFCurves" ||
342  param.mesh_partitioner_type == "Metis"))
343  libmesh_example_requires(false, "--disable-parmesh");
344 
345  mesh.partitioner() =
346  Factory<Partitioner>::build(param.mesh_partitioner_type);
347  }
348  catch (...)
349  {
350  libmesh_example_requires(false, param.mesh_partitioner_type + " partitioner support");
351  }
352  libMesh::err.rdbuf(oldbuf);
353 #endif // LIBMESH_HAVE_RTI
354  }
355 
356  // And an object to refine it
357  std::unique_ptr<MeshRefinement> mesh_refinement =
358  build_mesh_refinement(mesh, param);
359 
360  // And an EquationSystems to run on it
361  EquationSystems equation_systems (mesh);
362 
363  libMesh::out << "Reading in and building the mesh" << std::endl;
364 
365  // Read in the mesh
366  mesh.read(param.domainfile.c_str());
367  // Make all the elements of the mesh second order so we can compute
368  // with a higher order basis
370 
371  // Create a mesh refinement object to do the initial uniform refinements
372  // on the coarse grid read in from lshaped.xda
373  MeshRefinement initial_uniform_refinements(mesh);
374  initial_uniform_refinements.uniformly_refine(param.coarserefinements);
375 
376  libMesh::out << "Building system" << std::endl;
377 
378  // Build the FEMSystem
379  LaplaceSystem & system = equation_systems.add_system<LaplaceSystem> ("LaplaceSystem");
380 
381  // Set its parameters
382  set_system_parameters(system, param);
383 
384  libMesh::out << "Initializing systems" << std::endl;
385 
386  equation_systems.init ();
387 
388  // Print information about the mesh and system to the screen.
389  mesh.print_info();
390  equation_systems.print_info();
391  LinearSolver<Number> * linear_solver = system.get_linear_solver();
392 
393  {
394  // Adaptively solve the timestep
395  unsigned int a_step = 0;
396  for (; a_step != param.max_adaptivesteps; ++a_step)
397  {
398  // We can't adapt to both a tolerance and a
399  // target mesh size
400  if (param.global_tolerance != 0.)
401  libmesh_assert_equal_to (param.nelem_target, 0);
402  // If we aren't adapting to a tolerance we need a
403  // target mesh size
404  else
405  libmesh_assert_greater (param.nelem_target, 0);
406 
407  linear_solver->reuse_preconditioner(false);
408 
409  // Solve the forward problem
410  system.solve();
411 
412  // Write out the computed primal solution
413  write_output(equation_systems, a_step, "primal", param);
414 
415  // Get a pointer to the primal solution vector
416  NumericVector<Number> & primal_solution = *system.solution;
417 
418  // Declare a QoISet object, we need this object to set weights for our QoI error contributions
419  QoISet qois;
420 
421  // Declare a qoi_indices vector, each index will correspond to a QoI
422  std::vector<unsigned int> qoi_indices;
423  qoi_indices.push_back(0);
424  qoi_indices.push_back(1);
425  qois.add_indices(qoi_indices);
426 
427  // Set weights for each index, these will weight the contribution of each QoI in the final error
428  // estimate to be used for flagging elements for refinement
429  qois.set_weight(0, 0.5);
430  qois.set_weight(1, 0.5);
431 
432  // Make sure we get the contributions to the adjoint RHS from the sides
433  system.assemble_qoi_sides = true;
434 
435  // We are about to solve the adjoint system, but before we do this we see the same preconditioner
436  // flag to reuse the preconditioner from the forward solver
437  linear_solver->reuse_preconditioner(param.reuse_preconditioner);
438 
439  // Solve the adjoint system. This takes the transpose of the stiffness matrix and then
440  // solves the resulting system
441  system.adjoint_solve();
442 
443  // Now that we have solved the adjoint, set the adjoint_already_solved boolean to true, so we dont solve unnecessarily in the error estimator
444  system.set_adjoint_already_solved(true);
445 
446  // Get a pointer to the solution vector of the adjoint problem for QoI 0
447  NumericVector<Number> & dual_solution_0 = system.get_adjoint_solution(0);
448 
449  // Swap the primal and dual solutions so we can write out the adjoint solution
450  primal_solution.swap(dual_solution_0);
451  write_output(equation_systems, a_step, "adjoint_0", param);
452 
453  // Swap back
454  primal_solution.swap(dual_solution_0);
455 
456  // Get a pointer to the solution vector of the adjoint problem for QoI 0
457  NumericVector<Number> & dual_solution_1 = system.get_adjoint_solution(1);
458 
459  // Swap again
460  primal_solution.swap(dual_solution_1);
461  write_output(equation_systems, a_step, "adjoint_1", param);
462 
463  // Swap back again
464  primal_solution.swap(dual_solution_1);
465 
466  libMesh::out << "Adaptive step "
467  << a_step
468  << ", we have "
469  << mesh.n_active_elem()
470  << " active elements and "
471  << equation_systems.n_active_dofs()
472  << " active dofs."
473  << std::endl;
474 
475  // Postprocess, compute the approximate QoIs and write them out to the console
476  libMesh::out << "Postprocessing: " << std::endl;
477  system.postprocess_sides = true;
478  system.postprocess();
479  Number QoI_0_computed = system.get_QoI_value("computed", 0);
480  Number QoI_0_exact = system.get_QoI_value("exact", 0);
481  Number QoI_1_computed = system.get_QoI_value("computed", 1);
482  Number QoI_1_exact = system.get_QoI_value("exact", 1);
483 
484  libMesh::out << "The relative error in QoI 0 is "
485  << std::setprecision(17)
486  << std::abs(QoI_0_computed - QoI_0_exact) / std::abs(QoI_0_exact)
487  << std::endl;
488 
489  libMesh::out << "The relative error in QoI 1 is "
490  << std::setprecision(17)
491  << std::abs(QoI_1_computed - QoI_1_exact) / std::abs(QoI_1_exact)
492  << std::endl
493  << std::endl;
494 
495  // Now we construct the data structures for the mesh refinement process
496  ErrorVector error;
497 
498  // Build an error estimator object
499  std::unique_ptr<ErrorEstimator> error_estimator =
500  build_error_estimator(param, qois);
501 
502  // Estimate the error in each element using the Adjoint Residual or Kelly error estimator
503  error_estimator->estimate_error(system, error);
504 
505  // We have to refine either based on reaching an error tolerance or
506  // a number of elements target, which should be verified above
507  // Otherwise we flag elements by error tolerance or nelem target
508 
509  // Uniform refinement
510  if (param.refine_uniformly)
511  {
512  mesh_refinement->uniformly_refine(1);
513  }
514  // Adaptively refine based on reaching an error tolerance
515  else if (param.global_tolerance >= 0. && param.nelem_target == 0.)
516  {
517  mesh_refinement->flag_elements_by_error_tolerance (error);
518 
519  mesh_refinement->refine_and_coarsen_elements();
520  }
521  // Adaptively refine based on reaching a target number of elements
522  else
523  {
524  if (mesh.n_active_elem() >= param.nelem_target)
525  {
526  libMesh::out << "We reached the target number of elements." << std::endl << std::endl;
527  break;
528  }
529 
530  mesh_refinement->flag_elements_by_nelem_target (error);
531 
532  mesh_refinement->refine_and_coarsen_elements();
533  }
534 
535  // Dont forget to reinit the system after each adaptive refinement !
536  equation_systems.reinit();
537 
538  libMesh::out << "Refined mesh to "
539  << mesh.n_active_elem()
540  << " active elements and "
541  << equation_systems.n_active_dofs()
542  << " active dofs."
543  << std::endl;
544  }
545 
546  // Do one last solve if necessary
547  if (a_step == param.max_adaptivesteps)
548  {
549  linear_solver->reuse_preconditioner(false);
550  system.solve();
551 
552  write_output(equation_systems, a_step, "primal", param);
553 
554  NumericVector<Number> & primal_solution = *system.solution;
555 
556  QoISet qois;
557  std::vector<unsigned int> qoi_indices;
558 
559  qoi_indices.push_back(0);
560  qoi_indices.push_back(1);
561  qois.add_indices(qoi_indices);
562 
563  qois.set_weight(0, 0.5);
564  qois.set_weight(1, 0.5);
565 
566  system.assemble_qoi_sides = true;
567  linear_solver->reuse_preconditioner(param.reuse_preconditioner);
568  system.adjoint_solve();
569 
570  // Now that we have solved the adjoint, set the adjoint_already_solved boolean to true, so we dont solve unnecessarily in the error estimator
571  system.set_adjoint_already_solved(true);
572 
573  NumericVector<Number> & dual_solution_0 = system.get_adjoint_solution(0);
574 
575  primal_solution.swap(dual_solution_0);
576  write_output(equation_systems, a_step, "adjoint_0", param);
577 
578  primal_solution.swap(dual_solution_0);
579 
580  NumericVector<Number> & dual_solution_1 = system.get_adjoint_solution(1);
581 
582  primal_solution.swap(dual_solution_1);
583  write_output(equation_systems, a_step, "adjoint_1", param);
584 
585  primal_solution.swap(dual_solution_1);
586 
587  libMesh::out << "Adaptive step "
588  << a_step
589  << ", we have "
590  << mesh.n_active_elem()
591  << " active elements and "
592  << equation_systems.n_active_dofs()
593  << " active dofs."
594  << std::endl;
595 
596  libMesh::out << "Postprocessing: " << std::endl;
597  system.postprocess_sides = true;
598  system.postprocess();
599 
600  Number QoI_0_computed = system.get_QoI_value("computed", 0);
601  Number QoI_0_exact = system.get_QoI_value("exact", 0);
602  Number QoI_1_computed = system.get_QoI_value("computed", 1);
603  Number QoI_1_exact = system.get_QoI_value("exact", 1);
604 
605  libMesh::out << "The relative error in QoI 0 is "
606  << std::setprecision(17)
607  << std::abs(QoI_0_computed - QoI_0_exact) / std::abs(QoI_0_exact)
608  << std::endl;
609 
610  libMesh::out << "The relative error in QoI 1 is "
611  << std::setprecision(17)
612  << std::abs(QoI_1_computed - QoI_1_exact) / std::abs(QoI_1_exact)
613  << std::endl
614  << std::endl;
615 
616  // Hard coded asserts to ensure that the actual numbers we are getting are what they should be
617  if (param.max_adaptivesteps > 5 && param.coarserefinements > 2)
618  {
619  libmesh_assert_less(std::abs(QoI_0_computed - QoI_0_exact)/std::abs(QoI_0_exact), 4.e-5);
620  libmesh_assert_less(std::abs(QoI_1_computed - QoI_1_exact)/std::abs(QoI_1_exact), 1.e-4);
621  }
622  else
623  {
624  // This seems to be loose enough for the case of 2 coarse
625  // refinements, 4 adaptive steps
626  libmesh_assert_less(std::abs(QoI_0_computed - QoI_0_exact)/std::abs(QoI_0_exact), 4.e-4);
627  libmesh_assert_less(std::abs(QoI_1_computed - QoI_1_exact)/std::abs(QoI_1_exact), 2.e-3);
628  }
629  }
630  }
631 
632  libMesh::err << '[' << mesh.processor_id()
633  << "] Completing output."
634  << std::endl;
635 
636 #endif // #ifndef LIBMESH_ENABLE_AMR
637 
638  // All done.
639  return 0;
640 }

References std::abs(), libMesh::QoISet::add_indices(), libMesh::EquationSystems::add_system(), libMesh::DifferentiableSystem::adjoint_solve(), libMesh::MeshBase::all_second_order(), libMesh::DifferentiableQoI::assemble_qoi_sides, libMesh::Factory< Base >::build(), build_error_estimator(), build_mesh_refinement(), libMesh::default_solver_package(), libMesh::err, libMesh::System::get_adjoint_solution(), libMesh::DifferentiableSystem::get_linear_solver(), LaplaceSystem::get_QoI_value(), libMesh::TriangleWrapper::init(), libMesh::EquationSystems::init(), libMesh::INVALID_SOLVER_PACKAGE, libMesh::MeshBase::is_replicated(), mesh, libMesh::EquationSystems::n_active_dofs(), libMesh::MeshBase::n_active_elem(), libMesh::out, libMesh::MeshBase::partitioner(), LaplaceSystem::postprocess(), libMesh::DifferentiableSystem::postprocess_sides, libMesh::EquationSystems::print_info(), libMesh::MeshBase::print_info(), libMesh::ParallelObject::processor_id(), libMesh::BasicOStreamProxy< charT, traits >::rdbuf(), FEMParameters::read(), libMesh::MeshBase::read(), libMesh::EquationSystems::reinit(), libMesh::LinearSolver< T >::reuse_preconditioner(), libMesh::System::set_adjoint_already_solved(), set_system_parameters(), libMesh::QoISet::set_weight(), libMesh::System::solution, libMesh::FEMSystem::solve(), libMesh::NumericVector< T >::swap(), libMesh::MeshRefinement::uniformly_refine(), and write_output().

◆ set_system_parameters()

void set_system_parameters ( LaplaceSystem system,
FEMParameters param 
)

Definition at line 162 of file adjoints_ex1.C.

164 {
165  // Use analytical jacobians?
166  system.analytic_jacobians() = param.analytic_jacobians;
167 
168  // Verify analytic jacobians against numerical ones?
170 
171  // Use the prescribed FE type
172  system.fe_family() = param.fe_family[0];
173  system.fe_order() = param.fe_order[0];
174 
175  // More desperate debugging options
177  system.print_solutions = param.print_solutions;
179  system.print_residuals = param.print_residuals;
181  system.print_jacobians = param.print_jacobians;
182 
183  // No transient time solver
184  system.time_solver = libmesh_make_unique<SteadySolver>(system);
185 
186  // Nonlinear solver options
187  {
188  NewtonSolver * solver = new NewtonSolver(system);
189  system.time_solver->diff_solver() = std::unique_ptr<DiffSolver>(solver);
190 
191  solver->quiet = param.solver_quiet;
192  solver->verbose = param.solver_verbose;
194  solver->minsteplength = param.min_step_length;
199  if (system.time_solver->reduce_deltat_on_diffsolver_failure)
200  {
201  solver->continue_after_max_iterations = true;
202  solver->continue_after_backtrack_failure = true;
203  }
204 
205  // And the linear solver options
209  }
210 }

References LaplaceSystem::analytic_jacobians(), FEMParameters::analytic_jacobians, libMesh::DiffSolver::continue_after_backtrack_failure, libMesh::DiffSolver::continue_after_max_iterations, LaplaceSystem::fe_family(), FEMParameters::fe_family, LaplaceSystem::fe_order(), FEMParameters::fe_order, FEMParameters::initial_linear_tolerance, libMesh::DiffSolver::initial_linear_tolerance, FEMParameters::linear_tolerance_multiplier, libMesh::NewtonSolver::linear_tolerance_multiplier, FEMParameters::max_linear_iterations, libMesh::DiffSolver::max_linear_iterations, FEMParameters::max_nonlinear_iterations, libMesh::DiffSolver::max_nonlinear_iterations, FEMParameters::min_step_length, FEMParameters::minimum_linear_tolerance, libMesh::DiffSolver::minimum_linear_tolerance, libMesh::NewtonSolver::minsteplength, FEMParameters::print_jacobian_norms, libMesh::DifferentiableSystem::print_jacobian_norms, FEMParameters::print_jacobians, libMesh::DifferentiableSystem::print_jacobians, FEMParameters::print_residual_norms, libMesh::DifferentiableSystem::print_residual_norms, FEMParameters::print_residuals, libMesh::DifferentiableSystem::print_residuals, FEMParameters::print_solution_norms, libMesh::DifferentiableSystem::print_solution_norms, FEMParameters::print_solutions, libMesh::DifferentiableSystem::print_solutions, libMesh::DiffSolver::quiet, FEMParameters::relative_residual_tolerance, libMesh::DiffSolver::relative_residual_tolerance, FEMParameters::relative_step_tolerance, libMesh::DiffSolver::relative_step_tolerance, libMesh::NewtonSolver::require_residual_reduction, FEMParameters::require_residual_reduction, FEMParameters::solver_quiet, FEMParameters::solver_verbose, libMesh::DifferentiableSystem::time_solver, libMesh::DiffSolver::verbose, FEMParameters::verify_analytic_jacobians, and libMesh::FEMSystem::verify_analytic_jacobians.

Referenced by main().

◆ write_output()

void write_output ( EquationSystems es,
unsigned int  a_step,
std::string  solution_type,
FEMParameters param 
)

Definition at line 101 of file adjoints_ex1.C.

105 {
106  // Ignore parameters when there are no output formats available.
107  libmesh_ignore(es, a_step, solution_type, param);
108 
109 #ifdef LIBMESH_HAVE_GMV
110  if (param.output_gmv)
111  {
112  MeshBase & mesh = es.get_mesh();
113 
114  std::ostringstream file_name_gmv;
115  file_name_gmv << solution_type
116  << ".out.gmv."
117  << std::setw(2)
118  << std::setfill('0')
119  << std::right
120  << a_step;
121 
123  (file_name_gmv.str(), es);
124  }
125 #endif
126 
127 #ifdef LIBMESH_HAVE_EXODUS_API
128  if (param.output_exodus)
129  {
130  MeshBase & mesh = es.get_mesh();
131 
132  // We write out one file per adaptive step. The files are named in
133  // the following way:
134  // foo.e
135  // foo.e-s002
136  // foo.e-s003
137  // ...
138  // so that, if you open the first one with Paraview, it actually
139  // opens the entire sequence of adapted files.
140  std::ostringstream file_name_exodus;
141 
142  file_name_exodus << solution_type << ".e";
143  if (a_step > 0)
144  file_name_exodus << "-s"
145  << std::setw(3)
146  << std::setfill('0')
147  << std::right
148  << a_step + 1;
149 
150  // We write each adaptive step as a pseudo "time" step, where the
151  // time simply matches the (1-based) adaptive step we are on.
152  ExodusII_IO(mesh).write_timestep(file_name_exodus.str(),
153  es,
154  1,
155  /*time=*/a_step + 1);
156  }
157 #endif
158 }

References libMesh::EquationSystems::get_mesh(), libMesh::libmesh_ignore(), mesh, FEMParameters::output_exodus, FEMParameters::output_gmv, libMesh::MeshOutput< MT >::write_equation_systems(), and libMesh::ExodusII_IO::write_timestep().

Referenced by main().

libMesh::LinearSolver::reuse_preconditioner
virtual void reuse_preconditioner(bool)
Set the same_preconditioner flag, which indicates if we reuse the same preconditioner for subsequent ...
Definition: linear_solver.C:129
set_system_parameters
void set_system_parameters(LaplaceSystem &system, FEMParameters &param)
Definition: adjoints_ex1.C:162
FEMParameters::print_jacobians
bool print_jacobians
Definition: femparameters.h:118
libMesh::Number
Real Number
Definition: libmesh_common.h:195
libMesh::FEMSystem::solve
virtual void solve() override
Invokes the solver associated with the system.
Definition: fem_system.C:1046
libMesh::Mesh
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition: mesh.h:50
LaplaceSystem::postprocess
virtual void postprocess()
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
Definition: L-shaped.C:168
libMesh::DifferentiableSystem::print_jacobian_norms
bool print_jacobian_norms
Set print_jacobian_norms to true to print |J| whenever it is assembled.
Definition: diff_system.h:341
libMesh::MeshRefinement::coarsen_threshold
Real & coarsen_threshold()
The coarsen_threshold provides hysteresis in AMR/C strategies.
Definition: mesh_refinement.h:897
libMesh::EquationSystems::get_mesh
const MeshBase & get_mesh() const
Definition: equation_systems.h:637
libMesh::MeshBase::read
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false)=0
Interfaces for reading/writing a mesh to/from a file.
FEMParameters::coarsen_fraction
libMesh::Real coarsen_fraction
Definition: femparameters.h:61
libMesh::DifferentiableSystem::print_residual_norms
bool print_residual_norms
Set print_residual_norms to true to print |F| whenever it is assembled.
Definition: diff_system.h:331
libMesh::AdjointResidualErrorEstimator::error_plot_suffix
std::string error_plot_suffix
To aid in investigating error estimator behavior, set this string to a suffix with which to plot (pre...
Definition: adjoint_residual_error_estimator.h:104
libMesh::PatchRecoveryErrorEstimator
This class implements the Patch Recovery error indicator.
Definition: patch_recovery_error_estimator.h:55
FEMParameters::max_nonlinear_iterations
unsigned int max_nonlinear_iterations
Definition: femparameters.h:131
libMesh::NewtonSolver::require_residual_reduction
bool require_residual_reduction
If this is set to true, the solver is forced to test the residual after each Newton step,...
Definition: newton_solver.h:98
libMesh::MeshBase::all_second_order
virtual void all_second_order(const bool full_ordered=true)=0
Converts a (conforming, non-refined) mesh with linear elements into a mesh with second-order elements...
libMesh::NumericVector::swap
virtual void swap(NumericVector< T > &v)
Swaps the contents of this with v.
Definition: numeric_vector.h:989
FEMParameters::print_residuals
bool print_residuals
Definition: femparameters.h:118
FEMParameters::print_solution_norms
bool print_solution_norms
Definition: femparameters.h:118
FEMParameters::print_residual_norms
bool print_residual_norms
Definition: femparameters.h:118
libMesh::BasicOStreamProxy::rdbuf
streambufT * rdbuf() const
Get the associated stream buffer.
Definition: ostream_proxy.h:143
libMesh::DifferentiableSystem::print_residuals
bool print_residuals
Set print_residuals to true to print F whenever it is assembled.
Definition: diff_system.h:336
libMesh::System::get_adjoint_solution
NumericVector< Number > & get_adjoint_solution(unsigned int i=0)
Definition: system.C:957
libMesh::DiffSolver::continue_after_backtrack_failure
bool continue_after_backtrack_failure
Defaults to false, telling the DiffSolver to throw an error when the backtracking scheme fails to fin...
Definition: diff_solver.h:180
libMesh::H1_SEMINORM
Definition: enum_norm_type.h:43
FEMParameters::output_gmv
bool output_gmv
Definition: femparameters.h:68
FEMParameters::refine_fraction
libMesh::Real refine_fraction
Definition: femparameters.h:61
FEMParameters::output_exodus
bool output_exodus
Definition: femparameters.h:68
libMesh::DifferentiableSystem::print_solution_norms
bool print_solution_norms
Set print_residual_norms to true to print |U| whenever it is used in an assembly() call.
Definition: diff_system.h:320
libMesh::default_solver_package
SolverPackage default_solver_package()
Definition: libmesh.C:993
FEMParameters::initial_linear_tolerance
double initial_linear_tolerance
Definition: femparameters.h:134
mesh
MeshBase & mesh
Definition: mesh_communication.C:1257
libMesh::ExodusII_IO::write_timestep
void write_timestep(const std::string &fname, const EquationSystems &es, const int timestep, const Real time, const std::set< std::string > *system_names=nullptr)
Writes out the solution at a specific timestep.
Definition: exodusII_io.C:1286
libMesh::GMVIO
This class implements writing meshes in the GMV format.
Definition: gmv_io.h:54
libMesh::NewtonSolver::linear_tolerance_multiplier
double linear_tolerance_multiplier
The tolerance for linear solves is kept below this multiplier (which defaults to 1e-3) times the norm...
Definition: newton_solver.h:143
FEMParameters::fe_order
std::vector< unsigned int > fe_order
Definition: femparameters.h:109
libMesh::ExodusII_IO
The ExodusII_IO class implements reading meshes in the ExodusII file format from Sandia National Labs...
Definition: exodusII_io.h:51
FEMParameters::solver_quiet
bool solver_quiet
Definition: femparameters.h:128
FEMParameters::require_residual_reduction
bool require_residual_reduction
Definition: femparameters.h:128
FEMParameters::coarsen_threshold
libMesh::Real coarsen_threshold
Definition: femparameters.h:61
FEMParameters::max_linear_iterations
unsigned int max_linear_iterations
Definition: femparameters.h:131
libMesh::DifferentiableSystem::time_solver
std::unique_ptr< TimeSolver > time_solver
A pointer to the solver object we're going to use.
Definition: diff_system.h:233
libMesh::NumericVector< Number >
FEMParameters::indicator_type
std::string indicator_type
Definition: femparameters.h:145
LaplaceSystem::analytic_jacobians
bool & analytic_jacobians()
Definition: L-shaped.h:26
libMesh::TriangleWrapper::init
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
libMesh::MeshRefinement
Implements (adaptive) mesh refinement algorithms for a MeshBase.
Definition: mesh_refinement.h:61
FEMParameters::print_solutions
bool print_solutions
Definition: femparameters.h:118
FEMParameters::fe_family
std::vector< std::string > fe_family
Definition: femparameters.h:108
libMesh::MeshBase
This is the MeshBase class.
Definition: mesh_base.h:78
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
FEMParameters::solver_verbose
bool solver_verbose
Definition: femparameters.h:128
libMesh::DiffSolver::minimum_linear_tolerance
double minimum_linear_tolerance
The tolerance for linear solves is kept above this minimum.
Definition: diff_solver.h:215
libMesh::AdjointResidualErrorEstimator::qoi_set
QoISet & qoi_set()
Access to the QoISet (default: weight all QoIs equally) to use when computing errors.
Definition: adjoint_residual_error_estimator.h:89
libMesh::DiffSolver::relative_step_tolerance
Real relative_step_tolerance
Definition: diff_solver.h:204
libMesh::DiffSolver::verbose
bool verbose
The DiffSolver may print a lot more to libMesh::out if verbose is set to true; default is false.
Definition: diff_solver.h:168
libMesh::QoISet
Data structure for specifying which Quantities of Interest should be calculated in an adjoint or a pa...
Definition: qoi_set.h:45
libMesh::Factory
Factory class definition.
Definition: factory.h:46
libMesh::INVALID_SOLVER_PACKAGE
Definition: enum_solver_package.h:43
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::libmesh_ignore
void libmesh_ignore(const Args &...)
Definition: libmesh_common.h:526
LaplaceSystem
Definition: L-shaped.h:11
libMesh::DifferentiableSystem::print_jacobians
bool print_jacobians
Set print_jacobians to true to print J whenever it is assembled.
Definition: diff_system.h:346
libMesh::DiffSolver::continue_after_max_iterations
bool continue_after_max_iterations
Defaults to true, telling the DiffSolver to continue rather than exit when a solve has reached its ma...
Definition: diff_solver.h:174
build_error_estimator
std::unique_ptr< ErrorEstimator > build_error_estimator(FEMParameters &param, QoISet &qois)
Definition: adjoints_ex1.C:239
libMesh::DifferentiableSystem::get_linear_solver
virtual LinearSolver< Number > * get_linear_solver() const override
Definition: diff_system.C:175
FEMParameters::relative_residual_tolerance
libMesh::Real relative_residual_tolerance
Definition: femparameters.h:132
libMesh::ErrorVector
The ErrorVector is a specialization of the StatisticsVector for error data computed on a finite eleme...
Definition: error_vector.h:50
libMesh::QoISet::set_weight
void set_weight(std::size_t, Real)
Set the weight for this index.
Definition: qoi_set.h:229
FEMParameters::relative_step_tolerance
libMesh::Real relative_step_tolerance
Definition: femparameters.h:132
libMesh::DifferentiableSystem::adjoint_solve
virtual std::pair< unsigned int, Real > adjoint_solve(const QoISet &qoi_indices=QoISet()) override
This function sets the _is_adjoint boolean member of TimeSolver to true and then calls the adjoint_so...
Definition: diff_system.C:164
FEMParameters::minimum_linear_tolerance
double minimum_linear_tolerance
Definition: femparameters.h:134
libMesh::LibMeshInit
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition: libmesh.h:83
libMesh::NewtonSolver
This class defines a solver which uses the default libMesh linear solver in a quasiNewton method to h...
Definition: newton_solver.h:46
LaplaceSystem::fe_order
unsigned int & fe_order()
Definition: L-shaped.h:25
libMesh::MeshRefinement::nelem_target
dof_id_type & nelem_target()
If nelem_target is set to a nonzero value, methods like flag_elements_by_nelem_target() will attempt ...
Definition: mesh_refinement.h:903
write_output
void write_output(EquationSystems &es, unsigned int a_step, std::string solution_type, FEMParameters &param)
Definition: adjoints_ex1.C:101
libMesh::EquationSystems
This is the EquationSystems class.
Definition: equation_systems.h:74
libMesh::MeshOutput::write_equation_systems
virtual void write_equation_systems(const std::string &, const EquationSystems &, const std::set< std::string > *system_names=nullptr)
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition: mesh_output.C:31
libMesh::DiffSolver::quiet
bool quiet
The DiffSolver should not print anything to libMesh::out unless quiet is set to false; default is tru...
Definition: diff_solver.h:162
libMesh::DifferentiableQoI::assemble_qoi_sides
bool assemble_qoi_sides
If assemble_qoi_sides is true (it is false by default), the assembly loop for a quantity of interest ...
Definition: diff_qoi.h:85
libMesh::AdjointResidualErrorEstimator::dual_error_estimator
std::unique_ptr< ErrorEstimator > & dual_error_estimator()
Access to the "subestimator" (default: PatchRecovery) to use on the dual/adjoint solution.
Definition: adjoint_residual_error_estimator.h:83
libMesh::MeshRefinement::coarsen_fraction
Real & coarsen_fraction()
The coarsen_fraction sets either a desired target or a desired maximum number of elements to flag for...
Definition: mesh_refinement.h:885
libMesh::DiffSolver::relative_residual_tolerance
Real relative_residual_tolerance
Definition: diff_solver.h:192
FEMParameters::global_tolerance
libMesh::Real global_tolerance
Definition: femparameters.h:60
libMesh::System::solution
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1539
libMesh::PatchRecoveryErrorEstimator::set_patch_reuse
void set_patch_reuse(bool)
Definition: patch_recovery_error_estimator.C:58
libMesh::MeshRefinement::refine_fraction
Real & refine_fraction()
The refine_fraction sets either a desired target or a desired maximum number of elements to flag for ...
Definition: mesh_refinement.h:879
FEMParameters::min_step_length
libMesh::Real min_step_length
Definition: femparameters.h:130
FEMParameters::read
void read(GetPot &input, const std::vector< std::string > *other_variable_names=nullptr)
Definition: femparameters.C:154
FEMParameters::patch_reuse
bool patch_reuse
Definition: femparameters.h:146
libMesh::FEMSystem::verify_analytic_jacobians
Real verify_analytic_jacobians
If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calc...
Definition: fem_system.h:209
libMesh::MeshBase::print_info
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the mesh.
Definition: mesh_base.C:585
libMesh::LinearSolver< Number >
libMesh::QoISet::add_indices
void add_indices(const std::vector< unsigned int > &indices)
Add this indices to the set to be calculated.
Definition: qoi_set.C:46
libMesh::DiffSolver::max_linear_iterations
unsigned int max_linear_iterations
Each linear solver step should exit after max_linear_iterations is exceeded.
Definition: diff_solver.h:148
libMesh::MeshRefinement::absolute_global_tolerance
Real & absolute_global_tolerance()
If absolute_global_tolerance is set to a nonzero value, methods like flag_elements_by_global_toleranc...
Definition: mesh_refinement.h:909
libMesh::MeshRefinement::coarsen_by_parents
bool & coarsen_by_parents()
If coarsen_by_parents is true, complete groups of sibling elements (elements with the same parent) wi...
Definition: mesh_refinement.h:873
libMesh::DifferentiableSystem::postprocess_sides
bool postprocess_sides
If postprocess_sides is true (it is false by default), the postprocessing loop will loop over all sid...
Definition: diff_system.h:314
FEMParameters::analytic_jacobians
bool analytic_jacobians
Definition: femparameters.h:114
libMesh::DifferentiableSystem::print_solutions
bool print_solutions
Set print_solutions to true to print U whenever it is used in an assembly() call.
Definition: diff_system.h:326
FEMParameters::verify_analytic_jacobians
libMesh::Real verify_analytic_jacobians
Definition: femparameters.h:115
FEMParameters::print_jacobian_norms
bool print_jacobian_norms
Definition: femparameters.h:118
libMesh::err
OStreamProxy err
FEMParameters
Definition: femparameters.h:22
libMesh::DiffSolver::max_nonlinear_iterations
unsigned int max_nonlinear_iterations
The DiffSolver should exit in failure if max_nonlinear_iterations is exceeded and continue_after_max_...
Definition: diff_solver.h:156
FEMParameters::nelem_target
unsigned int nelem_target
Definition: femparameters.h:59
FEMParameters::linear_tolerance_multiplier
double linear_tolerance_multiplier
Definition: femparameters.h:134
LaplaceSystem::fe_family
std::string & fe_family()
Definition: L-shaped.h:24
libMesh::NewtonSolver::minsteplength
Real minsteplength
If the quasi-Newton step length must be reduced to below this factor to give a residual reduction,...
Definition: newton_solver.h:137
LaplaceSystem::get_QoI_value
Number & get_QoI_value(std::string type, unsigned int QoI_index)
Definition: L-shaped.h:32
libMesh::out
OStreamProxy out
build_mesh_refinement
std::unique_ptr< MeshRefinement > build_mesh_refinement(MeshBase &mesh, FEMParameters &param)
Definition: adjoints_ex1.C:216
libMesh::AdjointResidualErrorEstimator
This class implements a goal oriented error indicator, by weighting residual-based estimates from the...
Definition: adjoint_residual_error_estimator.h:49
libMesh::AdjointResidualErrorEstimator::primal_error_estimator
std::unique_ptr< ErrorEstimator > & primal_error_estimator()
Access to the "subestimator" (default: PatchRecovery) to use on the primal/forward solution.
Definition: adjoint_residual_error_estimator.h:77
libMesh::MeshBase::n_active_elem
virtual dof_id_type n_active_elem() const =0
libMesh::MeshBase::is_replicated
virtual bool is_replicated() const
Definition: mesh_base.h:181
libMesh::DiffSolver::initial_linear_tolerance
double initial_linear_tolerance
Any required linear solves will at first be done with this tolerance; the DiffSolver may tighten the ...
Definition: diff_solver.h:210
libMesh::System::set_adjoint_already_solved
void set_adjoint_already_solved(bool setting)
Setter for the adjoint_already_solved boolean.
Definition: system.h:402
libMesh::MeshBase::partitioner
virtual std::unique_ptr< Partitioner > & partitioner()
A partitioner to use at each prepare_for_use()
Definition: mesh_base.h:127