libMesh
Functions
adjoints_ex5.C File Reference

Go to the source code of this file.

Functions

void write_output (EquationSystems &es, unsigned int t_step, std::string solution_type, FEMParameters &param)
 
void set_system_parameters (HeatSystem &system, FEMParameters &param)
 
int main (int argc, char **argv)
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 290 of file adjoints_ex5.C.

291 {
292  // Skip adaptive examples on a non-adaptive libMesh build
293 #ifndef LIBMESH_ENABLE_AMR
294  libmesh_ignore(argc, argv);
295  libmesh_example_requires(false, "--enable-amr");
296 #else
297  // Skip this 2D example if libMesh was compiled as 1D-only.
298  libmesh_example_requires(2 <= LIBMESH_DIM, "2D support");
299 
300  // We use Dirichlet boundary conditions here
301 #ifndef LIBMESH_ENABLE_DIRICHLET
302  libmesh_example_requires(false, "--enable-dirichlet");
303 #endif
304 
305  // Initialize libMesh.
306  LibMeshInit init (argc, argv);
307 
308  // This doesn't converge with Trilinos for some reason...
309  libmesh_example_requires(libMesh::default_solver_package() == PETSC_SOLVERS, "--enable-petsc");
310 
311  libMesh::out << "Started " << argv[0] << std::endl;
312 
313  // Make sure the general input file exists, and parse it
314  {
315  std::ifstream i("general.in");
316  if (!i)
317  libmesh_error_msg('[' << init.comm().rank() << "] Can't find general.in; exiting early.");
318  }
319  GetPot infile("general.in");
320 
321  // Read in parameters from the input file
322  FEMParameters param(init.comm());
323  param.read(infile);
324 
325  // Create a mesh with the given dimension, distributed
326  // across the default MPI communicator.
327  Mesh mesh(init.comm(), cast_int<unsigned char>(param.dimension));
328 
329  // And an object to refine it
330  auto mesh_refinement = libmesh_make_unique<MeshRefinement>(mesh);
331 
332  // And an EquationSystems to run on it
333  EquationSystems equation_systems (mesh);
334 
335  libMesh::out << "Building mesh" << std::endl;
336 
337  // Build a unit square
338  ElemType elemtype;
339 
340  if (param.elementtype == "tri" ||
341  param.elementtype == "unstructured")
342  elemtype = TRI3;
343  else
344  elemtype = QUAD4;
345 
346  MeshTools::Generation::build_square (mesh, param.coarsegridx, param.coarsegridy,
347  param.domain_xmin, param.domain_xmin + param.domain_edge_width,
348  param.domain_ymin, param.domain_ymin + param.domain_edge_length,
349  elemtype);
350 
351  libMesh::out << "Building system" << std::endl;
352 
353  HeatSystem & system = equation_systems.add_system<HeatSystem> ("HeatSystem");
354 
355  set_system_parameters(system, param);
356 
357  libMesh::out << "Initializing systems" << std::endl;
358 
359  // Initialize the system
360  equation_systems.init ();
361 
362  // Refine the grid again if requested
363  for (unsigned int i=0; i != param.extrarefinements; ++i)
364  {
365  mesh_refinement->uniformly_refine(1);
366  equation_systems.reinit();
367  }
368 
369  libMesh::out << "Setting primal initial conditions" << std::endl;
370 
372 
374  equation_systems.parameters);
375 
376  // Output the H1 norm of the initial conditions
377  libMesh::out << "|U("
378  << system.time
379  << ")|= "
380  << system.calculate_norm(*system.solution, 0, H1)
381  << std::endl
382  << std::endl;
383 
384  // Add an adjoint vector, this will be computed after the forward
385  // time stepping is complete
386  //
387  // Tell the library not to save adjoint solutions during the forward
388  // solve
389  //
390  // Tell the library not to project this vector, and hence, memory
391  // solution history to not save it.
392  //
393  // Make this vector ghosted so we can localize it to each element
394  // later.
395  const std::string & adjoint_solution_name = "adjoint_solution0";
396  system.add_vector("adjoint_solution0", false, GHOSTED);
397 
398  // Close up any resources initial.C needed
400 
401  // Plot the initial conditions
402  write_output(equation_systems, 0, "primal", param);
403 
404  // Print information about the mesh and system to the screen.
405  mesh.print_info();
406  equation_systems.print_info();
407 
408  // In optimized mode we catch any solver errors, so that we can
409  // write the proper footers before closing. In debug mode we just
410  // let the exception throw so that gdb can grab it.
411 #ifdef NDEBUG
412  try
413  {
414 #endif
415  // Now we begin the timestep loop to compute the time-accurate
416  // solution of the equations.
417  for (unsigned int t_step=param.initial_timestep;
418  t_step != param.initial_timestep + param.n_timesteps; ++t_step)
419  {
420  // A pretty update message
421  libMesh::out << " Solving time step "
422  << t_step
423  << ", time = "
424  << system.time
425  << std::endl;
426 
427  // Solve the forward problem at time t, to obtain the solution at time t + dt
428  system.solve();
429 
430  // Output the H1 norm of the computed solution
431  libMesh::out << "|U("
432  << system.time + system.deltat
433  << ")|= "
434  << system.calculate_norm(*system.solution, 0, H1)
435  << std::endl;
436 
437  // Advance to the next timestep in a transient problem
438  libMesh::out << "Advancing timestep" << std::endl << std::endl;
439  system.time_solver->advance_timestep();
440 
441  // Write out this timestep
442  write_output(equation_systems, t_step+1, "primal", param);
443  }
444  // End timestep loop
445 
447 
448  // Now we will solve the backwards in time adjoint problem
449  libMesh::out << std::endl << "Solving the adjoint problem" << std::endl;
450 
451  // We need to tell the library that it needs to project the adjoint, so
452  // MemorySolutionHistory knows it has to save it
453 
454  // Tell the library to project the adjoint vector, and hence, memory solution history to
455  // save it
456  system.set_vector_preservation(adjoint_solution_name, true);
457 
458  libMesh::out << "Setting adjoint initial conditions Z("
459  << system.time
460  << ")"
461  <<std::endl;
462 
463  // Need to call adjoint_advance_timestep once for the initial condition setup
464  libMesh::out<<"Retrieving solutions at time t="<<system.time<<std::endl;
465  system.time_solver->adjoint_advance_timestep();
466 
467  // Output the H1 norm of the retrieved solutions (u^i and u^i+1)
468  libMesh::out << "|U("
469  << system.time + system.deltat
470  << ")|= "
471  << system.calculate_norm(*system.solution, 0, H1)
472  << std::endl;
473 
474  libMesh::out << "|U("
475  << system.time
476  << ")|= "
477  << system.calculate_norm(system.get_vector("_old_nonlinear_solution"), 0, H1)
478  << std::endl;
479 
480  // The first thing we have to do is to apply the adjoint initial
481  // condition. The user should supply these. Here they are specified
482  // in the functions adjoint_initial_value and adjoint_initial_gradient
485  equation_systems.parameters,
486  system.get_adjoint_solution(0));
487 
488  // Since we have specified an adjoint solution for the current
489  // time (T), set the adjoint_already_solved boolean to true, so
490  // we dont solve unnecessarily in the adjoint sensitivity method
491  system.set_adjoint_already_solved(true);
492 
493  libMesh::out << "|Z("
494  << system.time
495  << ")|= "
496  << system.calculate_norm(system.get_adjoint_solution(), 0, H1)
497  << std::endl
498  << std::endl;
499 
500  write_output(equation_systems, param.n_timesteps, "dual", param);
501 
502  // Now that the adjoint initial condition is set, we will start the
503  // backwards in time adjoint integration
504 
505  // For loop stepping backwards in time
506  for (unsigned int t_step=param.initial_timestep;
507  t_step != param.initial_timestep + param.n_timesteps; ++t_step)
508  {
509  //A pretty update message
510  libMesh::out << " Solving adjoint time step "
511  << t_step
512  << ", time = "
513  << system.time
514  << std::endl;
515 
516  // The adjoint_advance_timestep function calls the retrieve
517  // function of the memory_solution_history class via the
518  // memory_solution_history object we declared earlier. The
519  // retrieve function sets the system primal vectors to their
520  // values at the current timestep.
521  libMesh::out << "Retrieving solutions at time t=" << system.time << std::endl;
522  system.time_solver->adjoint_advance_timestep();
523 
524  // Output the H1 norm of the retrieved solution
525  libMesh::out << "|U("
526  << system.time + system.deltat
527  << ")|= "
528  << system.calculate_norm(*system.solution, 0, H1)
529  << std::endl;
530 
531  libMesh::out << "|U("
532  << system.time
533  << ")|= "
534  << system.calculate_norm(system.get_vector("_old_nonlinear_solution"), 0, H1)
535  << std::endl;
536 
537  system.set_adjoint_already_solved(false);
538 
539  system.adjoint_solve();
540 
541  // Now that we have solved the adjoint, set the
542  // adjoint_already_solved boolean to true, so we dont solve
543  // unnecessarily in the error estimator
544  system.set_adjoint_already_solved(true);
545 
546  libMesh::out << "|Z("
547  << system.time
548  << ")|= "
549  << system.calculate_norm(system.get_adjoint_solution(), 0, H1)
550  << std::endl
551  << std::endl;
552 
553  // Get a pointer to the primal solution vector
554  NumericVector<Number> & primal_solution = *system.solution;
555 
556  // Get a pointer to the solution vector of the adjoint problem for QoI 0
557  NumericVector<Number> & dual_solution_0 = system.get_adjoint_solution(0);
558 
559  // Swap the primal and dual solutions so we can write out the adjoint solution
560  primal_solution.swap(dual_solution_0);
561 
562  write_output(equation_systems, param.n_timesteps - (t_step + 1), "dual", param);
563 
564  // Swap back
565  primal_solution.swap(dual_solution_0);
566  }
567  // End adjoint timestep loop
568 
569  // Now that we have computed both the primal and adjoint solutions, we compute the sensitivities to the parameter p
570  // dQ/dp = partialQ/partialp - partialR/partialp
571  // partialQ/partialp = (Q(p+dp) - Q(p-dp))/(2*dp), this is not supported by the library yet
572  // partialR/partialp = (R(u,z;p+dp) - R(u,z;p-dp))/(2*dp), where
573  // R(u,z;p+dp) = int_{0}^{T} f(z;p+dp) - <partialu/partialt, z>(p+dp) - <g(u),z>(p+dp)
574  // To do this we need to step forward in time, and compute the perturbed R at each time step and accumulate it
575  // Then once all time steps are over, we can compute (R(u,z;p+dp) - R(u,z;p-dp))/(2*dp)
576 
577  // Now we begin the timestep loop to compute the time-accurate
578  // adjoint sensitivities
579  for (unsigned int t_step=param.initial_timestep;
580  t_step != param.initial_timestep + param.n_timesteps; ++t_step)
581  {
582  // A pretty update message
583  libMesh::out << "Retrieving "
584  << t_step
585  << ", time = "
586  << system.time
587  << std::endl;
588 
589  // Retrieve the primal and adjoint solutions at the current timestep
590  system.time_solver->retrieve_timestep();
591 
592  libMesh::out << "|U("
593  << system.time + system.deltat
594  << ")|= "
595  << system.calculate_norm(*system.solution, 0, H1)
596  << std::endl;
597 
598  libMesh::out << "|U("
599  << system.time
600  << ")|= "
601  << system.calculate_norm(system.get_vector("_old_nonlinear_solution"), 0, H1)
602  << std::endl;
603 
604  libMesh::out << "|Z("
605  << system.time
606  << ")|= "
607  << system.calculate_norm(system.get_adjoint_solution(0), 0, H1)
608  << std::endl
609  << std::endl;
610 
611  // Call the postprocess function which we have overloaded to compute
612  // accumulate the perturbed residuals
613  dynamic_cast<HeatSystem &>(system).perturb_accumulate_residuals(dynamic_cast<HeatSystem &>(system).get_parameter_vector());
614 
615  // Move the system time forward (retrieve_timestep does not do this)
616  system.time += system.deltat;
617  }
618 
619  // A pretty update message
620  libMesh::out << "Retrieving final time = "
621  << system.time
622  << std::endl;
623 
624  // Retrieve the primal and adjoint solutions at the current timestep
625  system.time_solver->retrieve_timestep();
626 
627  libMesh::out << "|U("
628  << system.time + system.deltat
629  << ")|= "
630  << system.calculate_norm(*system.solution, 0, H1)
631  << std::endl;
632 
633  libMesh::out << "|U("
634  << system.time
635  << ")|= "
636  << system.calculate_norm(system.get_vector("_old_nonlinear_solution"), 0, H1)
637  << std::endl;
638 
639  libMesh::out << "|Z("
640  << system.time
641  << ")|= "
642  << system.calculate_norm(system.get_adjoint_solution(0), 0, H1)
643  << std::endl
644  << std::endl;
645 
646  // Call the postprocess function which we have overloaded to compute
647  // accumulate the perturbed residuals
648  dynamic_cast<HeatSystem &>(system).perturb_accumulate_residuals(dynamic_cast<HeatSystem &>(system).get_parameter_vector());
649 
650  // Now that we computed the accumulated, perturbed residuals, we can compute the
651  // approximate sensitivity
652  Number sensitivity_0_0 = (dynamic_cast<HeatSystem &>(system)).compute_final_sensitivity();
653 
654  // Print it out
655  libMesh::out << "Sensitivity of QoI 0 w.r.t parameter 0 is: "
656  << sensitivity_0_0
657  << std::endl;
658 
659  // Hard coded test to ensure that the actual numbers we are
660  // getting are what they should be
661  // The 2e-4 tolerance is chosen to ensure success even with
662  // 32-bit floats
663  if(std::abs(sensitivity_0_0 - (-5.37173)) >= 2.e-4)
664  libmesh_error_msg("Mismatch in sensitivity gold value!");
665 
666 #ifdef NDEBUG
667  }
668  catch (...)
669  {
670  libMesh::err << '[' << mesh.processor_id()
671  << "] Caught exception; exiting early." << std::endl;
672  }
673 #endif
674 
675  libMesh::err << '[' << mesh.processor_id()
676  << "] Completing output."
677  << std::endl;
678 
679  // All done.
680  return 0;
681 
682 #endif // LIBMESH_ENABLE_AMR
683 }

References std::abs(), libMesh::System::add_vector(), adjoint_initial_grad(), adjoint_initial_value(), libMesh::DifferentiableSystem::adjoint_solve(), libMesh::MeshTools::Generation::build_square(), libMesh::System::calculate_norm(), libMesh::default_solver_package(), libMesh::DifferentiableSystem::deltat, libMesh::err, finish_initialization(), libMesh::System::get_adjoint_solution(), libMesh::System::get_vector(), libMesh::GHOSTED, libMesh::H1, libMesh::TriangleWrapper::init(), initial_grad(), initial_value(), libMesh::libmesh_ignore(), mesh, libMesh::out, libMesh::PETSC_SOLVERS, libMesh::System::project_solution(), libMesh::System::project_vector(), libMesh::QUAD4, FEMParameters::read(), read_initial_parameters(), libMesh::System::set_adjoint_already_solved(), set_system_parameters(), libMesh::System::set_vector_preservation(), libMesh::System::solution, libMesh::FEMSystem::solve(), libMesh::NumericVector< T >::swap(), libMesh::System::time, libMesh::DifferentiableSystem::time_solver, libMesh::TRI3, and write_output().

◆ set_system_parameters()

void set_system_parameters ( HeatSystem system,
FEMParameters param 
)

Definition at line 170 of file adjoints_ex5.C.

172 {
173  // Use the prescribed FE type
174  system.fe_family() = param.fe_family[0];
175  system.fe_order() = param.fe_order[0];
176 
177  // Use analytical jacobians?
178  system.analytic_jacobians() = param.analytic_jacobians;
179 
180  // Verify analytic jacobians against numerical ones?
183 
184  // More desperate debugging options
186  system.print_solutions = param.print_solutions;
188  system.print_residuals = param.print_residuals;
190  system.print_jacobians = param.print_jacobians;
193 
194  // Solve this as a time-dependent or steady system
195  if (param.transient)
196  {
197  UnsteadySolver *innersolver;
198  if (param.timesolver_core == "euler")
199  {
200  EulerSolver *eulersolver =
201  new EulerSolver(system);
202 
203  eulersolver->theta = param.timesolver_theta;
204  innersolver = eulersolver;
205  }
206  else
207  libmesh_error_msg("This example (and unsteady adjoints in libMesh) only support Backward Euler and explicit methods.");
208 
209  system.time_solver =
210  std::unique_ptr<TimeSolver>(innersolver);
211  }
212  else
213  system.time_solver = libmesh_make_unique<SteadySolver>(system);
214 
215  // The Memory Solution History object we will set the system SolutionHistory object to
216  MemorySolutionHistory heatsystem_solution_history(system);
217  system.time_solver->set_solution_history(heatsystem_solution_history);
218 
219  system.time_solver->reduce_deltat_on_diffsolver_failure =
220  param.deltat_reductions;
221  system.time_solver->quiet = param.time_solver_quiet;
222 
223 #ifdef LIBMESH_ENABLE_DIRICHLET
224  // Create any Dirichlet boundary conditions
225  typedef
226  std::map<boundary_id_type, FunctionBase<Number> *>::
227  const_iterator Iter;
228 
229  for (Iter i = param.dirichlet_conditions.begin();
230  i != param.dirichlet_conditions.end(); ++i)
231  {
232  boundary_id_type b = i->first;
233  FunctionBase<Number> *f = i->second;
234  std::set<boundary_id_type> bdys; bdys.insert(b);
235 
236  system.get_dof_map().add_dirichlet_boundary(DirichletBoundary(bdys,
238  f));
239 
240  libMesh::out << "Added Dirichlet boundary " << b << " for variables ";
241  for (std::size_t vi=0; vi != param.dirichlet_condition_variables[b].size(); ++vi)
243  libMesh::out << std::endl;
244  }
245 #endif // LIBMESH_ENABLE_DIRICHLET
246 
247  // Set the time stepping options
248  system.deltat = param.deltat;
249 
250  // And the integration options
252 
253  // And the nonlinear solver options
254  if (param.use_petsc_snes)
255  {
256 #ifdef LIBMESH_HAVE_PETSC
257  PetscDiffSolver *solver = new PetscDiffSolver(system);
258  system.time_solver->diff_solver() = std::unique_ptr<DiffSolver>(solver);
259 #else
260  libmesh_error_msg("This example requires libMesh to be compiled with PETSc support.");
261 #endif
262  }
263  else
264  {
265  NewtonSolver *solver = new NewtonSolver(system);
266  system.time_solver->diff_solver() = std::unique_ptr<DiffSolver>(solver);
267 
268  solver->quiet = param.solver_quiet;
269  solver->verbose = param.solver_verbose;
270  solver->max_nonlinear_iterations = param.max_nonlinear_iterations;
271  solver->minsteplength = param.min_step_length;
272  solver->relative_step_tolerance = param.relative_step_tolerance;
273  solver->relative_residual_tolerance = param.relative_residual_tolerance;
274  solver->require_residual_reduction = param.require_residual_reduction;
275  solver->linear_tolerance_multiplier = param.linear_tolerance_multiplier;
276  if (system.time_solver->reduce_deltat_on_diffsolver_failure)
277  {
278  solver->continue_after_max_iterations = true;
279  solver->continue_after_backtrack_failure = true;
280  }
281 
282  // And the linear solver options
283  solver->max_linear_iterations = param.max_linear_iterations;
284  solver->initial_linear_tolerance = param.initial_linear_tolerance;
285  solver->minimum_linear_tolerance = param.minimum_linear_tolerance;
286  }
287 }

References libMesh::DofMap::add_dirichlet_boundary(), HeatSystem::analytic_jacobians(), FEMParameters::analytic_jacobians, FEMParameters::deltat, libMesh::DifferentiableSystem::deltat, FEMParameters::deltat_reductions, FEMParameters::dirichlet_condition_variables, FEMParameters::dirichlet_conditions, FEMParameters::extra_quadrature_order, libMesh::System::extra_quadrature_order, HeatSystem::fe_family(), FEMParameters::fe_family, HeatSystem::fe_order(), FEMParameters::fe_order, libMesh::System::get_dof_map(), FEMParameters::initial_linear_tolerance, FEMParameters::linear_tolerance_multiplier, FEMParameters::max_linear_iterations, FEMParameters::max_nonlinear_iterations, FEMParameters::min_step_length, FEMParameters::minimum_linear_tolerance, FEMParameters::numerical_jacobian_h, libMesh::FEMSystem::numerical_jacobian_h, libMesh::out, FEMParameters::print_element_jacobians, libMesh::DifferentiableSystem::print_element_jacobians, FEMParameters::print_element_residuals, libMesh::DifferentiableSystem::print_element_residuals, 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, FEMParameters::relative_residual_tolerance, FEMParameters::relative_step_tolerance, FEMParameters::require_residual_reduction, FEMParameters::solver_quiet, FEMParameters::solver_verbose, libMesh::DifferentiableSystem::time_solver, FEMParameters::time_solver_quiet, FEMParameters::timesolver_core, FEMParameters::timesolver_theta, FEMParameters::transient, FEMParameters::use_petsc_snes, FEMParameters::verify_analytic_jacobians, and libMesh::FEMSystem::verify_analytic_jacobians.

Referenced by main().

◆ write_output()

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

Definition at line 113 of file adjoints_ex5.C.

117 {
118  // Ignore parameters when there are no output formats available.
119  libmesh_ignore(es, t_step, solution_type, param);
120 
121 #ifdef LIBMESH_HAVE_GMV
122  if (param.output_gmv)
123  {
124  MeshBase & mesh = es.get_mesh();
125 
126  std::ostringstream file_name_gmv;
127  file_name_gmv << solution_type
128  << ".out.gmv."
129  << std::setw(2)
130  << std::setfill('0')
131  << std::right
132  << t_step;
133 
134  GMVIO(mesh).write_equation_systems(file_name_gmv.str(), es);
135  }
136 #endif
137 
138 #ifdef LIBMESH_HAVE_EXODUS_API
139  if (param.output_exodus)
140  {
141  MeshBase & mesh = es.get_mesh();
142 
143  // We write out one file per timestep. The files are named in
144  // the following way:
145  // foo.e
146  // foo.e-s002
147  // foo.e-s003
148  // ...
149  // so that, if you open the first one with Paraview, it actually
150  // opens the entire sequence of adapted files.
151  std::ostringstream file_name_exodus;
152 
153  file_name_exodus << solution_type << ".e";
154  if (t_step > 0)
155  file_name_exodus << "-s"
156  << std::setw(3)
157  << std::setfill('0')
158  << std::right
159  << t_step + 1;
160 
161  // TODO: Get the current time from the System...
162  ExodusII_IO(mesh).write_timestep(file_name_exodus.str(),
163  es,
164  1,
165  /*time=*/t_step + 1);
166  }
167 #endif
168 }

References libMesh::libmesh_ignore(), mesh, FEMParameters::output_exodus, and FEMParameters::output_gmv.

Referenced by main().

libMesh::System::set_vector_preservation
void set_vector_preservation(const std::string &vec_name, bool preserve)
Allows one to set the boolean controlling whether the vector identified by vec_name should be "preser...
Definition: system.C:855
FEMParameters::use_petsc_snes
bool use_petsc_snes
Definition: femparameters.h:127
libMesh::DifferentiableSystem::deltat
Real deltat
For time-dependent problems, this is the amount delta t to advance the solution in time.
Definition: diff_system.h:260
FEMParameters::print_jacobians
bool print_jacobians
Definition: femparameters.h:118
FEMParameters::dirichlet_conditions
std::map< libMesh::boundary_id_type, libMesh::FunctionBase< libMesh::Number > * > dirichlet_conditions
Definition: femparameters.h:90
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::System::project_vector
void project_vector(NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr, int is_adjoint=-1) const
Projects arbitrary functions onto a vector of degree of freedom values for the current system.
Definition: system_projection.C:991
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::DifferentiableSystem::print_element_jacobians
bool print_element_jacobians
Set print_element_jacobians to true to print each J_elem contribution.
Definition: diff_system.h:361
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::PETSC_SOLVERS
Definition: enum_solver_package.h:36
FEMParameters::max_nonlinear_iterations
unsigned int max_nonlinear_iterations
Definition: femparameters.h:131
libMesh::DofMap::add_dirichlet_boundary
void add_dirichlet_boundary(const DirichletBoundary &dirichlet_boundary)
Adds a copy of the specified Dirichlet boundary to the system.
Definition: dof_map_constraints.C:4390
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
finish_initialization
void finish_initialization()
Definition: initial.C:11
write_output
void write_output(EquationSystems &es, unsigned int t_step, std::string solution_type, FEMParameters &param)
Definition: adjoints_ex5.C:113
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::System::extra_quadrature_order
int extra_quadrature_order
A member int that can be employed to indicate increased or reduced quadrature order.
Definition: system.h:1524
FEMParameters::output_gmv
bool output_gmv
Definition: femparameters.h:68
HeatSystem::analytic_jacobians
bool & analytic_jacobians()
Definition: heatsystem.h:50
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::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
FEMParameters::fe_order
std::vector< unsigned int > fe_order
Definition: femparameters.h:109
libMesh::boundary_id_type
int8_t boundary_id_type
Definition: id_types.h:51
FEMParameters::timesolver_core
std::string timesolver_core
Definition: femparameters.h:37
FEMParameters::solver_quiet
bool solver_quiet
Definition: femparameters.h:128
FEMParameters::require_residual_reduction
bool require_residual_reduction
Definition: femparameters.h:128
HeatSystem::fe_order
unsigned int & fe_order()
Definition: heatsystem.h:48
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::TriangleWrapper::init
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
libMesh::FEMSystem::numerical_jacobian_h
Real numerical_jacobian_h
If calculating numeric jacobians is required, the FEMSystem will perturb each solution vector entry b...
Definition: fem_system.h:181
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
HeatSystem::fe_family
std::string & fe_family()
Definition: heatsystem.h:47
std::abs
MetaPhysicL::DualNumber< T, D > abs(const MetaPhysicL::DualNumber< T, D > &in)
FEMParameters::solver_verbose
bool solver_verbose
Definition: femparameters.h:128
HeatSystem
Definition: heatsystem.h:30
FEMParameters::transient
bool transient
Definition: femparameters.h:35
adjoint_initial_value
Number adjoint_initial_value(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: adjoint_initial.C:35
libMesh::libmesh_ignore
void libmesh_ignore(const Args &...)
Definition: libmesh_common.h:526
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
FEMParameters::print_element_jacobians
bool print_element_jacobians
Definition: femparameters.h:118
libMesh::TRI3
Definition: enum_elem_type.h:39
FEMParameters::relative_residual_tolerance
libMesh::Real relative_residual_tolerance
Definition: femparameters.h:132
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
set_system_parameters
void set_system_parameters(HeatSystem &system, FEMParameters &param)
Definition: adjoints_ex5.C:170
adjoint_initial_grad
Gradient adjoint_initial_grad(const Point &p, const Parameters &, const std::string &, const std::string &)
Definition: adjoint_initial.C:47
libMesh::System::time
Real time
For time-dependent problems, this is the time t at the beginning of the current timestep.
Definition: system.h:1561
FEMParameters::timesolver_theta
libMesh::Real timesolver_theta
Definition: femparameters.h:38
libMesh::System::solution
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Definition: system.h:1539
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::extra_quadrature_order
int extra_quadrature_order
Definition: femparameters.h:110
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
initial_grad
Gradient initial_grad(const Point &, const Parameters &, const std::string &, const std::string &)
Definition: initial.C:30
FEMParameters::deltat
libMesh::Real deltat
Definition: femparameters.h:38
FEMParameters::numerical_jacobian_h
libMesh::Real numerical_jacobian_h
Definition: femparameters.h:116
libMesh::System::calculate_norm
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
Definition: system.C:1356
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
libMesh::System::get_dof_map
const DofMap & get_dof_map() const
Definition: system.h:2099
libMesh::err
OStreamProxy err
FEMParameters
Definition: femparameters.h:22
libMesh::H1
Definition: enum_norm_type.h:37
FEMParameters::deltat_reductions
unsigned int deltat_reductions
Definition: femparameters.h:36
FEMParameters::linear_tolerance_multiplier
double linear_tolerance_multiplier
Definition: femparameters.h:134
libMesh::System::project_solution
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
Definition: system_projection.C:950
FEMParameters::dirichlet_condition_variables
std::map< libMesh::boundary_id_type, std::vector< unsigned int > > dirichlet_condition_variables
Definition: femparameters.h:93
initial_value
Number initial_value(const Point &, const Parameters &, const std::string &, const std::string &)
Definition: initial.C:18
libMesh::out
OStreamProxy out
libMesh::DifferentiableSystem::print_element_residuals
bool print_element_residuals
Set print_element_residuals to true to print each R_elem contribution.
Definition: diff_system.h:356
libMesh::System::get_vector
const NumericVector< Number > & get_vector(const std::string &vec_name) const
Definition: system.C:774
read_initial_parameters
void read_initial_parameters()
Definition: initial.C:7
FEMParameters::print_element_residuals
bool print_element_residuals
Definition: femparameters.h:118
FEMParameters::time_solver_quiet
bool time_solver_quiet
Definition: femparameters.h:128
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33
libMesh::System::set_adjoint_already_solved
void set_adjoint_already_solved(bool setting)
Setter for the adjoint_already_solved boolean.
Definition: system.h:402