libMesh
Functions
adjoints_ex6.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)
 
void set_system_parameters (PoissonSystem &system, FEMParameters &param)
 
std::unique_ptr< MeshRefinementbuild_mesh_refinement (MeshBase &mesh, FEMParameters &param)
 
std::unique_ptr< AdjointRefinementEstimatorbuild_adjoint_refinement_error_estimator (QoISet &qois)
 
int main (int argc, char **argv)
 

Function Documentation

◆ build_adjoint_refinement_error_estimator()

std::unique_ptr<AdjointRefinementEstimator> build_adjoint_refinement_error_estimator ( QoISet qois)

Definition at line 190 of file adjoints_ex6.C.

191 {
192  libMesh::out << "Computing the error estimate using the Adjoint Refinement Error Estimator\n" << std::endl;
193 
194  AdjointRefinementEstimator * adjoint_refinement_estimator = new AdjointRefinementEstimator;
195 
196  adjoint_refinement_estimator->qoi_set() = qois;
197 
198  // We enrich the FE space for the dual problem by doing 2 uniform h refinements
199  adjoint_refinement_estimator->number_h_refinements = 2;
200 
201  return std::unique_ptr<AdjointRefinementEstimator>(adjoint_refinement_estimator);
202 }

References libMesh::AdjointRefinementEstimator::number_h_refinements, libMesh::out, and libMesh::AdjointRefinementEstimator::qoi_set().

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 208 of file adjoints_ex6.C.

209 {
210  // Initialize libMesh.
211  LibMeshInit init (argc, argv);
212 
213  // Skip adaptive examples on a non-adaptive libMesh build
214 #ifndef LIBMESH_ENABLE_AMR
215  libmesh_example_requires(false, "--enable-amr");
216 #else
217 
218  // We use Dirichlet boundary conditions here
219 #ifndef LIBMESH_ENABLE_DIRICHLET
220  libmesh_example_requires(false, "--enable-dirichlet");
221 #endif
222 
223  // This doesn't converge with Eigen BICGSTAB for some reason...
224  libmesh_example_requires((libMesh::default_solver_package() != EIGEN_SOLVERS) &&
226  "--enable-petsc or --enable-trilinos");
227 
228  libMesh::out << "Started " << argv[0] << std::endl;
229 
230  // Make sure the general input file exists, and parse it
231  {
232  std::ifstream i("general.in");
233  if (!i)
234  libmesh_error_msg('[' << init.comm().rank() << "] Can't find general.in; exiting early.");
235  }
236  GetPot infile("general.in");
237 
238  // Read in parameters from the input file
239  FEMParameters param(init.comm());
240  param.read(infile);
241 
242  // Skip this default-2D example if libMesh was compiled as 1D-only.
243  libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
244 
245  // Create a mesh, with dimension to be overridden later, distributed
246  // across the default MPI communicator.
247  Mesh mesh(init.comm());
248 
249  // And an object to refine it
250  std::unique_ptr<MeshRefinement> mesh_refinement =
251  build_mesh_refinement(mesh, param);
252 
253  // And an EquationSystems to run on it
254  EquationSystems equation_systems (mesh);
255 
256  libMesh::out << "Reading in and building the mesh" << std::endl;
257 
258  // Read in the mesh
260  (mesh, 2, 2,
261  0.0, 1.0,
262  0.0, 1.0,
263  QUAD4);
264 
265  // Make all the elements of the mesh second order so we can compute
266  // with a higher order basis
268 
269  // Create a mesh refinement object to do the initial uniform refinements
270  // on the coarse grid read in from lshaped.xda
271  MeshRefinement initial_uniform_refinements(mesh);
272  initial_uniform_refinements.uniformly_refine(param.coarserefinements);
273 
274  libMesh::out << "Building system" << std::endl;
275 
276  // Build the FEMSystem
277  PoissonSystem & system = equation_systems.add_system<PoissonSystem> ("PoissonSystem");
278 
279  // Set its parameters
280  set_system_parameters(system, param);
281 
282  libMesh::out << "Initializing systems" << std::endl;
283 
284  equation_systems.init ();
285 
286  // Add an adjoint_solution0 vector to the system
287  system.add_vector("adjoint_solution0", false, GHOSTED);
288 
289  // Print information about the mesh and system to the screen.
290  mesh.print_info();
291  equation_systems.print_info();
292 
293  // Get a pointer to the linear solver object to be able to reuse preconditioner
294  LinearSolver<Number> * linear_solver = system.get_linear_solver();
295 
296  {
297  // Adaptively solve the timestep
298  unsigned int a_step = 0;
299  for (; a_step != param.max_adaptivesteps; ++a_step)
300  {
301  // We can't adapt to both a tolerance and a
302  // target mesh size
303  if (param.global_tolerance != 0.)
304  libmesh_assert_equal_to (param.nelem_target, 0);
305  // If we aren't adapting to a tolerance we need a
306  // target mesh size
307  else
308  libmesh_assert_greater (param.nelem_target, 0);
309 
310  // Dont reuse preconditioners before the primal solve
311  linear_solver->reuse_preconditioner(false);
312 
313  // Solve the forward problem
314  system.solve();
315 
316  // Write out the computed primal solution
317  write_output(equation_systems, a_step, "primal");
318 
319  // Declare a QoISet object, we need this object to set weights for our QoI error contributions
320  QoISet qois;
321 
322  // Declare a qoi_indices vector, each index will correspond to a QoI
323  std::vector<unsigned int> qoi_indices;
324  qoi_indices.push_back(0);
325  qois.add_indices(qoi_indices);
326 
327  // Set weights for each index, these will weight the contribution of each QoI in the final error
328  // estimate to be used for flagging elements for refinement
329  qois.set_weight(0, 1.0);
330 
331  // Make sure we get the contributions to the adjoint RHS from the sides
332  system.assemble_qoi_sides = true;
333 
334  // We are about to solve the adjoint system, but before we do this we see the same preconditioner
335  // flag to reuse the preconditioner from the forward solver
336  linear_solver->reuse_preconditioner(param.reuse_preconditioner);
337 
338  // Solve the adjoint system. This takes the transpose of the stiffness matrix and then
339  // solves the resulting system
340  system.adjoint_solve();
341 
342  //Now that we have solved the adjoint, set the adjoint_already_solved boolean to true, so we dont solve unnecessarily in the error estimator
343  system.set_adjoint_already_solved(true);
344 
345  // Get a pointer to the primal solution vector
346  NumericVector<Number> & primal_solution = *system.solution;
347 
348  //Get a pointer to the solution vector of the adjoint problem for QoI 0
349  NumericVector<Number> & dual_solution_0 = system.get_adjoint_solution(0);
350 
351  //Swap the primal and dual solutions so we can write out the adjoint solution
352  primal_solution.swap(dual_solution_0);
353  write_output(equation_systems, a_step, "adjoint_0");
354 
355  //Swap back
356  primal_solution.swap(dual_solution_0);
357 
358  libMesh::out << "Adaptive step " << a_step << ", we have " << mesh.n_active_elem()
359  << " active elements and "
360  << equation_systems.n_active_dofs()
361  << " active dofs." << std::endl ;
362 
363  // Postprocess, compute the approximate QoIs and write them out to the console
364  libMesh::out << "Postprocessing: " << std::endl;
365  system.postprocess_sides = true;
366  system.postprocess();
367 
368  Number QoI_0_computed = system.get_QoI_value("computed", 0);
369  Number QoI_0_exact = system.get_QoI_value("exact", 0);
370 
371  libMesh::out << "The computed QoI 0 is " << std::setprecision(17)
372  << QoI_0_computed << std::endl;
373  libMesh::out << "The relative error in QoI 0 is " << std::setprecision(17)
374  << std::abs(QoI_0_computed - QoI_0_exact) << std::endl; // / std::abs(QoI_0_exact)
375 
376  // We will declare an error vector for passing to the adjoint refinement error estimator
377  ErrorVector QoI_elementwise_error;
378 
379  // Build an adjoint refinement error estimator object
380  std::unique_ptr<AdjointRefinementEstimator> adjoint_refinement_error_estimator =
382 
383  // Estimate the error in each element using the Adjoint Refinement estimator
384  adjoint_refinement_error_estimator->estimate_error(system, QoI_elementwise_error);
385 
386  // Print out the computed error estimate, note that we access the global error estimates
387  // using an accessor function, right now sum(QoI_elementwise_error) != global_QoI_error_estimate
388  libMesh::out << "The computed relative error in QoI 0 is " << std::setprecision(17)
389  << std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(0)) << std::endl; // / std::abs(QoI_0_exact)
390 
391  // Also print out effectivity indices (estimated error/true error)
392  libMesh::out << "The effectivity index for the computed error in QoI 0 is " << std::setprecision(17)
393  << std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(0)) /
394  std::abs(QoI_0_computed - QoI_0_exact) << std::endl;
395 
396  // For refinement purposes we need to sort by error
397  // *magnitudes*, but AdjointRefinement gives us signed errors.
398  if (!param.refine_uniformly)
399  for (std::size_t i=0; i<QoI_elementwise_error.size(); i++)
400  if (QoI_elementwise_error[i] != 0.)
401  QoI_elementwise_error[i] = std::abs(QoI_elementwise_error[i]);
402 
403  // We have to refine either based on reaching an error tolerance or
404  // a number of elements target, which should be verified above
405  // Otherwise we flag elements by error tolerance or nelem target
406 
407  // Uniform refinement
408  if (param.refine_uniformly)
409  {
410  mesh_refinement->uniformly_refine(1);
411  }
412  // Adaptively refine based on reaching an error tolerance
413  else if (param.global_tolerance >= 0. && param.nelem_target == 0.)
414  {
415  mesh_refinement->flag_elements_by_error_tolerance (QoI_elementwise_error);
416 
417  mesh_refinement->refine_and_coarsen_elements();
418  }
419  // Adaptively refine based on reaching a target number of elements
420  else
421  {
422  if (mesh.n_active_elem() >= param.nelem_target)
423  {
424  libMesh::out << "We reached the target number of elements.\n" << std::endl;
425  break;
426  }
427 
428  mesh_refinement->flag_elements_by_nelem_target (QoI_elementwise_error);
429 
430  mesh_refinement->refine_and_coarsen_elements();
431  }
432 
433  // Dont forget to reinit the system after each adaptive refinement!
434  equation_systems.reinit();
435 
436  libMesh::out << "Refined mesh to "
437  << mesh.n_active_elem()
438  << " active elements and "
439  << equation_systems.n_active_dofs()
440  << " active dofs." << std::endl;
441  }
442 
443  // On the last adaptive step, dont refine elements and check regressions via asserts
444  if (a_step == param.max_adaptivesteps)
445  {
446  linear_solver->reuse_preconditioner(false);
447  system.solve();
448 
449  write_output(equation_systems, a_step, "primal");
450 
451  NumericVector<Number> & primal_solution = *system.solution;
452 
453  QoISet qois;
454  std::vector<unsigned int> qoi_indices;
455 
456  qoi_indices.push_back(0);
457  qois.add_indices(qoi_indices);
458 
459  qois.set_weight(0, 1.0);
460 
461  system.assemble_qoi_sides = true;
462 
463  linear_solver->reuse_preconditioner(param.reuse_preconditioner);
464  system.adjoint_solve();
465  system.set_adjoint_already_solved(true);
466 
467  NumericVector<Number> & dual_solution_0 = system.get_adjoint_solution(0);
468 
469  primal_solution.swap(dual_solution_0);
470  write_output(equation_systems, a_step, "adjoint_0");
471 
472  primal_solution.swap(dual_solution_0);
473 
474  libMesh::out << "Adaptive step " << a_step << ", we have " << mesh.n_active_elem()
475  << " active elements and "
476  << equation_systems.n_active_dofs()
477  << " active dofs." << std::endl ;
478 
479  libMesh::out << "Postprocessing: " << std::endl;
480  system.postprocess_sides = true;
481  system.postprocess();
482 
483  Number QoI_0_computed = system.get_QoI_value("computed", 0);
484  Number QoI_0_exact = system.get_QoI_value("exact", 0);
485 
486  libMesh::out << "The computed QoI 0 is " << std::setprecision(17)
487  << QoI_0_computed << std::endl;
488  libMesh::out << "The relative error in QoI 0 is " << std::setprecision(17)
489  << std::abs(QoI_0_computed - QoI_0_exact) << std::endl; // / std::abs(QoI_0_exact)
490 
491 
492  // We will declare an error vector for passing to the adjoint
493  // refinement error estimator Right now, only the first entry
494  // of this vector will be filled (with the global QoI error
495  // estimate) Later, each entry of the vector will contain
496  // elementwise error that the user can sum to get the total
497  // error
498  ErrorVector QoI_elementwise_error;
499 
500  // Build an adjoint refinement error estimator object
501  std::unique_ptr<AdjointRefinementEstimator> adjoint_refinement_error_estimator =
503 
504  // Estimate the error in each element using the Adjoint Refinement estimator
505  adjoint_refinement_error_estimator->estimate_error(system, QoI_elementwise_error);
506 
507  // Print out the computed error estimate, note that we access
508  // the global error estimates using an accessor function,
509  // right now sum(QoI_elementwise_error) != global_QoI_error_estimate
510  libMesh::out << "The computed relative error in QoI 0 is " << std::setprecision(17)
511  << std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(0)) << std::endl; // / std::abs(QoI_0_exact)
512 
513  // Also print out effectivity indices (estimated error/true error)
514  libMesh::out << "The effectivity index for the computed error in QoI 0 is " << std::setprecision(17)
515  << std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(0)) /
516  std::abs(QoI_0_computed - QoI_0_exact) << std::endl;
517 
518  // Hard coded assert to ensure that the actual numbers we are getting are what they should be
519 
520  // The effectivity index isn't exactly reproducible at single precision
521  // libmesh_assert_less(std::abs(std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(0)) / std::abs(QoI_0_computed - QoI_0_exact) - 0.84010976704434637), 1.e-5);
522  // libmesh_assert_less(std::abs(std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(1)) / std::abs(QoI_1_computed - QoI_1_exact) - 0.48294428289950514), 1.e-5);
523 
524  // But the effectivity indices should always be sane
525  // libmesh_assert_less(std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(0)) / std::abs(QoI_0_computed - QoI_0_exact), 2.5);
526  // libmesh_assert_greater(std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(0)) / std::abs(QoI_0_computed - QoI_0_exact), .4);
527  // libmesh_assert_less(std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(1)) / std::abs(QoI_1_computed - QoI_1_exact), 2.5);
528  // libmesh_assert_greater(std::abs(adjoint_refinement_error_estimator->get_global_QoI_error_estimate(1)) / std::abs(QoI_1_computed - QoI_1_exact), .4);
529 
530  // And the computed errors should still be low
531  // libmesh_assert_less(std::abs(QoI_0_computed - QoI_0_exact), 2e-4);
532  // libmesh_assert_less(std::abs(QoI_1_computed - QoI_1_exact), 2e-4);
533  }
534  }
535 
536  libMesh::err << '[' << mesh.processor_id()
537  << "] Completing output." << std::endl;
538 
539 #endif // #ifndef LIBMESH_ENABLE_AMR
540 
541  // All done.
542  return 0;
543 }

References std::abs(), libMesh::QoISet::add_indices(), libMesh::EquationSystems::add_system(), libMesh::System::add_vector(), libMesh::DifferentiableSystem::adjoint_solve(), libMesh::MeshBase::all_second_order(), libMesh::DifferentiableQoI::assemble_qoi_sides, build_adjoint_refinement_error_estimator(), build_mesh_refinement(), libMesh::MeshTools::Generation::build_square(), libMesh::default_solver_package(), libMesh::EIGEN_SOLVERS, libMesh::err, libMesh::System::get_adjoint_solution(), libMesh::DifferentiableSystem::get_linear_solver(), PoissonSystem::get_QoI_value(), libMesh::GHOSTED, libMesh::TriangleWrapper::init(), libMesh::EquationSystems::init(), libMesh::INVALID_SOLVER_PACKAGE, mesh, libMesh::EquationSystems::n_active_dofs(), libMesh::MeshBase::n_active_elem(), libMesh::out, PoissonSystem::postprocess(), libMesh::DifferentiableSystem::postprocess_sides, libMesh::EquationSystems::print_info(), libMesh::MeshBase::print_info(), libMesh::ParallelObject::processor_id(), libMesh::QUAD4, FEMParameters::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 ( PoissonSystem system,
FEMParameters param 
)

Definition at line 118 of file adjoints_ex6.C.

119 {
120  // Use analytical jacobians?
121  system.analytic_jacobians() = param.analytic_jacobians;
122 
123  // Verify analytic jacobians against numerical ones?
125 
126  // Use the prescribed FE type
127  system.fe_family() = param.fe_family[0];
128  system.fe_order() = param.fe_order[0];
129 
130  // More desperate debugging options
132  system.print_solutions = param.print_solutions;
134  system.print_residuals = param.print_residuals;
136  system.print_jacobians = param.print_jacobians;
137 
138  // No transient time solver
139  system.time_solver = libmesh_make_unique<SteadySolver>(system);
140 
141  // Nonlinear solver options
142  {
143  NewtonSolver * solver = new NewtonSolver(system);
144  system.time_solver->diff_solver() = std::unique_ptr<DiffSolver>(solver);
145 
146  solver->quiet = param.solver_quiet;
148  solver->minsteplength = param.min_step_length;
153  if (system.time_solver->reduce_deltat_on_diffsolver_failure)
154  {
155  solver->continue_after_max_iterations = true;
156  solver->continue_after_backtrack_failure = true;
157  }
158 
159  // And the linear solver options
163  }
164 }

References PoissonSystem::analytic_jacobians(), FEMParameters::analytic_jacobians, libMesh::DiffSolver::continue_after_backtrack_failure, libMesh::DiffSolver::continue_after_max_iterations, PoissonSystem::fe_family(), FEMParameters::fe_family, PoissonSystem::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, libMesh::DifferentiableSystem::time_solver, 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 
)

Definition at line 97 of file adjoints_ex6.C.

100 {
101 #ifdef LIBMESH_HAVE_GMV
102  MeshBase & mesh = es.get_mesh();
103 
104  std::ostringstream file_name_gmv;
105  file_name_gmv << solution_type
106  << ".out.gmv."
107  << std::setw(2)
108  << std::setfill('0')
109  << std::right
110  << a_step;
111 
113  (file_name_gmv.str(), es);
114 #endif
115 }

References libMesh::EquationSystems::get_mesh(), mesh, and libMesh::MeshOutput< MT >::write_equation_systems().

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
FEMParameters::print_jacobians
bool print_jacobians
Definition: femparameters.h:118
libMesh::Number
Real Number
Definition: libmesh_common.h:195
PoissonSystem::fe_order
unsigned int & fe_order()
Definition: poisson.h:22
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
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
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
FEMParameters::max_nonlinear_iterations
unsigned int max_nonlinear_iterations
Definition: femparameters.h:131
PoissonSystem::postprocess
virtual void postprocess(void)
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
Definition: poisson.C:189
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::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
build_adjoint_refinement_error_estimator
std::unique_ptr< AdjointRefinementEstimator > build_adjoint_refinement_error_estimator(QoISet &qois)
Definition: adjoints_ex6.C:190
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
FEMParameters::refine_fraction
libMesh::Real refine_fraction
Definition: femparameters.h:61
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::GHOSTED
Definition: enum_parallel_type.h:37
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::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
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 >
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
set_system_parameters
void set_system_parameters(PoissonSystem &system, FEMParameters &param)
Definition: adjoints_ex6.C:118
libMesh::MeshTools::Generation::build_square
void build_square(UnstructuredMesh &mesh, const unsigned int nx, const unsigned int ny, const Real xmin=0., const Real xmax=1., const Real ymin=0., const Real ymax=1., const ElemType type=INVALID_ELEM, const bool gauss_lobatto_grid=false)
A specialized build_cube() for 2D meshes.
Definition: mesh_generation.C:1501
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)
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::DiffSolver::relative_step_tolerance
Real relative_step_tolerance
Definition: diff_solver.h:204
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::INVALID_SOLVER_PACKAGE
Definition: enum_solver_package.h:43
build_mesh_refinement
std::unique_ptr< MeshRefinement > build_mesh_refinement(MeshBase &mesh, FEMParameters &param)
Definition: adjoints_ex6.C:170
libMesh::ParallelObject::processor_id
processor_id_type processor_id() const
Definition: parallel_object.h:106
libMesh::QUAD4
Definition: enum_elem_type.h:41
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
write_output
void write_output(EquationSystems &es, unsigned int a_step, std::string solution_type)
Definition: adjoints_ex6.C:97
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::AdjointRefinementEstimator::number_h_refinements
unsigned char number_h_refinements
How many h refinements to perform to get the fine grid.
Definition: adjoint_refinement_estimator.h:116
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
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
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::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::AdjointRefinementEstimator::qoi_set
QoISet & qoi_set()
Access to the QoISet (default: weight all QoIs equally) to use when computing errors.
Definition: adjoint_refinement_estimator.h:73
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
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::AdjointRefinementEstimator
This class implements a "brute force" goal-oriented error estimator which computes an estimate of err...
Definition: adjoint_refinement_estimator.h:50
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
libMesh::System::add_vector
NumericVector< Number > & add_vector(const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL)
Adds the additional vector vec_name to this system.
Definition: system.C:661
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
PoissonSystem
Definition: poisson.h:11
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
PoissonSystem::get_QoI_value
Number & get_QoI_value(std::string type, unsigned int QoI_index)
Definition: poisson.h:29
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
libMesh::out
OStreamProxy out
PoissonSystem::fe_family
std::string & fe_family()
Definition: poisson.h:21
libMesh::EIGEN_SOLVERS
Definition: enum_solver_package.h:40
libMesh::MeshBase::n_active_elem
virtual dof_id_type n_active_elem() const =0
PoissonSystem::analytic_jacobians
bool & analytic_jacobians()
Definition: poisson.h:23
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