$extrastylesheet
#include <continuation_system.h>

Public Types | |
| enum | Predictor { Euler, AB2, Invalid_Predictor } |
| typedef ContinuationSystem | sys_type |
| typedef FEMSystem | Parent |
| typedef bool(TimeSolver::* | TimeSolverResPtr )(bool, DiffContext &) |
| typedef std::map< std::string, SparseMatrix< Number > * >::iterator | matrices_iterator |
| typedef std::map< std::string, SparseMatrix< Number > * >::const_iterator | const_matrices_iterator |
| typedef std::map< std::string, NumericVector< Number > * >::iterator | vectors_iterator |
| typedef std::map< std::string, NumericVector< Number > * >::const_iterator | const_vectors_iterator |
Public Member Functions | |
| ContinuationSystem (EquationSystems &es, const std::string &name, const unsigned int number) | |
| virtual | ~ContinuationSystem () |
| virtual void | clear () |
| virtual void | solve () |
| void | continuation_solve () |
| void | advance_arcstep () |
| void | set_max_arclength_stepsize (Real maxds) |
| void | save_current_solution () |
| virtual void | assembly (bool get_residual, bool get_jacobian, bool apply_heterogeneous_constraints=false) |
| void | mesh_position_get () |
| void | mesh_position_set () |
| virtual UniquePtr< DiffContext > | build_context () |
| virtual void | init_context (DiffContext &) |
| virtual void | postprocess () |
| virtual void | assemble_qoi (const QoISet &indices=QoISet()) |
| virtual void | assemble_qoi_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) |
| void | numerical_jacobian (TimeSolverResPtr res, FEMContext &context) const |
| void | numerical_elem_jacobian (FEMContext &context) const |
| void | numerical_side_jacobian (FEMContext &context) const |
| void | numerical_nonlocal_jacobian (FEMContext &context) const |
| virtual void | reinit () |
| virtual void | assemble () |
| virtual LinearSolver< Number > * | get_linear_solver () const |
| virtual std::pair< unsigned int, Real > | get_linear_solve_parameters () const |
| virtual void | release_linear_solver (LinearSolver< Number > *) const |
| virtual std::pair< unsigned int, Real > | adjoint_solve (const QoISet &qoi_indices=QoISet()) |
| virtual UniquePtr < DifferentiablePhysics > | clone_physics () |
| virtual UniquePtr < DifferentiableQoI > | clone () |
| const DifferentiablePhysics * | get_physics () const |
| DifferentiablePhysics * | get_physics () |
| void | attach_physics (DifferentiablePhysics *physics_in) |
| const DifferentiableQoI * | get_qoi () const |
| DifferentiableQoI * | get_qoi () |
| void | attach_qoi (DifferentiableQoI *qoi_in) |
| void | set_time_solver (UniquePtr< TimeSolver > _time_solver) |
| TimeSolver & | get_time_solver () |
| const TimeSolver & | get_time_solver () const |
| virtual void | element_postprocess (DiffContext &) |
| virtual void | side_postprocess (DiffContext &) |
| sys_type & | system () |
| virtual void | disable_cache () |
| virtual std::string | system_type () const |
| virtual void | assemble_residual_derivatives (const ParameterVector ¶meters) |
| virtual std::pair< unsigned int, Real > | sensitivity_solve (const ParameterVector ¶meters) |
| virtual std::pair< unsigned int, Real > | weighted_sensitivity_solve (const ParameterVector ¶meters, const ParameterVector &weights) |
| virtual std::pair< unsigned int, Real > | weighted_sensitivity_adjoint_solve (const ParameterVector ¶meters, const ParameterVector &weights, const QoISet &qoi_indices=QoISet()) |
| virtual void | adjoint_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities) |
| virtual void | forward_qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities) |
| virtual void | qoi_parameter_hessian (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &hessian) |
| virtual void | qoi_parameter_hessian_vector_product (const QoISet &qoi_indices, const ParameterVector ¶meters, const ParameterVector &vector, SensitivityData &product) |
| SparseMatrix< Number > & | add_matrix (const std::string &mat_name) |
| bool | have_matrix (const std::string &mat_name) const |
| const SparseMatrix< Number > * | request_matrix (const std::string &mat_name) const |
| SparseMatrix< Number > * | request_matrix (const std::string &mat_name) |
| const SparseMatrix< Number > & | get_matrix (const std::string &mat_name) const |
| SparseMatrix< Number > & | get_matrix (const std::string &mat_name) |
| virtual unsigned int | n_matrices () const |
| void | init () |
| virtual void | reinit_constraints () |
| bool | is_initialized () |
| virtual void | update () |
| virtual void | restrict_solve_to (const SystemSubset *subset, const SubsetSolveMode subset_solve_mode=SUBSET_ZERO) |
| bool | is_adjoint_already_solved () const |
| void | set_adjoint_already_solved (bool setting) |
| virtual void | qoi_parameter_sensitivity (const QoISet &qoi_indices, const ParameterVector ¶meters, SensitivityData &sensitivities) |
| virtual bool | compare (const System &other_system, const Real threshold, const bool verbose) const |
| const std::string & | name () const |
| void | project_solution (FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) const |
| void | project_solution (FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL) const |
| void | project_solution (Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters) const |
| void | project_vector (NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL, int is_adjoint=-1) const |
| void | project_vector (NumericVector< Number > &new_vector, FEMFunctionBase< Number > *f, FEMFunctionBase< Gradient > *g=NULL, int is_adjoint=-1) const |
| void | project_vector (Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters, NumericVector< Number > &new_vector, int is_adjoint=-1) const |
| void | boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL) |
| void | boundary_project_solution (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters) |
| void | boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, NumericVector< Number > &new_vector, FunctionBase< Number > *f, FunctionBase< Gradient > *g=NULL, int is_adjoint=-1) const |
| void | boundary_project_vector (const std::set< boundary_id_type > &b, const std::vector< unsigned int > &variables, Number fptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), Gradient gptr(const Point &p, const Parameters ¶meters, const std::string &sys_name, const std::string &unknown_name), const Parameters ¶meters, NumericVector< Number > &new_vector, int is_adjoint=-1) const |
| unsigned int | number () const |
| void | update_global_solution (std::vector< Number > &global_soln) const |
| void | update_global_solution (std::vector< Number > &global_soln, const processor_id_type dest_proc) const |
| const MeshBase & | get_mesh () const |
| MeshBase & | get_mesh () |
| const DofMap & | get_dof_map () const |
| DofMap & | get_dof_map () |
| const EquationSystems & | get_equation_systems () const |
| EquationSystems & | get_equation_systems () |
| bool | active () const |
| void | activate () |
| void | deactivate () |
| void | set_basic_system_only () |
| vectors_iterator | vectors_begin () |
| const_vectors_iterator | vectors_begin () const |
| vectors_iterator | vectors_end () |
| const_vectors_iterator | vectors_end () const |
| NumericVector< Number > & | add_vector (const std::string &vec_name, const bool projections=true, const ParallelType type=PARALLEL) |
| void | remove_vector (const std::string &vec_name) |
| bool & | project_solution_on_reinit (void) |
| bool | have_vector (const std::string &vec_name) const |
| const NumericVector< Number > * | request_vector (const std::string &vec_name) const |
| NumericVector< Number > * | request_vector (const std::string &vec_name) |
| const NumericVector< Number > * | request_vector (const unsigned int vec_num) const |
| NumericVector< Number > * | request_vector (const unsigned int vec_num) |
| const NumericVector< Number > & | get_vector (const std::string &vec_name) const |
| NumericVector< Number > & | get_vector (const std::string &vec_name) |
| const NumericVector< Number > & | get_vector (const unsigned int vec_num) const |
| NumericVector< Number > & | get_vector (const unsigned int vec_num) |
| const std::string & | vector_name (const unsigned int vec_num) const |
| const std::string & | vector_name (const NumericVector< Number > &vec_reference) const |
| void | set_vector_as_adjoint (const std::string &vec_name, int qoi_num) |
| int | vector_is_adjoint (const std::string &vec_name) const |
| void | set_vector_preservation (const std::string &vec_name, bool preserve) |
| bool | vector_preservation (const std::string &vec_name) const |
| NumericVector< Number > & | add_adjoint_solution (unsigned int i=0) |
| NumericVector< Number > & | get_adjoint_solution (unsigned int i=0) |
| const NumericVector< Number > & | get_adjoint_solution (unsigned int i=0) const |
| NumericVector< Number > & | add_sensitivity_solution (unsigned int i=0) |
| NumericVector< Number > & | get_sensitivity_solution (unsigned int i=0) |
| const NumericVector< Number > & | get_sensitivity_solution (unsigned int i=0) const |
| NumericVector< Number > & | add_weighted_sensitivity_adjoint_solution (unsigned int i=0) |
| NumericVector< Number > & | get_weighted_sensitivity_adjoint_solution (unsigned int i=0) |
| const NumericVector< Number > & | get_weighted_sensitivity_adjoint_solution (unsigned int i=0) const |
| NumericVector< Number > & | add_weighted_sensitivity_solution () |
| NumericVector< Number > & | get_weighted_sensitivity_solution () |
| const NumericVector< Number > & | get_weighted_sensitivity_solution () const |
| NumericVector< Number > & | add_adjoint_rhs (unsigned int i=0) |
| NumericVector< Number > & | get_adjoint_rhs (unsigned int i=0) |
| const NumericVector< Number > & | get_adjoint_rhs (unsigned int i=0) const |
| NumericVector< Number > & | add_sensitivity_rhs (unsigned int i=0) |
| NumericVector< Number > & | get_sensitivity_rhs (unsigned int i=0) |
| const NumericVector< Number > & | get_sensitivity_rhs (unsigned int i=0) const |
| unsigned int | n_vectors () const |
| unsigned int | n_vars () const |
| unsigned int | n_variable_groups () const |
| unsigned int | n_components () const |
| dof_id_type | n_dofs () const |
| dof_id_type | n_active_dofs () const |
| dof_id_type | n_constrained_dofs () const |
| dof_id_type | n_local_constrained_dofs () const |
| dof_id_type | n_local_dofs () const |
| unsigned int | add_variable (const std::string &var, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| unsigned int | add_variable (const std::string &var, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| unsigned int | add_variables (const std::vector< std::string > &vars, const FEType &type, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| unsigned int | add_variables (const std::vector< std::string > &vars, const Order order=FIRST, const FEFamily=LAGRANGE, const std::set< subdomain_id_type > *const active_subdomains=NULL) |
| const Variable & | variable (unsigned int var) const |
| const VariableGroup & | variable_group (unsigned int vg) const |
| bool | has_variable (const std::string &var) const |
| const std::string & | variable_name (const unsigned int i) const |
| unsigned short int | variable_number (const std::string &var) const |
| void | get_all_variable_numbers (std::vector< unsigned int > &all_variable_numbers) const |
| unsigned int | variable_scalar_number (const std::string &var, unsigned int component) const |
| unsigned int | variable_scalar_number (unsigned int var_num, unsigned int component) const |
| const FEType & | variable_type (const unsigned int i) const |
| const FEType & | variable_type (const std::string &var) const |
| bool | identify_variable_groups () const |
| void | identify_variable_groups (const bool) |
| Real | calculate_norm (const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type) const |
| Real | calculate_norm (const NumericVector< Number > &v, const SystemNorm &norm) const |
| void | read_header (Xdr &io, const std::string &version, const bool read_header=true, const bool read_additional_data=true, const bool read_legacy_format=false) |
| void | read_legacy_data (Xdr &io, const bool read_additional_data=true) |
| template<typename ValType > | |
| void | read_serialized_data (Xdr &io, const bool read_additional_data=true) |
| void | read_serialized_data (Xdr &io, const bool read_additional_data=true) |
| template<typename InValType > | |
| std::size_t | read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const |
| std::size_t | read_serialized_vectors (Xdr &io, const std::vector< NumericVector< Number > * > &vectors) const |
| template<typename InValType > | |
| void | read_parallel_data (Xdr &io, const bool read_additional_data) |
| void | read_parallel_data (Xdr &io, const bool read_additional_data) |
| void | write_header (Xdr &io, const std::string &version, const bool write_additional_data) const |
| void | write_serialized_data (Xdr &io, const bool write_additional_data=true) const |
| std::size_t | write_serialized_vectors (Xdr &io, const std::vector< const NumericVector< Number > * > &vectors) const |
| void | write_parallel_data (Xdr &io, const bool write_additional_data) const |
| std::string | get_info () const |
| void | attach_init_function (void fptr(EquationSystems &es, const std::string &name)) |
| void | attach_init_object (Initialization &init) |
| void | attach_assemble_function (void fptr(EquationSystems &es, const std::string &name)) |
| void | attach_assemble_object (Assembly &assemble) |
| void | attach_constraint_function (void fptr(EquationSystems &es, const std::string &name)) |
| void | attach_constraint_object (Constraint &constrain) |
| void | attach_QOI_function (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices)) |
| void | attach_QOI_object (QOI &qoi) |
| void | attach_QOI_derivative (void fptr(EquationSystems &es, const std::string &name, const QoISet &qoi_indices, bool include_liftfunc, bool apply_constraints)) |
| void | attach_QOI_derivative_object (QOIDerivative &qoi_derivative) |
| virtual void | user_initialization () |
| virtual void | user_assembly () |
| virtual void | user_constrain () |
| virtual void | user_QOI (const QoISet &qoi_indices) |
| virtual void | user_QOI_derivative (const QoISet &qoi_indices=QoISet(), bool include_liftfunc=true, bool apply_constraints=true) |
| virtual void | re_update () |
| virtual void | restrict_vectors () |
| virtual void | prolong_vectors () |
| Number | current_solution (const dof_id_type global_dof_number) const |
| Number | point_value (unsigned int var, const Point &p, const bool insist_on_success=true) const |
| Number | point_value (unsigned int var, const Point &p, const Elem &e) const |
| Gradient | point_gradient (unsigned int var, const Point &p, const bool insist_on_success=true) const |
| Gradient | point_gradient (unsigned int var, const Point &p, const Elem &e) const |
| Tensor | point_hessian (unsigned int var, const Point &p, const bool insist_on_success=true) const |
| Tensor | point_hessian (unsigned int var, const Point &p, const Elem &e) const |
| void | local_dof_indices (const unsigned int var, std::set< dof_id_type > &var_indices) const |
| void | zero_variable (NumericVector< Number > &v, unsigned int var_num) const |
| const Parallel::Communicator & | comm () const |
| processor_id_type | n_processors () const |
| processor_id_type | processor_id () const |
| virtual void | clear_physics () |
| virtual void | init_physics (const System &sys) |
| virtual bool | element_time_derivative (bool request_jacobian, DiffContext &) |
| virtual bool | element_constraint (bool request_jacobian, DiffContext &) |
| virtual bool | side_time_derivative (bool request_jacobian, DiffContext &) |
| virtual bool | side_constraint (bool request_jacobian, DiffContext &) |
| virtual bool | nonlocal_time_derivative (bool request_jacobian, DiffContext &) |
| virtual bool | nonlocal_constraint (bool request_jacobian, DiffContext &) |
| virtual void | time_evolving (unsigned int var) |
| bool | is_time_evolving (unsigned int var) const |
| virtual bool | eulerian_residual (bool request_jacobian, DiffContext &) |
| virtual bool | eulerian_residual (bool request_jacobian, DiffContext &context) |
| virtual bool | mass_residual (bool request_jacobian, DiffContext &) |
| virtual bool | mass_residual (bool request_jacobian, DiffContext &) |
| virtual bool | side_mass_residual (bool request_jacobian, DiffContext &) |
| virtual bool | nonlocal_mass_residual (bool request_jacobian, DiffContext &c) |
| virtual void | set_mesh_system (System *sys) |
| const System * | get_mesh_system () const |
| System * | get_mesh_system () |
| virtual void | set_mesh_x_var (unsigned int var) |
| unsigned int | get_mesh_x_var () const |
| virtual void | set_mesh_y_var (unsigned int var) |
| unsigned int | get_mesh_y_var () const |
| virtual void | set_mesh_z_var (unsigned int var) |
| unsigned int | get_mesh_z_var () const |
| bool | _eulerian_time_deriv (bool request_jacobian, DiffContext &) |
| virtual void | init_qoi (std::vector< Number > &) |
| virtual void | clear_qoi () |
| virtual void | element_qoi (DiffContext &, const QoISet &) |
| virtual void | element_qoi_derivative (DiffContext &, const QoISet &) |
| virtual void | side_qoi (DiffContext &, const QoISet &) |
| virtual void | side_qoi_derivative (DiffContext &, const QoISet &) |
| virtual void | thread_join (std::vector< Number > &qoi, const std::vector< Number > &other_qoi, const QoISet &qoi_indices) |
| virtual void | parallel_op (const Parallel::Communicator &communicator, std::vector< Number > &sys_qoi, std::vector< Number > &local_qoi, const QoISet &qoi_indices) |
Static Public Member Functions | |
| static std::string | get_info () |
| static void | print_info (std::ostream &out=libMesh::out) |
| static unsigned int | n_objects () |
| static void | enable_print_counter_info () |
| static void | disable_print_counter_info () |
Public Attributes | |
| Real * | continuation_parameter |
| bool | quiet |
| Real | continuation_parameter_tolerance |
| Real | solution_tolerance |
| Real | initial_newton_tolerance |
| Real | old_continuation_parameter |
| Real | min_continuation_parameter |
| Real | max_continuation_parameter |
| Real | Theta |
| Real | Theta_LOCA |
| unsigned int | n_backtrack_steps |
| unsigned int | n_arclength_reductions |
| Real | ds_min |
| Predictor | predictor |
| Real | newton_stepgrowth_aggressiveness |
| bool | newton_progress_check |
| bool | fe_reinit_during_postprocess |
| Real | numerical_jacobian_h |
| Real | verify_analytic_jacobians |
| UniquePtr< TimeSolver > | time_solver |
| Real | deltat |
| bool | postprocess_sides |
| bool | print_solution_norms |
| bool | print_solutions |
| bool | print_residual_norms |
| bool | print_residuals |
| bool | print_jacobian_norms |
| bool | print_jacobians |
| bool | print_element_solutions |
| bool | print_element_residuals |
| bool | print_element_jacobians |
| SparseMatrix< Number > * | matrix |
| NumericVector< Number > * | rhs |
| bool | assemble_before_solve |
| bool | use_fixed_solution |
| int | extra_quadrature_order |
| UniquePtr< NumericVector < Number > > | solution |
| UniquePtr< NumericVector < Number > > | current_local_solution |
| Real | time |
| std::vector< Number > | qoi |
| bool | compute_internal_sides |
| bool | assemble_qoi_sides |
| bool | assemble_qoi_internal_sides |
| bool | assemble_qoi_elements |
Protected Types | |
| enum | RHS_Mode { Residual, G_Lambda } |
| typedef std::map< std::string, std::pair< unsigned int, unsigned int > > | Counts |
Protected Member Functions | |
| virtual void | init_data () |
| virtual void | init_matrices () |
| void | project_vector (NumericVector< Number > &, int is_adjoint=-1) const |
| void | project_vector (const NumericVector< Number > &, NumericVector< Number > &, int is_adjoint=-1) const |
| void | increment_constructor_count (const std::string &name) |
| void | increment_destructor_count (const std::string &name) |
Protected Attributes | |
| RHS_Mode | rhs_mode |
| DifferentiablePhysics * | _diff_physics |
| DifferentiableQoI * | diff_qoi |
| const Parallel::Communicator & | _communicator |
| System * | _mesh_sys |
| unsigned int | _mesh_x_var |
| unsigned int | _mesh_y_var |
| unsigned int | _mesh_z_var |
| std::vector< bool > | _time_evolving |
Static Protected Attributes | |
| static Counts | _counts |
| static Threads::atomic < unsigned int > | _n_objects |
| static Threads::spin_mutex | _mutex |
| static bool | _enable_print_counter = true |
Private Member Functions | |
| void | initialize_tangent () |
| void | solve_tangent () |
| void | update_solution () |
| void | set_Theta () |
| void | set_Theta_LOCA () |
| void | apply_predictor () |
Private Attributes | |
| NumericVector< Number > * | du_ds |
| NumericVector< Number > * | previous_du_ds |
| NumericVector< Number > * | previous_u |
| NumericVector< Number > * | y |
| NumericVector< Number > * | y_old |
| NumericVector< Number > * | z |
| NumericVector< Number > * | delta_u |
| UniquePtr< LinearSolver< Number > > | linear_solver |
| bool | tangent_initialized |
| NewtonSolver * | newton_solver |
| Real | dlambda_ds |
| Real | ds |
| Real | ds_current |
| Real | previous_dlambda_ds |
| Real | previous_ds |
| unsigned int | newton_step |
This class inherits from the FEMSystem. It can be used to do arclength continuation. Most of the ideas and the notation here come from HB Keller's 1977 paper:
* @InProceedings{Kell-1977,
* author = {H.~B.~Keller},
* title = {{Numerical solution of bifurcation and nonlinear eigenvalue problems}},
* booktitle = {Applications of Bifurcation Theory, P.~H.~Rabinowitz (ed.)},
* year = 1977,
* publisher = {Academic Press},
* pages = {359--389},
* notes = {QA 3 U45 No.\ 38 (PMA)}
* }
* Definition at line 54 of file continuation_system.h.
typedef std::map<std::string, SparseMatrix<Number>* >::const_iterator libMesh::ImplicitSystem::const_matrices_iterator [inherited] |
Definition at line 280 of file implicit_system.h.
typedef std::map<std::string, NumericVector<Number>* >::const_iterator libMesh::System::const_vectors_iterator [inherited] |
typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts [protected, inherited] |
Data structure to log the information. The log is identified by the class name.
Definition at line 113 of file reference_counter.h.
typedef std::map<std::string, SparseMatrix<Number>* >::iterator libMesh::ImplicitSystem::matrices_iterator [inherited] |
Matrix iterator typedefs.
Definition at line 279 of file implicit_system.h.
The type of the parent.
Reimplemented from libMesh::FEMSystem.
Definition at line 78 of file continuation_system.h.
The type of system.
Reimplemented from libMesh::FEMSystem.
Definition at line 73 of file continuation_system.h.
typedef bool(TimeSolver::* libMesh::FEMSystem::TimeSolverResPtr)(bool, DiffContext &) [inherited] |
Syntax sugar to make numerical_jacobian() declaration easier.
Definition at line 199 of file fem_system.h.
typedef std::map<std::string, NumericVector<Number>* >::iterator libMesh::System::vectors_iterator [inherited] |
The code provides the ability to select from different predictor schemes for getting the initial guess for the solution at the next point on the solution arc.
| Euler |
First-order Euler predictor |
| AB2 |
Second-order explicit Adams-Bashforth predictor |
| Invalid_Predictor |
Invalid predictor |
Definition at line 220 of file continuation_system.h.
{
Euler,
AB2,
Invalid_Predictor
};
enum libMesh::ContinuationSystem::RHS_Mode [protected] |
There are (so far) two different vectors which may be assembled using the assembly routine: 1.) The Residual = the normal PDE weighted residual 2.) G_Lambda = the derivative wrt the parameter lambda of the PDE weighted residual
It is up to the derived class to handle writing separate assembly code for the different cases. Usually something like: switch (rhs_mode) { case Residual: { Fu(i) += ... // normal PDE residual break; }
case G_Lambda: { Fu(i) += ... // derivative wrt control parameter break; }
Definition at line 285 of file continuation_system.h.
| libMesh::ContinuationSystem::ContinuationSystem | ( | EquationSystems & | es, |
| const std::string & | name, | ||
| const unsigned int | number | ||
| ) |
Constructor. Optionally initializes required data structures.
Definition at line 29 of file continuation_system.C.
References linear_solver, libMesh::System::name(), and libMesh::on_command_line().
: Parent(es, name_in, number_in), continuation_parameter(NULL), quiet(true), continuation_parameter_tolerance(1.e-6), solution_tolerance(1.e-6), initial_newton_tolerance(0.01), old_continuation_parameter(0.), min_continuation_parameter(0.), max_continuation_parameter(0.), Theta(1.), Theta_LOCA(1.), //tau(1.), n_backtrack_steps(5), n_arclength_reductions(5), ds_min(1.e-8), predictor(Euler), newton_stepgrowth_aggressiveness(1.), newton_progress_check(true), rhs_mode(Residual), linear_solver(LinearSolver<Number>::build(es.comm())), tangent_initialized(false), newton_solver(NULL), dlambda_ds(0.707), ds(0.1), ds_current(0.1), previous_dlambda_ds(0.), previous_ds(0.), newton_step(0) { // Warn about using untested code libmesh_experimental(); if (libMesh::on_command_line("--solver_system_names")) linear_solver->init((this->name()+"_").c_str()); else linear_solver->init(); }
| libMesh::ContinuationSystem::~ContinuationSystem | ( | ) | [virtual] |
Destructor.
Definition at line 73 of file continuation_system.C.
References clear().
{
this->clear();
}
| bool libMesh::DifferentiablePhysics::_eulerian_time_deriv | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inherited] |
This method simply combines element_time_derivative() and eulerian_residual(), which makes its address useful as a pointer-to-member-function when refactoring.
Referenced by libMesh::EulerSolver::element_residual(), and libMesh::Euler2Solver::element_residual().
| void libMesh::System::activate | ( | ) | [inline, inherited] |
Activates the system. Only active systems are solved.
Definition at line 2001 of file system.h.
References libMesh::System::_active.
{
_active = true;
}
| bool libMesh::System::active | ( | ) | const [inline, inherited] |
true if the system is active, false otherwise. An active system will be solved. Definition at line 1993 of file system.h.
References libMesh::System::_active.
{
return _active;
}
| NumericVector< Number > & libMesh::System::add_adjoint_rhs | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 1048 of file system.C.
References libMesh::System::add_vector().
Referenced by libMesh::ExplicitSystem::assemble_qoi_derivative(), and libMesh::FEMSystem::assemble_qoi_derivative().
{
std::ostringstream adjoint_rhs_name;
adjoint_rhs_name << "adjoint_rhs" << i;
return this->add_vector(adjoint_rhs_name.str(), false);
}
| NumericVector< Number > & libMesh::System::add_adjoint_solution | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 984 of file system.C.
References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().
Referenced by libMesh::ImplicitSystem::adjoint_solve().
{
std::ostringstream adjoint_name;
adjoint_name << "adjoint_solution" << i;
NumericVector<Number> &returnval = this->add_vector(adjoint_name.str());
this->set_vector_as_adjoint(adjoint_name.str(), i);
return returnval;
}
| SparseMatrix< Number > & libMesh::ImplicitSystem::add_matrix | ( | const std::string & | mat_name | ) | [inherited] |
Adds the additional matrix mat_name to this system. Only allowed prior to assemble(). All additional matrices have the same sparsity pattern as the matrix used during solution. When not System but the user wants to initialize the mayor matrix, then all the additional matrices, if existent, have to be initialized by the user, too.
Definition at line 207 of file implicit_system.C.
References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::ParallelObject::comm(), and libMesh::ImplicitSystem::have_matrix().
Referenced by libMesh::ImplicitSystem::add_system_matrix(), libMesh::EigenTimeSolver::init(), and libMesh::NewmarkSystem::NewmarkSystem().
{
// only add matrices before initializing...
if (!_can_add_matrices)
libmesh_error_msg("ERROR: Too late. Cannot add matrices to the system after initialization"
<< "\n any more. You should have done this earlier.");
// Return the matrix if it is already there.
if (this->have_matrix(mat_name))
return *(_matrices[mat_name]);
// Otherwise build the matrix and return it.
SparseMatrix<Number>* buf = SparseMatrix<Number>::build(this->comm()).release();
_matrices.insert (std::make_pair (mat_name, buf));
return *buf;
}
| NumericVector< Number > & libMesh::System::add_sensitivity_rhs | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 1078 of file system.C.
References libMesh::System::add_vector().
Referenced by libMesh::ImplicitSystem::assemble_residual_derivatives().
{
std::ostringstream sensitivity_rhs_name;
sensitivity_rhs_name << "sensitivity_rhs" << i;
return this->add_vector(sensitivity_rhs_name.str(), false);
}
| NumericVector< Number > & libMesh::System::add_sensitivity_solution | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 933 of file system.C.
References libMesh::System::add_vector().
Referenced by libMesh::ImplicitSystem::sensitivity_solve().
{
std::ostringstream sensitivity_name;
sensitivity_name << "sensitivity_solution" << i;
return this->add_vector(sensitivity_name.str());
}
| unsigned int libMesh::System::add_variable | ( | const std::string & | var, |
| const FEType & | type, | ||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL |
||
| ) | [inherited] |
Adds the variable var to the list of variables for this system. Returns the index number for the new variable.
Definition at line 1108 of file system.C.
References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::add_variables(), libMesh::VariableGroup::append(), libMesh::System::identify_variable_groups(), libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_variable_groups(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::System::variable_name(), and libMesh::System::variable_type().
Referenced by libMesh::System::add_variable(), libMesh::ErrorVector::plot_error(), and libMesh::System::read_header().
{
libmesh_assert(!this->is_initialized());
// Make sure the variable isn't there already
// or if it is, that it's the type we want
for (unsigned int v=0; v<this->n_vars(); v++)
if (this->variable_name(v) == var)
{
if (this->variable_type(v) == type)
return _variables[v].number();
libmesh_error_msg("ERROR: incompatible variable " << var << " has already been added for this system!");
}
// Optimize for VariableGroups here - if the user is adding multiple
// variables of the same FEType and subdomain restriction, catch
// that here and add them as members of the same VariableGroup.
//
// start by setting this flag to whatever the user has requested
// and then consider the conditions which should negate it.
bool should_be_in_vg = this->identify_variable_groups();
// No variable groups, nothing to add to
if (!this->n_variable_groups())
should_be_in_vg = false;
else
{
VariableGroup &vg(_variable_groups.back());
// get a pointer to their subdomain restriction, if any.
const std::set<subdomain_id_type> * const
their_active_subdomains (vg.implicitly_active() ?
NULL : &vg.active_subdomains());
// Different types?
if (vg.type() != type)
should_be_in_vg = false;
// they are restricted, we aren't?
if (their_active_subdomains && !active_subdomains)
should_be_in_vg = false;
// they aren't restriced, we are?
if (!their_active_subdomains && active_subdomains)
should_be_in_vg = false;
if (their_active_subdomains && active_subdomains)
// restricted to different sets?
if (*their_active_subdomains != *active_subdomains)
should_be_in_vg = false;
// OK, after all that, append the variable to the vg if none of the conditions
// were violated
if (should_be_in_vg)
{
const unsigned short curr_n_vars = cast_int<unsigned short>
(this->n_vars());
vg.append (var);
_variables.push_back(vg(vg.n_variables()-1));
_variable_numbers[var] = curr_n_vars;
return curr_n_vars;
}
}
// otherwise, fall back to adding a single variable group
return this->add_variables (std::vector<std::string>(1, var),
type,
active_subdomains);
}
| unsigned int libMesh::System::add_variable | ( | const std::string & | var, |
| const Order | order = FIRST, |
||
| const FEFamily | family = LAGRANGE, |
||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL |
||
| ) | [inherited] |
Adds the variable var to the list of variables for this system. Same as before, but assumes LAGRANGE as default value for FEType.family.
Definition at line 1186 of file system.C.
References libMesh::System::add_variable().
{
return this->add_variable(var,
FEType(order, family),
active_subdomains);
}
| unsigned int libMesh::System::add_variables | ( | const std::vector< std::string > & | vars, |
| const FEType & | type, | ||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL |
||
| ) | [inherited] |
Adds the variable var to the list of variables for this system. Returns the index number for the new variable.
Definition at line 1198 of file system.C.
References libMesh::System::_variable_groups, libMesh::System::_variable_numbers, libMesh::System::_variables, libMesh::System::is_initialized(), libMesh::libmesh_assert(), libMesh::System::n_components(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::System::variable_name(), and libMesh::System::variable_type().
Referenced by libMesh::System::add_variable(), and libMesh::System::add_variables().
{
libmesh_assert(!this->is_initialized());
// Make sure the variable isn't there already
// or if it is, that it's the type we want
for (unsigned int ov=0; ov<vars.size(); ov++)
for (unsigned int v=0; v<this->n_vars(); v++)
if (this->variable_name(v) == vars[ov])
{
if (this->variable_type(v) == type)
return _variables[v].number();
libmesh_error_msg("ERROR: incompatible variable " << vars[ov] << " has already been added for this system!");
}
const unsigned short curr_n_vars = cast_int<unsigned short>
(this->n_vars());
const unsigned int next_first_component = this->n_components();
// Add the variable group to the list
_variable_groups.push_back((active_subdomains == NULL) ?
VariableGroup(this, vars, curr_n_vars,
next_first_component, type) :
VariableGroup(this, vars, curr_n_vars,
next_first_component, type, *active_subdomains));
const VariableGroup &vg (_variable_groups.back());
// Add each component of the group individually
for (unsigned short v=0; v<vars.size(); v++)
{
_variables.push_back (vg(v));
_variable_numbers[vars[v]] = cast_int<unsigned short>
(curr_n_vars+v);
}
libmesh_assert_equal_to ((curr_n_vars+vars.size()), this->n_vars());
// BSK - Defer this now to System::init_data() so we can detect
// VariableGroups 12/28/2012
// // Add the variable group to the _dof_map
// _dof_map->add_variable_group (vg);
// Return the number of the new variable
return cast_int<unsigned int>(curr_n_vars+vars.size()-1);
}
| unsigned int libMesh::System::add_variables | ( | const std::vector< std::string > & | vars, |
| const Order | order = FIRST, |
||
| const FEFamily | family = LAGRANGE, |
||
| const std::set< subdomain_id_type > *const | active_subdomains = NULL |
||
| ) | [inherited] |
Adds the variable var to the list of variables for this system. Same as before, but assumes LAGRANGE as default value for FEType.family.
Definition at line 1251 of file system.C.
References libMesh::System::add_variables().
{
return this->add_variables(vars,
FEType(order, family),
active_subdomains);
}
| NumericVector< Number > & libMesh::System::add_vector | ( | const std::string & | vec_name, |
| const bool | projections = true, |
||
| const ParallelType | type = PARALLEL |
||
| ) | [inherited] |
Adds the additional vector vec_name to this system. All the additional vectors are similarly distributed, like the solution, and inititialized to zero.
By default vectors added by add_vector are projected to changed grids by reinit(). To zero them instead (more efficient), pass "false" as the second argument
Definition at line 689 of file system.C.
References libMesh::System::_dof_map, libMesh::System::_is_initialized, libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::ParallelObject::comm(), libMesh::GHOSTED, libMesh::System::have_vector(), libMesh::NumericVector< T >::init(), libMesh::System::n_dofs(), and libMesh::System::n_local_dofs().
Referenced by libMesh::System::add_adjoint_rhs(), libMesh::System::add_adjoint_solution(), libMesh::System::add_sensitivity_rhs(), libMesh::System::add_sensitivity_solution(), libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::System::add_weighted_sensitivity_solution(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::UnsteadySolver::init(), init_data(), libMesh::NewmarkSystem::NewmarkSystem(), libMesh::System::read_header(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), and libMesh::FrequencySystem::set_frequencies_by_steps().
{
// Return the vector if it is already there.
if (this->have_vector(vec_name))
return *(_vectors[vec_name]);
// Otherwise build the vector
NumericVector<Number>* buf = NumericVector<Number>::build(this->comm()).release();
_vectors.insert (std::make_pair (vec_name, buf));
_vector_projections.insert (std::make_pair (vec_name, projections));
_vector_types.insert (std::make_pair (vec_name, type));
// Vectors are primal by default
_vector_is_adjoint.insert (std::make_pair (vec_name, -1));
// Initialize it if necessary
if (_is_initialized)
{
if(type == GHOSTED)
{
#ifdef LIBMESH_ENABLE_GHOSTED
buf->init (this->n_dofs(), this->n_local_dofs(),
_dof_map->get_send_list(), false,
GHOSTED);
#else
libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
#endif
}
else
buf->init (this->n_dofs(), this->n_local_dofs(), false, type);
}
return *buf;
}
| NumericVector< Number > & libMesh::System::add_weighted_sensitivity_adjoint_solution | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 1016 of file system.C.
References libMesh::System::add_vector(), and libMesh::System::set_vector_as_adjoint().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
{
std::ostringstream adjoint_name;
adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
NumericVector<Number> &returnval = this->add_vector(adjoint_name.str());
this->set_vector_as_adjoint(adjoint_name.str(), i);
return returnval;
}
| NumericVector< Number > & libMesh::System::add_weighted_sensitivity_solution | ( | ) | [inherited] |
Definition at line 963 of file system.C.
References libMesh::System::add_vector().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_solve().
{
return this->add_vector("weighted_sensitivity_solution");
}
| void libMesh::ImplicitSystem::adjoint_qoi_parameter_sensitivity | ( | const QoISet & | qoi_indices, |
| const ParameterVector & | parameters, | ||
| SensitivityData & | sensitivities | ||
| ) | [virtual, inherited] |
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
Uses adjoint_solve() and the adjoint sensitivity method.
Currently uses finite differenced derivatives (partial q / partial p) and (partial R / partial p).
Reimplemented from libMesh::System.
Definition at line 700 of file implicit_system.C.
References libMesh::SensitivityData::allocate_data(), libMesh::get_dof_map(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.
{
// We currently get partial derivatives via central differencing
const Real delta_p = TOLERANCE;
ParameterVector& parameters =
const_cast<ParameterVector&>(parameters_in);
const unsigned int Np = cast_int<unsigned int>
(parameters.size());
const unsigned int Nq = cast_int<unsigned int>
(qoi.size());
// An introduction to the problem:
//
// Residual R(u(p),p) = 0
// partial R / partial u = J = system matrix
//
// This implies that:
// d/dp(R) = 0
// (partial R / partial p) +
// (partial R / partial u) * (partial u / partial p) = 0
// We first do an adjoint solve:
// J^T * z = (partial q / partial u)
// if we havent already or dont have an initial condition for the adjoint
if (!this->is_adjoint_already_solved())
{
this->adjoint_solve(qoi_indices);
}
// Get ready to fill in senstivities:
sensitivities.allocate_data(qoi_indices, *this, parameters);
// We use the identities:
// dq/dp = (partial q / partial p) + (partial q / partial u) *
// (partial u / partial p)
// dq/dp = (partial q / partial p) + (J^T * z) *
// (partial u / partial p)
// dq/dp = (partial q / partial p) + z * J *
// (partial u / partial p)
// Leading to our final formula:
// dq/dp = (partial q / partial p) - z * (partial R / partial p)
// In the case of adjoints with heterogenous Dirichlet boundary
// function phi, where
// q := R(u,phi) + S(u)
// the final formula works out to:
// dq/dp = (partial S / partial p) - z * (partial R / partial p)
// Because we currently have no direct access to
// (partial S / partial p), we use the identity
// (partial S / partial p) = (partial q / partial p) -
// phi * (partial R / partial p)
// to derive an equivalent equation:
// dq/dp = (partial q / partial p) - (z+phi) * (partial R / partial p)
// If we have non-zero adjoint dofs on Dirichlet constrained
// boundary dofs, then we need the residual components
// corresponding to those dofs when using r*z to compute R(u,z), so
// we can't apply constraints.
//
// If we aren't in that situation we could apply constraints but
// it will be faster not to.
this->get_dof_map().stash_dof_constraints();
for (unsigned int j=0; j != Np; ++j)
{
// (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
// (partial R / partial p) ~= (rhs(p+dp) - rhs(p-dp))/(2*dp)
Number old_parameter = *parameters[j];
// Number old_qoi = this->qoi;
*parameters[j] = old_parameter - delta_p;
this->assemble_qoi(qoi_indices);
std::vector<Number> qoi_minus = this->qoi;
this->assembly(true, false, true);
this->rhs->close();
// FIXME - this can and should be optimized to avoid the clone()
UniquePtr<NumericVector<Number> > partialR_partialp = this->rhs->clone();
*partialR_partialp *= -1;
*parameters[j] = old_parameter + delta_p;
this->assemble_qoi(qoi_indices);
std::vector<Number>& qoi_plus = this->qoi;
std::vector<Number> partialq_partialp(Nq, 0);
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
this->assembly(true, false, true);
this->rhs->close();
*partialR_partialp += *this->rhs;
*partialR_partialp /= (2.*delta_p);
// Don't leave the parameter changed
*parameters[j] = old_parameter;
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
sensitivities[i][j] = partialq_partialp[i] -
partialR_partialp->dot(this->get_adjoint_solution(i));
if (this->get_dof_map().has_adjoint_dirichlet_boundaries(i))
{
UniquePtr<NumericVector<Number> > lift_func =
this->get_adjoint_solution(i).zero_clone();
this->get_dof_map().enforce_adjoint_constraints_exactly
(*lift_func.get(), i);
sensitivities[i][j] += partialR_partialp->dot(*lift_func);
}
}
}
// All parameters have been reset.
// We didn't cache the original rhs or matrix for memory reasons,
// but we can restore them to a state consistent solution -
// principle of least surprise.
this->get_dof_map().unstash_dof_constraints();
this->assembly(true, true);
this->rhs->close();
this->matrix->close();
this->assemble_qoi(qoi_indices);
}
| std::pair< unsigned int, Real > libMesh::DifferentiableSystem::adjoint_solve | ( | const QoISet & | qoi_indices = QoISet() | ) | [virtual, inherited] |
This function sets the _is_adjoint boolean member of TimeSolver to true and then calls the adjoint_solve in implicit system
Reimplemented from libMesh::ImplicitSystem.
Definition at line 144 of file diff_system.C.
References libMesh::DifferentiableSystem::get_time_solver(), and libMesh::TimeSolver::set_is_adjoint().
{
// Get the time solver object associated with the system, and tell it that
// we are solving the adjoint problem
this->get_time_solver().set_is_adjoint(true);
return this->ImplicitSystem::adjoint_solve(qoi_indices);
}
Call this function after a continuation solve to compute the tangent and get the next initial guess.
Definition at line 937 of file continuation_system.C.
References solve_tangent(), and update_solution().
{
// Solve for the updated tangent du1/ds, d(lambda1)/ds
solve_tangent();
// Advance the solution and the parameter to the next value.
update_solution();
}
| void libMesh::ContinuationSystem::apply_predictor | ( | ) | [private] |
Applies the predictor to the current solution to get a guess for the next solution.
Definition at line 1376 of file continuation_system.C.
References AB2, continuation_parameter, dlambda_ds, ds_current, du_ds, Euler, predictor, previous_dlambda_ds, previous_ds, previous_du_ds, libMesh::Real, and libMesh::System::solution.
Referenced by continuation_solve(), and update_solution().
{
if (predictor == Euler)
{
// 1.) Euler Predictor
// Predict next the solution
solution->add(ds_current, *du_ds);
solution->close();
// Predict next parameter value
*continuation_parameter += ds_current*dlambda_ds;
}
else if (predictor == AB2)
{
// 2.) 2nd-order explicit AB predictor
libmesh_assert_not_equal_to (previous_ds, 0.0);
const Real stepratio = ds_current/previous_ds;
// Build up next solution value.
solution->add( 0.5*ds_current*(2.+stepratio), *du_ds);
solution->add(-0.5*ds_current*stepratio , *previous_du_ds);
solution->close();
// Next parameter value
*continuation_parameter +=
0.5*ds_current*((2.+stepratio)*dlambda_ds -
stepratio*previous_dlambda_ds);
}
else
libmesh_error_msg("Unknown predictor!");
}
| void libMesh::DifferentiableSystem::assemble | ( | ) | [virtual, inherited] |
Prepares matrix and rhs for matrix assembly. Users should not reimplement this
Reimplemented from libMesh::ImplicitSystem.
Definition at line 125 of file diff_system.C.
References libMesh::DifferentiableSystem::assembly().
{
this->assembly(true, true);
}
| void libMesh::FEMSystem::assemble_qoi | ( | const QoISet & | indices = QoISet() | ) | [virtual, inherited] |
Runs a qoi assembly loop over all elements, and if assemble_qoi_sides is true over all sides.
Users may have to override this function if they have any quantities of interest that are not expressible as a sum of element qois.
Reimplemented from libMesh::ExplicitSystem.
Definition at line 1108 of file fem_system.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::ParallelObject::comm(), libMesh::DifferentiableSystem::diff_qoi, libMesh::System::get_mesh(), libMesh::QoISet::has_index(), mesh, libMesh::DifferentiableQoI::parallel_op(), libMesh::Threads::parallel_reduce(), libMesh::System::qoi, libMesh::START_LOG(), and libMesh::System::update().
{
START_LOG("assemble_qoi()", "FEMSystem");
const MeshBase& mesh = this->get_mesh();
this->update();
const unsigned int Nq = cast_int<unsigned int>(qoi.size());
// the quantity of interest is assumed to be a sum of element and
// side terms
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
qoi[i] = 0;
// Create a non-temporary qoi_contributions object, so we can query
// its results after the reduction
QoIContributions qoi_contributions(*this, *(this->diff_qoi), qoi_indices);
// Loop over every active mesh element on this processor
Threads::parallel_reduce(elem_range.reset(mesh.active_local_elements_begin(),
mesh.active_local_elements_end()),
qoi_contributions);
this->diff_qoi->parallel_op( this->comm(), this->qoi, qoi_contributions.qoi, qoi_indices );
STOP_LOG("assemble_qoi()", "FEMSystem");
}
| void libMesh::FEMSystem::assemble_qoi_derivative | ( | const QoISet & | qoi_indices = QoISet(), |
| bool | include_liftfunc = true, |
||
| bool | apply_constraints = true |
||
| ) | [virtual, inherited] |
Runs a qoi derivative assembly loop over all elements, and if assemble_qoi_sides is true over all sides.
Users may have to override this function for quantities of interest that are not expressible as a sum of element qois.
Reimplemented from libMesh::ExplicitSystem.
Definition at line 1140 of file fem_system.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::System::add_adjoint_rhs(), libMesh::DifferentiableSystem::diff_qoi, libMesh::System::get_mesh(), libMesh::QoISet::has_index(), mesh, libMesh::Threads::parallel_for(), libMesh::System::qoi, libMesh::START_LOG(), libMesh::System::update(), and libMesh::NumericVector< T >::zero().
{
START_LOG("assemble_qoi_derivative()", "FEMSystem");
const MeshBase& mesh = this->get_mesh();
this->update();
// The quantity of interest derivative assembly accumulates on
// initially zero vectors
for (unsigned int i=0; i != qoi.size(); ++i)
if (qoi_indices.has_index(i))
this->add_adjoint_rhs(i).zero();
// Loop over every active mesh element on this processor
Threads::parallel_for(elem_range.reset(mesh.active_local_elements_begin(),
mesh.active_local_elements_end()),
QoIDerivativeContributions(*this, qoi_indices,
*(this->diff_qoi),
include_liftfunc,
apply_constraints));
STOP_LOG("assemble_qoi_derivative()", "FEMSystem");
}
| void libMesh::ImplicitSystem::assemble_residual_derivatives | ( | const ParameterVector & | parameters | ) | [virtual, inherited] |
Residual parameter derivative function.
Uses finite differences by default.
This will assemble the sensitivity rhs vectors to hold -(partial R / partial p_i), making them ready to solve the forward sensitivity equation.
Can be overloaded in derived classes.
Reimplemented from libMesh::System.
Definition at line 660 of file implicit_system.C.
References libMesh::System::add_sensitivity_rhs(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.
Referenced by libMesh::ImplicitSystem::sensitivity_solve().
{
Real deltap = TOLERANCE;
ParameterVector& parameters =
const_cast<ParameterVector&>(parameters_in);
const unsigned int Np = cast_int<unsigned int>
(parameters.size());
for (unsigned int p=0; p != Np; ++p)
{
NumericVector<Number> &sensitivity_rhs = this->add_sensitivity_rhs(p);
// Approximate -(partial R / partial p) by
// (R(p-dp) - R(p+dp)) / (2*dp)
Number old_parameter = *parameters[p];
*parameters[p] -= deltap;
this->assembly(true, false, true);
this->rhs->close();
sensitivity_rhs = *this->rhs;
*parameters[p] = old_parameter + deltap;
this->assembly(true, false, true);
this->rhs->close();
sensitivity_rhs -= *this->rhs;
sensitivity_rhs /= (2*deltap);
sensitivity_rhs.close();
*parameters[p] = old_parameter;
}
}
| void libMesh::FEMSystem::assembly | ( | bool | get_residual, |
| bool | get_jacobian, | ||
| bool | apply_heterogeneous_constraints = false |
||
| ) | [virtual, inherited] |
Prepares matrix or rhs for matrix assembly. Users may reimplement this to add pre- or post-assembly code before or after calling FEMSystem::assembly()
Implements libMesh::DifferentiableSystem.
Definition at line 831 of file fem_system.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::DenseMatrix< T >::add(), libMesh::FEMSystem::build_context(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::err, libMesh::FEType::family, libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::System::get_mesh(), libMesh::FEMSystem::init_context(), libMesh::NumericVector< T >::l1_norm(), libMesh::DenseMatrix< T >::l1_norm(), libMesh::SparseMatrix< T >::l1_norm(), libMesh::libmesh_assert(), libMesh::ImplicitSystem::matrix, std::max(), mesh, libMesh::ParallelObject::n_processors(), libMesh::System::n_variable_groups(), libMesh::FEMSystem::numerical_nonlocal_jacobian(), libMesh::out, libMesh::Threads::parallel_for(), libMesh::FEMContext::pre_fe_reinit(), libMesh::BasicOStreamProxy< charT, traits >::precision(), libMesh::DifferentiableSystem::print_jacobian_norms, libMesh::DifferentiableSystem::print_jacobians, libMesh::DifferentiableSystem::print_residual_norms, libMesh::DifferentiableSystem::print_residuals, libMesh::DifferentiableSystem::print_solution_norms, libMesh::DifferentiableSystem::print_solutions, libMesh::ParallelObject::processor_id(), libMesh::Real, libMesh::ExplicitSystem::rhs, libMesh::SCALAR, libMesh::DenseVector< T >::size(), libMesh::System::solution, libMesh::START_LOG(), libMesh::DifferentiableSystem::time_solver, libMesh::Variable::type(), libMesh::System::update(), libMesh::System::variable_group(), libMesh::FEMSystem::verify_analytic_jacobians, libMesh::DenseMatrix< T >::zero(), libMesh::NumericVector< T >::zero(), and libMesh::SparseMatrix< T >::zero().
Referenced by continuation_solve(), and solve_tangent().
{
libmesh_assert(get_residual || get_jacobian);
std::string log_name;
if (get_residual && get_jacobian)
log_name = "assembly()";
else if (get_residual)
log_name = "assembly(get_residual)";
else
log_name = "assembly(get_jacobian)";
START_LOG(log_name, "FEMSystem");
const MeshBase& mesh = this->get_mesh();
// this->get_vector("_nonlinear_solution").localize
// (*current_local_nonlinear_solution,
// dof_map.get_send_list());
this->update();
if (print_solution_norms)
{
// this->get_vector("_nonlinear_solution").close();
this->solution->close();
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out << "|U| = "
// << this->get_vector("_nonlinear_solution").l1_norm()
<< this->solution->l1_norm()
<< std::endl;
libMesh::out.precision(old_precision);
}
if (print_solutions)
{
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
// libMesh::out << "U = [" << this->get_vector("_nonlinear_solution")
libMesh::out << "U = [" << *(this->solution)
<< "];" << std::endl;
libMesh::out.precision(old_precision);
}
// Is this definitely necessary? [RHS]
// Yes. [RHS 2012]
if (get_jacobian)
matrix->zero();
if (get_residual)
rhs->zero();
// Stupid C++ lets you set *Real* verify_analytic_jacobians = true!
if (verify_analytic_jacobians > 0.5)
{
libMesh::err << "WARNING! verify_analytic_jacobians was set "
<< "to absurdly large value of "
<< verify_analytic_jacobians << std::endl;
libMesh::err << "Resetting to 1e-6!" << std::endl;
verify_analytic_jacobians = 1e-6;
}
// In time-dependent problems, the nonlinear function we're trying
// to solve at each timestep may depend on the particular solver
// we're using
libmesh_assert(time_solver.get());
// Build the residual and jacobian contributions on every active
// mesh element on this processor
Threads::parallel_for
(elem_range.reset(mesh.active_local_elements_begin(),
mesh.active_local_elements_end()),
AssemblyContributions(*this, get_residual, get_jacobian,
apply_heterogeneous_constraints));
// Check and see if we have SCALAR variables
bool have_scalar = false;
for(unsigned int i=0; i != this->n_variable_groups(); ++i)
{
if( this->variable_group(i).type().family == SCALAR )
{
have_scalar = true;
break;
}
}
// SCALAR dofs are stored on the last processor, so we'll evaluate
// their equation terms there and only if we have a SCALAR variable
if ( this->processor_id() == (this->n_processors()-1) && have_scalar )
{
UniquePtr<DiffContext> con = this->build_context();
FEMContext &_femcontext = cast_ref<FEMContext&>(*con);
this->init_context(_femcontext);
_femcontext.pre_fe_reinit(*this, NULL);
bool jacobian_computed =
this->time_solver->nonlocal_residual(get_jacobian, _femcontext);
// Nonlocal residuals are likely to be length 0, in which case we
// don't need to do any more. And we shouldn't try to do any
// more; lots of DenseVector/DenseMatrix code assumes rank>0.
if (_femcontext.get_elem_residual().size())
{
// Compute a numeric jacobian if we have to
if (get_jacobian && !jacobian_computed)
{
// Make sure we didn't compute a jacobian and lie about it
libmesh_assert_equal_to (_femcontext.get_elem_jacobian().l1_norm(), 0.0);
// Logging of numerical jacobians is done separately
this->numerical_nonlocal_jacobian(_femcontext);
}
// Compute a numeric jacobian if we're asked to verify the
// analytic jacobian we got
if (get_jacobian && jacobian_computed &&
this->verify_analytic_jacobians != 0.0)
{
DenseMatrix<Number> analytic_jacobian(_femcontext.get_elem_jacobian());
_femcontext.get_elem_jacobian().zero();
// Logging of numerical jacobians is done separately
this->numerical_nonlocal_jacobian(_femcontext);
Real analytic_norm = analytic_jacobian.l1_norm();
Real numerical_norm = _femcontext.get_elem_jacobian().l1_norm();
// If we can continue, we'll probably prefer the analytic jacobian
analytic_jacobian.swap(_femcontext.get_elem_jacobian());
// The matrix "analytic_jacobian" will now hold the error matrix
analytic_jacobian.add(-1.0, _femcontext.get_elem_jacobian());
Real error_norm = analytic_jacobian.l1_norm();
Real relative_error = error_norm /
std::max(analytic_norm, numerical_norm);
if (relative_error > this->verify_analytic_jacobians)
{
libMesh::err << "Relative error " << relative_error
<< " detected in analytic jacobian on nonlocal dofs!"
<< std::endl;
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out << "J_analytic nonlocal = "
<< _femcontext.get_elem_jacobian() << std::endl;
analytic_jacobian.add(1.0, _femcontext.get_elem_jacobian());
libMesh::out << "J_numeric nonlocal = "
<< analytic_jacobian << std::endl;
libMesh::out.precision(old_precision);
libmesh_error_msg("Relative error too large, exiting!");
}
}
add_element_system
(*this, get_residual, get_jacobian,
apply_heterogeneous_constraints, _femcontext);
}
}
if (get_residual && (print_residual_norms || print_residuals))
this->rhs->close();
if (get_residual && print_residual_norms)
{
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out << "|F| = " << this->rhs->l1_norm() << std::endl;
libMesh::out.precision(old_precision);
}
if (get_residual && print_residuals)
{
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out << "F = [" << *(this->rhs) << "];" << std::endl;
libMesh::out.precision(old_precision);
}
if (get_jacobian && (print_jacobian_norms || print_jacobians))
this->matrix->close();
if (get_jacobian && print_jacobian_norms)
{
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out << "|J| = " << this->matrix->l1_norm() << std::endl;
libMesh::out.precision(old_precision);
}
if (get_jacobian && print_jacobians)
{
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out << "J = [" << *(this->matrix) << "];" << std::endl;
libMesh::out.precision(old_precision);
}
STOP_LOG(log_name, "FEMSystem");
}
| void libMesh::System::attach_assemble_function | ( | void | fptrEquationSystems &es,const std::string &name | ) | [inherited] |
Register a user function to use in assembling the system matrix and RHS.
Definition at line 1779 of file system.C.
References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, libMesh::libmesh_assert(), and libMesh::out.
{
libmesh_assert(fptr);
if (_assemble_system_object != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both assembly function and object!"
<< std::endl;
_assemble_system_object = NULL;
}
_assemble_system_function = fptr;
}
| void libMesh::System::attach_assemble_object | ( | System::Assembly & | assemble_in | ) | [inherited] |
Register a user object to use in assembling the system matrix and RHS.
Definition at line 1798 of file system.C.
References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, and libMesh::out.
{
if (_assemble_system_function != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both assembly object and function!"
<< std::endl;
_assemble_system_function = NULL;
}
_assemble_system_object = &assemble_in;
}
| void libMesh::System::attach_constraint_function | ( | void | fptrEquationSystems &es,const std::string &name | ) | [inherited] |
Register a user function for imposing constraints.
Definition at line 1814 of file system.C.
References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, libMesh::libmesh_assert(), and libMesh::out.
{
libmesh_assert(fptr);
if (_constrain_system_object != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both constraint function and object!"
<< std::endl;
_constrain_system_object = NULL;
}
_constrain_system_function = fptr;
}
| void libMesh::System::attach_constraint_object | ( | System::Constraint & | constrain | ) | [inherited] |
Register a user object for imposing constraints.
Definition at line 1833 of file system.C.
References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, and libMesh::out.
{
if (_constrain_system_function != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both constraint object and function!"
<< std::endl;
_constrain_system_function = NULL;
}
_constrain_system_object = &constrain;
}
| void libMesh::System::attach_init_function | ( | void | fptrEquationSystems &es,const std::string &name | ) | [inherited] |
Register a user function to use in initializing the system.
Definition at line 1744 of file system.C.
References libMesh::System::_init_system_function, libMesh::System::_init_system_object, libMesh::libmesh_assert(), and libMesh::out.
{
libmesh_assert(fptr);
if (_init_system_object != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both initialization function and object!"
<< std::endl;
_init_system_object = NULL;
}
_init_system_function = fptr;
}
| void libMesh::System::attach_init_object | ( | System::Initialization & | init_in | ) | [inherited] |
Register a user class to use to initialize the system. Note this is exclusive with the attach_init_function.
Definition at line 1763 of file system.C.
References libMesh::System::_init_system_function, libMesh::System::_init_system_object, and libMesh::out.
{
if (_init_system_function != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both initialization object and function!"
<< std::endl;
_init_system_function = NULL;
}
_init_system_object = &init_in;
}
| void libMesh::DifferentiableSystem::attach_physics | ( | DifferentiablePhysics * | physics_in | ) | [inline, inherited] |
Attach external Physics object.
Definition at line 181 of file diff_system.h.
References libMesh::DifferentiableSystem::_diff_physics, libMesh::DifferentiablePhysics::clone_physics(), and libMesh::DifferentiablePhysics::init_physics().
{ this->_diff_physics = (physics_in->clone_physics()).release();
this->_diff_physics->init_physics(*this);}
| void libMesh::DifferentiableSystem::attach_qoi | ( | DifferentiableQoI * | qoi_in | ) | [inline, inherited] |
Attach external QoI object.
Definition at line 202 of file diff_system.h.
References libMesh::DifferentiableQoI::clone(), libMesh::DifferentiableSystem::diff_qoi, libMesh::DifferentiableQoI::init_qoi(), and libMesh::System::qoi.
| void libMesh::System::attach_QOI_derivative | ( | void | fptrEquationSystems &es,const std::string &name,const QoISet &qoi_indices,bool include_liftfunc,bool apply_constraints | ) | [inherited] |
Register a user function for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs
Definition at line 1885 of file system.C.
References libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, libMesh::libmesh_assert(), and libMesh::out.
{
libmesh_assert(fptr);
if (_qoi_evaluate_derivative_object != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both QOI derivative function and object!"
<< std::endl;
_qoi_evaluate_derivative_object = NULL;
}
_qoi_evaluate_derivative_function = fptr;
}
| void libMesh::System::attach_QOI_derivative_object | ( | QOIDerivative & | qoi_derivative | ) | [inherited] |
Register a user object for evaluating derivatives of a quantity of interest with respect to test functions, whose values should be placed in System::rhs
Definition at line 1904 of file system.C.
References libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, and libMesh::out.
{
if (_qoi_evaluate_derivative_function != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both QOI derivative object and function!"
<< std::endl;
_qoi_evaluate_derivative_function = NULL;
}
_qoi_evaluate_derivative_object = &qoi_derivative;
}
| void libMesh::System::attach_QOI_function | ( | void | fptrEquationSystems &es,const std::string &name,const QoISet &qoi_indices | ) | [inherited] |
Register a user function for evaluating the quantities of interest, whose values should be placed in System::qoi
Definition at line 1849 of file system.C.
References libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, libMesh::libmesh_assert(), and libMesh::out.
{
libmesh_assert(fptr);
if (_qoi_evaluate_object != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both QOI function and object!"
<< std::endl;
_qoi_evaluate_object = NULL;
}
_qoi_evaluate_function = fptr;
}
| void libMesh::System::attach_QOI_object | ( | QOI & | qoi | ) | [inherited] |
Register a user object for evaluating the quantities of interest, whose values should be placed in System::qoi
Definition at line 1869 of file system.C.
References libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, and libMesh::out.
{
if (_qoi_evaluate_function != NULL)
{
libmesh_here();
libMesh::out << "WARNING: Cannot specify both QOI object and function!"
<< std::endl;
_qoi_evaluate_function = NULL;
}
_qoi_evaluate_object = &qoi_in;
}
| void libMesh::System::boundary_project_solution | ( | const std::set< boundary_id_type > & | b, |
| const std::vector< unsigned int > & | variables, | ||
| FunctionBase< Number > * | f, | ||
| FunctionBase< Gradient > * | g = NULL |
||
| ) | [inherited] |
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
This method projects an arbitary boundary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 678 of file system_projection.C.
{
this->boundary_project_vector(b, variables, *solution, f, g);
solution->localize(*current_local_solution);
}
| void libMesh::System::boundary_project_solution | ( | const std::set< boundary_id_type > & | b, |
| const std::vector< unsigned int > & | variables, | ||
| Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | ||
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | ||
| const Parameters & | parameters | ||
| ) | [inherited] |
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
This method projects components of an arbitrary boundary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 654 of file system_projection.C.
{
WrappedFunction<Number> f(*this, fptr, ¶meters);
WrappedFunction<Gradient> g(*this, gptr, ¶meters);
this->boundary_project_solution(b, variables, &f, &g);
}
| void libMesh::System::boundary_project_vector | ( | const std::set< boundary_id_type > & | b, |
| const std::vector< unsigned int > & | variables, | ||
| NumericVector< Number > & | new_vector, | ||
| FunctionBase< Number > * | f, | ||
| FunctionBase< Gradient > * | g = NULL, |
||
| int | is_adjoint = -1 |
||
| ) | const [inherited] |
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.
This method projects an arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 722 of file system_projection.C.
References libMesh::NumericVector< T >::close(), libMesh::get_dof_map(), libMesh::Threads::parallel_for(), and libMesh::START_LOG().
{
START_LOG ("boundary_project_vector()", "System");
Threads::parallel_for
(ConstElemRange (this->get_mesh().active_local_elements_begin(),
this->get_mesh().active_local_elements_end() ),
BoundaryProjectSolution(b, variables, *this, f, g,
this->get_equation_systems().parameters,
new_vector)
);
// We don't do SCALAR dofs when just projecting the boundary, so
// we're done here.
new_vector.close();
#ifdef LIBMESH_ENABLE_CONSTRAINTS
if (is_adjoint == -1)
this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
else if (is_adjoint >= 0)
this->get_dof_map().enforce_adjoint_constraints_exactly(new_vector,
is_adjoint);
#endif
STOP_LOG("boundary_project_vector()", "System");
}
| void libMesh::System::boundary_project_vector | ( | const std::set< boundary_id_type > & | b, |
| const std::vector< unsigned int > & | variables, | ||
| Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | ||
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | ||
| const Parameters & | parameters, | ||
| NumericVector< Number > & | new_vector, | ||
| int | is_adjoint = -1 |
||
| ) | const [inherited] |
Projects arbitrary boundary functions onto a vector of degree of freedom values for the current system. Only degrees of freedom which affect the function's trace on a boundary in the set b are affected. Only degrees of freedom associated with the variables listed in the vector variables are projected. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.
This method projects an arbitrary boundary function via L2 projections and nodal interpolations on each element.
Definition at line 697 of file system_projection.C.
{
WrappedFunction<Number> f(*this, fptr, ¶meters);
WrappedFunction<Gradient> g(*this, gptr, ¶meters);
this->boundary_project_vector(b, variables, new_vector, &f, &g,
is_adjoint);
}
| UniquePtr< DiffContext > libMesh::FEMSystem::build_context | ( | ) | [virtual, inherited] |
Builds a FEMContext object with enough information to do evaluations on each element.
For most problems, the default FEMSystem implementation is correct; users who subclass FEMContext will need to also reimplement this method to build it.
Reimplemented from libMesh::DifferentiableSystem.
Definition at line 1299 of file fem_system.C.
References libMesh::DifferentiableSystem::deltat, libMesh::DifferentiablePhysics::get_mesh_system(), libMesh::DifferentiablePhysics::get_mesh_x_var(), libMesh::DifferentiablePhysics::get_mesh_y_var(), libMesh::DifferentiablePhysics::get_mesh_z_var(), libMesh::DifferentiableSystem::get_physics(), libMesh::DifferentiableSystem::get_time_solver(), libMesh::TimeSolver::is_adjoint(), libMesh::DiffContext::is_adjoint(), libMesh::libmesh_assert(), libMesh::DiffContext::set_deltat_pointer(), libMesh::FEMContext::set_mesh_system(), libMesh::FEMContext::set_mesh_x_var(), libMesh::FEMContext::set_mesh_y_var(), and libMesh::FEMContext::set_mesh_z_var().
Referenced by libMesh::FEMSystem::assembly(), libMesh::FEMSystem::mesh_position_get(), and libMesh::FEMSystem::mesh_position_set().
{
FEMContext* fc = new FEMContext(*this);
DifferentiablePhysics* phys = this->get_physics();
libmesh_assert (phys);
// If we are solving a moving mesh problem, tell that to the Context
fc->set_mesh_system(phys->get_mesh_system());
fc->set_mesh_x_var(phys->get_mesh_x_var());
fc->set_mesh_y_var(phys->get_mesh_y_var());
fc->set_mesh_z_var(phys->get_mesh_z_var());
fc->set_deltat_pointer( &deltat );
// If we are solving the adjoint problem, tell that to the Context
fc->is_adjoint() = this->get_time_solver().is_adjoint();
return UniquePtr<DiffContext>(fc);
}
| Real libMesh::System::calculate_norm | ( | const NumericVector< Number > & | v, |
| unsigned int | var, | ||
| FEMNormType | norm_type | ||
| ) | const [inherited] |
var in the vector v, in the specified norm (e.g. L2, L_INF, H1) Definition at line 1405 of file system.C.
References libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::L2, libMesh::System::n_vars(), and libMesh::Real.
Referenced by libMesh::AdaptiveTimeSolver::calculate_norm(), and libMesh::UnsteadySolver::du().
{
//short circuit to save time
if(norm_type == DISCRETE_L1 ||
norm_type == DISCRETE_L2 ||
norm_type == DISCRETE_L_INF)
return discrete_var_norm(v,var,norm_type);
// Not a discrete norm
std::vector<FEMNormType> norms(this->n_vars(), L2);
std::vector<Real> weights(this->n_vars(), 0.0);
norms[var] = norm_type;
weights[var] = 1.0;
Real val = this->calculate_norm(v, SystemNorm(norms, weights));
return val;
}
| Real libMesh::System::calculate_norm | ( | const NumericVector< Number > & | v, |
| const SystemNorm & | norm | ||
| ) | const [inherited] |
v, using component_norm and component_scale to choose and weight the norms of each variable. Definition at line 1426 of file system.C.
References libMesh::System::_dof_map, std::abs(), libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::TypeVector< T >::add_scaled(), libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::ParallelObject::comm(), libMesh::FEType::default_quadrature_rule(), libMesh::DISCRETE_L1, libMesh::DISCRETE_L2, libMesh::DISCRETE_L_INF, libMesh::System::discrete_var_norm(), libMesh::DofMap::dof_indices(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::H1, libMesh::H1_SEMINORM, libMesh::H2, libMesh::H2_SEMINORM, libMesh::SystemNorm::is_discrete(), libMesh::L1, libMesh::NumericVector< T >::l1_norm(), libMesh::L2, libMesh::NumericVector< T >::l2_norm(), libMesh::L_INF, libMesh::NumericVector< T >::linfty_norm(), libMesh::NumericVector< T >::localize(), std::max(), libMesh::Parallel::Communicator::max(), libMesh::MeshBase::mesh_dimension(), libMesh::System::n_vars(), libMesh::TensorTools::norm_sq(), libMesh::Real, libMesh::SERIAL, libMesh::TypeVector< T >::size(), libMesh::TypeTensor< T >::size(), libMesh::NumericVector< T >::size(), libMesh::TypeVector< T >::size_sq(), libMesh::TypeTensor< T >::size_sq(), libMesh::START_LOG(), libMesh::Parallel::Communicator::sum(), libMesh::SystemNorm::type(), libMesh::DofMap::variable_type(), libMesh::W1_INF_SEMINORM, libMesh::W2_INF_SEMINORM, libMesh::SystemNorm::weight(), and libMesh::SystemNorm::weight_sq().
{
// This function must be run on all processors at once
parallel_object_only();
START_LOG ("calculate_norm()", "System");
// Zero the norm before summation
Real v_norm = 0.;
if (norm.is_discrete())
{
STOP_LOG ("calculate_norm()", "System");
//Check to see if all weights are 1.0 and all types are equal
FEMNormType norm_type0 = norm.type(0);
unsigned int check_var = 0;
for (; check_var != this->n_vars(); ++check_var)
if((norm.weight(check_var) != 1.0) || (norm.type(check_var) != norm_type0))
break;
//All weights were 1.0 so just do the full vector discrete norm
if(check_var == this->n_vars())
{
if(norm_type0 == DISCRETE_L1)
return v.l1_norm();
if(norm_type0 == DISCRETE_L2)
return v.l2_norm();
if(norm_type0 == DISCRETE_L_INF)
return v.linfty_norm();
else
libmesh_error_msg("Invalid norm_type0 = " << norm_type0);
}
for (unsigned int var=0; var != this->n_vars(); ++var)
{
// Skip any variables we don't need to integrate
if (norm.weight(var) == 0.0)
continue;
v_norm += norm.weight(var) * discrete_var_norm(v, var, norm.type(var));
}
return v_norm;
}
// Localize the potentially parallel vector
UniquePtr<NumericVector<Number> > local_v = NumericVector<Number>::build(this->comm());
local_v->init(v.size(), true, SERIAL);
v.localize (*local_v, _dof_map->get_send_list());
unsigned int dim = this->get_mesh().mesh_dimension();
// I'm not sure how best to mix Hilbert norms on some variables (for
// which we'll want to square then sum then square root) with norms
// like L_inf (for which we'll just want to take an absolute value
// and then sum).
bool using_hilbert_norm = true,
using_nonhilbert_norm = true;
// Loop over all variables
for (unsigned int var=0; var != this->n_vars(); ++var)
{
// Skip any variables we don't need to integrate
Real norm_weight_sq = norm.weight_sq(var);
if (norm_weight_sq == 0.0)
continue;
Real norm_weight = norm.weight(var);
// Check for unimplemented norms (rather than just returning 0).
FEMNormType norm_type = norm.type(var);
if((norm_type==H1) ||
(norm_type==H2) ||
(norm_type==L2) ||
(norm_type==H1_SEMINORM) ||
(norm_type==H2_SEMINORM))
{
if (!using_hilbert_norm)
libmesh_not_implemented();
using_nonhilbert_norm = false;
}
else if ((norm_type==L1) ||
(norm_type==L_INF) ||
(norm_type==W1_INF_SEMINORM) ||
(norm_type==W2_INF_SEMINORM))
{
if (!using_nonhilbert_norm)
libmesh_not_implemented();
using_hilbert_norm = false;
}
else
libmesh_not_implemented();
const FEType& fe_type = this->get_dof_map().variable_type(var);
UniquePtr<QBase> qrule =
fe_type.default_quadrature_rule (dim);
UniquePtr<FEBase> fe
(FEBase::build(dim, fe_type));
fe->attach_quadrature_rule (qrule.get());
const std::vector<Real>& JxW = fe->get_JxW();
const std::vector<std::vector<Real> >* phi = NULL;
if (norm_type == H1 ||
norm_type == H2 ||
norm_type == L2 ||
norm_type == L1 ||
norm_type == L_INF)
phi = &(fe->get_phi());
const std::vector<std::vector<RealGradient> >* dphi = NULL;
if (norm_type == H1 ||
norm_type == H2 ||
norm_type == H1_SEMINORM ||
norm_type == W1_INF_SEMINORM)
dphi = &(fe->get_dphi());
#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
const std::vector<std::vector<RealTensor> >* d2phi = NULL;
if (norm_type == H2 ||
norm_type == H2_SEMINORM ||
norm_type == W2_INF_SEMINORM)
d2phi = &(fe->get_d2phi());
#endif
std::vector<dof_id_type> dof_indices;
// Begin the loop over the elements
MeshBase::const_element_iterator el =
this->get_mesh().active_local_elements_begin();
const MeshBase::const_element_iterator end_el =
this->get_mesh().active_local_elements_end();
for ( ; el != end_el; ++el)
{
const Elem* elem = *el;
fe->reinit (elem);
this->get_dof_map().dof_indices (elem, dof_indices, var);
const unsigned int n_qp = qrule->n_points();
const unsigned int n_sf = cast_int<unsigned int>
(dof_indices.size());
// Begin the loop over the Quadrature points.
for (unsigned int qp=0; qp<n_qp; qp++)
{
if (norm_type == L1)
{
Number u_h = 0.;
for (unsigned int i=0; i != n_sf; ++i)
u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
v_norm += norm_weight *
JxW[qp] * std::abs(u_h);
}
if (norm_type == L_INF)
{
Number u_h = 0.;
for (unsigned int i=0; i != n_sf; ++i)
u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
v_norm = std::max(v_norm, norm_weight * std::abs(u_h));
}
if (norm_type == H1 ||
norm_type == H2 ||
norm_type == L2)
{
Number u_h = 0.;
for (unsigned int i=0; i != n_sf; ++i)
u_h += (*phi)[i][qp] * (*local_v)(dof_indices[i]);
v_norm += norm_weight_sq *
JxW[qp] * TensorTools::norm_sq(u_h);
}
if (norm_type == H1 ||
norm_type == H2 ||
norm_type == H1_SEMINORM)
{
Gradient grad_u_h;
for (unsigned int i=0; i != n_sf; ++i)
grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
v_norm += norm_weight_sq *
JxW[qp] * grad_u_h.size_sq();
}
if (norm_type == W1_INF_SEMINORM)
{
Gradient grad_u_h;
for (unsigned int i=0; i != n_sf; ++i)
grad_u_h.add_scaled((*dphi)[i][qp], (*local_v)(dof_indices[i]));
v_norm = std::max(v_norm, norm_weight * grad_u_h.size());
}
#ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
if (norm_type == H2 ||
norm_type == H2_SEMINORM)
{
Tensor hess_u_h;
for (unsigned int i=0; i != n_sf; ++i)
hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
v_norm += norm_weight_sq *
JxW[qp] * hess_u_h.size_sq();
}
if (norm_type == W2_INF_SEMINORM)
{
Tensor hess_u_h;
for (unsigned int i=0; i != n_sf; ++i)
hess_u_h.add_scaled((*d2phi)[i][qp], (*local_v)(dof_indices[i]));
v_norm = std::max(v_norm, norm_weight * hess_u_h.size());
}
#endif
}
}
}
if (using_hilbert_norm)
{
this->comm().sum(v_norm);
v_norm = std::sqrt(v_norm);
}
else
{
this->comm().max(v_norm);
}
STOP_LOG ("calculate_norm()", "System");
return v_norm;
}
| void libMesh::ContinuationSystem::clear | ( | ) | [virtual] |
Clear all the data structures associated with the system.
Reimplemented from libMesh::FEMSystem.
Definition at line 81 of file continuation_system.C.
References libMesh::FEMSystem::clear().
Referenced by ~ContinuationSystem().
{
// FIXME: Do anything here, e.g. zero vectors, etc?
// Call the Parent's clear function
Parent::clear();
}
| virtual void libMesh::DifferentiablePhysics::clear_physics | ( | ) | [virtual, inherited] |
Clear any data structures associated with the physics.
Referenced by libMesh::DifferentiableSystem::clear().
| virtual void libMesh::DifferentiableQoI::clear_qoi | ( | ) | [inline, virtual, inherited] |
Clear all the data structures associated with the QoI.
Definition at line 75 of file diff_qoi.h.
Referenced by libMesh::DifferentiableSystem::clear().
{}
| virtual UniquePtr<DifferentiableQoI> libMesh::DifferentiableSystem::clone | ( | ) | [inline, virtual, inherited] |
We don't allow systems to be attached to each other
Implements libMesh::DifferentiableQoI.
Definition at line 156 of file diff_system.h.
{
libmesh_not_implemented();
// dummy
return UniquePtr<DifferentiableQoI>(this);
}
| virtual UniquePtr<DifferentiablePhysics> libMesh::DifferentiableSystem::clone_physics | ( | ) | [inline, virtual, inherited] |
We don't allow systems to be attached to each other
Implements libMesh::DifferentiablePhysics.
Definition at line 146 of file diff_system.h.
{
libmesh_not_implemented();
// dummy
return UniquePtr<DifferentiablePhysics>(this);
}
| const Parallel::Communicator& libMesh::ParallelObject::comm | ( | ) | const [inline, inherited] |
Parallel::Communicator object used by this mesh. Definition at line 86 of file parallel_object.h.
References libMesh::ParallelObject::_communicator.
Referenced by libMesh::__libmesh_petsc_diff_solver_monitor(), libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_residual(), libMesh::MeshRefinement::_coarsen_elements(), libMesh::ExactSolution::_compute_error(), libMesh::MetisPartitioner::_do_partition(), libMesh::ParmetisPartitioner::_do_repartition(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_get_diagonal(), libMesh::SlepcEigenSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult(), libMesh::PetscLinearSolver< T >::_petsc_shell_matrix_mult_add(), libMesh::EquationSystems::_read_impl(), libMesh::MeshRefinement::_refine_elements(), libMesh::ImplicitSystem::add_matrix(), libMesh::System::add_vector(), libMesh::UnstructuredMesh::all_second_order(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assemble_qoi(), libMesh::MeshCommunication::assign_global_indices(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::DofMap::attach_matrix(), libMesh::MeshTools::bounding_box(), libMesh::MeshBase::cache_elem_dims(), libMesh::System::calculate_norm(), libMesh::MeshRefinement::coarsen_elements(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::MeshTools::correct_node_proc_ids(), libMesh::MeshCommunication::delete_remote_elements(), libMesh::DofMap::distribute_dofs(), DMlibMeshFunction(), DMlibMeshSetSystem_libMesh(), libMesh::MeshRefinement::eliminate_unrefined_patches(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::MeshRefinement::flag_elements_by_elem_fraction(), libMesh::MeshRefinement::flag_elements_by_error_fraction(), libMesh::MeshRefinement::flag_elements_by_nelem_target(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::LocationMap< T >::init(), libMesh::TimeSolver::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::EigenSystem::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ParmetisPartitioner::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::ParallelMesh::libmesh_assert_valid_parallel_flags(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::MeshRefinement::limit_level_mismatch_at_edge(), libMesh::MeshRefinement::limit_level_mismatch_at_node(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshCommunication::make_elems_parallel_consistent(), libMesh::MeshRefinement::make_flags_parallel_consistent(), libMesh::MeshCommunication::make_node_ids_parallel_consistent(), libMesh::MeshCommunication::make_node_proc_ids_parallel_consistent(), libMesh::MeshCommunication::make_nodes_parallel_consistent(), libMesh::MeshRefinement::make_refinement_compatible(), libMesh::FEMSystem::mesh_position_set(), libMesh::MeshSerializer::MeshSerializer(), libMesh::ParallelMesh::n_active_elem(), libMesh::MeshTools::n_active_levels(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::MeshTools::n_levels(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::MeshTools::n_p_levels(), libMesh::ParallelMesh::parallel_max_elem_id(), libMesh::ParallelMesh::parallel_max_node_id(), libMesh::ParallelMesh::parallel_n_elem(), libMesh::ParallelMesh::parallel_n_nodes(), libMesh::Partitioner::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshBase::prepare_for_use(), libMesh::System::project_vector(), libMesh::Nemesis_IO::read(), libMesh::XdrIO::read(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::MeshBase::recalculate_n_partitions(), libMesh::MeshRefinement::refine_and_coarsen_elements(), libMesh::MeshRefinement::refine_elements(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::MeshBase::subdomain_ids(), libMesh::BoundaryInfo::sync(), libMesh::Parallel::sync_element_data_by_parent_id(), libMesh::Parallel::sync_node_data_by_element_id(), libMesh::MeshRefinement::test_level_one(), libMesh::MeshRefinement::test_unflagged(), libMesh::MeshTools::total_weight(), libMesh::NameBasedIO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::LegacyXdrIO::write_mesh(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), and libMesh::DivaIO::write_stream().
{ return _communicator; }
| bool libMesh::System::compare | ( | const System & | other_system, |
| const Real | threshold, | ||
| const bool | verbose | ||
| ) | const [virtual, inherited] |
true when the other system contains identical data, up to the given threshold. Outputs some diagnostic info when verbose is set. Definition at line 539 of file system.C.
References libMesh::System::_is_initialized, libMesh::System::_sys_name, libMesh::System::_vectors, libMesh::System::get_vector(), libMesh::libmesh_assert(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::out, and libMesh::System::solution.
Referenced by libMesh::EquationSystems::compare().
{
// we do not care for matrices, but for vectors
libmesh_assert (_is_initialized);
libmesh_assert (other_system._is_initialized);
if (verbose)
{
libMesh::out << " Systems \"" << _sys_name << "\"" << std::endl;
libMesh::out << " comparing matrices not supported." << std::endl;
libMesh::out << " comparing names...";
}
// compare the name: 0 means identical
const int name_result = _sys_name.compare(other_system.name());
if (verbose)
{
if (name_result == 0)
libMesh::out << " identical." << std::endl;
else
libMesh::out << " names not identical." << std::endl;
libMesh::out << " comparing solution vector...";
}
// compare the solution: -1 means identical
const int solu_result = solution->compare (*other_system.solution.get(),
threshold);
if (verbose)
{
if (solu_result == -1)
libMesh::out << " identical up to threshold." << std::endl;
else
libMesh::out << " first difference occured at index = "
<< solu_result << "." << std::endl;
}
// safety check, whether we handle at least the same number
// of vectors
std::vector<int> ov_result;
if (this->n_vectors() != other_system.n_vectors())
{
if (verbose)
{
libMesh::out << " Fatal difference. This system handles "
<< this->n_vectors() << " add'l vectors," << std::endl
<< " while the other system handles "
<< other_system.n_vectors()
<< " add'l vectors." << std::endl
<< " Aborting comparison." << std::endl;
}
return false;
}
else if (this->n_vectors() == 0)
{
// there are no additional vectors...
ov_result.clear ();
}
else
{
// compare other vectors
for (const_vectors_iterator pos = _vectors.begin();
pos != _vectors.end(); ++pos)
{
if (verbose)
libMesh::out << " comparing vector \""
<< pos->first << "\" ...";
// assume they have the same name
const NumericVector<Number>& other_system_vector =
other_system.get_vector(pos->first);
ov_result.push_back(pos->second->compare (other_system_vector,
threshold));
if (verbose)
{
if (ov_result[ov_result.size()-1] == -1)
libMesh::out << " identical up to threshold." << std::endl;
else
libMesh::out << " first difference occured at" << std::endl
<< " index = " << ov_result[ov_result.size()-1] << "." << std::endl;
}
}
} // finished comparing additional vectors
bool overall_result;
// sum up the results
if ((name_result==0) && (solu_result==-1))
{
if (ov_result.size()==0)
overall_result = true;
else
{
bool ov_identical;
unsigned int n = 0;
do
{
ov_identical = (ov_result[n]==-1);
n++;
}
while (ov_identical && n<ov_result.size());
overall_result = ov_identical;
}
}
else
overall_result = false;
if (verbose)
{
libMesh::out << " finished comparisons, ";
if (overall_result)
libMesh::out << "found no differences." << std::endl << std::endl;
else
libMesh::out << "found differences." << std::endl << std::endl;
}
return overall_result;
}
Perform a continuation solve of the system. In general, you can only begin the continuation solves after either reading in or solving for two previous values of the control parameter. The prior two solutions are required for starting up the continuation method.
Definition at line 359 of file continuation_system.C.
References std::abs(), libMesh::NumericVector< T >::add(), apply_predictor(), libMesh::FEMSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), continuation_parameter, continuation_parameter_tolerance, delta_u, dlambda_ds, libMesh::NumericVector< T >::dot(), ds_current, du_ds, G_Lambda, initial_newton_tolerance, initialize_tangent(), libMesh::NumericVector< T >::l2_norm(), libMesh::libmesh_real(), linear_solver, libMesh::ImplicitSystem::matrix, max_continuation_parameter, libMesh::DiffSolver::max_linear_iterations, libMesh::DiffSolver::max_nonlinear_iterations, std::min(), min_continuation_parameter, n_arclength_reductions, n_backtrack_steps, newton_progress_check, newton_solver, newton_step, old_continuation_parameter, libMesh::out, std::pow(), libMesh::BasicOStreamProxy< charT, traits >::precision(), previous_u, quiet, libMesh::Real, Residual, libMesh::ExplicitSystem::rhs, rhs_mode, libMesh::NumericVector< T >::scale(), libMesh::BasicOStreamProxy< charT, traits >::setf(), libMesh::System::solution, solution_tolerance, tangent_initialized, Theta, Theta_LOCA, libMesh::DifferentiableSystem::time_solver, libMesh::BasicOStreamProxy< charT, traits >::unsetf(), y, y_old, z, and libMesh::NumericVector< T >::zero().
{
// Be sure the user has set the continuation parameter pointer
if (!continuation_parameter)
libmesh_error_msg("You must set the continuation_parameter pointer " \
<< "to a member variable of the derived class, preferably in the " \
<< "Derived class's init_data function. This is how the ContinuationSystem " \
<< "updates the continuation parameter.");
// Use extra precision for all the numbers printed in this function.
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out.setf(std::ios_base::scientific);
// We can't start solving the augmented PDE system unless the tangent
// vectors have been initialized. This only needs to occur once.
if (!tangent_initialized)
initialize_tangent();
// Save the old value of -du/dlambda. This will be used after the Newton iterations
// to compute the angle between previous tangent vectors. This cosine of this angle is
//
// tau := abs( (du/d(lambda)_i , du/d(lambda)_{i-1}) / (||du/d(lambda)_i|| * ||du/d(lambda)_{i-1}||) )
//
// The scaling factor tau (which should vary between 0 and 1) is used to shrink the step-size ds
// when we are approaching a turning point. Note that it can only shrink the step size.
*y_old = *y;
// Set pointer to underlying Newton solver
if (!newton_solver)
newton_solver = cast_ptr<NewtonSolver*> (this->time_solver->diff_solver().get());
// A pair for catching return values from linear system solves.
std::pair<unsigned int, Real> rval;
// Convergence flag for the entire arcstep
bool arcstep_converged = false;
// Begin loop over arcstep reductions.
for (unsigned int ns=0; ns<n_arclength_reductions; ++ns)
{
if (!quiet)
{
libMesh::out << "Current arclength stepsize, ds_current=" << ds_current << std::endl;
libMesh::out << "Current parameter value, lambda=" << *continuation_parameter << std::endl;
}
// Upon exit from the nonlinear loop, the newton_converged flag
// will tell us the convergence status of Newton's method.
bool newton_converged = false;
// The nonlinear residual before *any* nonlinear steps have been taken.
Real nonlinear_residual_firststep = 0.;
// The nonlinear residual from the current "k" Newton step, before the Newton step
Real nonlinear_residual_beforestep = 0.;
// The nonlinear residual from the current "k" Newton step, after the Newton step
Real nonlinear_residual_afterstep = 0.;
// The linear solver tolerance, can be updated dynamically at each Newton step.
Real current_linear_tolerance = 0.;
// The nonlinear loop
for (newton_step=0; newton_step<newton_solver->max_nonlinear_iterations; ++newton_step)
{
libMesh::out << "\n === Starting Newton step " << newton_step << " ===" << std::endl;
// Set the linear system solver tolerance
// // 1.) Set the current linear tolerance based as a multiple of the current residual of the system.
// const Real residual_multiple = 1.e-4;
// Real current_linear_tolerance = residual_multiple*nonlinear_residual_beforestep;
// // But if the current residual isn't small, don't let the solver exit with zero iterations!
// if (current_linear_tolerance > 1.)
// current_linear_tolerance = residual_multiple;
// 2.) Set the current linear tolerance based on the method based on technique of Eisenstat & Walker.
if (newton_step==0)
{
// At first step, only try reducing the residual by a small amount
current_linear_tolerance = initial_newton_tolerance;//0.01;
}
else
{
// The new tolerance is based on the ratio of the most recent tolerances
const Real alp=0.5*(1.+std::sqrt(5.));
const Real gam=0.9;
libmesh_assert_not_equal_to (nonlinear_residual_beforestep, 0.0);
libmesh_assert_not_equal_to (nonlinear_residual_afterstep, 0.0);
current_linear_tolerance = std::min(gam*std::pow(nonlinear_residual_afterstep/nonlinear_residual_beforestep, alp),
current_linear_tolerance*current_linear_tolerance
);
// Don't let it get ridiculously small!!
if (current_linear_tolerance < 1.e-12)
current_linear_tolerance = 1.e-12;
}
if (!quiet)
libMesh::out << "Using current_linear_tolerance=" << current_linear_tolerance << std::endl;
// Assemble the residual (and Jacobian).
rhs_mode = Residual;
assembly(true, // Residual
true); // Jacobian
rhs->close();
// Save the current nonlinear residual. We don't need to recompute the residual unless
// this is the first step, since it was already computed as part of the convergence check
// at the end of the last loop iteration.
if (newton_step==0)
{
nonlinear_residual_beforestep = rhs->l2_norm();
// Store the residual before any steps have been taken. This will *not*
// be updated at each step, and can be used to see if any progress has
// been made from the initial residual at later steps.
nonlinear_residual_firststep = nonlinear_residual_beforestep;
const Real old_norm_u = solution->l2_norm();
libMesh::out << " (before step) ||R||_{L2} = " << nonlinear_residual_beforestep << std::endl;
libMesh::out << " (before step) ||R||_{L2}/||u|| = " << nonlinear_residual_beforestep / old_norm_u << std::endl;
// In rare cases (very small arcsteps), it's possible that the residual is
// already below our absolute linear tolerance.
if (nonlinear_residual_beforestep < solution_tolerance)
{
if (!quiet)
libMesh::out << "Initial guess satisfied linear tolerance, exiting with zero Newton iterations!" << std::endl;
// Since we go straight from here to the solve of the next tangent, we
// have to close the matrix before it can be assembled again.
matrix->close();
newton_converged=true;
break; // out of Newton iterations, with newton_converged=true
}
}
else
{
nonlinear_residual_beforestep = nonlinear_residual_afterstep;
}
// Solve the linear system G_u*z = G
// Initial guess?
z->zero(); // It seems to be extremely important to zero z here, otherwise the solver quits early.
z->close();
// It's possible that we have selected the current_linear_tolerance so large that
// a guess of z=zero yields a linear system residual |Az + R| small enough that the
// linear solver exits in zero iterations. If this happens, we will reduce the
// current_linear_tolerance until the linear solver does at least 1 iteration.
do
{
rval =
linear_solver->solve(*matrix,
*z,
*rhs,
//1.e-12,
current_linear_tolerance,
newton_solver->max_linear_iterations); // max linear iterations
if (rval.first==0)
{
if (newton_step==0)
{
libMesh::out << "Repeating initial solve with smaller linear tolerance!" << std::endl;
current_linear_tolerance *= initial_newton_tolerance; // reduce the linear tolerance to force the solver to do some work
}
else
// We shouldn't get here ... it means the linear solver did no work on a Newton
// step other than the first one. If this happens, we need to think more about our
// tolerance selection.
libmesh_error_msg("Linear solver did no work!");
}
} while (rval.first==0);
if (!quiet)
libMesh::out << " G_u*z = G solver converged at step "
<< rval.first
<< " linear tolerance = "
<< rval.second
<< "."
<< std::endl;
// Sometimes (I am not sure why) the linear solver exits after zero iterations.
// Perhaps it is hitting PETSc's divergence tolerance dtol??? If this occurs,
// we should break out of the Newton iteration loop because nothing further is
// going to happen... Of course if the tolerance is already small enough after
// zero iterations (how can this happen?!) we should not quit.
if ((rval.first == 0) && (rval.second > current_linear_tolerance*nonlinear_residual_beforestep))
{
if (!quiet)
libMesh::out << "Linear solver exited in zero iterations!" << std::endl;
// Try to find out the reason for convergence/divergence
linear_solver->print_converged_reason();
break; // out of Newton iterations
}
// Note: need to scale z by -1 since our code always solves Jx=R
// instead of Jx=-R.
z->scale(-1.);
z->close();
// Assemble the G_Lambda vector, skip residual.
rhs_mode = G_Lambda;
// Assemble both rhs and Jacobian
assembly(true, // Residual
false); // Jacobian
// Not sure if this is really necessary
rhs->close();
const Real yrhsnorm=rhs->l2_norm();
if (yrhsnorm == 0.0)
libmesh_error_msg("||G_Lambda|| = 0");
// We select a tolerance for the y-system which is based on the inexact Newton
// tolerance but scaled by an extra term proportional to the RHS (which is not -> 0 in this case)
const Real ysystemtol=current_linear_tolerance*(nonlinear_residual_beforestep/yrhsnorm);
if (!quiet)
libMesh::out << "ysystemtol=" << ysystemtol << std::endl;
// Solve G_u*y = G_{\lambda}
// FIXME: Initial guess? This is really a solve for -du/dlambda so we could try
// initializing it with the latest approximation to that... du/dlambda ~ du/ds * ds/dlambda
//*y = *solution;
//y->add(-1., *previous_u);
//y->scale(-1. / (*continuation_parameter - old_continuation_parameter)); // Be careful of divide by zero...
//y->close();
// const unsigned int max_attempts=1;
// unsigned int attempt=0;
// do
// {
// if (!quiet)
// libMesh::out << "Trying to solve tangent system, attempt " << attempt << std::endl;
rval =
linear_solver->solve(*matrix,
*y,
*rhs,
//1.e-12,
ysystemtol,
newton_solver->max_linear_iterations); // max linear iterations
if (!quiet)
libMesh::out << " G_u*y = G_{lambda} solver converged at step "
<< rval.first
<< ", linear tolerance = "
<< rval.second
<< "."
<< std::endl;
// Sometimes (I am not sure why) the linear solver exits after zero iterations.
// Perhaps it is hitting PETSc's divergence tolerance dtol??? If this occurs,
// we should break out of the Newton iteration loop because nothing further is
// going to happen...
if ((rval.first == 0) && (rval.second > ysystemtol))
{
if (!quiet)
libMesh::out << "Linear solver exited in zero iterations!" << std::endl;
break; // out of Newton iterations
}
// ++attempt;
// } while ((attempt<max_attempts) && (rval.first==newton_solver->max_linear_iterations));
// Compute N, the residual of the arclength constraint eqn.
// Note 1: N(u,lambda,s) := (u-u_{old}, du_ds) + (lambda-lambda_{old}, dlambda_ds) - _ds
// We temporarily use the delta_u vector as a temporary vector for this calculation.
*delta_u = *solution;
delta_u->add(-1., *previous_u);
// First part of the arclength constraint
const Number N1 = Theta_LOCA*Theta_LOCA*Theta*delta_u->dot(*du_ds);
const Number N2 = ((*continuation_parameter) - old_continuation_parameter)*dlambda_ds;
const Number N3 = ds_current;
if (!quiet)
{
libMesh::out << " N1=" << N1 << std::endl;
libMesh::out << " N2=" << N2 << std::endl;
libMesh::out << " N3=" << N3 << std::endl;
}
// The arclength constraint value
const Number N = N1+N2-N3;
if (!quiet)
libMesh::out << " N=" << N << std::endl;
const Number duds_dot_z = du_ds->dot(*z);
const Number duds_dot_y = du_ds->dot(*y);
//libMesh::out << "duds_dot_z=" << duds_dot_z << std::endl;
//libMesh::out << "duds_dot_y=" << duds_dot_y << std::endl;
//libMesh::out << "dlambda_ds=" << dlambda_ds << std::endl;
const Number delta_lambda_numerator = -(N + Theta_LOCA*Theta_LOCA*Theta*duds_dot_z);
const Number delta_lambda_denominator = (dlambda_ds - Theta_LOCA*Theta_LOCA*Theta*duds_dot_y);
libmesh_assert_not_equal_to (delta_lambda_denominator, 0.0);
// Now, we are ready to compute the step delta_lambda
const Number delta_lambda_comp = delta_lambda_numerator /
delta_lambda_denominator;
// Lambda is real-valued
const Real delta_lambda = libmesh_real(delta_lambda_comp);
// Knowing delta_lambda, we are ready to update delta_u
// delta_u = z - delta_lambda*y
delta_u->zero();
delta_u->add(1., *z);
delta_u->add(-delta_lambda, *y);
delta_u->close();
// Update the system solution and the continuation parameter.
solution->add(1., *delta_u);
solution->close();
*continuation_parameter += delta_lambda;
// Did the Newton step actually reduce the residual?
rhs_mode = Residual;
assembly(true, // Residual
false); // Jacobian
rhs->close();
nonlinear_residual_afterstep = rhs->l2_norm();
// In a "normal" Newton step, ||du||/||R|| > 1 since the most recent
// step is where you "just were" and the current residual is where
// you are now. It can occur that ||du||/||R|| < 1, but these are
// likely not good cases to attempt backtracking (?).
const Real norm_du_norm_R = delta_u->l2_norm() / nonlinear_residual_afterstep;
if (!quiet)
libMesh::out << " norm_du_norm_R=" << norm_du_norm_R << std::endl;
// Factor to decrease the stepsize by for backtracking
Real newton_stepfactor = 1.;
const bool attempt_backtracking =
(nonlinear_residual_afterstep > solution_tolerance)
&& (nonlinear_residual_afterstep > nonlinear_residual_beforestep)
&& (n_backtrack_steps>0)
&& (norm_du_norm_R > 1.)
;
// If residual is not reduced, do Newton back tracking.
if (attempt_backtracking)
{
if (!quiet)
libMesh::out << "Newton step did not reduce residual." << std::endl;
// back off the previous step.
solution->add(-1., *delta_u);
solution->close();
*continuation_parameter -= delta_lambda;
// Backtracking: start cutting the Newton stepsize by halves until
// the new residual is actually smaller...
for (unsigned int backtrack_step=0; backtrack_step<n_backtrack_steps; ++backtrack_step)
{
newton_stepfactor *= 0.5;
if (!quiet)
libMesh::out << "Shrinking step size by " << newton_stepfactor << std::endl;
// Take fractional step
solution->add(newton_stepfactor, *delta_u);
solution->close();
*continuation_parameter += newton_stepfactor*delta_lambda;
rhs_mode = Residual;
assembly(true, // Residual
false); // Jacobian
rhs->close();
nonlinear_residual_afterstep = rhs->l2_norm();
if (!quiet)
libMesh::out << "At shrink step "
<< backtrack_step
<< ", nonlinear_residual_afterstep="
<< nonlinear_residual_afterstep
<< std::endl;
if (nonlinear_residual_afterstep < nonlinear_residual_beforestep)
{
if (!quiet)
libMesh::out << "Backtracking succeeded!" << std::endl;
break; // out of backtracking loop
}
else
{
// Back off that step
solution->add(-newton_stepfactor, *delta_u);
solution->close();
*continuation_parameter -= newton_stepfactor*delta_lambda;
}
// Save a copy of the solution from before the Newton step.
//UniquePtr<NumericVector<Number> > prior_iterate = solution->clone();
}
} // end if (attempte_backtracking)
// If we tried backtracking but the residual is still not reduced, print message.
if ((attempt_backtracking) && (nonlinear_residual_afterstep > nonlinear_residual_beforestep))
{
//libMesh::err << "Backtracking failed." << std::endl;
libMesh::out << "Backtracking failed." << std::endl;
// 1.) Quit, exit program.
//libmesh_error_msg("Backtracking failed!");
// 2.) Continue with last newton_stepfactor
if (newton_step<3)
{
solution->add(newton_stepfactor, *delta_u);
solution->close();
*continuation_parameter += newton_stepfactor*delta_lambda;
if (!quiet)
libMesh::out << "Backtracking could not reduce residual ... continuing anyway!" << std::endl;
}
// 3.) Break out of Newton iteration loop with newton_converged = false,
// reduce the arclength stepsize, and try again.
else
{
break; // out of Newton iteration loop, with newton_converged=false
}
}
// Another type of convergence check: suppose the residual has not been reduced
// from its initial value after half of the allowed Newton steps have occurred.
// In our experience, this typically means that it isn't going to converge and
// we could probably save time by dropping out of the Newton iteration loop and
// trying a smaller arcstep.
if (this->newton_progress_check)
{
if ((nonlinear_residual_afterstep > nonlinear_residual_firststep) &&
(newton_step+1 > static_cast<unsigned int>(0.5*newton_solver->max_nonlinear_iterations)))
{
libMesh::out << "Progress check failed: the current residual: "
<< nonlinear_residual_afterstep
<< ", is\n"
<< "larger than the initial residual, and half of the allowed\n"
<< "number of Newton iterations have elapsed.\n"
<< "Exiting Newton iterations with converged==false." << std::endl;
break; // out of Newton iteration loop, newton_converged = false
}
}
// Safety check: Check the current continuation parameter against user-provided min-allowable parameter value
if (*continuation_parameter < min_continuation_parameter)
{
libMesh::out << "Continuation parameter fell below min-allowable value." << std::endl;
break; // out of Newton iteration loop, newton_converged = false
}
// Safety check: Check the current continuation parameter against user-provided max-allowable parameter value
if ( (max_continuation_parameter != 0.0) &&
(*continuation_parameter > max_continuation_parameter) )
{
libMesh::out << "Current continuation parameter value: "
<< *continuation_parameter
<< " exceeded max-allowable value."
<< std::endl;
break; // out of Newton iteration loop, newton_converged = false
}
// Check the convergence of the parameter and the solution. If they are small
// enough, we can break out of the Newton iteration loop.
const Real norm_delta_u = delta_u->l2_norm();
const Real norm_u = solution->l2_norm();
libMesh::out << " delta_lambda = " << delta_lambda << std::endl;
libMesh::out << " newton_stepfactor*delta_lambda = " << newton_stepfactor*delta_lambda << std::endl;
libMesh::out << " lambda_current = " << *continuation_parameter << std::endl;
libMesh::out << " ||delta_u|| = " << norm_delta_u << std::endl;
libMesh::out << " ||delta_u||/||u|| = " << norm_delta_u / norm_u << std::endl;
// Evaluate the residual at the current Newton iterate. We don't want to detect
// convergence due to a small Newton step when the residual is still not small.
rhs_mode = Residual;
assembly(true, // Residual
false); // Jacobian
rhs->close();
const Real norm_residual = rhs->l2_norm();
libMesh::out << " ||R||_{L2} = " << norm_residual << std::endl;
libMesh::out << " ||R||_{L2}/||u|| = " << norm_residual / norm_u << std::endl;
// FIXME: The norm_delta_u tolerance (at least) should be relative.
// It doesn't make sense to converge a solution whose size is ~ 10^5 to
// a tolerance of 1.e-6. Oh, and we should also probably check the
// (relative) size of the residual as well, instead of just the step.
if ((std::abs(delta_lambda) < continuation_parameter_tolerance) &&
//(norm_delta_u < solution_tolerance) && // This is a *very* strict criterion we can probably skip
(norm_residual < solution_tolerance))
{
if (!quiet)
libMesh::out << "Newton iterations converged!" << std::endl;
newton_converged = true;
break; // out of Newton iterations
}
} // end nonlinear loop
if (!newton_converged)
{
libMesh::out << "Newton iterations of augmented system did not converge!" << std::endl;
// Reduce ds_current, recompute the solution and parameter, and continue to next
// arcstep, if there is one.
ds_current *= 0.5;
// Go back to previous solution and parameter value.
*solution = *previous_u;
*continuation_parameter = old_continuation_parameter;
// Compute new predictor with smaller ds
apply_predictor();
}
else
{
// Set step convergence and break out
arcstep_converged=true;
break; // out of arclength reduction loop
}
} // end loop over arclength reductions
// Check for convergence of the whole arcstep. If not converged at this
// point, we have no choice but to quit.
if (!arcstep_converged)
libmesh_error_msg("Arcstep failed to converge after max number of reductions! Exiting...");
// Print converged solution control parameter and max value.
libMesh::out << "lambda_current=" << *continuation_parameter << std::endl;
//libMesh::out << "u_max=" << solution->max() << std::endl;
// Reset old stream precision and flags.
libMesh::out.precision(old_precision);
libMesh::out.unsetf(std::ios_base::scientific);
// Note: we don't want to go on to the next guess yet, since the user may
// want to post-process this data. It's up to the user to call advance_arcstep()
// when they are ready to go on.
}
| Number libMesh::System::current_solution | ( | const dof_id_type | global_dof_number | ) | const [inherited] |
Definition at line 184 of file system.C.
References libMesh::System::_dof_map, and libMesh::System::current_local_solution.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::HPCoarsenTest::select_refinement(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().
{
// Check the sizes
libmesh_assert_less (global_dof_number, _dof_map->n_dofs());
libmesh_assert_less (global_dof_number, current_local_solution->size());
return (*current_local_solution)(global_dof_number);
}
| void libMesh::System::deactivate | ( | ) | [inline, inherited] |
Deactivates the system. Only active systems are solved.
Definition at line 2009 of file system.h.
References libMesh::System::_active.
{
_active = false;
}
| void libMesh::ImplicitSystem::disable_cache | ( | ) | [virtual, inherited] |
Assembles & solves the linear system Ax=b. Avoids use of any cached data that might affect any solve result. Should be overloaded in derived systems.
Reimplemented from libMesh::System.
Definition at line 296 of file implicit_system.C.
References libMesh::System::assemble_before_solve, libMesh::ImplicitSystem::get_linear_solver(), and libMesh::LinearSolver< T >::reuse_preconditioner().
{
this->assemble_before_solve = true;
this->get_linear_solver()->reuse_preconditioner(false);
}
| void libMesh::ReferenceCounter::disable_print_counter_info | ( | ) | [static, inherited] |
Definition at line 106 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
Referenced by libMesh::LibMeshInit::LibMeshInit().
{
_enable_print_counter = false;
return;
}
| virtual bool libMesh::DifferentiablePhysics::element_constraint | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Adds the constraint contribution on elem to elem_residual. If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.
Users may need to reimplement this for their particular PDE.
To implement the constraint 0 = G(u), the user should examine u = elem_solution and add (G(u), phi_i) to elem_residual in elem_constraint().
Definition at line 119 of file diff_physics.h.
Referenced by libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), libMesh::SteadySolver::element_residual(), and libMesh::EigenTimeSolver::element_residual().
{
return request_jacobian;
}
| virtual void libMesh::DifferentiableSystem::element_postprocess | ( | DiffContext & | ) | [inline, virtual, inherited] |
Does any work that needs to be done on elem in a postprocessing loop.
Definition at line 259 of file diff_system.h.
{}
| virtual void libMesh::DifferentiableQoI::element_qoi | ( | DiffContext & | , |
| const QoISet & | |||
| ) | [inline, virtual, inherited] |
Does any work that needs to be done on elem in a quantity of interest assembly loop, outputting to elem_qoi.
Only qois included in the supplied QoISet need to be assembled.
Definition at line 108 of file diff_qoi.h.
{}
| virtual void libMesh::DifferentiableQoI::element_qoi_derivative | ( | DiffContext & | , |
| const QoISet & | |||
| ) | [inline, virtual, inherited] |
Does any work that needs to be done on elem in a quantity of interest derivative assembly loop, outputting to elem_qoi_derivative
Only qois included in the supplied QoISet need their derivatives assembled.
Definition at line 120 of file diff_qoi.h.
{}
| virtual bool libMesh::DifferentiablePhysics::element_time_derivative | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Adds the time derivative contribution on elem to elem_residual. If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.
Users need to reimplement this for their particular PDE.
To implement the physics model du/dt = F(u), the user should examine u = elem_solution and add (F(u), phi_i) to elem_residual in elem_time_derivative().
Definition at line 101 of file diff_physics.h.
Referenced by libMesh::SteadySolver::element_residual(), and libMesh::EigenTimeSolver::element_residual().
{
return request_jacobian;
}
| void libMesh::ReferenceCounter::enable_print_counter_info | ( | ) | [static, inherited] |
Methods to enable/disable the reference counter output from print_info()
Definition at line 100 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter.
{
_enable_print_counter = true;
return;
}
| virtual bool libMesh::FEMPhysics::eulerian_residual | ( | bool | request_jacobian, |
| DiffContext & | context | ||
| ) | [virtual, inherited] |
Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh.
This function assumes that the user's time derivative equations (except for any equations involving unknown mesh xyz coordinates themselves) are expressed in an Eulerian frame of reference, and that the user is satisfied with an unstabilized convection term. Lagrangian equations will probably require overriding eulerian_residual() with a blank function; ALE or stabilized formulations will require reimplementing eulerian_residual() entirely.
Reimplemented from libMesh::DifferentiablePhysics.
| virtual bool libMesh::DifferentiablePhysics::eulerian_residual | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Adds a pseudo-convection contribution on elem to elem_residual, if the nodes of elem are being translated by a moving mesh.
The library provides a basic implementation in FEMPhysics::eulerian_residual()
Reimplemented in libMesh::FEMPhysics.
Definition at line 246 of file diff_physics.h.
{
return request_jacobian;
}
| void libMesh::ImplicitSystem::forward_qoi_parameter_sensitivity | ( | const QoISet & | qoi_indices, |
| const ParameterVector & | parameters, | ||
| SensitivityData & | sensitivities | ||
| ) | [virtual, inherited] |
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
Uses the forward sensitivity method.
Currently uses finite differenced derivatives (partial q / partial p) and (partial R / partial p).
Reimplemented from libMesh::System.
Definition at line 838 of file implicit_system.C.
References libMesh::SensitivityData::allocate_data(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::ParameterVector::size(), and libMesh::TOLERANCE.
{
// We currently get partial derivatives via central differencing
const Real delta_p = TOLERANCE;
ParameterVector& parameters =
const_cast<ParameterVector&>(parameters_in);
const unsigned int Np = cast_int<unsigned int>
(parameters.size());
const unsigned int Nq = cast_int<unsigned int>
(qoi.size());
// An introduction to the problem:
//
// Residual R(u(p),p) = 0
// partial R / partial u = J = system matrix
//
// This implies that:
// d/dp(R) = 0
// (partial R / partial p) +
// (partial R / partial u) * (partial u / partial p) = 0
// We first solve for (partial u / partial p) for each parameter:
// J * (partial u / partial p) = - (partial R / partial p)
this->sensitivity_solve(parameters);
// Get ready to fill in senstivities:
sensitivities.allocate_data(qoi_indices, *this, parameters);
// We use the identity:
// dq/dp = (partial q / partial p) + (partial q / partial u) *
// (partial u / partial p)
// We get (partial q / partial u) from the user
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ true,
/* apply_constraints = */ false);
// FIXME: what do we do with adjoint boundary conditions here?
// We don't need these to be closed() in this function, but libMesh
// standard practice is to have them closed() by the time the
// function exits
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
this->get_adjoint_rhs(i).close();
for (unsigned int j=0; j != Np; ++j)
{
// (partial q / partial p) ~= (q(p+dp)-q(p-dp))/(2*dp)
Number old_parameter = *parameters[j];
*parameters[j] = old_parameter - delta_p;
this->assemble_qoi();
std::vector<Number> qoi_minus = this->qoi;
*parameters[j] = old_parameter + delta_p;
this->assemble_qoi();
std::vector<Number>& qoi_plus = this->qoi;
std::vector<Number> partialq_partialp(Nq, 0);
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
partialq_partialp[i] = (qoi_plus[i] - qoi_minus[i]) / (2.*delta_p);
// Don't leave the parameter changed
*parameters[j] = old_parameter;
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
sensitivities[i][j] = partialq_partialp[i] +
this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(j));
}
// All parameters have been reset.
// We didn't cache the original rhs or matrix for memory reasons,
// but we can restore them to a state consistent solution -
// principle of least surprise.
this->assembly(true, true);
this->rhs->close();
this->matrix->close();
this->assemble_qoi(qoi_indices);
}
| NumericVector< Number > & libMesh::System::get_adjoint_rhs | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 1058 of file system.C.
References libMesh::System::get_vector().
Referenced by libMesh::ImplicitSystem::adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
{
std::ostringstream adjoint_rhs_name;
adjoint_rhs_name << "adjoint_rhs" << i;
return this->get_vector(adjoint_rhs_name.str());
}
| const NumericVector< Number > & libMesh::System::get_adjoint_rhs | ( | unsigned int | i = 0 | ) | const [inherited] |
Definition at line 1068 of file system.C.
References libMesh::System::get_vector().
{
std::ostringstream adjoint_rhs_name;
adjoint_rhs_name << "adjoint_rhs" << i;
return this->get_vector(adjoint_rhs_name.str());
}
| NumericVector< Number > & libMesh::System::get_adjoint_solution | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 996 of file system.C.
References libMesh::System::get_vector().
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
{
std::ostringstream adjoint_name;
adjoint_name << "adjoint_solution" << i;
return this->get_vector(adjoint_name.str());
}
| const NumericVector< Number > & libMesh::System::get_adjoint_solution | ( | unsigned int | i = 0 | ) | const [inherited] |
Definition at line 1006 of file system.C.
References libMesh::System::get_vector().
{
std::ostringstream adjoint_name;
adjoint_name << "adjoint_solution" << i;
return this->get_vector(adjoint_name.str());
}
| void libMesh::System::get_all_variable_numbers | ( | std::vector< unsigned int > & | all_variable_numbers | ) | const [inherited] |
Fills all_variable_numbers with all the variable numbers for the variables that have been added to this system.
Definition at line 1285 of file system.C.
References libMesh::System::_variable_numbers, and libMesh::System::n_vars().
{
all_variable_numbers.resize(n_vars());
// Make sure the variable exists
std::map<std::string, unsigned short int>::const_iterator
it = _variable_numbers.begin();
std::map<std::string, unsigned short int>::const_iterator
it_end = _variable_numbers.end();
unsigned int count = 0;
for( ; it != it_end; ++it)
{
all_variable_numbers[count] = it->second;
count++;
}
}
| const DofMap & libMesh::System::get_dof_map | ( | ) | const [inline, inherited] |
_dof_map. Definition at line 1977 of file system.h.
References libMesh::System::_dof_map.
Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::System::calculate_norm(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshFunction(), DMlibMeshSetSystem_libMesh(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::System::get_info(), libMesh::EquationSystems::get_solution(), libMesh::SystemSubsetBySubdomain::init(), libMesh::UnsteadySolver::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::CondensedEigenSystem::initialize_condensed_dofs(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::UnsteadySolver::old_nonlinear_solution(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::ErrorVector::plot_error(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_vector(), libMesh::System::re_update(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::UnsteadySolver::reinit(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::EquationSystems::reinit(), libMesh::System::reinit_constraints(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::HPCoarsenTest::select_refinement(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), libMesh::ImplicitSystem::weighted_sensitivity_solve(), libMesh::System::write_parallel_data(), libMesh::EnsightIO::write_scalar_ascii(), libMesh::System::write_SCALAR_dofs(), and libMesh::EnsightIO::write_vector_ascii().
{
return *_dof_map;
}
| DofMap & libMesh::System::get_dof_map | ( | ) | [inline, inherited] |
_dof_map. Definition at line 1985 of file system.h.
References libMesh::System::_dof_map.
{
return *_dof_map;
}
| const EquationSystems& libMesh::System::get_equation_systems | ( | ) | const [inline, inherited] |
Definition at line 715 of file system.h.
References libMesh::System::_equation_systems.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::NewmarkSystem::clear(), libMesh::FrequencySystem::clear_all(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::FrequencySystem::init_data(), libMesh::FrequencySystem::n_frequencies(), libMesh::System::project_vector(), libMesh::FrequencySystem::set_current_frequency(), libMesh::FrequencySystem::set_frequencies(), libMesh::FrequencySystem::set_frequencies_by_range(), libMesh::FrequencySystem::set_frequencies_by_steps(), libMesh::NewmarkSystem::set_newmark_parameters(), libMesh::NonlinearImplicitSystem::set_solver_parameters(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), and libMesh::WrappedFunction< Output >::WrappedFunction().
{ return _equation_systems; }
| EquationSystems& libMesh::System::get_equation_systems | ( | ) | [inline, inherited] |
Definition at line 720 of file system.h.
References libMesh::System::_equation_systems.
{ return _equation_systems; }
| std::string libMesh::ReferenceCounter::get_info | ( | ) | [static, inherited] |
Gets a string containing the reference information.
Definition at line 47 of file reference_counter.C.
References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().
Referenced by libMesh::ReferenceCounter::print_info().
{
#if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
std::ostringstream oss;
oss << '\n'
<< " ---------------------------------------------------------------------------- \n"
<< "| Reference count information |\n"
<< " ---------------------------------------------------------------------------- \n";
for (Counts::iterator it = _counts.begin();
it != _counts.end(); ++it)
{
const std::string name(it->first);
const unsigned int creations = it->second.first;
const unsigned int destructions = it->second.second;
oss << "| " << name << " reference count information:\n"
<< "| Creations: " << creations << '\n'
<< "| Destructions: " << destructions << '\n';
}
oss << " ---------------------------------------------------------------------------- \n";
return oss.str();
#else
return "";
#endif
}
| std::string libMesh::System::get_info | ( | ) | const [inherited] |
Definition at line 1660 of file system.C.
References libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::DofMap::get_info(), libMesh::FEType::inf_map, libMesh::System::n_constrained_dofs(), libMesh::System::n_dofs(), libMesh::System::n_local_constrained_dofs(), libMesh::System::n_local_dofs(), libMesh::System::n_matrices(), libMesh::System::n_variable_groups(), libMesh::VariableGroup::n_variables(), libMesh::System::n_vectors(), libMesh::VariableGroup::name(), libMesh::System::name(), libMesh::System::number(), libMesh::FEType::order, libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::System::system_type(), libMesh::Variable::type(), libMesh::DofMap::variable_group(), and libMesh::System::variable_group().
{
std::ostringstream oss;
const std::string& sys_name = this->name();
oss << " System #" << this->number() << ", \"" << sys_name << "\"\n"
<< " Type \"" << this->system_type() << "\"\n"
<< " Variables=";
for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
{
const VariableGroup &vg_description (this->variable_group(vg));
if (vg_description.n_variables() > 1) oss << "{ ";
for (unsigned int vn=0; vn<vg_description.n_variables(); vn++)
oss << "\"" << vg_description.name(vn) << "\" ";
if (vg_description.n_variables() > 1) oss << "} ";
}
oss << '\n';
oss << " Finite Element Types=";
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
oss << "\""
<< Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
<< "\" ";
#else
for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
{
oss << "\""
<< Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().family)
<< "\", \""
<< Utility::enum_to_string<FEFamily>(this->get_dof_map().variable_group(vg).type().radial_family)
<< "\" ";
}
oss << '\n' << " Infinite Element Mapping=";
for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
oss << "\""
<< Utility::enum_to_string<InfMapType>(this->get_dof_map().variable_group(vg).type().inf_map)
<< "\" ";
#endif
oss << '\n';
oss << " Approximation Orders=";
for (unsigned int vg=0; vg<this->n_variable_groups(); vg++)
{
#ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
oss << "\""
<< Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
<< "\" ";
#else
oss << "\""
<< Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().order)
<< "\", \""
<< Utility::enum_to_string<Order>(this->get_dof_map().variable_group(vg).type().radial_order)
<< "\" ";
#endif
}
oss << '\n';
oss << " n_dofs()=" << this->n_dofs() << '\n';
oss << " n_local_dofs()=" << this->n_local_dofs() << '\n';
#ifdef LIBMESH_ENABLE_CONSTRAINTS
oss << " n_constrained_dofs()=" << this->n_constrained_dofs() << '\n';
oss << " n_local_constrained_dofs()=" << this->n_local_constrained_dofs() << '\n';
#endif
oss << " " << "n_vectors()=" << this->n_vectors() << '\n';
oss << " " << "n_matrices()=" << this->n_matrices() << '\n';
// oss << " " << "n_additional_matrices()=" << this->n_additional_matrices() << '\n';
oss << this->get_dof_map().get_info();
return oss.str();
}
| std::pair< unsigned int, Real > libMesh::DifferentiableSystem::get_linear_solve_parameters | ( | ) | const [virtual, inherited] |
Returns an integer corresponding to the upper iteration count limit and a Real corresponding to the convergence tolerance to be used in linear adjoint and/or sensitivity solves
Reimplemented from libMesh::ImplicitSystem.
Definition at line 164 of file diff_system.C.
References libMesh::libmesh_assert(), and libMesh::DifferentiableSystem::time_solver.
{
libmesh_assert(time_solver.get());
libmesh_assert_equal_to (&(time_solver->system()), this);
return std::make_pair(this->time_solver->diff_solver()->max_linear_iterations,
this->time_solver->diff_solver()->relative_residual_tolerance);
}
| LinearSolver< Number > * libMesh::DifferentiableSystem::get_linear_solver | ( | ) | const [virtual, inherited] |
Returns a pointer to a linear solver appropriate for use in adjoint and/or sensitivity solves
Reimplemented from libMesh::ImplicitSystem.
Definition at line 155 of file diff_system.C.
References libMesh::libmesh_assert(), and libMesh::DifferentiableSystem::time_solver.
{
libmesh_assert(time_solver.get());
libmesh_assert_equal_to (&(time_solver->system()), this);
return this->time_solver->linear_solver().get();
}
| const SparseMatrix< Number > & libMesh::ImplicitSystem::get_matrix | ( | const std::string & | mat_name | ) | const [inherited] |
mat_name. None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized. Definition at line 253 of file implicit_system.C.
References libMesh::ImplicitSystem::_matrices.
Referenced by libMesh::NewmarkSystem::compute_matrix(), libMesh::EigenTimeSolver::solve(), and libMesh::NewmarkSystem::update_rhs().
{
// Make sure the matrix exists
const_matrices_iterator pos = _matrices.find (mat_name);
if (pos == _matrices.end())
libmesh_error_msg("ERROR: matrix " << mat_name << " does not exist in this system!");
return *(pos->second);
}
| SparseMatrix< Number > & libMesh::ImplicitSystem::get_matrix | ( | const std::string & | mat_name | ) | [inherited] |
mat_name. None of these matrices is involved in the solution process. Access is only granted when the matrix is already properly initialized. Definition at line 266 of file implicit_system.C.
References libMesh::ImplicitSystem::_matrices.
{
// Make sure the matrix exists
matrices_iterator pos = _matrices.find (mat_name);
if (pos == _matrices.end())
libmesh_error_msg("ERROR: matrix " << mat_name << " does not exist in this system!");
return *(pos->second);
}
| const MeshBase & libMesh::System::get_mesh | ( | ) | const [inline, inherited] |
_mesh. Definition at line 1961 of file system.h.
References libMesh::System::_mesh.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::HPCoarsenTest::add_projection(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::System::calculate_norm(), DMCreateDomainDecomposition_libMesh(), DMCreateFieldDecomposition_libMesh(), DMlibMeshSetSystem_libMesh(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::FEMContext::FEMContext(), libMesh::SystemSubsetBySubdomain::init(), libMesh::System::init_data(), libMesh::EigenSystem::init_matrices(), libMesh::ImplicitSystem::init_matrices(), libMesh::System::local_dof_indices(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::FEMSystem::postprocess(), libMesh::System::project_vector(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::ImplicitSystem::reinit(), libMesh::EigenSystem::reinit(), libMesh::HPSingularity::select_refinement(), libMesh::HPCoarsenTest::select_refinement(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().
{
return _mesh;
}
| MeshBase & libMesh::System::get_mesh | ( | ) | [inline, inherited] |
_mesh. Definition at line 1969 of file system.h.
References libMesh::System::_mesh.
{
return _mesh;
}
| const System * libMesh::DifferentiablePhysics::get_mesh_system | ( | ) | const [inline, inherited] |
Returns a const reference to the system with variables corresponding to mesh nodal coordinates, or NULL if the mesh is fixed. Useful for ALE calculations.
Definition at line 477 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_sys.
Referenced by libMesh::FEMSystem::build_context().
{
return _mesh_sys;
}
| System * libMesh::DifferentiablePhysics::get_mesh_system | ( | ) | [inline, inherited] |
Returns a reference to the system with variables corresponding to mesh nodal coordinates, or NULL if the mesh is fixed.
Definition at line 483 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_sys.
{
return _mesh_sys;
}
| unsigned int libMesh::DifferentiablePhysics::get_mesh_x_var | ( | ) | const [inline, inherited] |
Returns the variable number corresponding to the mesh x coordinate. Useful for ALE calculations.
Definition at line 489 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_x_var.
Referenced by libMesh::FEMSystem::build_context().
{
return _mesh_x_var;
}
| unsigned int libMesh::DifferentiablePhysics::get_mesh_y_var | ( | ) | const [inline, inherited] |
Returns the variable number corresponding to the mesh y coordinate. Useful for ALE calculations.
Definition at line 495 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_y_var.
Referenced by libMesh::FEMSystem::build_context().
{
return _mesh_y_var;
}
| unsigned int libMesh::DifferentiablePhysics::get_mesh_z_var | ( | ) | const [inline, inherited] |
Returns the variable number corresponding to the mesh z coordinate. Useful for ALE calculations.
Definition at line 501 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_z_var.
Referenced by libMesh::FEMSystem::build_context().
{
return _mesh_z_var;
}
| const DifferentiablePhysics* libMesh::DifferentiableSystem::get_physics | ( | ) | const [inline, inherited] |
Returns const reference to DifferentiablePhysics object. Note that if no external Physics object is attached, the default is this.
Definition at line 168 of file diff_system.h.
References libMesh::DifferentiableSystem::_diff_physics.
Referenced by libMesh::FEMSystem::build_context(), and libMesh::FEMSystem::init_context().
{ return this->_diff_physics; }
| DifferentiablePhysics* libMesh::DifferentiableSystem::get_physics | ( | ) | [inline, inherited] |
Returns reference to DifferentiablePhysics object. Note that if no external Physics object is attached, the default is this.
Definition at line 175 of file diff_system.h.
References libMesh::DifferentiableSystem::_diff_physics.
{ return this->_diff_physics; }
| const DifferentiableQoI* libMesh::DifferentiableSystem::get_qoi | ( | ) | const [inline, inherited] |
Returns const reference to DifferentiableQoI object. Note that if no external QoI object is attached, the default is this.
Definition at line 189 of file diff_system.h.
References libMesh::DifferentiableSystem::diff_qoi.
{ return this->diff_qoi; }
| DifferentiableQoI* libMesh::DifferentiableSystem::get_qoi | ( | ) | [inline, inherited] |
Returns reference to DifferentiableQoI object. Note that if no external QoI object is attached, the default is this.
Definition at line 196 of file diff_system.h.
References libMesh::DifferentiableSystem::diff_qoi.
{ return this->diff_qoi; }
| NumericVector< Number > & libMesh::System::get_sensitivity_rhs | ( | unsigned int | i = 0 | ) | [inherited] |
assemble_residual_derivatives() is called.When assembled, this vector should hold -(partial R / partial p_i)
Definition at line 1088 of file system.C.
References libMesh::System::get_vector().
Referenced by libMesh::ImplicitSystem::sensitivity_solve().
{
std::ostringstream sensitivity_rhs_name;
sensitivity_rhs_name << "sensitivity_rhs" << i;
return this->get_vector(sensitivity_rhs_name.str());
}
| const NumericVector< Number > & libMesh::System::get_sensitivity_rhs | ( | unsigned int | i = 0 | ) | const [inherited] |
Definition at line 1098 of file system.C.
References libMesh::System::get_vector().
{
std::ostringstream sensitivity_rhs_name;
sensitivity_rhs_name << "sensitivity_rhs" << i;
return this->get_vector(sensitivity_rhs_name.str());
}
| NumericVector< Number > & libMesh::System::get_sensitivity_solution | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 943 of file system.C.
References libMesh::System::get_vector().
Referenced by libMesh::ImplicitSystem::sensitivity_solve().
{
std::ostringstream sensitivity_name;
sensitivity_name << "sensitivity_solution" << i;
return this->get_vector(sensitivity_name.str());
}
| const NumericVector< Number > & libMesh::System::get_sensitivity_solution | ( | unsigned int | i = 0 | ) | const [inherited] |
Definition at line 953 of file system.C.
References libMesh::System::get_vector().
{
std::ostringstream sensitivity_name;
sensitivity_name << "sensitivity_solution" << i;
return this->get_vector(sensitivity_name.str());
}
| TimeSolver & libMesh::DifferentiableSystem::get_time_solver | ( | ) | [inline, inherited] |
Returns a pointer to the time solver attached to the calling system
Definition at line 346 of file diff_system.h.
References libMesh::libmesh_assert(), and libMesh::DifferentiableSystem::time_solver.
Referenced by libMesh::DifferentiableSystem::adjoint_solve(), libMesh::FEMSystem::build_context(), libMesh::FEMSystem::postprocess(), and libMesh::DifferentiableSystem::solve().
{
libmesh_assert(time_solver.get());
libmesh_assert_equal_to (&(time_solver->system()), this);
return *time_solver;
}
| const TimeSolver & libMesh::DifferentiableSystem::get_time_solver | ( | ) | const [inline, inherited] |
Non-const version of the above
Definition at line 354 of file diff_system.h.
References libMesh::libmesh_assert(), and libMesh::DifferentiableSystem::time_solver.
{
libmesh_assert(time_solver.get());
libmesh_assert_equal_to (&(time_solver->system()), this);
return *time_solver;
}
| const NumericVector< Number > & libMesh::System::get_vector | ( | const std::string & | vec_name | ) | const [inherited] |
vec_name. Access is only granted when the vector is already properly initialized. Definition at line 801 of file system.C.
References libMesh::System::_vectors.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::System::compare(), libMesh::UnsteadySolver::du(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::NewmarkSystem::initial_conditions(), libMesh::UnsteadySolver::reinit(), libMesh::MemorySolutionHistory::retrieve(), libMesh::UnsteadySolver::retrieve_timestep(), libMesh::TwostepTimeSolver::solve(), libMesh::FrequencySystem::solve(), libMesh::NewmarkSystem::update_rhs(), and libMesh::NewmarkSystem::update_u_v_a().
{
// Make sure the vector exists
const_vectors_iterator pos = _vectors.find(vec_name);
if (pos == _vectors.end())
libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
return *(pos->second);
}
| NumericVector< Number > & libMesh::System::get_vector | ( | const std::string & | vec_name | ) | [inherited] |
vec_name. Access is only granted when the vector is already properly initialized. Definition at line 814 of file system.C.
References libMesh::System::_vectors.
{
// Make sure the vector exists
vectors_iterator pos = _vectors.find(vec_name);
if (pos == _vectors.end())
libmesh_error_msg("ERROR: vector " << vec_name << " does not exist in this system!");
return *(pos->second);
}
| const NumericVector< Number > & libMesh::System::get_vector | ( | const unsigned int | vec_num | ) | const [inherited] |
vec_num (where the vectors are counted starting with 0). Definition at line 827 of file system.C.
References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().
{
const_vectors_iterator v = vectors_begin();
const_vectors_iterator v_end = vectors_end();
unsigned int num = 0;
while((num<vec_num) && (v!=v_end))
{
num++;
++v;
}
libmesh_assert (v != v_end);
return *(v->second);
}
| NumericVector< Number > & libMesh::System::get_vector | ( | const unsigned int | vec_num | ) | [inherited] |
vec_num (where the vectors are counted starting with 0). Definition at line 843 of file system.C.
References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().
{
vectors_iterator v = vectors_begin();
vectors_iterator v_end = vectors_end();
unsigned int num = 0;
while((num<vec_num) && (v!=v_end))
{
num++;
++v;
}
libmesh_assert (v != v_end);
return *(v->second);
}
| NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution | ( | unsigned int | i = 0 | ) | [inherited] |
Definition at line 1028 of file system.C.
References libMesh::System::get_vector().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
{
std::ostringstream adjoint_name;
adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
return this->get_vector(adjoint_name.str());
}
| const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_adjoint_solution | ( | unsigned int | i = 0 | ) | const [inherited] |
Definition at line 1038 of file system.C.
References libMesh::System::get_vector().
{
std::ostringstream adjoint_name;
adjoint_name << "weighted_sensitivity_adjoint_solution" << i;
return this->get_vector(adjoint_name.str());
}
| NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution | ( | ) | [inherited] |
Definition at line 970 of file system.C.
References libMesh::System::get_vector().
Referenced by libMesh::ImplicitSystem::weighted_sensitivity_solve().
{
return this->get_vector("weighted_sensitivity_solution");
}
| const NumericVector< Number > & libMesh::System::get_weighted_sensitivity_solution | ( | ) | const [inherited] |
Definition at line 977 of file system.C.
References libMesh::System::get_vector().
{
return this->get_vector("weighted_sensitivity_solution");
}
| bool libMesh::System::has_variable | ( | const std::string & | var | ) | const [inherited] |
var exists in this System Definition at line 1263 of file system.C.
References libMesh::System::_variable_numbers.
Referenced by libMesh::GMVIO::copy_nodal_solution().
{
return _variable_numbers.count(var);
}
| bool libMesh::ImplicitSystem::have_matrix | ( | const std::string & | mat_name | ) | const [inline, inherited] |
true if this System has a matrix associated with the given name, false otherwise. Definition at line 381 of file implicit_system.h.
References libMesh::ImplicitSystem::_matrices.
Referenced by libMesh::ImplicitSystem::add_matrix(), and libMesh::EigenTimeSolver::init().
{
return (_matrices.count(mat_name));
}
| bool libMesh::System::have_vector | ( | const std::string & | vec_name | ) | const [inline, inherited] |
true if this System has a vector associated with the given name, false otherwise. Definition at line 2153 of file system.h.
References libMesh::System::_vectors.
Referenced by libMesh::System::add_vector(), and libMesh::System::remove_vector().
{
return (_vectors.count(vec_name));
}
| bool libMesh::System::identify_variable_groups | ( | ) | const [inline, inherited] |
true when VariableGroup structures should be automatically identified, false otherwise. Definition at line 2129 of file system.h.
References libMesh::System::_identify_variable_groups.
Referenced by libMesh::System::add_variable().
{
return _identify_variable_groups;
}
| void libMesh::System::identify_variable_groups | ( | const bool | ivg | ) | [inline, inherited] |
Toggle automatic VariableGroup identification.
Definition at line 2137 of file system.h.
References libMesh::System::_identify_variable_groups.
{
_identify_variable_groups = ivg;
}
| void libMesh::ReferenceCounter::increment_constructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the construction counter. Should be called in the constructor of any derived class that will be reference counted.
Definition at line 163 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.first++;
}
| void libMesh::ReferenceCounter::increment_destructor_count | ( | const std::string & | name | ) | [inline, protected, inherited] |
Increments the destruction counter. Should be called in the destructor of any derived class that will be reference counted.
Definition at line 176 of file reference_counter.h.
References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.
Referenced by libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().
{
Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
std::pair<unsigned int, unsigned int>& p = _counts[name];
p.second++;
}
| void libMesh::System::init | ( | ) | [inherited] |
Initializes degrees of freedom on the current mesh. Sets the
Definition at line 227 of file system.C.
References libMesh::System::_basic_system_only, libMesh::System::init_data(), libMesh::System::n_vars(), and libMesh::System::user_initialization().
{
// First initialize any required data:
// either only the basic System data
if (_basic_system_only)
System::init_data();
// or all the derived class' data too
else
this->init_data();
// If no variables have been added to this system
// don't do anything
if(!this->n_vars())
return;
// Then call the user-provided intialization function
this->user_initialization();
}
| void libMesh::FEMSystem::init_context | ( | DiffContext & | c | ) | [virtual, inherited] |
Reimplemented from libMesh::DifferentiablePhysics.
Definition at line 1323 of file fem_system.C.
References libMesh::DifferentiableSystem::deltat, libMesh::FEInterface::field_type(), libMesh::FEMContext::get_element_fe(), libMesh::FEAbstract::get_JxW(), libMesh::FEGenericBase< OutputType >::get_phi(), libMesh::DifferentiableSystem::get_physics(), libMesh::DifferentiablePhysics::is_time_evolving(), libMesh::System::n_vars(), libMesh::DiffContext::set_deltat_pointer(), libMesh::TYPE_SCALAR, libMesh::TYPE_VECTOR, and libMesh::System::variable_type().
Referenced by libMesh::FEMSystem::assembly(), libMesh::FEMSystem::mesh_position_get(), and libMesh::FEMSystem::mesh_position_set().
{
// Parent::init_context(c); // may be a good idea in derived classes
// Although we do this in DiffSystem::build_context() and
// FEMSystem::build_context() as well, we do it here just to be
// extra sure that the deltat pointer gets set. Since the
// intended behavior is for classes derived from FEMSystem to
// call Parent::init_context() in their own init_context()
// overloads, we can ensure that those classes get the correct
// deltat pointers even if they have different build_context()
// overloads.
c.set_deltat_pointer ( &deltat );
FEMContext &context = cast_ref<FEMContext&>(c);
// Make sure we're prepared to do mass integration
for (unsigned int var = 0; var != this->n_vars(); ++var)
if (this->get_physics()->is_time_evolving(var))
{
// Request shape functions based on FEType
switch( FEInterface::field_type( this->variable_type(var) ) )
{
case( TYPE_SCALAR ):
{
FEBase* elem_fe = NULL;
context.get_element_fe(var, elem_fe);
elem_fe->get_JxW();
elem_fe->get_phi();
}
break;
case( TYPE_VECTOR ):
{
FEGenericBase<RealGradient>* elem_fe = NULL;
context.get_element_fe(var, elem_fe);
elem_fe->get_JxW();
elem_fe->get_phi();
}
break;
default:
libmesh_error_msg("Unrecognized field type!");
}
}
}
| void libMesh::ContinuationSystem::init_data | ( | ) | [protected, virtual] |
Initializes the member data fields associated with the system, so that, e.g., assemble() may be used.
Reimplemented from libMesh::FEMSystem.
Definition at line 91 of file continuation_system.C.
References libMesh::System::add_vector(), delta_u, du_ds, libMesh::FEMSystem::init_data(), previous_du_ds, previous_u, y, y_old, and z.
{
// Add a vector which stores the tangent "du/ds" to the system and save its pointer.
du_ds = &(add_vector("du_ds"));
// Add a vector which stores the tangent "du/ds" to the system and save its pointer.
previous_du_ds = &(add_vector("previous_du_ds"));
// Add a vector to keep track of the previous nonlinear solution
// at the old value of lambda.
previous_u = &(add_vector("previous_u"));
// Add a vector to keep track of the temporary solution "y" of Ay=G_{\lambda}.
y = &(add_vector("y"));
// Add a vector to keep track of the "old value" of "y" which is the solution of Ay=G_{\lambda}.
y_old = &(add_vector("y_old"));
// Add a vector to keep track of the temporary solution "z" of Az=-G.
z = &(add_vector("z"));
// Add a vector to keep track of the Newton update during the constrained PDE solves.
delta_u = &(add_vector("delta_u"));
// Call the Parent's initialization routine.
Parent::init_data();
}
| void libMesh::ImplicitSystem::init_matrices | ( | ) | [protected, virtual, inherited] |
Initializes the matrices associated with this system.
Definition at line 105 of file implicit_system.C.
References libMesh::ImplicitSystem::_can_add_matrices, libMesh::ImplicitSystem::_matrices, libMesh::DofMap::attach_matrix(), libMesh::DofMap::compute_sparsity(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::SparseMatrix< T >::initialized(), libMesh::DofMap::is_attached(), libMesh::libmesh_assert(), and libMesh::ImplicitSystem::matrix.
Referenced by libMesh::ImplicitSystem::init_data().
{
libmesh_assert(matrix);
// Check for quick return in case the system matrix
// (and by extension all the matrices) has already
// been initialized
if (matrix->initialized())
return;
// Get a reference to the DofMap
DofMap& dof_map = this->get_dof_map();
// no chance to add other matrices
_can_add_matrices = false;
// Tell the matrices about the dof map, and vice versa
for (matrices_iterator pos = _matrices.begin();
pos != _matrices.end(); ++pos)
{
SparseMatrix<Number> &m = *(pos->second);
libmesh_assert (!m.initialized());
// We want to allow repeated init() on systems, but we don't
// want to attach the same matrix to the DofMap twice
if (!dof_map.is_attached(m))
dof_map.attach_matrix (m);
}
// Compute the sparsity pattern for the current
// mesh and DOF distribution. This also updates
// additional matrices, \p DofMap now knows them
dof_map.compute_sparsity (this->get_mesh());
// Initialize matrices
for (matrices_iterator pos = _matrices.begin();
pos != _matrices.end(); ++pos)
pos->second->init ();
// Set the additional matrices to 0.
for (matrices_iterator pos = _matrices.begin();
pos != _matrices.end(); ++pos)
pos->second->zero ();
}
| virtual void libMesh::DifferentiablePhysics::init_physics | ( | const System & | sys | ) | [virtual, inherited] |
Initialize any data structures associated with the physics.
Referenced by libMesh::DifferentiableSystem::attach_physics(), and libMesh::DifferentiableSystem::init_data().
| virtual void libMesh::DifferentiableQoI::init_qoi | ( | std::vector< Number > & | ) | [inline, virtual, inherited] |
Initialize system qoi. By default, does nothing in order to maintain backward compatibility for FEMSystem applications that control qoi.
Definition at line 69 of file diff_qoi.h.
Referenced by libMesh::DifferentiableSystem::attach_qoi().
{}
| void libMesh::ContinuationSystem::initialize_tangent | ( | ) | [private] |
Before starting arclength continuation, we need at least 2 prior solutions (both solution and u_previous should be filled with meaningful values) And we need to initialize the tangent vector. This only needs to be called once.
Definition at line 132 of file continuation_system.C.
References libMesh::NumericVector< T >::add(), libMesh::NumericVector< T >::close(), continuation_parameter, dlambda_ds, ds_current, du_ds, libMesh::NumericVector< T >::l2_norm(), libMesh::libmesh_assert(), old_continuation_parameter, libMesh::out, previous_u, quiet, libMesh::Real, libMesh::NumericVector< T >::scale(), set_Theta(), libMesh::System::solution, solve_tangent(), tangent_initialized, Theta, Theta_LOCA, update_solution(), and y.
Referenced by continuation_solve().
{
// Be sure the tangent was not already initialized.
libmesh_assert (!tangent_initialized);
// Compute delta_s_zero, the initial arclength travelled during the
// first step. Here we assume that previous_u and lambda_old store
// the previous solution and control parameter. You may need to
// read in an old solution (or solve the non-continuation system)
// first and call save_current_solution() before getting here.
// 1.) Compute delta_s_zero as ||u|| - ||u_old|| + ...
// Compute norms of the current and previous solutions
// Real norm_u = solution->l2_norm();
// Real norm_previous_u = previous_u->l2_norm();
// if (!quiet)
// {
// libMesh::out << "norm_u=" << norm_u << std::endl;
// libMesh::out << "norm_previous_u=" << norm_previous_u << std::endl;
// }
// if (norm_u == norm_previous_u)
// {
// libMesh::err << "Warning, it appears u and previous_u are the "
// << "same, are you sure this is correct?"
// << "It's possible you forgot to set one or the other..."
// << std::endl;
// }
// Real delta_s_zero = std::sqrt(
// (norm_u - norm_previous_u)*(norm_u - norm_previous_u) +
// (*continuation_parameter-old_continuation_parameter)*
// (*continuation_parameter-old_continuation_parameter)
// );
// // 2.) Compute delta_s_zero as ||u -u_old|| + ...
// *delta_u = *solution;
// delta_u->add(-1., *previous_u);
// delta_u->close();
// Real norm_delta_u = delta_u->l2_norm();
// Real norm_u = solution->l2_norm();
// Real norm_previous_u = previous_u->l2_norm();
// // Scale norm_delta_u by the bigger of either norm_u or norm_previous_u
// norm_delta_u /= std::max(norm_u, norm_previous_u);
// if (!quiet)
// {
// libMesh::out << "norm_u=" << norm_u << std::endl;
// libMesh::out << "norm_previous_u=" << norm_previous_u << std::endl;
// //libMesh::out << "norm_delta_u=" << norm_delta_u << std::endl;
// libMesh::out << "norm_delta_u/max(|u|,|u_old|)=" << norm_delta_u << std::endl;
// libMesh::out << "|norm_u-norm_previous_u|=" << std::abs(norm_u - norm_previous_u) << std::endl;
// }
// const Real dlambda = *continuation_parameter-old_continuation_parameter;
// if (!quiet)
// libMesh::out << "dlambda=" << dlambda << std::endl;
// Real delta_s_zero = std::sqrt(
// (norm_delta_u*norm_delta_u) +
// (dlambda*dlambda)
// );
// if (!quiet)
// libMesh::out << "delta_s_zero=" << delta_s_zero << std::endl;
// 1.) + 2.)
// // Now approximate the initial tangent d(lambda)/ds
// this->dlambda_ds = (*continuation_parameter-old_continuation_parameter) / delta_s_zero;
// // We can also approximate the deriv. wrt s by finite differences:
// // du/ds = (u1 - u0) / delta_s_zero.
// // FIXME: Use delta_u from above if we decide to keep that method.
// *du_ds = *solution;
// du_ds->add(-1., *previous_u);
// du_ds->scale(1./delta_s_zero);
// du_ds->close();
// 3.) Treating (u-previous_u)/(lambda - lambda_old) as an approximation to du/d(lambda),
// we follow the same technique as Carnes and Shadid.
// const Real dlambda = *continuation_parameter-old_continuation_parameter;
// libmesh_assert_greater (dlambda, 0.);
// // Use delta_u for temporary calculation of du/d(lambda)
// *delta_u = *solution;
// delta_u->add(-1., *previous_u);
// delta_u->scale(1. / dlambda);
// delta_u->close();
// // Determine initial normalization parameter
// const Real solution_size = std::max(solution->l2_norm(), previous_u->l2_norm());
// if (solution_size > 1.)
// {
// Theta = 1./solution_size;
// if (!quiet)
// libMesh::out << "Setting Normalization Parameter Theta=" << Theta << std::endl;
// }
// // Compute d(lambda)/ds
// // The correct sign of d(lambda)/ds should be positive, since we assume that (lambda > lambda_old)
// // but we could always double-check that as well.
// Real norm_delta_u = delta_u->l2_norm();
// this->dlambda_ds = 1. / std::sqrt(1. + Theta*Theta*norm_delta_u*norm_delta_u);
// // Finally, compute du/ds = d(lambda)/ds * du/d(lambda)
// *du_ds = *delta_u;
// du_ds->scale(dlambda_ds);
// du_ds->close();
// 4.) Use normalized arclength formula to estimate delta_s_zero
// // Determine initial normalization parameter
// set_Theta();
// // Compute (normalized) delta_s_zero
// *delta_u = *solution;
// delta_u->add(-1., *previous_u);
// delta_u->close();
// Real norm_delta_u = delta_u->l2_norm();
// const Real dlambda = *continuation_parameter-old_continuation_parameter;
// if (!quiet)
// libMesh::out << "dlambda=" << dlambda << std::endl;
// Real delta_s_zero = std::sqrt(
// (Theta_LOCA*Theta_LOCA*Theta*norm_delta_u*norm_delta_u) +
// (dlambda*dlambda)
// );
// *du_ds = *delta_u;
// du_ds->scale(1./delta_s_zero);
// dlambda_ds = dlambda / delta_s_zero;
// if (!quiet)
// {
// libMesh::out << "delta_s_zero=" << delta_s_zero << std::endl;
// libMesh::out << "initial d(lambda)/ds|_0 = " << dlambda_ds << std::endl;
// libMesh::out << "initial ||du_ds||_0 = " << du_ds->l2_norm() << std::endl;
// }
// // FIXME: Also store the initial finite-differenced approximation to -du/dlambda as y.
// // We stick to the convention of storing negative y, since that is what we typically
// // solve for anyway.
// *y = *delta_u;
// y->scale(-1./dlambda);
// y->close();
// 5.) Assume dlambda/ds_0 ~ 1/sqrt(2) and determine the value of Theta_LOCA which
// will satisfy this criterion
// Initial change in parameter
const Real dlambda = *continuation_parameter-old_continuation_parameter;
libmesh_assert_not_equal_to (dlambda, 0.0);
// Ideal initial value of dlambda_ds
dlambda_ds = 1. / std::sqrt(2.);
if (dlambda < 0.)
dlambda_ds *= -1.;
// This also implies the initial value of ds
ds_current = dlambda / dlambda_ds;
if (!quiet)
libMesh::out << "Setting ds_current|_0=" << ds_current << std::endl;
// Set y = -du/dlambda using finite difference approximation
*y = *solution;
y->add(-1., *previous_u);
y->scale(-1./dlambda);
y->close();
const Real ynorm=y->l2_norm();
// Finally, set the value of du_ds to be used in the upcoming
// tangent calculation. du/ds = du/dlambda * dlambda/ds
*du_ds = *y;
du_ds->scale(-dlambda_ds);
du_ds->close();
// Determine additional solution normalization parameter
// (Since we just set du/ds, it will be: ||du||*||du/ds||)
set_Theta();
// The value of Theta_LOCA which makes dlambda_ds = 1/sqrt(2),
// assuming our Theta = ||du||^2.
// Theta_LOCA = std::abs(dlambda);
// Assuming general Theta
Theta_LOCA = std::sqrt(1./Theta/ynorm/ynorm);
if (!quiet)
{
libMesh::out << "Setting initial Theta_LOCA = " << Theta_LOCA << std::endl;
libMesh::out << "Theta_LOCA^2*Theta = " << Theta_LOCA*Theta_LOCA*Theta << std::endl;
libMesh::out << "initial d(lambda)/ds|_0 = " << dlambda_ds << std::endl;
libMesh::out << "initial ||du_ds||_0 = " << du_ds->l2_norm() << std::endl;
}
// OK, we estimated the tangent at point u0.
// Now, to estimate the tangent at point u1, we call the solve_tangent routine.
// Set the flag which tells us the method has been initialized.
tangent_initialized = true;
solve_tangent();
// Advance the solution and the parameter to the next value.
update_solution();
}
| bool libMesh::System::is_adjoint_already_solved | ( | ) | const [inline, inherited] |
Accessor for the adjoint_already_solved boolean
Definition at line 375 of file system.h.
References libMesh::System::adjoint_already_solved.
Referenced by libMesh::AdjointResidualErrorEstimator::estimate_error().
{ return adjoint_already_solved;}
| bool libMesh::System::is_initialized | ( | ) | [inline, inherited] |
Returns true iff this system has been initialized.
Definition at line 2017 of file system.h.
References libMesh::System::_is_initialized.
Referenced by libMesh::System::add_variable(), and libMesh::System::add_variables().
{
return _is_initialized;
}
| bool libMesh::DifferentiablePhysics::is_time_evolving | ( | unsigned int | var | ) | const [inline, inherited] |
Returns true iff variable var is evolving with respect to time. In general, the user's init() function should have set time_evolving() for any variables which behave like du/dt = F(u), and should not call time_evolving() for any variables which behave like 0 = G(u).
Definition at line 234 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_time_evolving.
Referenced by libMesh::FEMSystem::init_context().
{
return _time_evolving[var];
}
| void libMesh::System::local_dof_indices | ( | const unsigned int | var, |
| std::set< dof_id_type > & | var_indices | ||
| ) | const [inherited] |
Fills the std::set with the degrees of freedom on the local processor corresponding the the variable number passed in.
Definition at line 1304 of file system.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::DofMap::dof_indices(), libMesh::DofMap::end_dof(), libMesh::DofMap::first_dof(), libMesh::System::get_dof_map(), and libMesh::System::get_mesh().
Referenced by libMesh::System::discrete_var_norm().
{
// Make sure the set is clear
var_indices.clear();
std::vector<dof_id_type> dof_indices;
// Begin the loop over the elements
MeshBase::const_element_iterator el =
this->get_mesh().active_local_elements_begin();
const MeshBase::const_element_iterator end_el =
this->get_mesh().active_local_elements_end();
const dof_id_type
first_local = this->get_dof_map().first_dof(),
end_local = this->get_dof_map().end_dof();
for ( ; el != end_el; ++el)
{
const Elem* elem = *el;
this->get_dof_map().dof_indices (elem, dof_indices, var);
for(unsigned int i=0; i<dof_indices.size(); i++)
{
dof_id_type dof = dof_indices[i];
//If the dof is owned by the local processor
if(first_local <= dof && dof < end_local)
var_indices.insert(dof_indices[i]);
}
}
}
| virtual bool libMesh::FEMPhysics::mass_residual | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [virtual, inherited] |
Subtracts a mass vector contribution on elem from elem_residual.
If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.
Many problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient variable u; users with more complicated transient problems will need to reimplement this themselves.
Reimplemented from libMesh::DifferentiablePhysics.
| virtual bool libMesh::DifferentiablePhysics::mass_residual | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Subtracts a mass vector contribution on elem from elem_residual.
If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.
Many problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient variable u; users with more complicated transient problems will need to reimplement this themselves.
Reimplemented in libMesh::FEMPhysics.
Definition at line 265 of file diff_physics.h.
Referenced by libMesh::EulerSolver::element_residual(), libMesh::Euler2Solver::element_residual(), and libMesh::EigenTimeSolver::element_residual().
{
return request_jacobian;
}
| void libMesh::FEMSystem::mesh_position_get | ( | ) | [inherited] |
Tells the FEMSystem to set the degree of freedom coefficients which should correspond to mesh nodal coordinates.
Definition at line 1370 of file fem_system.C.
References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::DifferentiablePhysics::_mesh_x_var, libMesh::DifferentiablePhysics::_mesh_y_var, libMesh::DifferentiablePhysics::_mesh_z_var, libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::FEMSystem::build_context(), libMesh::FEMContext::elem_position_get(), libMesh::DiffContext::get_dof_indices(), libMesh::DiffContext::get_elem_solution(), libMesh::System::get_mesh(), libMesh::FEMSystem::init_context(), libMesh::invalid_uint, mesh, libMesh::FEMContext::pre_fe_reinit(), libMesh::System::solution, and libMesh::System::update().
{
// This function makes no sense unless we've already picked out some
// variable(s) to reflect mesh position coordinates
if (!_mesh_sys)
libmesh_error_msg("_mesh_sys was NULL!");
// We currently assume mesh variables are in our own system
if (_mesh_sys != this)
libmesh_not_implemented();
// Loop over every active mesh element on this processor
const MeshBase& mesh = this->get_mesh();
MeshBase::const_element_iterator el =
mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end_el =
mesh.active_local_elements_end();
UniquePtr<DiffContext> con = this->build_context();
FEMContext &_femcontext = cast_ref<FEMContext&>(*con);
this->init_context(_femcontext);
// Get the solution's mesh variables from every element
for ( ; el != end_el; ++el)
{
_femcontext.pre_fe_reinit(*this, *el);
_femcontext.elem_position_get();
if (_mesh_x_var != libMesh::invalid_uint)
this->solution->insert(_femcontext.get_elem_solution(_mesh_x_var),
_femcontext.get_dof_indices(_mesh_x_var) );
if (_mesh_y_var != libMesh::invalid_uint)
this->solution->insert(_femcontext.get_elem_solution(_mesh_y_var),
_femcontext.get_dof_indices(_mesh_y_var));
if (_mesh_z_var != libMesh::invalid_uint)
this->solution->insert(_femcontext.get_elem_solution(_mesh_z_var),
_femcontext.get_dof_indices(_mesh_z_var));
}
this->solution->close();
// And make sure the current_local_solution is up to date too
this->System::update();
}
| void libMesh::FEMSystem::mesh_position_set | ( | ) | [inherited] |
Tells the FEMSystem to set the mesh nodal coordinates which should correspond to degree of freedom coefficients.
Definition at line 1041 of file fem_system.C.
References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::FEMSystem::build_context(), libMesh::ParallelObject::comm(), libMesh::FEMContext::elem_fe_reinit(), libMesh::FEMContext::elem_position_set(), libMesh::FEMContext::get_elem(), libMesh::System::get_mesh(), libMesh::Elem::has_children(), libMesh::FEMSystem::init_context(), libMesh::libmesh_assert(), mesh, libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::FEMContext::pre_fe_reinit(), and libMesh::Parallel::sync_dofobject_data_by_id().
Referenced by libMesh::FEMSystem::solve().
{
// If we don't need to move the mesh, we're done
if (_mesh_sys != this)
return;
MeshBase& mesh = this->get_mesh();
UniquePtr<DiffContext> con = this->build_context();
FEMContext &_femcontext = cast_ref<FEMContext&>(*con);
this->init_context(_femcontext);
// Move every mesh element we can
MeshBase::const_element_iterator el =
mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end_el =
mesh.active_local_elements_end();
for ( ; el != end_el; ++el)
{
// We need the algebraic data
_femcontext.pre_fe_reinit(*this, *el);
// And when asserts are on, we also need the FE so
// we can assert that the mesh data is of the right type.
#ifndef NDEBUG
_femcontext.elem_fe_reinit();
#endif
// This code won't handle moving subactive elements
libmesh_assert(!_femcontext.get_elem().has_children());
_femcontext.elem_position_set(1.);
}
// We've now got positions set on all local nodes (and some
// semilocal nodes); let's request positions for non-local nodes
// from their processors.
SyncNodalPositions sync_object(mesh);
Parallel::sync_dofobject_data_by_id
(this->comm(), mesh.nodes_begin(), mesh.nodes_end(), sync_object);
}
| dof_id_type libMesh::System::n_active_dofs | ( | ) | const [inline, inherited] |
Returns the number of active degrees of freedom for this System.
Definition at line 2145 of file system.h.
References libMesh::System::n_constrained_dofs(), and libMesh::System::n_dofs().
{
return this->n_dofs() - this->n_constrained_dofs();
}
| unsigned int libMesh::System::n_components | ( | ) | const [inline, inherited] |
n_vars() in the case of all scalar-valued variables. Definition at line 2049 of file system.h.
References libMesh::System::_variables, libMesh::Variable::first_scalar_number(), and libMesh::Variable::n_components().
Referenced by libMesh::System::add_variables(), and libMesh::System::project_vector().
{
if (_variables.empty())
return 0;
const Variable& last = _variables.back();
return last.first_scalar_number() + last.n_components();
}
| dof_id_type libMesh::System::n_constrained_dofs | ( | ) | const [inherited] |
Definition at line 147 of file system.C.
References libMesh::System::_dof_map.
Referenced by libMesh::System::get_info(), and libMesh::System::n_active_dofs().
{
#ifdef LIBMESH_ENABLE_CONSTRAINTS
return _dof_map->n_constrained_dofs();
#else
return 0;
#endif
}
| dof_id_type libMesh::System::n_dofs | ( | ) | const [inherited] |
Definition at line 140 of file system.C.
References libMesh::System::_dof_map.
Referenced by libMesh::System::add_vector(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::System::n_active_dofs(), libMesh::CondensedEigenSystem::n_global_non_condensed_dofs(), libMesh::System::project_vector(), libMesh::System::read_legacy_data(), libMesh::UnsteadySolver::reinit(), libMesh::System::reinit(), and libMesh::System::restrict_vectors().
{
return _dof_map->n_dofs();
}
| dof_id_type libMesh::System::n_local_constrained_dofs | ( | ) | const [inherited] |
Definition at line 162 of file system.C.
References libMesh::System::_dof_map.
Referenced by libMesh::System::get_info().
{
#ifdef LIBMESH_ENABLE_CONSTRAINTS
return _dof_map->n_local_constrained_dofs();
#else
return 0;
#endif
}
| dof_id_type libMesh::System::n_local_dofs | ( | ) | const [inherited] |
Definition at line 177 of file system.C.
References libMesh::System::_dof_map, and libMesh::ParallelObject::processor_id().
Referenced by libMesh::System::add_vector(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_info(), libMesh::UnsteadySolver::init_data(), libMesh::System::init_data(), libMesh::System::project_vector(), libMesh::UnsteadySolver::reinit(), libMesh::System::reinit(), and libMesh::System::restrict_vectors().
{
return _dof_map->n_dofs_on_processor (this->processor_id());
}
| unsigned int libMesh::ImplicitSystem::n_matrices | ( | ) | const [inline, virtual, inherited] |
Reimplemented from libMesh::System.
Definition at line 388 of file implicit_system.h.
References libMesh::ImplicitSystem::_matrices.
{
return cast_int<unsigned int>(_matrices.size());
}
| static unsigned int libMesh::ReferenceCounter::n_objects | ( | ) | [inline, static, inherited] |
Prints the number of outstanding (created, but not yet destroyed) objects.
Definition at line 79 of file reference_counter.h.
References libMesh::ReferenceCounter::_n_objects.
Referenced by libMesh::LibMeshInit::~LibMeshInit().
{ return _n_objects; }
| processor_id_type libMesh::ParallelObject::n_processors | ( | ) | const [inline, inherited] |
Definition at line 92 of file parallel_object.h.
References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::size().
Referenced by libMesh::ParmetisPartitioner::_do_repartition(), libMesh::ParallelMesh::add_elem(), libMesh::ParallelMesh::add_node(), libMesh::LaplaceMeshSmoother::allgather_graph(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::AztecLinearSolver< T >::AztecLinearSolver(), libMesh::ParallelMesh::clear(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::UnstructuredMesh::create_pid_mesh(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::EnsightIO::EnsightIO(), libMesh::MeshBase::get_info(), libMesh::EquationSystems::init(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::Nemesis_IO_Helper::initialize(), libMesh::MeshTools::libmesh_assert_valid_dof_ids(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::MeshTools::libmesh_assert_valid_refinement_flags(), libMesh::DofMap::local_variable_indices(), libMesh::MeshBase::n_active_elem_on_proc(), libMesh::MeshBase::n_elem_on_proc(), libMesh::MeshBase::n_nodes_on_proc(), libMesh::Partitioner::partition(), libMesh::MeshBase::partition(), libMesh::Partitioner::partition_unpartitioned_elements(), libMesh::PetscLinearSolver< T >::PetscLinearSolver(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::MeshTools::processor_bounding_box(), libMesh::System::project_vector(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::Partitioner::repartition(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::BoundaryInfo::sync(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::CheckpointIO::write(), libMesh::GMVIO::write_binary(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), and libMesh::XdrIO::write_serialized_nodesets().
{ return cast_int<processor_id_type>(_communicator.size()); }
| unsigned int libMesh::System::n_variable_groups | ( | ) | const [inline, inherited] |
VariableGroup variable groups in the system Definition at line 2041 of file system.h.
References libMesh::System::_variable_groups.
Referenced by libMesh::System::add_variable(), libMesh::FEMSystem::assembly(), libMesh::System::get_info(), and libMesh::System::init_data().
{
return cast_int<unsigned int>(_variable_groups.size());
}
| unsigned int libMesh::System::n_vars | ( | ) | const [inline, inherited] |
Definition at line 2033 of file system.h.
References libMesh::System::_variables.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::DiffContext::add_localized_vector(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::System::calculate_norm(), libMesh::DGFEMContext::DGFEMContext(), libMesh::DiffContext::DiffContext(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ErrorEstimator::estimate_errors(), libMesh::ExactSolution::ExactSolution(), libMesh::FEMContext::FEMContext(), libMesh::System::get_all_variable_numbers(), libMesh::EquationSystems::get_solution(), libMesh::System::init(), libMesh::FEMSystem::init_context(), libMesh::DGFEMContext::neighbor_side_fe_reinit(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::petsc_auto_fieldsplit(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_vector(), libMesh::System::re_update(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::System::reinit(), libMesh::HPCoarsenTest::select_refinement(), libMesh::SystemSubsetBySubdomain::set_var_nums(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), and libMesh::System::zero_variable().
{
return cast_int<unsigned int>(_variables.size());
}
| unsigned int libMesh::System::n_vectors | ( | ) | const [inline, inherited] |
_vectors map Definition at line 2161 of file system.h.
References libMesh::System::_vectors.
Referenced by libMesh::ExplicitSystem::add_system_rhs(), libMesh::System::compare(), libMesh::System::get_info(), and libMesh::System::write_header().
{
return cast_int<unsigned int>(_vectors.size());
}
| const std::string & libMesh::System::name | ( | ) | const [inline, inherited] |
Definition at line 1945 of file system.h.
References libMesh::System::_sys_name.
Referenced by libMesh::System::compare(), ContinuationSystem(), DMlibMeshSetUpName_Private(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactSolution::ExactSolution(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::System::get_info(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::NewtonSolver::init(), libMesh::TimeSolver::init_data(), libMesh::petsc_auto_fieldsplit(), libMesh::TimeSolver::reinit(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::NonlinearImplicitSystem::solve(), libMesh::System::user_assembly(), libMesh::System::user_constrain(), libMesh::System::user_initialization(), libMesh::System::user_QOI(), libMesh::System::user_QOI_derivative(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), and libMesh::System::write_serialized_data().
{
return _sys_name;
}
| virtual bool libMesh::DifferentiablePhysics::nonlocal_constraint | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Adds any nonlocal constraint contributions (e.g. some components of constraints in scalar variable equations) to elem_residual
If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.
Users may need to reimplement this for PDEs on systems to which SCALAR variables with non-tranient equations have been added.
Definition at line 204 of file diff_physics.h.
Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::SteadySolver::nonlocal_residual(), and libMesh::EigenTimeSolver::nonlocal_residual().
{
return request_jacobian;
}
| virtual bool libMesh::DifferentiablePhysics::nonlocal_mass_residual | ( | bool | request_jacobian, |
| DiffContext & | c | ||
| ) | [virtual, inherited] |
Subtracts any nonlocal mass vector contributions (e.g. any time derivative coefficients in scalar variable equations) from elem_residual
If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.
Many problems can use the reimplementation in FEMPhysics::mass_residual which subtracts (du/dt,v) for each transient scalar variable u; users with more complicated transient scalar variable equations will need to reimplement this themselves.
Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), and libMesh::EigenTimeSolver::nonlocal_residual().
| virtual bool libMesh::DifferentiablePhysics::nonlocal_time_derivative | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Adds any nonlocal time derivative contributions (e.g. some components of time derivatives in scalar variable equations) to elem_residual
If this method receives request_jacobian = true, then it should also modify elem_jacobian and return true if possible. If the Jacobian changes have not been computed then the method should return false.
Users may need to reimplement this for PDEs on systems to which SCALAR variables have been added.
Definition at line 186 of file diff_physics.h.
Referenced by libMesh::EulerSolver::nonlocal_residual(), libMesh::Euler2Solver::nonlocal_residual(), libMesh::SteadySolver::nonlocal_residual(), and libMesh::EigenTimeSolver::nonlocal_residual().
{
return request_jacobian;
}
| unsigned int libMesh::System::number | ( | ) | const [inline, inherited] |
Definition at line 1953 of file system.h.
References libMesh::System::_sys_number.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::EquationSystems::build_solution_vector(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::System::get_info(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::HPCoarsenTest::select_refinement(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::System::zero_variable().
{
return _sys_number;
}
| void libMesh::FEMSystem::numerical_elem_jacobian | ( | FEMContext & | context | ) | const [inherited] |
Uses the results of multiple element_residual() calls to numerically differentiate the corresponding jacobian on an element.
Definition at line 1272 of file fem_system.C.
References libMesh::TimeSolver::element_residual(), libMesh::FEMSystem::numerical_jacobian(), and libMesh::START_LOG().
{
START_LOG("numerical_elem_jacobian()", "FEMSystem");
this->numerical_jacobian(&TimeSolver::element_residual, context);
STOP_LOG("numerical_elem_jacobian()", "FEMSystem");
}
| void libMesh::FEMSystem::numerical_jacobian | ( | TimeSolverResPtr | res, |
| FEMContext & | context | ||
| ) | const [inherited] |
Uses the results of multiple res calls to numerically differentiate the corresponding jacobian.
Definition at line 1169 of file fem_system.C.
References libMesh::DifferentiablePhysics::_mesh_sys, libMesh::DifferentiablePhysics::_mesh_x_var, libMesh::DifferentiablePhysics::_mesh_y_var, libMesh::DifferentiablePhysics::_mesh_z_var, libMesh::DiffContext::get_dof_indices(), libMesh::FEMContext::get_elem(), libMesh::DiffContext::get_elem_jacobian(), libMesh::DiffContext::get_elem_residual(), libMesh::DiffContext::get_elem_solution(), libMesh::Elem::hmin(), libMesh::invalid_uint, libMesh::libmesh_real(), libMesh::FEMSystem::numerical_jacobian_h, libMesh::Elem::point(), libMesh::Real, and libMesh::DenseVector< T >::zero().
Referenced by libMesh::FEMSystem::numerical_elem_jacobian(), libMesh::FEMSystem::numerical_nonlocal_jacobian(), and libMesh::FEMSystem::numerical_side_jacobian().
{
// Logging is done by numerical_elem_jacobian
// or numerical_side_jacobian
DenseVector<Number> original_residual(context.get_elem_residual());
DenseVector<Number> backwards_residual(context.get_elem_residual());
DenseMatrix<Number> numeric_jacobian(context.get_elem_jacobian());
#ifdef DEBUG
DenseMatrix<Number> old_jacobian(context.get_elem_jacobian());
#endif
Real numerical_point_h = 0.;
if (_mesh_sys == this)
numerical_point_h = numerical_jacobian_h * context.get_elem().hmin();
for (unsigned int j = 0; j != context.get_dof_indices().size(); ++j)
{
// Take the "minus" side of a central differenced first derivative
Number original_solution = context.get_elem_solution()(j);
context.get_elem_solution()(j) -= numerical_jacobian_h;
// Make sure to catch any moving mesh terms
// FIXME - this could be less ugly
Real *coord = NULL;
if (_mesh_sys == this)
{
if (_mesh_x_var != libMesh::invalid_uint)
for (unsigned int k = 0;
k != context.get_dof_indices( _mesh_x_var ).size(); ++k)
if (context.get_dof_indices( _mesh_x_var )[k] ==
context.get_dof_indices()[j])
coord = &(context.get_elem().point(k)(0));
if (_mesh_y_var != libMesh::invalid_uint)
for (unsigned int k = 0;
k != context.get_dof_indices( _mesh_y_var ).size(); ++k)
if (context.get_dof_indices( _mesh_y_var )[k] ==
context.get_dof_indices()[j])
coord = &(context.get_elem().point(k)(1));
if (_mesh_z_var != libMesh::invalid_uint)
for (unsigned int k = 0;
k != context.get_dof_indices( _mesh_z_var ).size(); ++k)
if (context.get_dof_indices( _mesh_z_var )[k] ==
context.get_dof_indices()[j])
coord = &(context.get_elem().point(k)(2));
}
if (coord)
{
// We have enough information to scale the perturbations
// here appropriately
context.get_elem_solution()(j) = original_solution - numerical_point_h;
*coord = libmesh_real(context.get_elem_solution()(j));
}
context.get_elem_residual().zero();
((*time_solver).*(res))(false, context);
#ifdef DEBUG
libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
#endif
backwards_residual = context.get_elem_residual();
// Take the "plus" side of a central differenced first derivative
context.get_elem_solution()(j) = original_solution + numerical_jacobian_h;
if (coord)
{
context.get_elem_solution()(j) = original_solution + numerical_point_h;
*coord = libmesh_real(context.get_elem_solution()(j));
}
context.get_elem_residual().zero();
((*time_solver).*(res))(false, context);
#ifdef DEBUG
libmesh_assert_equal_to (old_jacobian, context.get_elem_jacobian());
#endif
context.get_elem_solution()(j) = original_solution;
if (coord)
{
*coord = libmesh_real(context.get_elem_solution()(j));
for (unsigned int i = 0; i != context.get_dof_indices().size(); ++i)
{
numeric_jacobian(i,j) =
(context.get_elem_residual()(i) - backwards_residual(i)) /
2. / numerical_point_h;
}
}
else
{
for (unsigned int i = 0; i != context.get_dof_indices().size(); ++i)
{
numeric_jacobian(i,j) =
(context.get_elem_residual()(i) - backwards_residual(i)) /
2. / numerical_jacobian_h;
}
}
}
context.get_elem_residual() = original_residual;
context.get_elem_jacobian() = numeric_jacobian;
}
| void libMesh::FEMSystem::numerical_nonlocal_jacobian | ( | FEMContext & | context | ) | const [inherited] |
Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jacobian on nonlocal DoFs.
Definition at line 1290 of file fem_system.C.
References libMesh::TimeSolver::nonlocal_residual(), libMesh::FEMSystem::numerical_jacobian(), and libMesh::START_LOG().
Referenced by libMesh::FEMSystem::assembly().
{
START_LOG("numerical_nonlocal_jacobian()", "FEMSystem");
this->numerical_jacobian(&TimeSolver::nonlocal_residual, context);
STOP_LOG("numerical_nonlocal_jacobian()", "FEMSystem");
}
| void libMesh::FEMSystem::numerical_side_jacobian | ( | FEMContext & | context | ) | const [inherited] |
Uses the results of multiple side_residual() calls to numerically differentiate the corresponding jacobian on an element's side.
Definition at line 1281 of file fem_system.C.
References libMesh::FEMSystem::numerical_jacobian(), libMesh::TimeSolver::side_residual(), and libMesh::START_LOG().
{
START_LOG("numerical_side_jacobian()", "FEMSystem");
this->numerical_jacobian(&TimeSolver::side_residual, context);
STOP_LOG("numerical_side_jacobian()", "FEMSystem");
}
| virtual void libMesh::DifferentiableQoI::parallel_op | ( | const Parallel::Communicator & | communicator, |
| std::vector< Number > & | sys_qoi, | ||
| std::vector< Number > & | local_qoi, | ||
| const QoISet & | qoi_indices | ||
| ) | [virtual, inherited] |
Method to populate system qoi data structure with process-local qoi. By default, simply sums process qois into system qoi.
Referenced by libMesh::FEMSystem::assemble_qoi().
| Gradient libMesh::System::point_gradient | ( | unsigned int | var, |
| const Point & | p, | ||
| const bool | insist_on_success = true |
||
| ) | const [inherited] |
Returns the gradient of the solution variable var at the physical point p in the mesh, similarly to point_value.
Definition at line 2092 of file system.C.
References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().
{
// This function must be called on every processor; there's no
// telling where in the partition p falls.
parallel_object_only();
// And every processor had better agree about which point we're
// looking for
#ifndef NDEBUG
this->comm().verify(p);
#endif // NDEBUG
// Get a reference to the mesh object associated with the system object that calls this function
const MeshBase &mesh = this->get_mesh();
// Use an existing PointLocator or create a new one
UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
PointLocatorBase& locator = *locator_ptr;
if (!insist_on_success)
locator.enable_out_of_mesh_mode();
// Get a pointer to the element that contains P
const Elem *e = locator(p);
Gradient grad_u;
if (e && e->processor_id() == this->processor_id())
grad_u = point_gradient(var, p, *e);
// If I have an element containing p, then let's let everyone know
processor_id_type lowest_owner =
(e && (e->processor_id() == this->processor_id())) ?
this->processor_id() : this->n_processors();
this->comm().min(lowest_owner);
// Everybody should get their value from a processor that was able
// to compute it.
// If nobody admits owning the point, we may have a problem.
if (lowest_owner != this->n_processors())
this->comm().broadcast(grad_u, lowest_owner);
else
libmesh_assert(!insist_on_success);
return grad_u;
}
| Gradient libMesh::System::point_gradient | ( | unsigned int | var, |
| const Point & | p, | ||
| const Elem & | e | ||
| ) | const [inherited] |
Returns the gradient of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.
Definition at line 2140 of file system.C.
References libMesh::TypeVector< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().
{
libmesh_assert_equal_to (e.processor_id(), this->processor_id());
// Ensuring that the given point is really in the element is an
// expensive assert, but as long as debugging is turned on we might
// as well try to catch a particularly nasty potential error
libmesh_assert (e.contains_point(p));
// Get the dof map to get the proper indices for our computation
const DofMap& dof_map = this->get_dof_map();
// Need dof_indices for phi[i][j]
std::vector<dof_id_type> dof_indices;
// Fill in the dof_indices for our element
dof_map.dof_indices (&e, dof_indices, var);
// Get the no of dofs assciated with this point
const unsigned int num_dofs = cast_int<unsigned int>
(dof_indices.size());
FEType fe_type = dof_map.variable_type(var);
// Build a FE again so we can calculate u(p)
UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
// Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
// Build a vector of point co-ordinates to send to reinit
std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
// Get the values of the shape function derivatives
const std::vector<std::vector<RealGradient> >& dphi = fe->get_dphi();
// Reinitialize the element and compute the shape function values at coor
fe->reinit (&e, &coor);
// Get ready to accumulate a gradient
Gradient grad_u;
for (unsigned int l=0; l<num_dofs; l++)
{
grad_u.add_scaled (dphi[l][0], this->current_solution (dof_indices[l]));
}
return grad_u;
}
| Tensor libMesh::System::point_hessian | ( | unsigned int | var, |
| const Point & | p, | ||
| const bool | insist_on_success = true |
||
| ) | const [inherited] |
Returns the second derivative tensor of the solution variable var at the physical point p in the mesh, similarly to point_value.
Definition at line 2191 of file system.C.
References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().
{
// This function must be called on every processor; there's no
// telling where in the partition p falls.
parallel_object_only();
// And every processor had better agree about which point we're
// looking for
#ifndef NDEBUG
this->comm().verify(p);
#endif // NDEBUG
// Get a reference to the mesh object associated with the system object that calls this function
const MeshBase &mesh = this->get_mesh();
// Use an existing PointLocator or create a new one
UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
PointLocatorBase& locator = *locator_ptr;
if (!insist_on_success)
locator.enable_out_of_mesh_mode();
// Get a pointer to the element that contains P
const Elem *e = locator(p);
Tensor hess_u;
if (e && e->processor_id() == this->processor_id())
hess_u = point_hessian(var, p, *e);
// If I have an element containing p, then let's let everyone know
processor_id_type lowest_owner =
(e && (e->processor_id() == this->processor_id())) ?
this->processor_id() : this->n_processors();
this->comm().min(lowest_owner);
// Everybody should get their value from a processor that was able
// to compute it.
// If nobody admits owning the point, we may have a problem.
if (lowest_owner != this->n_processors())
this->comm().broadcast(hess_u, lowest_owner);
else
libmesh_assert(!insist_on_success);
return hess_u;
}
| Tensor libMesh::System::point_hessian | ( | unsigned int | var, |
| const Point & | p, | ||
| const Elem & | e | ||
| ) | const [inherited] |
Returns the second derivative tensor of the solution variable var at the physical point p in local Elem e in the mesh, similarly to point_value.
Definition at line 2238 of file system.C.
References libMesh::TypeTensor< T >::add_scaled(), libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().
{
libmesh_assert_equal_to (e.processor_id(), this->processor_id());
// Ensuring that the given point is really in the element is an
// expensive assert, but as long as debugging is turned on we might
// as well try to catch a particularly nasty potential error
libmesh_assert (e.contains_point(p));
// Get the dof map to get the proper indices for our computation
const DofMap& dof_map = this->get_dof_map();
// Need dof_indices for phi[i][j]
std::vector<dof_id_type> dof_indices;
// Fill in the dof_indices for our element
dof_map.dof_indices (&e, dof_indices, var);
// Get the no of dofs assciated with this point
const unsigned int num_dofs = cast_int<unsigned int>
(dof_indices.size());
FEType fe_type = dof_map.variable_type(var);
// Build a FE again so we can calculate u(p)
UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
// Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
// Build a vector of point co-ordinates to send to reinit
std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
// Get the values of the shape function derivatives
const std::vector<std::vector<RealTensor> >& d2phi = fe->get_d2phi();
// Reinitialize the element and compute the shape function values at coor
fe->reinit (&e, &coor);
// Get ready to accumulate a hessian
Tensor hess_u;
for (unsigned int l=0; l<num_dofs; l++)
{
hess_u.add_scaled (d2phi[l][0], this->current_solution (dof_indices[l]));
}
return hess_u;
}
| Number libMesh::System::point_value | ( | unsigned int | var, |
| const Point & | p, | ||
| const bool | insist_on_success = true |
||
| ) | const [inherited] |
Returns the value of the solution variable var at the physical point p in the mesh, without knowing a priori which element contains p.
Note that this function uses MeshBase::sub_point_locator(); users may or may not want to call MeshBase::clear_point_locator() afterward. Also, point_locator() is expensive (N log N for initial construction, log N for evaluations). Avoid using this function in any context where you are already looping over elements.
Because the element containing p may lie on any processor, this function is parallel-only.
By default this method expects the point to reside inside the domain and will abort if no element can be found which contains . The optional parameter insist_on_success can be set to false to allow the method to return 0 when the point is not located.
Definition at line 1995 of file system.C.
References libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::PointLocatorBase::enable_out_of_mesh_mode(), libMesh::System::get_mesh(), libMesh::libmesh_assert(), mesh, libMesh::Parallel::Communicator::min(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::processor_id(), libMesh::DofObject::processor_id(), libMesh::MeshBase::sub_point_locator(), and libMesh::Parallel::Communicator::verify().
{
// This function must be called on every processor; there's no
// telling where in the partition p falls.
parallel_object_only();
// And every processor had better agree about which point we're
// looking for
#ifndef NDEBUG
this->comm().verify(p);
#endif // NDEBUG
// Get a reference to the mesh object associated with the system object that calls this function
const MeshBase &mesh = this->get_mesh();
// Use an existing PointLocator or create a new one
UniquePtr<PointLocatorBase> locator_ptr = mesh.sub_point_locator();
PointLocatorBase& locator = *locator_ptr;
if (!insist_on_success)
locator.enable_out_of_mesh_mode();
// Get a pointer to the element that contains P
const Elem *e = locator(p);
Number u = 0;
if (e && e->processor_id() == this->processor_id())
u = point_value(var, p, *e);
// If I have an element containing p, then let's let everyone know
processor_id_type lowest_owner =
(e && (e->processor_id() == this->processor_id())) ?
this->processor_id() : this->n_processors();
this->comm().min(lowest_owner);
// Everybody should get their value from a processor that was able
// to compute it.
// If nobody admits owning the point, we have a problem.
if (lowest_owner != this->n_processors())
this->comm().broadcast(u, lowest_owner);
else
libmesh_assert(!insist_on_success);
return u;
}
| Number libMesh::System::point_value | ( | unsigned int | var, |
| const Point & | p, | ||
| const Elem & | e | ||
| ) | const [inherited] |
Returns the value of the solution variable var at the physical point p contained in local Elem e
This version of point_value can be run in serial, but assumes e is in the local mesh partition.
Definition at line 2042 of file system.C.
References libMesh::FEGenericBase< OutputType >::build(), libMesh::Elem::contains_point(), libMesh::System::current_solution(), libMesh::Elem::dim(), libMesh::System::get_dof_map(), libMesh::FEInterface::inverse_map(), libMesh::libmesh_assert(), libMesh::ParallelObject::processor_id(), and libMesh::DofObject::processor_id().
{
libmesh_assert_equal_to (e.processor_id(), this->processor_id());
// Ensuring that the given point is really in the element is an
// expensive assert, but as long as debugging is turned on we might
// as well try to catch a particularly nasty potential error
libmesh_assert (e.contains_point(p));
// Get the dof map to get the proper indices for our computation
const DofMap& dof_map = this->get_dof_map();
// Need dof_indices for phi[i][j]
std::vector<dof_id_type> dof_indices;
// Fill in the dof_indices for our element
dof_map.dof_indices (&e, dof_indices, var);
// Get the no of dofs assciated with this point
const unsigned int num_dofs = cast_int<unsigned int>
(dof_indices.size());
FEType fe_type = dof_map.variable_type(var);
// Build a FE so we can calculate u(p)
UniquePtr<FEBase> fe (FEBase::build(e.dim(), fe_type));
// Map the physical co-ordinates to the master co-ordinates using the inverse_map from fe_interface.h
// Build a vector of point co-ordinates to send to reinit
std::vector<Point> coor(1, FEInterface::inverse_map(e.dim(), fe_type, &e, p));
// Get the shape function values
const std::vector<std::vector<Real> >& phi = fe->get_phi();
// Reinitialize the element and compute the shape function values at coor
fe->reinit (&e, &coor);
// Get ready to accumulate a value
Number u = 0;
for (unsigned int l=0; l<num_dofs; l++)
{
u += phi[l][0]*this->current_solution (dof_indices[l]);
}
return u;
}
| void libMesh::FEMSystem::postprocess | ( | ) | [virtual, inherited] |
Runs a postprocessing loop over all elements, and if postprocess_sides is true over all sides.
Reimplemented from libMesh::DifferentiableSystem.
Definition at line 1086 of file fem_system.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::System::get_mesh(), libMesh::DifferentiableSystem::get_time_solver(), mesh, libMesh::Threads::parallel_for(), libMesh::TimeSolver::set_is_adjoint(), libMesh::START_LOG(), and libMesh::System::update().
{
START_LOG("postprocess()", "FEMSystem");
const MeshBase& mesh = this->get_mesh();
this->update();
// Get the time solver object associated with the system, and tell it that
// we are not solving the adjoint problem
this->get_time_solver().set_is_adjoint(false);
// Loop over every active mesh element on this processor
Threads::parallel_for(elem_range.reset(mesh.active_local_elements_begin(),
mesh.active_local_elements_end()),
PostprocessContributions(*this));
STOP_LOG("postprocess()", "FEMSystem");
}
| void libMesh::ReferenceCounter::print_info | ( | std::ostream & | out = libMesh::out | ) | [static, inherited] |
Prints the reference information, by default to libMesh::out.
Definition at line 88 of file reference_counter.C.
References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().
Referenced by libMesh::LibMeshInit::~LibMeshInit().
{
if( _enable_print_counter ) out_stream << ReferenceCounter::get_info();
}
| processor_id_type libMesh::ParallelObject::processor_id | ( | ) | const [inline, inherited] |
Definition at line 98 of file parallel_object.h.
References libMesh::ParallelObject::_communicator, and libMesh::Parallel::Communicator::rank().
Referenced by libMesh::MetisPartitioner::_do_partition(), libMesh::EquationSystems::_read_impl(), libMesh::SerialMesh::active_local_elements_begin(), libMesh::ParallelMesh::active_local_elements_begin(), libMesh::SerialMesh::active_local_elements_end(), libMesh::ParallelMesh::active_local_elements_end(), libMesh::SerialMesh::active_local_subdomain_elements_begin(), libMesh::ParallelMesh::active_local_subdomain_elements_begin(), libMesh::SerialMesh::active_local_subdomain_elements_end(), libMesh::ParallelMesh::active_local_subdomain_elements_end(), libMesh::SerialMesh::active_not_local_elements_begin(), libMesh::ParallelMesh::active_not_local_elements_begin(), libMesh::SerialMesh::active_not_local_elements_end(), libMesh::ParallelMesh::active_not_local_elements_end(), libMesh::ParallelMesh::add_elem(), libMesh::DofMap::add_neighbors_to_send_list(), libMesh::ParallelMesh::add_node(), libMesh::UnstructuredMesh::all_second_order(), libMesh::FEMSystem::assembly(), libMesh::ParmetisPartitioner::assign_partitioning(), libMesh::ParallelMesh::assign_unique_ids(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::Nemesis_IO_Helper::build_element_and_node_maps(), libMesh::ParmetisPartitioner::build_graph(), libMesh::InfElemBuilder::build_inf_elem(), libMesh::DofMap::build_sparsity(), libMesh::ParallelMesh::clear(), libMesh::ExodusII_IO_Helper::close(), libMesh::Nemesis_IO_Helper::compute_border_node_ids(), libMesh::Nemesis_IO_Helper::compute_communication_map_parameters(), libMesh::Nemesis_IO_Helper::compute_internal_and_border_elems_and_internal_nodes(), libMesh::Nemesis_IO_Helper::compute_node_communication_maps(), libMesh::Nemesis_IO_Helper::compute_num_global_elem_blocks(), libMesh::Nemesis_IO_Helper::compute_num_global_nodesets(), libMesh::Nemesis_IO_Helper::compute_num_global_sidesets(), libMesh::Nemesis_IO_Helper::construct_nemesis_filename(), libMesh::ExodusII_IO_Helper::create(), libMesh::ParallelMesh::delete_elem(), libMesh::ParallelMesh::delete_node(), libMesh::DofMap::distribute_dofs(), libMesh::DofMap::distribute_local_dofs_node_major(), libMesh::DofMap::distribute_local_dofs_var_major(), libMesh::DofMap::end_dof(), libMesh::DofMap::end_old_dof(), libMesh::EnsightIO::EnsightIO(), libMesh::SerialMesh::facelocal_elements_begin(), libMesh::ParallelMesh::facelocal_elements_begin(), libMesh::SerialMesh::facelocal_elements_end(), libMesh::ParallelMesh::facelocal_elements_end(), libMesh::MeshFunction::find_element(), libMesh::UnstructuredMesh::find_neighbors(), libMesh::DofMap::first_dof(), libMesh::DofMap::first_old_dof(), libMesh::Nemesis_IO_Helper::get_cmap_params(), libMesh::Nemesis_IO_Helper::get_eb_info_global(), libMesh::Nemesis_IO_Helper::get_elem_cmap(), libMesh::Nemesis_IO_Helper::get_elem_map(), libMesh::MeshBase::get_info(), libMesh::Nemesis_IO_Helper::get_init_global(), libMesh::Nemesis_IO_Helper::get_init_info(), libMesh::Nemesis_IO_Helper::get_loadbal_param(), libMesh::Nemesis_IO_Helper::get_node_cmap(), libMesh::Nemesis_IO_Helper::get_node_map(), libMesh::Nemesis_IO_Helper::get_ns_param_global(), libMesh::Nemesis_IO_Helper::get_ss_param_global(), libMesh::SystemSubsetBySubdomain::init(), libMesh::ParmetisPartitioner::initialize(), libMesh::ExodusII_IO_Helper::initialize(), libMesh::ExodusII_IO_Helper::initialize_element_variables(), libMesh::ExodusII_IO_Helper::initialize_global_variables(), libMesh::ExodusII_IO_Helper::initialize_nodal_variables(), libMesh::ParallelMesh::insert_elem(), libMesh::SparsityPattern::Build::join(), libMesh::DofMap::last_dof(), libMesh::MeshTools::libmesh_assert_valid_procids< Elem >(), libMesh::MeshTools::libmesh_assert_valid_procids< Node >(), libMesh::SerialMesh::local_elements_begin(), libMesh::ParallelMesh::local_elements_begin(), libMesh::SerialMesh::local_elements_end(), libMesh::ParallelMesh::local_elements_end(), libMesh::SerialMesh::local_level_elements_begin(), libMesh::ParallelMesh::local_level_elements_begin(), libMesh::SerialMesh::local_level_elements_end(), libMesh::ParallelMesh::local_level_elements_end(), libMesh::SerialMesh::local_nodes_begin(), libMesh::ParallelMesh::local_nodes_begin(), libMesh::SerialMesh::local_nodes_end(), libMesh::ParallelMesh::local_nodes_end(), libMesh::SerialMesh::local_not_level_elements_begin(), libMesh::ParallelMesh::local_not_level_elements_begin(), libMesh::SerialMesh::local_not_level_elements_end(), libMesh::ParallelMesh::local_not_level_elements_end(), libMesh::DofMap::local_variable_indices(), libMesh::MeshRefinement::make_coarsening_compatible(), libMesh::MeshBase::n_active_local_elem(), libMesh::BoundaryInfo::n_boundary_conds(), libMesh::BoundaryInfo::n_edge_conds(), libMesh::DofMap::n_local_dofs(), libMesh::System::n_local_dofs(), libMesh::MeshBase::n_local_elem(), libMesh::MeshBase::n_local_nodes(), libMesh::BoundaryInfo::n_nodeset_conds(), libMesh::SerialMesh::not_local_elements_begin(), libMesh::ParallelMesh::not_local_elements_begin(), libMesh::SerialMesh::not_local_elements_end(), libMesh::ParallelMesh::not_local_elements_end(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::SparsityPattern::Build::operator()(), libMesh::PatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ParallelMesh::ParallelMesh(), libMesh::System::point_gradient(), libMesh::System::point_hessian(), libMesh::System::point_value(), libMesh::System::project_vector(), libMesh::Nemesis_IO_Helper::put_cmap_params(), libMesh::Nemesis_IO_Helper::put_elem_cmap(), libMesh::Nemesis_IO_Helper::put_elem_map(), libMesh::Nemesis_IO_Helper::put_loadbal_param(), libMesh::Nemesis_IO_Helper::put_node_cmap(), libMesh::Nemesis_IO_Helper::put_node_map(), libMesh::NameBasedIO::read(), libMesh::Nemesis_IO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::ExodusII_IO_Helper::read_elem_num_map(), libMesh::System::read_header(), libMesh::System::read_legacy_data(), libMesh::ExodusII_IO_Helper::read_node_num_map(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::XdrIO::read_serialized_bc_names(), libMesh::XdrIO::read_serialized_bcs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::System::read_serialized_data(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::MeshData::read_xdr(), libMesh::SerialMesh::semilocal_elements_begin(), libMesh::ParallelMesh::semilocal_elements_begin(), libMesh::SerialMesh::semilocal_elements_end(), libMesh::ParallelMesh::semilocal_elements_end(), libMesh::Partitioner::set_node_processor_ids(), libMesh::DofMap::set_nonlocal_dof_objects(), libMesh::LaplaceMeshSmoother::smooth(), libMesh::BoundaryInfo::sync(), libMesh::MeshTools::total_weight(), libMesh::ParallelMesh::update_parallel_id_counts(), libMesh::MeshTools::weight(), libMesh::NameBasedIO::write(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::EquationSystems::write(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::ExodusII_IO_Helper::write_element_values(), libMesh::ExodusII_IO_Helper::write_elements(), libMesh::ExodusII_IO::write_global_data(), libMesh::ExodusII_IO_Helper::write_global_values(), libMesh::System::write_header(), libMesh::ExodusII_IO::write_information_records(), libMesh::ExodusII_IO_Helper::write_information_records(), libMesh::ExodusII_IO_Helper::write_nodal_coordinates(), libMesh::UCDIO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::ExodusII_IO_Helper::write_nodal_values(), libMesh::ExodusII_IO_Helper::write_nodesets(), libMesh::Nemesis_IO_Helper::write_nodesets(), libMesh::System::write_parallel_data(), libMesh::System::write_SCALAR_dofs(), libMesh::XdrIO::write_serialized_bc_names(), libMesh::XdrIO::write_serialized_bcs(), libMesh::System::write_serialized_blocked_dof_objects(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::System::write_serialized_data(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::System::write_serialized_vector(), libMesh::System::write_serialized_vectors(), libMesh::ExodusII_IO_Helper::write_sidesets(), libMesh::Nemesis_IO_Helper::write_sidesets(), libMesh::ExodusII_IO::write_timestep(), and libMesh::ExodusII_IO_Helper::write_timestep().
{ return cast_int<processor_id_type>(_communicator.rank()); }
| void libMesh::System::project_solution | ( | FunctionBase< Number > * | f, |
| FunctionBase< Gradient > * | g = NULL |
||
| ) | const [inherited] |
Projects arbitrary functions onto the current solution. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 472 of file system_projection.C.
References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::System::project_vector(), and libMesh::System::solution.
Referenced by libMesh::System::project_solution().
{
this->project_vector(*solution, f, g);
solution->localize(*current_local_solution, _dof_map->get_send_list());
}
| void libMesh::System::project_solution | ( | FEMFunctionBase< Number > * | f, |
| FEMFunctionBase< Gradient > * | g = NULL |
||
| ) | const [inherited] |
Projects arbitrary functions onto the current solution. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 485 of file system_projection.C.
References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::System::project_vector(), and libMesh::System::solution.
{
this->project_vector(*solution, f, g);
solution->localize(*current_local_solution, _dof_map->get_send_list());
}
| void libMesh::System::project_solution | ( | Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, |
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | ||
| const Parameters & | parameters | ||
| ) | const [inherited] |
Projects arbitrary functions onto the current solution. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
This method projects an arbitrary function onto the solution via L2 projections and nodal interpolations on each element.
Definition at line 452 of file system_projection.C.
References libMesh::System::project_solution().
{
WrappedFunction<Number> f(*this, fptr, ¶meters);
WrappedFunction<Gradient> g(*this, gptr, ¶meters);
this->project_solution(&f, &g);
}
| bool& libMesh::System::project_solution_on_reinit | ( | void | ) | [inline, inherited] |
Tells the System whether or not to project the solution vector onto new grids when the system is reinitialized. The solution will be projected unless project_solution_on_reinit() = false is called.
Definition at line 797 of file system.h.
References libMesh::System::_solution_projection.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), and libMesh::MemorySolutionHistory::store().
{ return _solution_projection; }
| void libMesh::System::project_vector | ( | NumericVector< Number > & | new_vector, |
| FunctionBase< Number > * | f, | ||
| FunctionBase< Gradient > * | g = NULL, |
||
| int | is_adjoint = -1 |
||
| ) | const [inherited] |
Projects arbitrary functions onto a vector of degree of freedom values for the current system. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.
This method projects an arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 519 of file system_projection.C.
References libMesh::NumericVector< T >::close(), libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_equation_systems(), libMesh::System::get_mesh(), libMesh::System::n_components(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::Threads::parallel_for(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), libMesh::START_LOG(), libMesh::System::time, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::System::variable_scalar_number().
Referenced by libMesh::System::project_solution(), libMesh::System::project_vector(), and libMesh::System::restrict_vectors().
{
START_LOG ("project_vector()", "System");
Threads::parallel_for
(ConstElemRange (this->get_mesh().active_local_elements_begin(),
this->get_mesh().active_local_elements_end() ),
ProjectSolution(*this, f, g,
this->get_equation_systems().parameters,
new_vector)
);
// Also, load values into the SCALAR dofs
// Note: We assume that all SCALAR dofs are on the
// processor with highest ID
if(this->processor_id() == (this->n_processors()-1))
{
// We get different scalars as different
// components from a new-style f functor.
DenseVector<Number> fout(this->n_components());
bool filled_fout = false;
const DofMap& dof_map = this->get_dof_map();
for (unsigned int var=0; var<this->n_vars(); var++)
if(this->variable(var).type().family == SCALAR)
{
if (!filled_fout)
{
(*f) (Point(), this->time, fout);
filled_fout = true;
}
std::vector<dof_id_type> SCALAR_indices;
dof_map.SCALAR_dof_indices (SCALAR_indices, var);
const unsigned int n_SCALAR_dofs =
cast_int<unsigned int>(SCALAR_indices.size());
for (unsigned int i=0; i<n_SCALAR_dofs; i++)
{
const dof_id_type global_index = SCALAR_indices[i];
const unsigned int component_index =
this->variable_scalar_number(var,i);
new_vector.set(global_index, fout(component_index));
}
}
}
new_vector.close();
#ifdef LIBMESH_ENABLE_CONSTRAINTS
if (is_adjoint == -1)
this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
else if (is_adjoint >= 0)
this->get_dof_map().enforce_adjoint_constraints_exactly(new_vector,
is_adjoint);
#endif
STOP_LOG("project_vector()", "System");
}
| void libMesh::System::project_vector | ( | NumericVector< Number > & | new_vector, |
| FEMFunctionBase< Number > * | f, | ||
| FEMFunctionBase< Gradient > * | g = NULL, |
||
| int | is_adjoint = -1 |
||
| ) | const [inherited] |
Projects arbitrary functions onto a vector of degree of freedom values for the current system. The function value f and its gradient g are user-provided cloneable functors. A gradient g is only required/used for projecting onto finite element spaces with continuous derivatives. If non-default Parameters are to be used, they can be provided in the parameters argument.
Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.
This method projects an arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 587 of file system_projection.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::NumericVector< T >::close(), libMesh::FEMFunctionBase< Output >::component(), libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::Threads::parallel_for(), libMesh::FEMContext::pre_fe_reinit(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::NumericVector< T >::set(), libMesh::START_LOG(), libMesh::System::time, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::System::variable_scalar_number().
{
START_LOG ("project_fem_vector()", "System");
Threads::parallel_for
(ConstElemRange (this->get_mesh().active_local_elements_begin(),
this->get_mesh().active_local_elements_end() ),
ProjectFEMSolution(*this, f, g, new_vector)
);
// Also, load values into the SCALAR dofs
// Note: We assume that all SCALAR dofs are on the
// processor with highest ID
if(this->processor_id() == (this->n_processors()-1))
{
// FIXME: Do we want to first check for SCALAR vars before building this? [PB]
FEMContext context( *this );
const DofMap& dof_map = this->get_dof_map();
for (unsigned int var=0; var<this->n_vars(); var++)
if(this->variable(var).type().family == SCALAR)
{
// FIXME: We reinit with an arbitrary element in case the user
// doesn't override FEMFunctionBase::component. Is there
// any use case we're missing? [PB]
Elem *el = const_cast<Elem *>(*(this->get_mesh().active_local_elements_begin()));
context.pre_fe_reinit( *this, el );
std::vector<dof_id_type> SCALAR_indices;
dof_map.SCALAR_dof_indices (SCALAR_indices, var);
const unsigned int n_SCALAR_dofs =
cast_int<unsigned int>(SCALAR_indices.size());
for (unsigned int i=0; i<n_SCALAR_dofs; i++)
{
const dof_id_type global_index = SCALAR_indices[i];
const unsigned int component_index =
this->variable_scalar_number(var,i);
new_vector.set(global_index, f->component(context, component_index, Point(), this->time));
}
}
}
new_vector.close();
#ifdef LIBMESH_ENABLE_CONSTRAINTS
if (is_adjoint == -1)
this->get_dof_map().enforce_constraints_exactly(*this, &new_vector);
else if (is_adjoint >= 0)
this->get_dof_map().enforce_adjoint_constraints_exactly(new_vector,
is_adjoint);
#endif
STOP_LOG("project_fem_vector()", "System");
}
| void libMesh::System::project_vector | ( | Number | fptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, |
| Gradient | gptrconst Point &p,const Parameters ¶meters,const std::string &sys_name,const std::string &unknown_name, | ||
| const Parameters & | parameters, | ||
| NumericVector< Number > & | new_vector, | ||
| int | is_adjoint = -1 |
||
| ) | const [inherited] |
Projects arbitrary functions onto a vector of degree of freedom values for the current system. The function value fptr and its gradient gptr are represented by function pointers. A gradient gptr is only required/used for projecting onto finite element spaces with continuous derivatives.
Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.
This method projects an arbitrary function via L2 projections and nodal interpolations on each element.
Definition at line 498 of file system_projection.C.
References libMesh::System::project_vector().
{
WrappedFunction<Number> f(*this, fptr, ¶meters);
WrappedFunction<Gradient> g(*this, gptr, ¶meters);
this->project_vector(new_vector, &f, &g, is_adjoint);
}
| void libMesh::System::project_vector | ( | NumericVector< Number > & | vector, |
| int | is_adjoint = -1 |
||
| ) | const [protected, inherited] |
Projects the vector defined on the old mesh onto the new mesh.
Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.
Definition at line 255 of file system_projection.C.
References libMesh::NumericVector< T >::clone(), and libMesh::System::project_vector().
{
// Create a copy of the vector, which currently
// contains the old data.
UniquePtr<NumericVector<Number> >
old_vector (vector.clone());
// Project the old vector to the new vector
this->project_vector (*old_vector, vector, is_adjoint);
}
| void libMesh::System::project_vector | ( | const NumericVector< Number > & | old_v, |
| NumericVector< Number > & | new_v, | ||
| int | is_adjoint = -1 |
||
| ) | const [protected, inherited] |
Projects the vector defined on the old mesh onto the new mesh. The original vector is unchanged and the new vector is passed through the second argument.
Constrain the new vector using the requested adjoint rather than primal constraints if is_adjoint is non-negative.
This method projects the vector via L2 projections or nodal interpolations on each element.
This method projects a solution from an old mesh to a current, refined mesh. The input vector old_v gives the solution on the old mesh, while the new_v gives the solution (to be computed) on the new mesh.
Definition at line 273 of file system_projection.C.
References libMesh::NumericVector< T >::clear(), libMesh::NumericVector< T >::close(), libMesh::ParallelObject::comm(), libMesh::DofMap::enforce_adjoint_constraints_exactly(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::FEType::family, libMesh::NumericVector< T >::get(), libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::GHOSTED, libMesh::NumericVector< T >::init(), libMesh::libmesh_assert(), libMesh::NumericVector< T >::local_size(), libMesh::NumericVector< T >::localize(), libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::PARALLEL, libMesh::Threads::parallel_for(), libMesh::Threads::parallel_reduce(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::BuildProjectionList::send_list, libMesh::SERIAL, libMesh::NumericVector< T >::set(), libMesh::NumericVector< T >::size(), libMesh::START_LOG(), libMesh::Variable::type(), libMesh::NumericVector< T >::type(), libMesh::BuildProjectionList::unique(), and libMesh::System::variable().
{
START_LOG ("project_vector()", "System");
new_v.clear();
#ifdef LIBMESH_ENABLE_AMR
// Resize the new vector and get a serial version.
NumericVector<Number> *new_vector_ptr = NULL;
UniquePtr<NumericVector<Number> > new_vector_built;
NumericVector<Number> *local_old_vector;
UniquePtr<NumericVector<Number> > local_old_vector_built;
const NumericVector<Number> *old_vector_ptr = NULL;
ConstElemRange active_local_elem_range
(this->get_mesh().active_local_elements_begin(),
this->get_mesh().active_local_elements_end());
// If the old vector was uniprocessor, make the new
// vector uniprocessor
if (old_v.type() == SERIAL)
{
new_v.init (this->n_dofs(), false, SERIAL);
new_vector_ptr = &new_v;
old_vector_ptr = &old_v;
}
// Otherwise it is a parallel, distributed vector, which
// we need to localize.
else if (old_v.type() == PARALLEL)
{
// Build a send list for efficient localization
BuildProjectionList projection_list(*this);
Threads::parallel_reduce (active_local_elem_range,
projection_list);
// Create a sorted, unique send_list
projection_list.unique();
new_v.init (this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
new_vector_built = NumericVector<Number>::build(this->comm());
local_old_vector_built = NumericVector<Number>::build(this->comm());
new_vector_ptr = new_vector_built.get();
local_old_vector = local_old_vector_built.get();
new_vector_ptr->init(this->n_dofs(), false, SERIAL);
local_old_vector->init(old_v.size(), false, SERIAL);
old_v.localize(*local_old_vector, projection_list.send_list);
local_old_vector->close();
old_vector_ptr = local_old_vector;
}
else if (old_v.type() == GHOSTED)
{
// Build a send list for efficient localization
BuildProjectionList projection_list(*this);
Threads::parallel_reduce (active_local_elem_range,
projection_list);
// Create a sorted, unique send_list
projection_list.unique();
new_v.init (this->n_dofs(), this->n_local_dofs(),
this->get_dof_map().get_send_list(), false, GHOSTED);
local_old_vector_built = NumericVector<Number>::build(this->comm());
new_vector_ptr = &new_v;
local_old_vector = local_old_vector_built.get();
local_old_vector->init(old_v.size(), old_v.local_size(),
projection_list.send_list, false, GHOSTED);
old_v.localize(*local_old_vector, projection_list.send_list);
local_old_vector->close();
old_vector_ptr = local_old_vector;
}
else // unknown old_v.type()
libmesh_error_msg("ERROR: Unknown old_v.type() == " << old_v.type());
// Note that the above will have zeroed the new_vector.
// Just to be sure, assert that new_vector_ptr and old_vector_ptr
// were successfully set before trying to deref them.
libmesh_assert(new_vector_ptr);
libmesh_assert(old_vector_ptr);
NumericVector<Number> &new_vector = *new_vector_ptr;
const NumericVector<Number> &old_vector = *old_vector_ptr;
Threads::parallel_for (active_local_elem_range,
ProjectVector(*this,
old_vector,
new_vector)
);
// Copy the SCALAR dofs from old_vector to new_vector
// Note: We assume that all SCALAR dofs are on the
// processor with highest ID
if(this->processor_id() == (this->n_processors()-1))
{
const DofMap& dof_map = this->get_dof_map();
for (unsigned int var=0; var<this->n_vars(); var++)
if(this->variable(var).type().family == SCALAR)
{
// We can just map SCALAR dofs directly across
std::vector<dof_id_type> new_SCALAR_indices, old_SCALAR_indices;
dof_map.SCALAR_dof_indices (new_SCALAR_indices, var, false);
dof_map.SCALAR_dof_indices (old_SCALAR_indices, var, true);
const unsigned int new_n_dofs =
cast_int<unsigned int>(new_SCALAR_indices.size());
for (unsigned int i=0; i<new_n_dofs; i++)
{
new_vector.set( new_SCALAR_indices[i], old_vector(old_SCALAR_indices[i]) );
}
}
}
new_vector.close();
// If the old vector was serial, we probably need to send our values
// to other processors
//
// FIXME: I'm not sure how to make a NumericVector do that without
// creating a temporary parallel vector to use localize! - RHS
if (old_v.type() == SERIAL)
{
UniquePtr<NumericVector<Number> > dist_v = NumericVector<Number>::build(this->comm());
dist_v->init(this->n_dofs(), this->n_local_dofs(), false, PARALLEL);
dist_v->close();
for (dof_id_type i=0; i!=dist_v->size(); i++)
if (new_vector(i) != 0.0)
dist_v->set(i, new_vector(i));
dist_v->close();
dist_v->localize (new_v, this->get_dof_map().get_send_list());
new_v.close();
}
// If the old vector was parallel, we need to update it
// and free the localized copies
else if (old_v.type() == PARALLEL)
{
// We may have to set dof values that this processor doesn't
// own in certain special cases, like LAGRANGE FIRST or
// HERMITE THIRD elements on second-order meshes
for (dof_id_type i=0; i!=new_v.size(); i++)
if (new_vector(i) != 0.0)
new_v.set(i, new_vector(i));
new_v.close();
}
if (is_adjoint == -1)
this->get_dof_map().enforce_constraints_exactly(*this, &new_v);
else if (is_adjoint >= 0)
this->get_dof_map().enforce_adjoint_constraints_exactly(new_v,
is_adjoint);
#else
// AMR is disabled: simply copy the vector
new_v = old_v;
#endif // #ifdef LIBMESH_ENABLE_AMR
STOP_LOG("project_vector()", "System");
}
| void libMesh::System::prolong_vectors | ( | ) | [virtual, inherited] |
Prolong vectors after the mesh has refined
Definition at line 373 of file system.C.
References libMesh::System::restrict_vectors().
Referenced by libMesh::EquationSystems::reinit().
{
#ifdef LIBMESH_ENABLE_AMR
// Currently project_vector handles both restriction and prolongation
this->restrict_vectors();
#endif
}
| void libMesh::ImplicitSystem::qoi_parameter_hessian | ( | const QoISet & | qoi_indices, |
| const ParameterVector & | parameters, | ||
| SensitivityData & | hessian | ||
| ) | [virtual, inherited] |
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) This Hessian is the output of this method, where for each q_i, H_jk is stored in hessian.second_derivative(i,j,k).
Reimplemented from libMesh::System.
Definition at line 1137 of file implicit_system.C.
References libMesh::SensitivityData::allocate_hessian_data(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::SensitivityData::second_derivative(), libMesh::ParameterVector::size(), and libMesh::TOLERANCE.
{
// We currently get partial derivatives via finite differencing
const Real delta_p = TOLERANCE;
ParameterVector& parameters =
const_cast<ParameterVector&>(parameters_in);
// We'll use one temporary vector for matrix-vector-vector products
UniquePtr<NumericVector<Number> > tempvec = this->solution->zero_clone();
// And another temporary vector to hold a copy of the true solution
// so we can safely perturb this->solution.
UniquePtr<NumericVector<Number> > oldsolution = this->solution->clone();
const unsigned int Np = cast_int<unsigned int>
(parameters.size());
const unsigned int Nq = cast_int<unsigned int>
(qoi.size());
// For each quantity of interest q, the parameter sensitivity
// Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
//
// We calculate it from values and partial derivatives of the
// quantity of interest function Q, solution u, adjoint solution z,
// and residual R, as:
//
// q''_{kl} =
// Q''_{kl} + Q''_{uk}(u)*u'_l + Q''_{ul}(u) * u'_k +
// Q''_{uu}(u)*u'_k*u'_l -
// R''_{kl}(u,z) -
// R''_{uk}(u,z)*u'_l - R''_{ul}(u,z)*u'_k -
// R''_{uu}(u,z)*u'_k*u'_l
//
// See the adjoints model document for more details.
// We first do an adjoint solve to get z for each quantity of
// interest
// if we havent already or dont have an initial condition for the adjoint
if (!this->is_adjoint_already_solved())
{
this->adjoint_solve(qoi_indices);
}
// And a sensitivity solve to get u_k for each parameter
this->sensitivity_solve(parameters);
// Get ready to fill in second derivatives:
sensitivities.allocate_hessian_data(qoi_indices, *this, parameters);
for (unsigned int k=0; k != Np; ++k)
{
Number old_parameterk = *parameters[k];
// The Hessian is symmetric, so we just calculate the lower
// triangle and the diagonal, and we get the upper triangle from
// the transpose of the lower
for (unsigned int l=0; l != k+1; ++l)
{
// The second partial derivatives with respect to parameters
// are all calculated via a central finite difference
// stencil:
// F''_{kl} ~= (F(p+dp*e_k+dp*e_l) - F(p+dp*e_k-dp*e_l) -
// F(p-dp*e_k+dp*e_l) + F(p-dp*e_k-dp*e_l))/(4*dp^2)
// We will add Q''_{kl}(u) and subtract R''_{kl}(u,z) at the
// same time.
//
// We have to be careful with the perturbations to handle
// the k=l case
Number old_parameterl = *parameters[l];
*parameters[k] += delta_p;
*parameters[l] += delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
std::vector<Number> partial2q_term = this->qoi;
std::vector<Number> partial2R_term(this->qoi.size());
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
*parameters[l] -= 2.*delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
partial2q_term[i] -= this->qoi[i];
partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
}
*parameters[k] -= 2.*delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
partial2q_term[i] += this->qoi[i];
partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
}
*parameters[l] += 2.*delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
partial2q_term[i] -= this->qoi[i];
partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
partial2q_term[i] /= (4. * delta_p * delta_p);
partial2R_term[i] /= (4. * delta_p * delta_p);
}
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
Number current_terms = partial2q_term[i] - partial2R_term[i];
sensitivities.second_derivative(i,k,l) += current_terms;
if (k != l)
sensitivities.second_derivative(i,l,k) += current_terms;
}
// Don't leave the parameters perturbed
*parameters[l] = old_parameterl;
*parameters[k] = old_parameterk;
}
// We get (partial q / partial u) and
// (partial R / partial u) from the user, but centrally
// difference to get q_uk and R_uk terms:
// (partial^2 q / partial u partial k)
// q_uk*u'_l = (q_u(p+dp*e_k)*u'_l - q_u(p-dp*e_k)*u'_l)/(2*dp)
// R_uk*z*u'_l = (R_u(p+dp*e_k)*z*u'_l - R_u(p-dp*e_k)*z*u'_l)/(2*dp)
//
// To avoid creating Nq temporary vectors, we add these
// subterms to the sensitivities output one by one.
//
// FIXME: this is probably a bad order of operations for
// controlling floating point error.
*parameters[k] = old_parameterk + delta_p;
this->assembly(false, true);
this->matrix->close();
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ true,
/* apply_constraints = */ false);
for (unsigned int l=0; l != Np; ++l)
{
this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
Number current_terms =
(this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
sensitivities.second_derivative(i,k,l) += current_terms;
// We use the _uk terms twice; symmetry lets us reuse
// these calculations for the _ul terms.
sensitivities.second_derivative(i,l,k) += current_terms;
}
}
*parameters[k] = old_parameterk - delta_p;
this->assembly(false, true);
this->matrix->close();
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ true,
/* apply_constraints = */ false);
for (unsigned int l=0; l != Np; ++l)
{
this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
Number current_terms =
(-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
sensitivities.second_derivative(i,k,l) += current_terms;
// We use the _uk terms twice; symmetry lets us reuse
// these calculations for the _ul terms.
sensitivities.second_derivative(i,l,k) += current_terms;
}
}
// Don't leave the parameter perturbed
*parameters[k] = old_parameterk;
// Our last remaining terms are -R_uu(u,z)*u_k*u_l and
// Q_uu(u)*u_k*u_l
//
// We take directional central finite differences of R_u and Q_u
// to approximate these terms, e.g.:
//
// Q_uu(u)*u_k ~= (Q_u(u+dp*u_k) - Q_u(u-dp*u_k))/(2*dp)
*this->solution = this->get_sensitivity_solution(k);
*this->solution *= delta_p;
*this->solution += *oldsolution;
this->assembly(false, true);
this->matrix->close();
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ true,
/* apply_constraints = */ false);
// The Hessian is symmetric, so we just calculate the lower
// triangle and the diagonal, and we get the upper triangle from
// the transpose of the lower
//
// Note that, because we took the directional finite difference
// with respect to k and not l, we've added an O(delta_p^2)
// error to any permutational symmetry in the Hessian...
for (unsigned int l=0; l != k+1; ++l)
{
this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
Number current_terms =
(this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) -
tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
sensitivities.second_derivative(i,k,l) += current_terms;
if (k != l)
sensitivities.second_derivative(i,l,k) += current_terms;
}
}
*this->solution = this->get_sensitivity_solution(k);
*this->solution *= -delta_p;
*this->solution += *oldsolution;
this->assembly(false, true);
this->matrix->close();
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ true,
/* apply_constraints = */ false);
for (unsigned int l=0; l != k+1; ++l)
{
this->matrix->vector_mult(*tempvec, this->get_sensitivity_solution(l));
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
Number current_terms =
(-this->get_adjoint_rhs(i).dot(this->get_sensitivity_solution(l)) +
tempvec->dot(this->get_adjoint_solution(i))) / (2.*delta_p);
sensitivities.second_derivative(i,k,l) += current_terms;
if (k != l)
sensitivities.second_derivative(i,l,k) += current_terms;
}
}
// Don't leave the solution perturbed
*this->solution = *oldsolution;
}
// All parameters have been reset.
// Don't leave the qoi or system changed - principle of least
// surprise.
this->assembly(true, true);
this->rhs->close();
this->matrix->close();
this->assemble_qoi(qoi_indices);
}
| void libMesh::ImplicitSystem::qoi_parameter_hessian_vector_product | ( | const QoISet & | qoi_indices, |
| const ParameterVector & | parameters, | ||
| const ParameterVector & | vector, | ||
| SensitivityData & | product | ||
| ) | [virtual, inherited] |
For each of the system's quantities of interest q in qoi[qoi_indices], and for a vector of parameters p, the parameter sensitivity Hessian H_ij is defined as H_ij = (d^2 q)/(d p_i d p_j) The Hessian-vector product, for a vector v_k in parameter space, is S_j = H_jk v_k This product is the output of this method, where for each q_i, S_j is stored in sensitivities[i][j].
Reimplemented from libMesh::System.
Definition at line 930 of file implicit_system.C.
References libMesh::SensitivityData::allocate_data(), libMesh::ParameterVector::deep_copy(), libMesh::QoISet::has_index(), libMesh::Real, libMesh::ParameterVector::size(), libMesh::TOLERANCE, and libMesh::ParameterVector::value_copy().
{
// We currently get partial derivatives via finite differencing
const Real delta_p = TOLERANCE;
ParameterVector& parameters =
const_cast<ParameterVector&>(parameters_in);
// We'll use a single temporary vector for matrix-vector-vector products
UniquePtr<NumericVector<Number> > tempvec = this->solution->zero_clone();
const unsigned int Np = cast_int<unsigned int>
(parameters.size());
const unsigned int Nq = cast_int<unsigned int>
(qoi.size());
// For each quantity of interest q, the parameter sensitivity
// Hessian is defined as q''_{kl} = {d^2 q}/{d p_k d p_l}.
// Given a vector of parameter perturbation weights w_l, this
// function evaluates the hessian-vector product sum_l(q''_{kl}*w_l)
//
// We calculate it from values and partial derivatives of the
// quantity of interest function Q, solution u, adjoint solution z,
// parameter sensitivity adjoint solutions z^l, and residual R, as:
//
// sum_l(q''_{kl}*w_l) =
// sum_l(w_l * Q''_{kl}) + Q''_{uk}(u)*(sum_l(w_l u'_l)) -
// R'_k(u, sum_l(w_l*z^l)) - R'_{uk}(u,z)*(sum_l(w_l u'_l) -
// sum_l(w_l*R''_{kl}(u,z))
//
// See the adjoints model document for more details.
// We first do an adjoint solve to get z for each quantity of
// interest
// if we havent already or dont have an initial condition for the adjoint
if (!this->is_adjoint_already_solved())
{
this->adjoint_solve(qoi_indices);
}
// Get ready to fill in senstivities:
sensitivities.allocate_data(qoi_indices, *this, parameters);
// We can't solve for all the solution sensitivities u'_l or for all
// of the parameter sensitivity adjoint solutions z^l without
// requiring O(Nq*Np) linear solves. So we'll solve directly for their
// weighted sum - this is just O(Nq) solves.
// First solve for sum_l(w_l u'_l).
this->weighted_sensitivity_solve(parameters, vector);
// Then solve for sum_l(w_l z^l).
this->weighted_sensitivity_adjoint_solve(parameters, vector, qoi_indices);
for (unsigned int k=0; k != Np; ++k)
{
// We approximate sum_l(w_l * Q''_{kl}) with a central
// differencing pertubation:
// sum_l(w_l * Q''_{kl}) ~=
// (Q(p + dp*w_l*e_l + dp*e_k) - Q(p - dp*w_l*e_l + dp*e_k) -
// Q(p + dp*w_l*e_l - dp*e_k) + Q(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
// The sum(w_l*R''_kl) term requires the same sort of pertubation,
// and so we subtract it in at the same time:
// sum_l(w_l * R''_{kl}) ~=
// (R(p + dp*w_l*e_l + dp*e_k) - R(p - dp*w_l*e_l + dp*e_k) -
// R(p + dp*w_l*e_l - dp*e_k) + R(p - dp*w_l*e_l - dp*e_k))/(4*dp^2)
ParameterVector oldparameters, parameterperturbation;
parameters.deep_copy(oldparameters);
vector.deep_copy(parameterperturbation);
parameterperturbation *= delta_p;
parameters += parameterperturbation;
Number old_parameter = *parameters[k];
*parameters[k] = old_parameter + delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
std::vector<Number> partial2q_term = this->qoi;
std::vector<Number> partial2R_term(this->qoi.size());
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
partial2R_term[i] = this->rhs->dot(this->get_adjoint_solution(i));
*parameters[k] = old_parameter - delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
partial2q_term[i] -= this->qoi[i];
partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
}
oldparameters.value_copy(parameters);
parameterperturbation *= -1.0;
parameters += parameterperturbation;
// Re-center old_parameter, which may be affected by vector
old_parameter = *parameters[k];
*parameters[k] = old_parameter + delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
partial2q_term[i] -= this->qoi[i];
partial2R_term[i] -= this->rhs->dot(this->get_adjoint_solution(i));
}
*parameters[k] = old_parameter - delta_p;
this->assemble_qoi(qoi_indices);
this->assembly(true, false, true);
this->rhs->close();
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
partial2q_term[i] += this->qoi[i];
partial2R_term[i] += this->rhs->dot(this->get_adjoint_solution(i));
}
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
partial2q_term[i] /= (4. * delta_p * delta_p);
partial2R_term[i] /= (4. * delta_p * delta_p);
}
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
sensitivities[i][k] = partial2q_term[i] - partial2R_term[i];
// We get (partial q / partial u), R, and
// (partial R / partial u) from the user, but centrally
// difference to get q_uk, R_k, and R_uk terms:
// (partial R / partial k)
// R_k*sum(w_l*z^l) = (R(p+dp*e_k)*sum(w_l*z^l) - R(p-dp*e_k)*sum(w_l*z^l))/(2*dp)
// (partial^2 q / partial u partial k)
// q_uk = (q_u(p+dp*e_k) - q_u(p-dp*e_k))/(2*dp)
// (partial^2 R / partial u partial k)
// R_uk*z*sum(w_l*u'_l) = (R_u(p+dp*e_k)*z*sum(w_l*u'_l) - R_u(p-dp*e_k)*z*sum(w_l*u'_l))/(2*dp)
// To avoid creating Nq temporary vectors for q_uk or R_uk, we add
// subterms to the sensitivities output one by one.
//
// FIXME: this is probably a bad order of operations for
// controlling floating point error.
*parameters[k] = old_parameter + delta_p;
this->assembly(true, true);
this->rhs->close();
this->matrix->close();
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ true,
/* apply_constraints = */ false);
this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
sensitivities[i][k] += (this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) -
this->rhs->dot(this->get_weighted_sensitivity_adjoint_solution(i)) -
this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
}
*parameters[k] = old_parameter - delta_p;
this->assembly(true, true);
this->rhs->close();
this->matrix->close();
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ true,
/* apply_constraints = */ false);
this->matrix->vector_mult(*tempvec, this->get_weighted_sensitivity_solution());
for (unsigned int i=0; i != Nq; ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
sensitivities[i][k] += (-this->get_adjoint_rhs(i).dot(this->get_weighted_sensitivity_solution()) +
this->rhs->dot(this->get_weighted_sensitivity_adjoint_solution(i)) +
this->get_adjoint_solution(i).dot(*tempvec)) / (2.*delta_p);
}
}
// All parameters have been reset.
// Don't leave the qoi or system changed - principle of least
// surprise.
this->assembly(true, true);
this->rhs->close();
this->matrix->close();
this->assemble_qoi(qoi_indices);
}
| void libMesh::System::qoi_parameter_sensitivity | ( | const QoISet & | qoi_indices, |
| const ParameterVector & | parameters, | ||
| SensitivityData & | sensitivities | ||
| ) | [virtual, inherited] |
Solves for the derivative of each of the system's quantities of interest q in qoi[qoi_indices] with respect to each parameter in parameters, placing the result for qoi i and parameter j into sensitivities[i][j].
Note that parameters is a const vector, not a vector-of-const; parameter values in this vector need to be mutable for finite differencing to work.
Automatically chooses the forward method for problems with more quantities of interest than parameters, or the adjoint method otherwise.
This method is only usable in derived classes which overload an implementation.
Definition at line 523 of file system.C.
References libMesh::ParameterVector::size(), and libMesh::QoISet::size().
{
// Forward sensitivities are more efficient for Nq > Np
if (qoi_indices.size(*this) > parameters.size())
forward_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
// Adjoint sensitivities are more efficient for Np > Nq,
// and an adjoint may be more reusable than a forward
// solution sensitivity in the Np == Nq case.
else
adjoint_qoi_parameter_sensitivity(qoi_indices, parameters, sensitivities);
}
| void libMesh::System::re_update | ( | ) | [virtual, inherited] |
Re-update the local values when the mesh has changed. This method takes the data updated by update() and makes it up-to-date on the current mesh.
Reimplemented in libMesh::TransientSystem< RBConstruction >.
Definition at line 442 of file system.C.
References libMesh::System::current_local_solution, libMesh::System::get_dof_map(), libMesh::DofMap::get_send_list(), libMesh::System::n_vars(), and libMesh::System::solution.
{
parallel_object_only();
// If this system is empty... don't do anything!
if(!this->n_vars())
return;
const std::vector<dof_id_type>& send_list = this->get_dof_map().get_send_list ();
// Check sizes
libmesh_assert_equal_to (current_local_solution->size(), solution->size());
// Not true with ghosted vectors
// libmesh_assert_equal_to (current_local_solution->local_size(), solution->size());
// libmesh_assert (!send_list.empty());
libmesh_assert_less_equal (send_list.size(), solution->size());
// Create current_local_solution from solution. This will
// put a local copy of solution into current_local_solution.
solution->localize (*current_local_solution, send_list);
}
| void libMesh::System::read_header | ( | Xdr & | io, |
| const std::string & | version, | ||
| const bool | read_header = true, |
||
| const bool | read_additional_data = true, |
||
| const bool | read_legacy_format = false |
||
| ) | [inherited] |
Reads the basic data header for this System.
Definition at line 115 of file system_io.C.
References libMesh::System::_additional_data_written, libMesh::System::_written_var_indices, libMesh::System::add_variable(), libMesh::System::add_vector(), libMesh::Parallel::Communicator::broadcast(), libMesh::System::clear(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::MeshBase::mesh_dimension(), libMesh::MONOMIAL, libMesh::on_command_line(), libMesh::FEType::order, libMesh::out, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::Xdr::reading(), libMesh::System::variable_number(), libMesh::Xdr::version(), and libMesh::XYZ.
Referenced by libMesh::EquationSystems::_read_impl().
{
// This method implements the input of a
// System object, embedded in the output of
// an EquationSystems<T_sys>. This warrants some
// documentation. The output file essentially
// consists of 5 sections:
//
// for this system
//
// 5.) The number of variables in the system (unsigned int)
//
// for each variable in the system
//
// 6.) The name of the variable (string)
//
// 6.1.) Variable subdmains
//
// 7.) Combined in an FEType:
// - The approximation order(s) of the variable
// (Order Enum, cast to int/s)
// - The finite element family/ies of the variable
// (FEFamily Enum, cast to int/s)
//
// end variable loop
//
// 8.) The number of additional vectors (unsigned int),
//
// for each additional vector in the system object
//
// 9.) the name of the additional vector (string)
//
// end system
libmesh_assert (io.reading());
// Possibly clear data structures and start from scratch.
if (read_header_in)
this->clear ();
// Figure out if we need to read infinite element information.
// This will be true if the version string contains " with infinite elements"
const bool read_ifem_info =
(version.rfind(" with infinite elements") < version.size()) ||
libMesh::on_command_line ("--read_ifem_systems");
{
// 5.)
// Read the number of variables in the system
unsigned int nv=0;
if (this->processor_id() == 0)
io.data (nv);
this->comm().broadcast(nv);
_written_var_indices.clear();
_written_var_indices.resize(nv, 0);
for (unsigned int var=0; var<nv; var++)
{
// 6.)
// Read the name of the var-th variable
std::string var_name;
if (this->processor_id() == 0)
io.data (var_name);
this->comm().broadcast(var_name);
// 6.1.)
std::set<subdomain_id_type> domains;
if (io.version() >= LIBMESH_VERSION_ID(0,7,2))
{
std::vector<subdomain_id_type> domain_array;
if (this->processor_id() == 0)
io.data (domain_array);
for (std::vector<subdomain_id_type>::iterator it = domain_array.begin(); it != domain_array.end(); ++it)
domains.insert(*it);
}
this->comm().broadcast(domains);
// 7.)
// Read the approximation order(s) of the var-th variable
int order=0;
if (this->processor_id() == 0)
io.data (order);
this->comm().broadcast(order);
// do the same for infinite element radial_order
int rad_order=0;
if (read_ifem_info)
{
if (this->processor_id() == 0)
io.data(rad_order);
this->comm().broadcast(rad_order);
}
// Read the finite element type of the var-th variable
int fam=0;
if (this->processor_id() == 0)
io.data (fam);
this->comm().broadcast(fam);
FEType type;
type.order = static_cast<Order>(order);
type.family = static_cast<FEFamily>(fam);
// Check for incompatibilities. The shape function indexing was
// changed for the monomial and xyz finite element families to
// simplify extension to arbitrary p. The consequence is that
// old restart files will not be read correctly. This is expected
// to be an unlikely occurance, but catch it anyway.
if (read_legacy_format)
if ((type.family == MONOMIAL || type.family == XYZ) &&
((type.order > 2 && this->get_mesh().mesh_dimension() == 2) ||
(type.order > 1 && this->get_mesh().mesh_dimension() == 3)))
{
libmesh_here();
libMesh::out << "*****************************************************************\n"
<< "* WARNING: reading a potentially incompatible restart file!!! *\n"
<< "* contact libmesh-users@lists.sourceforge.net for more details *\n"
<< "*****************************************************************"
<< std::endl;
}
// Read additional information for infinite elements
int radial_fam=0;
int i_map=0;
if (read_ifem_info)
{
if (this->processor_id() == 0)
io.data (radial_fam);
this->comm().broadcast(radial_fam);
if (this->processor_id() == 0)
io.data (i_map);
this->comm().broadcast(i_map);
}
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
type.radial_order = static_cast<Order>(rad_order);
type.radial_family = static_cast<FEFamily>(radial_fam);
type.inf_map = static_cast<InfMapType>(i_map);
#endif
if (read_header_in)
{
if (domains.empty())
_written_var_indices[var] = this->add_variable (var_name, type);
else
_written_var_indices[var] = this->add_variable (var_name, type, &domains);
}
else
_written_var_indices[var] = this->variable_number(var_name);
}
}
// 8.)
// Read the number of additional vectors.
unsigned int nvecs=0;
if (this->processor_id() == 0)
io.data (nvecs);
this->comm().broadcast(nvecs);
// If nvecs > 0, this means that write_additional_data
// was true when this file was written. We will need to
// make use of this fact later.
if (nvecs > 0)
this->_additional_data_written = true;
for (unsigned int vec=0; vec<nvecs; vec++)
{
// 9.)
// Read the name of the vec-th additional vector
std::string vec_name;
if (this->processor_id() == 0)
io.data (vec_name);
this->comm().broadcast(vec_name);
if (read_additional_data)
{
// Systems now can handle adding post-initialization vectors
// libmesh_assert(this->_can_add_vectors);
// Some systems may have added their own vectors already
// libmesh_assert_equal_to (this->_vectors.count(vec_name), 0);
this->add_vector(vec_name);
}
}
}
| void libMesh::System::read_legacy_data | ( | Xdr & | io, |
| const bool | read_additional_data = true |
||
| ) | [inherited] |
Reads additional data, namely vectors, for this System.
Definition at line 310 of file system_io.C.
References libMesh::System::_additional_data_written, libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::MeshBase::active_elements_begin(), libMesh::MeshBase::active_elements_end(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::Xdr::data(), end, libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::System::n_dofs(), libMesh::System::n_vars(), libMesh::MeshBase::nodes_begin(), libMesh::MeshBase::nodes_end(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::System::solution, libMesh::sys, and libMesh::zero.
{
libmesh_deprecated();
// This method implements the output of the vectors
// contained in this System object, embedded in the
// output of an EquationSystems<T_sys>.
//
// 10.) The global solution vector, re-ordered to be node-major
// (More on this later.)
//
// for each additional vector in the object
//
// 11.) The global additional vector, re-ordered to be
// node-major (More on this later.)
libmesh_assert (io.reading());
// read and reordering buffers
std::vector<Number> global_vector;
std::vector<Number> reordered_vector;
// 10.)
// Read and set the solution vector
{
if (this->processor_id() == 0)
io.data (global_vector);
this->comm().broadcast(global_vector);
// Remember that the stored vector is node-major.
// We need to put it into whatever application-specific
// ordering we may have using the dof_map.
reordered_vector.resize(global_vector.size());
//libMesh::out << "global_vector.size()=" << global_vector.size() << std::endl;
//libMesh::out << "this->n_dofs()=" << this->n_dofs() << std::endl;
libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
dof_id_type cnt=0;
const unsigned int sys = this->number();
const unsigned int nv = cast_int<unsigned int>
(this->_written_var_indices.size());
libmesh_assert_less_equal (nv, this->n_vars());
for (unsigned int data_var=0; data_var<nv; data_var++)
{
const unsigned int var = _written_var_indices[data_var];
// First reorder the nodal DOF values
{
MeshBase::node_iterator
it = this->get_mesh().nodes_begin(),
end = this->get_mesh().nodes_end();
for (; it != end; ++it)
for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
DofObject::invalid_id);
libmesh_assert_less (cnt, global_vector.size());
reordered_vector[(*it)->dof_number(sys, var, index)] =
global_vector[cnt++];
}
}
// Then reorder the element DOF values
{
MeshBase::element_iterator
it = this->get_mesh().active_elements_begin(),
end = this->get_mesh().active_elements_end();
for (; it != end; ++it)
for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
DofObject::invalid_id);
libmesh_assert_less (cnt, global_vector.size());
reordered_vector[(*it)->dof_number(sys, var, index)] =
global_vector[cnt++];
}
}
}
*(this->solution) = reordered_vector;
}
// For each additional vector, simply go through the list.
// ONLY attempt to do this IF additional data was actually
// written to the file for this system (controlled by the
// _additional_data_written flag).
if (this->_additional_data_written)
{
std::map<std::string, NumericVector<Number>* >::iterator
pos = this->_vectors.begin();
for (; pos != this->_vectors.end(); ++pos)
{
// 11.)
// Read the values of the vec-th additional vector.
// Prior do _not_ clear, but fill with zero, since the
// additional vectors _have_ to have the same size
// as the solution vector
std::fill (global_vector.begin(), global_vector.end(), libMesh::zero);
if (this->processor_id() == 0)
io.data (global_vector);
this->comm().broadcast(global_vector);
// If read_additional_data==true, then we will keep this vector, otherwise
// we are going to throw it away.
if (read_additional_data)
{
// Remember that the stored vector is node-major.
// We need to put it into whatever application-specific
// ordering we may have using the dof_map.
std::fill (reordered_vector.begin(),
reordered_vector.end(),
libMesh::zero);
reordered_vector.resize(global_vector.size());
libmesh_assert_equal_to (global_vector.size(), this->n_dofs());
dof_id_type cnt=0;
const unsigned int sys = this->number();
const unsigned int nv = cast_int<unsigned int>
(this->_written_var_indices.size());
libmesh_assert_less_equal (nv, this->n_vars());
for (unsigned int data_var=0; data_var<nv; data_var++)
{
const unsigned int var = _written_var_indices[data_var];
// First reorder the nodal DOF values
{
MeshBase::node_iterator
it = this->get_mesh().nodes_begin(),
end = this->get_mesh().nodes_end();
for (; it!=end; ++it)
for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
DofObject::invalid_id);
libmesh_assert_less (cnt, global_vector.size());
reordered_vector[(*it)->dof_number(sys, var, index)] =
global_vector[cnt++];
}
}
// Then reorder the element DOF values
{
MeshBase::element_iterator
it = this->get_mesh().active_elements_begin(),
end = this->get_mesh().active_elements_end();
for (; it!=end; ++it)
for (unsigned int index=0; index<(*it)->n_comp(sys,var); index++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys, var, index),
DofObject::invalid_id);
libmesh_assert_less (cnt, global_vector.size());
reordered_vector[(*it)->dof_number(sys, var, index)] =
global_vector[cnt++];
}
}
}
// use the overloaded operator=(std::vector) to assign the values
*(pos->second) = reordered_vector;
}
}
} // end if (_additional_data_written)
}
| template void libMesh::System::read_parallel_data< Real > | ( | Xdr & | io, |
| const bool | read_additional_data | ||
| ) | [inherited] |
Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.
This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.
9.) The global solution vector, re-ordered to be node-major (More on this later.)
for each additional vector in the object
10.) The global additional vector, re-ordered to be node-major (More on this later.)
Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.
Definition at line 498 of file system_io.C.
References libMesh::System::_vectors, libMesh::System::_written_var_indices, libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::Xdr::is_open(), libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::System::solution, libMesh::Variable::type(), and libMesh::System::variable().
{
// PerfLog pl("IO Performance",false);
// pl.push("read_parallel_data");
dof_id_type total_read_size = 0;
libmesh_assert (io.reading());
libmesh_assert (io.is_open());
// build the ordered nodes and element maps.
// when writing/reading parallel files we need to iterate
// over our nodes/elements in order of increasing global id().
// however, this is not guaranteed to be ordering we obtain
// by using the node_iterators/element_iterators directly.
// so build a set, sorted by id(), that provides the ordering.
// further, for memory economy build the set but then transfer
// its contents to vectors, which will be sorted.
std::vector<const DofObject*> ordered_nodes, ordered_elements;
{
std::set<const DofObject*, CompareDofObjectsByID>
ordered_nodes_set (this->get_mesh().local_nodes_begin(),
this->get_mesh().local_nodes_end());
ordered_nodes.insert(ordered_nodes.end(),
ordered_nodes_set.begin(),
ordered_nodes_set.end());
}
{
std::set<const DofObject*, CompareDofObjectsByID>
ordered_elements_set (this->get_mesh().local_elements_begin(),
this->get_mesh().local_elements_end());
ordered_elements.insert(ordered_elements.end(),
ordered_elements_set.begin(),
ordered_elements_set.end());
}
// std::vector<Number> io_buffer;
std::vector<InValType> io_buffer;
// 9.)
//
// Actually read the solution components
// for the ith system to disk
io.data(io_buffer);
total_read_size += cast_int<dof_id_type>(io_buffer.size());
const unsigned int sys_num = this->number();
const unsigned int nv = cast_int<unsigned int>
(this->_written_var_indices.size());
libmesh_assert_less_equal (nv, this->n_vars());
dof_id_type cnt=0;
// Loop over each non-SCALAR variable and each node, and read out the value.
for (unsigned int data_var=0; data_var<nv; data_var++)
{
const unsigned int var = _written_var_indices[data_var];
if(this->variable(var).type().family != SCALAR)
{
// First read the node DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
libmesh_assert_less (cnt, io_buffer.size());
this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
}
// Then read the element DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
libmesh_assert_less (cnt, io_buffer.size());
this->solution->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
}
}
}
// Finally, read the SCALAR variables on the last processor
for (unsigned int data_var=0; data_var<nv; data_var++)
{
const unsigned int var = _written_var_indices[data_var];
if(this->variable(var).type().family == SCALAR)
{
if (this->processor_id() == (this->n_processors()-1))
{
const DofMap& dof_map = this->get_dof_map();
std::vector<dof_id_type> SCALAR_dofs;
dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
{
this->solution->set( SCALAR_dofs[i], io_buffer[cnt++] );
}
}
}
}
// And we're done setting solution entries
this->solution->close();
// Only read additional vectors if wanted
if (read_additional_data)
{
std::map<std::string, NumericVector<Number>* >::const_iterator
pos = _vectors.begin();
for(; pos != this->_vectors.end(); ++pos)
{
cnt=0;
io_buffer.clear();
// 10.)
//
// Actually read the additional vector components
// for the ith system to disk
io.data(io_buffer);
total_read_size += cast_int<dof_id_type>(io_buffer.size());
// Loop over each non-SCALAR variable and each node, and read out the value.
for (unsigned int data_var=0; data_var<nv; data_var++)
{
const unsigned int var = _written_var_indices[data_var];
if(this->variable(var).type().family != SCALAR)
{
// First read the node DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
libmesh_assert_less (cnt, io_buffer.size());
pos->second->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
}
// Then read the element DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
libmesh_assert_less (cnt, io_buffer.size());
pos->second->set((*it)->dof_number(sys_num, var, comp), io_buffer[cnt++]);
}
}
}
// Finally, read the SCALAR variables on the last processor
for (unsigned int data_var=0; data_var<nv; data_var++)
{
const unsigned int var = _written_var_indices[data_var];
if(this->variable(var).type().family == SCALAR)
{
if (this->processor_id() == (this->n_processors()-1))
{
const DofMap& dof_map = this->get_dof_map();
std::vector<dof_id_type> SCALAR_dofs;
dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
{
pos->second->set( SCALAR_dofs[i], io_buffer[cnt++] );
}
}
}
}
// And we're done setting entries for this variable
pos->second->close();
}
}
// const Real
// dt = pl.get_elapsed_time(),
// rate = total_read_size*sizeof(Number)/dt;
// libMesh::err << "Read " << total_read_size << " \"Number\" values\n"
// << " Elapsed time = " << dt << '\n'
// << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
// pl.pop("read_parallel_data");
}
| void libMesh::System::read_parallel_data | ( | Xdr & | io, |
| const bool | read_additional_data | ||
| ) | [inline, inherited] |
Non-templated version for backward compatibility.
Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will read an individual file for each processor in the simulation where the local solution components for that processor are stored.
Definition at line 1290 of file system.h.
{ read_parallel_data<Number>(io, read_additional_data); }
| template void libMesh::System::read_serialized_data< Real > | ( | Xdr & | io, |
| const bool | read_additional_data = true |
||
| ) | [inherited] |
Reads additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.
Definition at line 713 of file system_io.C.
References libMesh::System::_vectors, libMesh::ParallelObject::processor_id(), and libMesh::System::solution.
{
// This method implements the input of the vectors
// contained in this System object, embedded in the
// output of an EquationSystems<T_sys>.
//
// 10.) The global solution vector, re-ordered to be node-major
// (More on this later.)
//
// for each additional vector in the object
//
// 11.) The global additional vector, re-ordered to be
// node-major (More on this later.)
parallel_object_only();
std::string comment;
// PerfLog pl("IO Performance",false);
// pl.push("read_serialized_data");
// std::size_t total_read_size = 0;
// 10.)
// Read the global solution vector
{
// total_read_size +=
this->read_serialized_vector<InValType>(io, *this->solution);
// get the comment
if (this->processor_id() == 0)
io.comment (comment);
}
// 11.)
// Only read additional vectors if wanted
if (read_additional_data)
{
std::map<std::string, NumericVector<Number>* >::const_iterator
pos = _vectors.begin();
for(; pos != this->_vectors.end(); ++pos)
{
// total_read_size +=
this->read_serialized_vector<InValType>(io, *pos->second);
// get the comment
if (this->processor_id() == 0)
io.comment (comment);
}
}
// const Real
// dt = pl.get_elapsed_time(),
// rate = total_read_size*sizeof(Number)/dt;
// libMesh::out << "Read " << total_read_size << " \"Number\" values\n"
// << " Elapsed time = " << dt << '\n'
// << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
// pl.pop("read_serialized_data");
}
| void libMesh::System::read_serialized_data | ( | Xdr & | io, |
| const bool | read_additional_data = true |
||
| ) | [inline, inherited] |
| template std::size_t libMesh::System::read_serialized_vectors< Real > | ( | Xdr & | io, |
| const std::vector< NumericVector< Number > * > & | vectors | ||
| ) | const [inherited] |
Read a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.
Definition at line 2193 of file system_io.C.
References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_blocked_dof_objects(), libMesh::Xdr::reading(), libMesh::SCALAR, libMesh::Variable::type(), and libMesh::System::variable().
{
parallel_object_only();
// Error checking
// #ifndef NDEBUG
// // In parallel we better be reading a parallel vector -- if not
// // we will not set all of its components below!!
// if (this->n_processors() > 1)
// {
// libmesh_assert (vec.type() == PARALLEL ||
// vec.type() == GHOSTED);
// }
// #endif
libmesh_assert (io.reading());
if (this->processor_id() == 0)
{
// sizes
unsigned int num_vecs=0;
dof_id_type vector_length=0;
// Get the number of vectors
io.data(num_vecs);
// Get the buffer size
io.data(vector_length);
libmesh_assert_equal_to (num_vecs, vectors.size());
if (num_vecs != 0)
{
libmesh_assert_not_equal_to (vectors[0], 0);
libmesh_assert_equal_to (vectors[0]->size(), vector_length);
}
}
// no need to actually communicate these.
// this->comm().broadcast(num_vecs);
// this->comm().broadcast(vector_length);
// Cache these - they are not free!
const dof_id_type
n_nodes = this->get_mesh().n_nodes(),
n_elem = this->get_mesh().n_elem();
std::size_t read_length = 0.;
//---------------------------------
// Collect the values for all nodes
read_length +=
this->read_serialized_blocked_dof_objects (n_nodes,
this->get_mesh().local_nodes_begin(),
this->get_mesh().local_nodes_end(),
InValType(),
io,
vectors);
//------------------------------------
// Collect the values for all elements
read_length +=
this->read_serialized_blocked_dof_objects (n_elem,
this->get_mesh().local_elements_begin(),
this->get_mesh().local_elements_end(),
InValType(),
io,
vectors);
//-------------------------------------------
// Finally loop over all the SCALAR variables
for (unsigned int vec=0; vec<vectors.size(); vec++)
for (unsigned int var=0; var<this->n_vars(); var++)
if(this->variable(var).type().family == SCALAR)
{
libmesh_assert_not_equal_to (vectors[vec], 0);
read_length +=
this->read_SCALAR_dofs (var, io, *vectors[vec]);
}
//---------------------------------------
// last step - must close all the vectors
for (unsigned int vec=0; vec<vectors.size(); vec++)
{
libmesh_assert_not_equal_to (vectors[vec], 0);
vectors[vec]->close();
}
return read_length;
}
| std::size_t libMesh::System::read_serialized_vectors | ( | Xdr & | io, |
| const std::vector< NumericVector< Number > * > & | vectors | ||
| ) | const [inline, inherited] |
Non-templated version for backward compatibility.
Read a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.
Definition at line 1268 of file system.h.
{ return read_serialized_vectors<Number>(io, vectors); }
| void libMesh::DifferentiableSystem::reinit | ( | ) | [virtual, inherited] |
Reinitializes the member data fields associated with the system, so that, e.g., assemble() may be used.
Reimplemented from libMesh::ImplicitSystem.
Definition at line 85 of file diff_system.C.
References libMesh::libmesh_assert(), libMesh::ImplicitSystem::reinit(), and libMesh::DifferentiableSystem::time_solver.
{
Parent::reinit();
libmesh_assert(time_solver.get());
libmesh_assert_equal_to (&(time_solver->system()), this);
time_solver->reinit();
}
| void libMesh::System::reinit_constraints | ( | ) | [virtual, inherited] |
Reinitializes the constraints for this system.
Definition at line 412 of file system.C.
References libMesh::System::_mesh, libMesh::DofMap::create_dof_constraints(), libMesh::System::get_dof_map(), libMesh::DofMap::prepare_send_list(), libMesh::DofMap::process_constraints(), libMesh::System::time, and libMesh::System::user_constrain().
{
get_dof_map().create_dof_constraints(_mesh, this->time);
user_constrain();
get_dof_map().process_constraints(_mesh);
get_dof_map().prepare_send_list();
}
| void libMesh::DifferentiableSystem::release_linear_solver | ( | LinearSolver< Number > * | ) | const [virtual, inherited] |
Releases a pointer to a linear solver acquired by this->get_linear_solver()
Reimplemented from libMesh::ImplicitSystem.
Definition at line 174 of file diff_system.C.
{
}
| void libMesh::System::remove_vector | ( | const std::string & | vec_name | ) | [inherited] |
Removes the additional vector vec_name from this system
Definition at line 727 of file system.C.
References libMesh::System::_vector_is_adjoint, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, and libMesh::System::have_vector().
{
//Return if the vector does not exist
if ( !(this->have_vector(vec_name)) )
return;
_vectors[vec_name]->clear();
delete _vectors[vec_name];
_vectors[vec_name] = NULL;
_vectors.erase(vec_name);
_vector_projections.erase(vec_name);
_vector_is_adjoint.erase(vec_name);
_vector_types.erase(vec_name);
}
| const SparseMatrix< Number > * libMesh::ImplicitSystem::request_matrix | ( | const std::string & | mat_name | ) | const [inherited] |
mat_name, or returns NULL if no matrix by that name exists. Definition at line 227 of file implicit_system.C.
References libMesh::ImplicitSystem::_matrices.
Referenced by libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), and libMesh::LinearImplicitSystem::solve().
{
// Make sure the matrix exists
const_matrices_iterator pos = _matrices.find (mat_name);
if (pos == _matrices.end())
return NULL;
return pos->second;
}
| SparseMatrix< Number > * libMesh::ImplicitSystem::request_matrix | ( | const std::string & | mat_name | ) | [inherited] |
mat_name, or returns NULL if no matrix by that name exists. Definition at line 240 of file implicit_system.C.
References libMesh::ImplicitSystem::_matrices.
{
// Make sure the matrix exists
matrices_iterator pos = _matrices.find (mat_name);
if (pos == _matrices.end())
return NULL;
return pos->second;
}
| const NumericVector< Number > * libMesh::System::request_vector | ( | const std::string & | vec_name | ) | const [inherited] |
System has a vector associated with the given name, NULL otherwise. Definition at line 743 of file system.C.
References libMesh::System::_vectors.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error().
{
const_vectors_iterator pos = _vectors.find(vec_name);
if (pos == _vectors.end())
return NULL;
return pos->second;
}
| NumericVector< Number > * libMesh::System::request_vector | ( | const std::string & | vec_name | ) | [inherited] |
System has a vector associated with the given name, NULL otherwise. Definition at line 755 of file system.C.
References libMesh::System::_vectors.
{
vectors_iterator pos = _vectors.find(vec_name);
if (pos == _vectors.end())
return NULL;
return pos->second;
}
| const NumericVector< Number > * libMesh::System::request_vector | ( | const unsigned int | vec_num | ) | const [inherited] |
vec_num (where the vectors are counted starting with 0), or returns NULL if the system has no such vector. Definition at line 767 of file system.C.
References libMesh::System::vectors_begin(), and libMesh::System::vectors_end().
{
const_vectors_iterator v = vectors_begin();
const_vectors_iterator v_end = vectors_end();
unsigned int num = 0;
while((num<vec_num) && (v!=v_end))
{
num++;
++v;
}
if (v==v_end)
return NULL;
return v->second;
}
| NumericVector< Number > * libMesh::System::request_vector | ( | const unsigned int | vec_num | ) | [inherited] |
vec_num (where the vectors are counted starting with 0), or returns NULL if the system has no such vector. Definition at line 784 of file system.C.
References libMesh::System::vectors_begin(), and libMesh::System::vectors_end().
{
vectors_iterator v = vectors_begin();
vectors_iterator v_end = vectors_end();
unsigned int num = 0;
while((num<vec_num) && (v!=v_end))
{
num++;
++v;
}
if (v==v_end)
return NULL;
return v->second;
}
| void libMesh::System::restrict_solve_to | ( | const SystemSubset * | subset, |
| const SubsetSolveMode | subset_solve_mode = SUBSET_ZERO |
||
| ) | [virtual, inherited] |
After calling this method, any solve will be restricted to the given subdomain. To disable this mode, call this method with subset being a NULL pointer.
Reimplemented in libMesh::LinearImplicitSystem.
Definition at line 466 of file system.C.
{
if(subset!=NULL)
{
libmesh_not_implemented();
}
}
| void libMesh::System::restrict_vectors | ( | ) | [virtual, inherited] |
Restrict vectors after the mesh has coarsened
Definition at line 320 of file system.C.
References libMesh::System::_dof_map, libMesh::System::_solution_projection, libMesh::System::_vector_projections, libMesh::System::_vector_types, libMesh::System::_vectors, libMesh::System::current_local_solution, libMesh::GHOSTED, libMesh::System::n_dofs(), libMesh::System::n_local_dofs(), libMesh::System::project_vector(), libMesh::System::solution, and libMesh::System::vector_is_adjoint().
Referenced by libMesh::System::prolong_vectors(), and libMesh::EquationSystems::reinit().
{
#ifdef LIBMESH_ENABLE_AMR
// Restrict the _vectors on the coarsened cells
for (vectors_iterator pos = _vectors.begin(); pos != _vectors.end(); ++pos)
{
NumericVector<Number>* v = pos->second;
if (_vector_projections[pos->first])
{
this->project_vector (*v, this->vector_is_adjoint(pos->first));
}
else
{
ParallelType type = _vector_types[pos->first];
if(type == GHOSTED)
{
#ifdef LIBMESH_ENABLE_GHOSTED
pos->second->init (this->n_dofs(), this->n_local_dofs(),
_dof_map->get_send_list(), false,
GHOSTED);
#else
libmesh_error_msg("Cannot initialize ghosted vectors when they are not enabled.");
#endif
}
else
pos->second->init (this->n_dofs(), this->n_local_dofs(), false, type);
}
}
const std::vector<dof_id_type>& send_list = _dof_map->get_send_list ();
// Restrict the solution on the coarsened cells
if (_solution_projection)
this->project_vector (*solution);
#ifdef LIBMESH_ENABLE_GHOSTED
current_local_solution->init(this->n_dofs(),
this->n_local_dofs(), send_list,
false, GHOSTED);
#else
current_local_solution->init(this->n_dofs());
#endif
if (_solution_projection)
solution->localize (*current_local_solution, send_list);
#endif // LIBMESH_ENABLE_AMR
}
Stores the current solution and continuation parameter (as "previous_u" and "old_continuation_paramter") for later referral. You may need to call this e.g. after the first regular solve, in order to store the first solution, before computing a second solution and beginning arclength continuation.
Definition at line 1365 of file continuation_system.C.
References continuation_parameter, old_continuation_parameter, previous_u, and libMesh::System::solution.
Referenced by update_solution().
{
// Save the old solution vector
*previous_u = *solution;
// Save the old value of lambda
old_continuation_parameter = *continuation_parameter;
}
| std::pair< unsigned int, Real > libMesh::ImplicitSystem::sensitivity_solve | ( | const ParameterVector & | parameters | ) | [virtual, inherited] |
Assembles & solves the linear system(s) (dR/du)*u_p = -dR/dp, for those parameters contained within parameters.
Returns a pair with the total number of linear iterations performed and the (sum of the) final residual norms
Reimplemented from libMesh::System.
Definition at line 304 of file implicit_system.C.
References libMesh::System::add_sensitivity_solution(), libMesh::System::assemble_before_solve, libMesh::ImplicitSystem::assemble_residual_derivatives(), libMesh::ImplicitSystem::assembly(), libMesh::SparseMatrix< T >::close(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::System::get_sensitivity_rhs(), libMesh::System::get_sensitivity_solution(), libMesh::ImplicitSystem::matrix, libMesh::pc, libMesh::ImplicitSystem::release_linear_solver(), libMesh::ImplicitSystem::request_matrix(), libMesh::ParameterVector::size(), libMesh::LinearSolver< T >::solve(), and libMesh::START_LOG().
{
// Log how long the linear solve takes.
START_LOG("sensitivity_solve()", "ImplicitSystem");
// The forward system should now already be solved.
// Now assemble the corresponding sensitivity system.
if (this->assemble_before_solve)
{
// Build the Jacobian
this->assembly(false, true);
this->matrix->close();
// Reset and build the RHS from the residual derivatives
this->assemble_residual_derivatives(parameters);
}
// The sensitivity problem is linear
LinearSolver<Number> *linear_solver = this->get_linear_solver();
// Our iteration counts and residuals will be sums of the individual
// results
std::pair<unsigned int, Real> solver_params =
this->get_linear_solve_parameters();
std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
// Solve the linear system.
SparseMatrix<Number> *pc = this->request_matrix("Preconditioner");
for (unsigned int p=0; p != parameters.size(); ++p)
{
std::pair<unsigned int, Real> rval =
linear_solver->solve (*matrix, pc,
this->add_sensitivity_solution(p),
this->get_sensitivity_rhs(p),
solver_params.second,
solver_params.first);
totalrval.first += rval.first;
totalrval.second += rval.second;
}
// The linear solver may not have fit our constraints exactly
#ifdef LIBMESH_ENABLE_CONSTRAINTS
for (unsigned int p=0; p != parameters.size(); ++p)
this->get_dof_map().enforce_constraints_exactly
(*this, &this->get_sensitivity_solution(p),
/* homogeneous = */ true);
#endif
this->release_linear_solver(linear_solver);
// Stop logging the nonlinear solve
STOP_LOG("sensitivity_solve()", "ImplicitSystem");
return totalrval;
}
| void libMesh::System::set_adjoint_already_solved | ( | bool | setting | ) | [inline, inherited] |
Setter for the adjoint_already_solved boolean
Definition at line 381 of file system.h.
References libMesh::System::adjoint_already_solved.
{ adjoint_already_solved = setting;}
| void libMesh::System::set_basic_system_only | ( | ) | [inline, inherited] |
Sets the system to be "basic only": i.e. advanced system components such as ImplicitSystem matrices may not be initialized. This is useful for efficiency in certain utility programs that never use System::solve(). This method must be called after the System or derived class is created but before it is initialized; e.g. from within EquationSystems::read()
Definition at line 2025 of file system.h.
References libMesh::System::_basic_system_only.
Referenced by libMesh::EquationSystems::_read_impl().
{
_basic_system_only = true;
}
| void libMesh::ContinuationSystem::set_max_arclength_stepsize | ( | Real | maxds | ) | [inline] |
Sets (initializes) the max-allowable ds value and the current ds value. Call this before beginning arclength continuation. The default max stepsize is 0.1
Definition at line 127 of file continuation_system.h.
References ds, and ds_current.
{ ds=maxds; ds_current=maxds; }
| void libMesh::DifferentiablePhysics::set_mesh_system | ( | System * | sys | ) | [inline, virtual, inherited] |
Tells the DifferentiablePhysics that system sys contains the isoparametric Lagrangian variables which correspond to the coordinates of mesh nodes, in problems where the mesh itself is expected to move in time.
The system with mesh coordinate data (which may be this system itself, for fully coupled moving mesh problems) is currently assumed to have new (end of time step) mesh coordinates stored in solution, old (beginning of time step) mesh coordinates stored in _old_nonlinear_solution, and constant velocity motion during each time step.
Activating this function ensures that local (but not neighbor!) element geometry is correctly repositioned when evaluating element residuals.
Currently sys must be *this for a tightly coupled moving mesh problem or NULL to stop mesh movement; loosely coupled moving mesh problems are not implemented.
This code is experimental. "Trust but verify, and not in that order"
Definition at line 433 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_sys, and libMesh::sys.
{
// For now we assume that we're doing fully coupled mesh motion
// if (sys && sys != this)
// libmesh_not_implemented();
// For the foreseeable future we'll assume that we keep these
// Systems in the same EquationSystems
// libmesh_assert_equal_to (&this->get_equation_systems(),
// &sys->get_equation_systems());
// And for the immediate future this code may not even work
libmesh_experimental();
_mesh_sys = sys;
}
| void libMesh::DifferentiablePhysics::set_mesh_x_var | ( | unsigned int | var | ) | [inline, virtual, inherited] |
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the x coordinate of mesh nodes, in problems where the mesh itself is expected to move in time.
The system with mesh coordinate data (which may be this system itself, for fully coupled moving mesh problems) is currently assumed to have new (end of time step) mesh coordinates stored in solution, old (beginning of time step) mesh coordinates stored in _old_nonlinear_solution, and constant velocity motion during each time step.
Activating this function ensures that local (but not neighbor!) element geometry is correctly repositioned when evaluating element residuals.
Definition at line 453 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_x_var.
{
_mesh_x_var = var;
}
| void libMesh::DifferentiablePhysics::set_mesh_y_var | ( | unsigned int | var | ) | [inline, virtual, inherited] |
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the y coordinate of mesh nodes.
Definition at line 461 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_y_var.
{
_mesh_y_var = var;
}
| void libMesh::DifferentiablePhysics::set_mesh_z_var | ( | unsigned int | var | ) | [inline, virtual, inherited] |
Tells the DifferentiablePhysics that variable var from the mesh system should be used to update the z coordinate of mesh nodes.
Definition at line 469 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_mesh_z_var.
{
_mesh_z_var = var;
}
| void libMesh::ContinuationSystem::set_Theta | ( | ) | [private] |
A centralized function for setting the normalization parameter theta
Definition at line 1066 of file continuation_system.C.
References libMesh::out, quiet, and Theta.
Referenced by initialize_tangent(), and update_solution().
{
// // Use the norm of the latest solution, squared.
//const Real normu = solution->l2_norm();
//libmesh_assert_not_equal_to (normu, 0.0);
//Theta = 1./normu/normu;
// // 1.) Use the norm of du, squared
// *delta_u = *solution;
// delta_u->add(-1, *previous_u);
// delta_u->close();
// const Real normdu = delta_u->l2_norm();
// if (normdu < 1.) // don't divide by zero or make a huge scaling parameter.
// Theta = 1.;
// else
// Theta = 1./normdu/normdu;
// 2.) Use 1.0, i.e. don't scale
Theta=1.;
// 3.) Use a formula which attempts to make the "solution triangle" isosceles.
// libmesh_assert_less (std::abs(dlambda_ds), 1.);
// *delta_u = *solution;
// delta_u->add(-1, *previous_u);
// delta_u->close();
// const Real normdu = delta_u->l2_norm();
// Theta = std::sqrt(1. - dlambda_ds*dlambda_ds) / normdu * tau * ds;
// // 4.) Use the norm of du and the norm of du/ds
// *delta_u = *solution;
// delta_u->add(-1, *previous_u);
// delta_u->close();
// const Real normdu = delta_u->l2_norm();
// du_ds->close();
// const Real normduds = du_ds->l2_norm();
// if (normduds < 1.e-12)
// {
// libMesh::out << "Setting initial Theta= 1./normdu/normdu" << std::endl;
// libMesh::out << "normdu=" << normdu << std::endl;
// // Don't use this scaling if the solution delta is already O(1)
// if (normdu > 1.)
// Theta = 1./normdu/normdu;
// else
// Theta = 1.;
// }
// else
// {
// libMesh::out << "Setting Theta= 1./normdu/normduds" << std::endl;
// libMesh::out << "normdu=" << normdu << std::endl;
// libMesh::out << "normduds=" << normduds << std::endl;
// // Don't use this scaling if the solution delta is already O(1)
// if ((normdu>1.) || (normduds>1.))
// Theta = 1./normdu/normduds;
// else
// Theta = 1.;
// }
if (!quiet)
libMesh::out << "Setting Normalization Parameter Theta=" << Theta << std::endl;
}
| void libMesh::ContinuationSystem::set_Theta_LOCA | ( | ) | [private] |
A centralized function for setting the other normalization parameter, i.e. the one suggested by the LOCA developers.
Definition at line 1136 of file continuation_system.C.
References std::abs(), dlambda_ds, libMesh::out, quiet, and Theta_LOCA.
Referenced by update_solution().
{
// We also recompute the LOCA normalization parameter based on the
// most recently computed value of dlambda_ds
// if (!quiet)
// libMesh::out << "(Theta_LOCA) dlambda_ds=" << dlambda_ds << std::endl;
// Formula makes no sense if |dlambda_ds| > 1
libmesh_assert_less (std::abs(dlambda_ds), 1.);
// 1.) Attempt to implement the method in LOCA paper
// const Real g = 1./std::sqrt(2.); // "desired" dlambda_ds
// // According to the LOCA people, we only renormalize for
// // when |dlambda_ds| exceeds some pre-selected maximum (which they take to be zero, btw).
// if (std::abs(dlambda_ds) > .9)
// {
// // Note the *= ... This is updating the previous value of Theta_LOCA
// // Note: The LOCA people actually use Theta_LOCA^2 to normalize their arclength constraint.
// Theta_LOCA *= std::abs( (dlambda_ds/g)*std::sqrt( (1.-g*g) / (1.-dlambda_ds*dlambda_ds) ) );
// // Suggested max-allowable value for Theta_LOCA
// if (Theta_LOCA > 1.e8)
// {
// Theta_LOCA = 1.e8;
// if (!quiet)
// libMesh::out << "max Theta_LOCA=" << Theta_LOCA << " has been selected." << std::endl;
// }
// }
// else
// Theta_LOCA=1.0;
// 2.) FIXME: Should we do *= or just =? This function is of dlambda_ds is
// < 1, |dlambda_ds| < 1/sqrt(2) ~~ .7071
// > 1, |dlambda_ds| > 1/sqrt(2) ~~ .7071
Theta_LOCA *= std::abs( dlambda_ds / std::sqrt( (1.-dlambda_ds*dlambda_ds) ) );
// Suggested max-allowable value for Theta_LOCA. I've never come close
// to this value in my code.
if (Theta_LOCA > 1.e8)
{
Theta_LOCA = 1.e8;
if (!quiet)
libMesh::out << "max Theta_LOCA=" << Theta_LOCA << " has been selected." << std::endl;
}
// 3.) Use 1.0, i.e. don't scale
//Theta_LOCA=1.0;
if (!quiet)
libMesh::out << "Setting Theta_LOCA=" << Theta_LOCA << std::endl;
}
| void libMesh::DifferentiableSystem::set_time_solver | ( | UniquePtr< TimeSolver > | _time_solver | ) | [inline, inherited] |
Sets the time_solver FIXME: This code is a little dangerous as it transfers ownership from the TimeSolver creator to this class. The user must no longer access his original TimeSolver object after calling this function.
Definition at line 219 of file diff_system.h.
References libMesh::DifferentiableSystem::time_solver.
{
time_solver.reset(_time_solver.release());
}
| void libMesh::System::set_vector_as_adjoint | ( | const std::string & | vec_name, |
| int | qoi_num | ||
| ) | [inherited] |
Allows one to set the QoI index controlling whether the vector identified by vec_name represents a solution from the adjoint (qoi_num >= 0) or primal (qoi_num == -1) space. This becomes significant if those spaces have differing heterogeneous Dirichlet constraints.
qoi_num == -2 can be used to indicate a vector which should not be affected by constraints during projection operations.
Definition at line 912 of file system.C.
References libMesh::System::_vector_is_adjoint.
Referenced by libMesh::System::add_adjoint_solution(), and libMesh::System::add_weighted_sensitivity_adjoint_solution().
{
// We reserve -1 for vectors which get primal constraints, -2 for
// vectors which get no constraints
libmesh_assert_greater_equal(qoi_num, -2);
_vector_is_adjoint[vec_name] = qoi_num;
}
| void libMesh::System::set_vector_preservation | ( | const std::string & | vec_name, |
| bool | preserve | ||
| ) | [inherited] |
Allows one to set the boolean controlling whether the vector identified by vec_name should be "preserved": projected to new meshes, saved, etc.
Definition at line 894 of file system.C.
References libMesh::System::_vector_projections.
{
_vector_projections[vec_name] = preserve;
}
| virtual bool libMesh::DifferentiablePhysics::side_constraint | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Adds the constraint contribution on side of elem to elem_residual. If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.
Users may need to reimplement this for their particular PDE depending on the boundary conditions.
To implement a weak form of the constraint 0 = G(u), the user should examine u = elem_solution and add (G(u), phi_i) boundary integral contributions to elem_residual in side_constraint().
Definition at line 168 of file diff_physics.h.
Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::side_residual(), libMesh::SteadySolver::side_residual(), and libMesh::EigenTimeSolver::side_residual().
{
return request_jacobian;
}
| virtual bool libMesh::DifferentiablePhysics::side_mass_residual | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Subtracts a mass vector contribution on side of elem from elem_residual. If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.
For most problems, the default implementation of "do nothing" is correct; users with boundary conditions including time derivatives may need to reimplement this themselves.
Definition at line 282 of file diff_physics.h.
Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::side_residual(), and libMesh::EigenTimeSolver::side_residual().
{
return request_jacobian;
}
| virtual void libMesh::DifferentiableSystem::side_postprocess | ( | DiffContext & | ) | [inline, virtual, inherited] |
Does any work that needs to be done on side of elem in a postprocessing loop.
Definition at line 265 of file diff_system.h.
{}
| virtual void libMesh::DifferentiableQoI::side_qoi | ( | DiffContext & | , |
| const QoISet & | |||
| ) | [inline, virtual, inherited] |
Does any work that needs to be done on side of elem in a quantity of interest assembly loop, outputting to elem_qoi.
Only qois included in the supplied QoISet need to be assembled.
Definition at line 131 of file diff_qoi.h.
{}
| virtual void libMesh::DifferentiableQoI::side_qoi_derivative | ( | DiffContext & | , |
| const QoISet & | |||
| ) | [inline, virtual, inherited] |
Does any work that needs to be done on side of elem in a quantity of interest derivative assembly loop, outputting to elem_qoi_derivative.
Only qois included in the supplied QoISet need their derivatives assembled.
Definition at line 143 of file diff_qoi.h.
{}
| virtual bool libMesh::DifferentiablePhysics::side_time_derivative | ( | bool | request_jacobian, |
| DiffContext & | |||
| ) | [inline, virtual, inherited] |
Adds the time derivative contribution on side of elem to elem_residual. If this method receives request_jacobian = true, then it should compute elem_jacobian and return true if possible. If elem_jacobian has not been computed then the method should return false.
Users may need to reimplement this for their particular PDE depending on the boundary conditions.
To implement a weak form of the source term du/dt = F(u) on sides, such as might arise in a flux boundary condition, the user should examine u = elem_solution and add (F(u), phi_i) boundary integral contributions to elem_residual in side_constraint().
Definition at line 148 of file diff_physics.h.
Referenced by libMesh::EulerSolver::side_residual(), libMesh::Euler2Solver::side_residual(), libMesh::SteadySolver::side_residual(), and libMesh::EigenTimeSolver::side_residual().
{
return request_jacobian;
}
| void libMesh::ContinuationSystem::solve | ( | ) | [virtual] |
Perform a standard "solve" of the system, without doing continuation.
Reimplemented from libMesh::FEMSystem.
Definition at line 122 of file continuation_system.C.
References Residual, and rhs_mode.
{
// Set the Residual RHS mode, and call the normal solve routine.
rhs_mode = Residual;
DifferentiableSystem::solve();
}
| void libMesh::ContinuationSystem::solve_tangent | ( | ) | [private] |
Special solve algorithm for solving the tangent system.
Definition at line 957 of file continuation_system.C.
References libMesh::NumericVector< T >::add(), libMesh::FEMSystem::assembly(), libMesh::NumericVector< T >::close(), continuation_parameter, delta_u, dlambda_ds, libMesh::NumericVector< T >::dot(), du_ds, G_Lambda, libMesh::NumericVector< T >::l2_norm(), libMesh::libmesh_assert(), libMesh::libmesh_real(), linear_solver, libMesh::ImplicitSystem::matrix, libMesh::DiffSolver::max_linear_iterations, newton_solver, old_continuation_parameter, libMesh::out, previous_dlambda_ds, previous_du_ds, previous_u, quiet, libMesh::Real, libMesh::ExplicitSystem::rhs, rhs_mode, libMesh::NumericVector< T >::scale(), libMesh::System::solution, tangent_initialized, Theta, Theta_LOCA, libMesh::DifferentiableSystem::time_solver, y, and libMesh::NumericVector< T >::zero().
Referenced by advance_arcstep(), and initialize_tangent().
{
// We shouldn't call this unless the current tangent already makes sense.
libmesh_assert (tangent_initialized);
// Set pointer to underlying Newton solver
if (!newton_solver)
newton_solver =
cast_ptr<NewtonSolver*> (this->time_solver->diff_solver().get());
// Assemble the system matrix AND rhs, with rhs = G_{\lambda}
this->rhs_mode = G_Lambda;
// Assemble Residual and Jacobian
this->assembly(true, // Residual
true); // Jacobian
// Not sure if this is really necessary
rhs->close();
// Solve G_u*y = G_{\lambda}
std::pair<unsigned int, Real> rval =
linear_solver->solve(*matrix,
*y,
*rhs,
1.e-12, // relative linear tolerance
2*newton_solver->max_linear_iterations); // max linear iterations
// FIXME: If this doesn't converge at all, the new tangent vector is
// going to be really bad...
if (!quiet)
libMesh::out << "G_u*y = G_{lambda} solver converged at step "
<< rval.first
<< " linear tolerance = "
<< rval.second
<< "."
<< std::endl;
// Save old solution and parameter tangents for possible use in higher-order
// predictor schemes.
previous_dlambda_ds = dlambda_ds;
*previous_du_ds = *du_ds;
// 1.) Previous, probably wrong, technique!
// // Solve for the updated d(lambda)/ds
// // denom = N_{lambda} - (du_ds)^t y
// // = d(lambda)/ds - (du_ds)^t y
// Real denom = dlambda_ds - du_ds->dot(*y);
// //libMesh::out << "denom=" << denom << std::endl;
// libmesh_assert_not_equal_to (denom, 0.0);
// dlambda_ds = 1.0 / denom;
// if (!quiet)
// libMesh::out << "dlambda_ds=" << dlambda_ds << std::endl;
// // Compute the updated value of du/ds = -_dlambda_ds * y
// du_ds->zero();
// du_ds->add(-dlambda_ds, *y);
// du_ds->close();
// 2.) From Brian Carnes' paper...
// According to Carnes, y comes from solving G_u * y = -G_{\lambda}
y->scale(-1.);
const Real ynorm = y->l2_norm();
dlambda_ds = 1. / std::sqrt(1. + Theta_LOCA*Theta_LOCA*Theta*ynorm*ynorm);
// Determine the correct sign for dlambda_ds.
// We will use delta_u to temporarily compute this sign.
*delta_u = *solution;
delta_u->add(-1., *previous_u);
delta_u->close();
const Real sgn_dlambda_ds =
libmesh_real(Theta_LOCA*Theta_LOCA*Theta*y->dot(*delta_u) +
(*continuation_parameter-old_continuation_parameter));
if (sgn_dlambda_ds < 0.)
{
if (!quiet)
libMesh::out << "dlambda_ds is negative." << std::endl;
dlambda_ds *= -1.;
}
// Finally, set the new tangent vector, du/ds = dlambda/ds * y.
du_ds->zero();
du_ds->add(dlambda_ds, *y);
du_ds->close();
if (!quiet)
{
libMesh::out << "d(lambda)/ds = " << dlambda_ds << std::endl;
libMesh::out << "||du_ds|| = " << du_ds->l2_norm() << std::endl;
}
// Our next solve expects y ~ -du/dlambda, so scale it back by -1 again now.
y->scale(-1.);
y->close();
}
| sys_type& libMesh::ImplicitSystem::system | ( | ) | [inline, inherited] |
Reimplemented from libMesh::ExplicitSystem.
Reimplemented in libMesh::NonlinearImplicitSystem, libMesh::RBConstruction, libMesh::RBConstructionBase< LinearImplicitSystem >, libMesh::LinearImplicitSystem, and libMesh::TransientSystem< RBConstruction >.
Definition at line 74 of file implicit_system.h.
Referenced by libMesh::NoxNonlinearSolver< T >::solve().
{ return *this; }
| virtual std::string libMesh::ImplicitSystem::system_type | ( | ) | const [inline, virtual, inherited] |
"Implicit". Helps in identifying the system type in an equation system file. Reimplemented from libMesh::ExplicitSystem.
Reimplemented in libMesh::NonlinearImplicitSystem, libMesh::LinearImplicitSystem, libMesh::RBConstruction, libMesh::FrequencySystem, libMesh::NewmarkSystem, and libMesh::TransientSystem< RBConstruction >.
Definition at line 116 of file implicit_system.h.
{ return "Implicit"; }
| virtual void libMesh::DifferentiableQoI::thread_join | ( | std::vector< Number > & | qoi, |
| const std::vector< Number > & | other_qoi, | ||
| const QoISet & | qoi_indices | ||
| ) | [virtual, inherited] |
Method to combine thread-local qois. By default, simply sums thread qois.
| virtual void libMesh::DifferentiablePhysics::time_evolving | ( | unsigned int | var | ) | [inline, virtual, inherited] |
Tells the DiffSystem that variable var is evolving with respect to time. In general, the user's init() function should call time_evolving() for any variables which behave like du/dt = F(u), and should not call time_evolving() for any variables which behave like 0 = G(u).
Most derived systems will not have to reimplment this function; however any system which reimplements mass_residual() may have to reimplement time_evolving() to prepare data structures.
Definition at line 221 of file diff_physics.h.
References libMesh::DifferentiablePhysics::_time_evolving.
{
if (_time_evolving.size() <= var)
_time_evolving.resize(var+1, false);
_time_evolving[var] = true;
}
| void libMesh::System::update | ( | ) | [virtual, inherited] |
Update the local values to reflect the solution on neighboring processors.
Definition at line 421 of file system.C.
References libMesh::System::_dof_map, libMesh::System::current_local_solution, libMesh::libmesh_assert(), and libMesh::System::solution.
Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_solution_vector(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), DMlibMeshFunction(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EquationSystems::get_solution(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::postprocess(), libMesh::NewtonSolver::solve(), libMesh::ExplicitSystem::solve(), libMesh::LinearImplicitSystem::solve(), and libMesh::NonlinearImplicitSystem::solve().
{
libmesh_assert(solution->closed());
const std::vector<dof_id_type>& send_list = _dof_map->get_send_list ();
// Check sizes
libmesh_assert_equal_to (current_local_solution->size(), solution->size());
// More processors than elements => empty send_list
// libmesh_assert (!send_list.empty());
libmesh_assert_less_equal (send_list.size(), solution->size());
// Create current_local_solution from solution. This will
// put a local copy of solution into current_local_solution.
// Only the necessary values (specified by the send_list)
// are copied to minimize communication
solution->localize (*current_local_solution, send_list);
}
| void libMesh::System::update_global_solution | ( | std::vector< Number > & | global_soln | ) | const [inherited] |
Fill the input vector global_soln so that it contains the global solution on all processors. Requires communication with all other processors.
Definition at line 670 of file system.C.
References libMesh::System::solution.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::EquationSystems::build_discontinuous_solution_vector(), and libMesh::ExactErrorEstimator::estimate_error().
| void libMesh::System::update_global_solution | ( | std::vector< Number > & | global_soln, |
| const processor_id_type | dest_proc | ||
| ) | const [inherited] |
Fill the input vector global_soln so that it contains the global solution on processor dest_proc. Requires communication with all other processors.
Definition at line 679 of file system.C.
References libMesh::System::solution.
| void libMesh::ContinuationSystem::update_solution | ( | ) | [private] |
This function (which assumes the most recent tangent vector has been computed) updates the solution and the control parameter with the initial guess for the next point on the continuation path.
Definition at line 1193 of file continuation_system.C.
References std::abs(), libMesh::NumericVector< T >::add(), apply_predictor(), libMesh::NumericVector< T >::close(), continuation_parameter, delta_u, libMesh::NumericVector< T >::dot(), ds, ds_current, ds_min, libMesh::NumericVector< T >::l2_norm(), libMesh::libmesh_assert(), libMesh::DiffSolver::max_nonlinear_iterations, newton_solver, newton_step, newton_stepgrowth_aggressiveness, old_continuation_parameter, libMesh::out, libMesh::BasicOStreamProxy< charT, traits >::precision(), previous_ds, previous_u, quiet, libMesh::Real, save_current_solution(), set_Theta(), set_Theta_LOCA(), libMesh::BasicOStreamProxy< charT, traits >::setf(), libMesh::System::solution, tangent_initialized, Theta, Theta_LOCA, libMesh::BasicOStreamProxy< charT, traits >::unsetf(), y, and y_old.
Referenced by advance_arcstep(), and initialize_tangent().
{
// Set some stream formatting flags
std::streamsize old_precision = libMesh::out.precision();
libMesh::out.precision(16);
libMesh::out.setf(std::ios_base::scientific);
// We must have a tangent that makes sense before we can update the solution.
libmesh_assert (tangent_initialized);
// Compute tau, the stepsize scaling parameter which attempts to
// reduce ds when the angle between the most recent two tangent
// vectors becomes large. tau is actually the (absolute value of
// the) cosine of the angle between these two vectors... so if tau ~
// 0 the angle is ~ 90 degrees, while if tau ~ 1 the angle is ~ 0
// degrees.
y_old->close();
y->close();
const Real yoldnorm = y_old->l2_norm();
const Real ynorm = y->l2_norm();
const Number yoldy = y_old->dot(*y);
const Real yold_over_y = yoldnorm/ynorm;
if (!quiet)
{
libMesh::out << "yoldnorm=" << yoldnorm << std::endl;
libMesh::out << "ynorm=" << ynorm << std::endl;
libMesh::out << "yoldy=" << yoldy << std::endl;
libMesh::out << "yoldnorm/ynorm=" << yoldnorm/ynorm << std::endl;
}
// Save the current value of ds before updating it
previous_ds = ds_current;
// // 1.) Cosine method (for some reason this always predicts the angle is ~0)
// // Don't try divinding by zero
// if ((yoldnorm > 1.e-12) && (ynorm > 1.e-12))
// tau = std::abs(yoldy) / yoldnorm / ynorm;
// else
// tau = 1.;
// // 2.) Relative size of old and new du/dlambda method with cutoff of 0.9
// if ((yold_over_y < 0.9) && (yold_over_y > 1.e-6))
// tau = yold_over_y;
// else
// tau = 1.;
// 3.) Grow (or shrink) the arclength stepsize by the ratio of du/dlambda, but do not
// exceed the user-specified value of ds.
if (yold_over_y > 1.e-6)
{
// // 1.) Scale current ds by the ratio of successive tangents.
// ds_current *= yold_over_y;
// if (ds_current > ds)
// ds_current = ds;
// 2.) Technique 1 tends to shrink the step fairly well (and even if it doesn't
// get very small, we still have step reduction) but it seems to grow the step
// very slowly. Another possible technique is step-doubling:
// if (yold_over_y > 1.)
// ds_current *= 2.;
// else
// ds_current *= yold_over_y;
// 3.) Technique 2 may over-zealous when we are also using the Newton stepgrowth
// factor. For technique 3 we multiply by yold_over_y unless yold_over_y > 2
// in which case we use 2.
// if (yold_over_y > 2.)
// ds_current *= 2.;
// else
// ds_current *= yold_over_y;
// 4.) Double-or-halve. We double the arc-step if the ratio of successive tangents
// is larger than 'double_threshold', halve it if it is less than 'halve_threshold'
const Real double_threshold = 0.5;
const Real halve_threshold = 0.5;
if (yold_over_y > double_threshold)
ds_current *= 2.;
else if (yold_over_y < halve_threshold)
ds_current *= 0.5;
// Also possibly use the number of Newton iterations required to compute the previous
// step (relative to the maximum-allowed number of Newton iterations) to grow the step.
if (newton_stepgrowth_aggressiveness > 0.)
{
libmesh_assert(newton_solver);
const unsigned int Nmax = newton_solver->max_nonlinear_iterations;
// // The LOCA Newton step growth technique (note: only grows step length)
// const Real stepratio = static_cast<Real>(Nmax-(newton_step+1))/static_cast<Real>(Nmax-1.);
// const Real newtonstep_growthfactor = 1. + newton_stepgrowth_aggressiveness*stepratio*stepratio;
// The "Nopt/N" method, may grow or shrink the step. Assume Nopt=Nmax/2.
const Real newtonstep_growthfactor =
newton_stepgrowth_aggressiveness * 0.5 *
static_cast<Real>(Nmax) / static_cast<Real>(newton_step+1);
if (!quiet)
libMesh::out << "newtonstep_growthfactor=" << newtonstep_growthfactor << std::endl;
ds_current *= newtonstep_growthfactor;
}
}
// Don't let the stepsize get above the user's maximum-allowed stepsize.
if (ds_current > ds)
ds_current = ds;
// Check also for a minimum allowed stepsize.
if (ds_current < ds_min)
{
libMesh::out << "Enforcing minimum-allowed arclength stepsize of " << ds_min << std::endl;
ds_current = ds_min;
}
if (!quiet)
{
libMesh::out << "Current step size: ds_current=" << ds_current << std::endl;
}
// Recompute scaling factor Theta for
// the current solution before updating.
set_Theta();
// Also, recompute the LOCA scaling factor, which attempts to
// maintain a reasonable value of dlambda/ds
set_Theta_LOCA();
libMesh::out << "Theta*Theta_LOCA^2=" << Theta*Theta_LOCA*Theta_LOCA << std::endl;
// Based on the asymptotic singular behavior of du/dlambda near simple turning points,
// we can compute a single parameter which may suggest that we are close to a singularity.
*delta_u = *solution;
delta_u->add(-1, *previous_u);
delta_u->close();
const Real normdu = delta_u->l2_norm();
const Real C = (std::log (Theta_LOCA*normdu) /
std::log (std::abs(*continuation_parameter-old_continuation_parameter))) - 1.0;
if (!quiet)
libMesh::out << "C=" << C << std::endl;
// Save the current value of u and lambda before updating.
save_current_solution();
if (!quiet)
{
libMesh::out << "Updating the solution with the tangent guess." << std::endl;
libMesh::out << "||u_old||=" << this->solution->l2_norm() << std::endl;
libMesh::out << "lambda_old=" << *continuation_parameter << std::endl;
}
// Since we solved for the tangent vector, now we can compute an
// initial guess for the new solution, and an initial guess for the
// new value of lambda.
apply_predictor();
if (!quiet)
{
libMesh::out << "||u_new||=" << this->solution->l2_norm() << std::endl;
libMesh::out << "lambda_new=" << *continuation_parameter << std::endl;
}
// Unset previous stream flags
libMesh::out.precision(old_precision);
libMesh::out.unsetf(std::ios_base::scientific);
}
| void libMesh::System::user_assembly | ( | ) | [virtual, inherited] |
Calls user's attached assembly function, or is overloaded by the user in derived classes.
Definition at line 1934 of file system.C.
References libMesh::System::_assemble_system_function, libMesh::System::_assemble_system_object, libMesh::System::_equation_systems, libMesh::System::Assembly::assemble(), and libMesh::System::name().
Referenced by libMesh::System::assemble().
{
// Call the user-provided assembly function,
// if it was provided
if (_assemble_system_function != NULL)
this->_assemble_system_function (_equation_systems, this->name());
// ...or the user-provided assembly object.
else if (_assemble_system_object != NULL)
this->_assemble_system_object->assemble();
}
| void libMesh::System::user_constrain | ( | ) | [virtual, inherited] |
Calls user's attached constraint function, or is overloaded by the user in derived classes.
Definition at line 1948 of file system.C.
References libMesh::System::_constrain_system_function, libMesh::System::_constrain_system_object, libMesh::System::_equation_systems, libMesh::System::Constraint::constrain(), and libMesh::System::name().
Referenced by libMesh::EquationSystems::allgather(), libMesh::System::init_data(), libMesh::EquationSystems::reinit(), and libMesh::System::reinit_constraints().
{
// Call the user-provided constraint function,
// if it was provided
if (_constrain_system_function!= NULL)
this->_constrain_system_function(_equation_systems, this->name());
// ...or the user-provided constraint object.
else if (_constrain_system_object != NULL)
this->_constrain_system_object->constrain();
}
| void libMesh::System::user_initialization | ( | ) | [virtual, inherited] |
Calls user's attached initialization function, or is overloaded by the user in derived classes.
Definition at line 1920 of file system.C.
References libMesh::System::_equation_systems, libMesh::System::_init_system_function, libMesh::System::_init_system_object, libMesh::System::Initialization::initialize(), and libMesh::System::name().
Referenced by libMesh::System::init(), and libMesh::NewmarkSystem::initial_conditions().
{
// Call the user-provided intialization function,
// if it was provided
if (_init_system_function != NULL)
this->_init_system_function (_equation_systems, this->name());
// ...or the user-provided initialization object.
else if (_init_system_object != NULL)
this->_init_system_object->initialize();
}
| void libMesh::System::user_QOI | ( | const QoISet & | qoi_indices | ) | [virtual, inherited] |
Calls user's attached quantity of interest function, or is overloaded by the user in derived classes.
Definition at line 1962 of file system.C.
References libMesh::System::_equation_systems, libMesh::System::_qoi_evaluate_function, libMesh::System::_qoi_evaluate_object, libMesh::System::name(), and libMesh::System::QOI::qoi().
Referenced by libMesh::System::assemble_qoi().
{
// Call the user-provided quantity of interest function,
// if it was provided
if (_qoi_evaluate_function != NULL)
this->_qoi_evaluate_function(_equation_systems, this->name(), qoi_indices);
// ...or the user-provided QOI function object.
else if (_qoi_evaluate_object != NULL)
this->_qoi_evaluate_object->qoi(qoi_indices);
}
| void libMesh::System::user_QOI_derivative | ( | const QoISet & | qoi_indices = QoISet(), |
| bool | include_liftfunc = true, |
||
| bool | apply_constraints = true |
||
| ) | [virtual, inherited] |
Calls user's attached quantity of interest derivative function, or is overloaded by the user in derived classes.
Definition at line 1976 of file system.C.
References libMesh::System::_equation_systems, libMesh::System::_qoi_evaluate_derivative_function, libMesh::System::_qoi_evaluate_derivative_object, libMesh::System::name(), and libMesh::System::QOIDerivative::qoi_derivative().
Referenced by libMesh::System::assemble_qoi_derivative().
{
// Call the user-provided quantity of interest derivative,
// if it was provided
if (_qoi_evaluate_derivative_function != NULL)
this->_qoi_evaluate_derivative_function
(_equation_systems, this->name(), qoi_indices, include_liftfunc,
apply_constraints);
// ...or the user-provided QOI derivative function object.
else if (_qoi_evaluate_derivative_object != NULL)
this->_qoi_evaluate_derivative_object->qoi_derivative
(qoi_indices, include_liftfunc, apply_constraints);
}
| const Variable & libMesh::System::variable | ( | unsigned int | var | ) | const [inline, inherited] |
Return a constant reference to Variable var.
Definition at line 2061 of file system.h.
References libMesh::System::_variables.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::EquationSystems::build_solution_vector(), libMesh::EquationSystems::get_solution(), libMesh::System::project_vector(), libMesh::System::read_parallel_data(), libMesh::System::read_SCALAR_dofs(), libMesh::System::read_serialized_vector(), libMesh::System::read_serialized_vectors(), libMesh::System::write_header(), libMesh::System::write_parallel_data(), libMesh::System::write_serialized_vector(), and libMesh::System::write_serialized_vectors().
{
libmesh_assert_less (i, _variables.size());
return _variables[i];
}
| const VariableGroup & libMesh::System::variable_group | ( | unsigned int | vg | ) | const [inline, inherited] |
Return a constant reference to VariableGroup vg.
Definition at line 2071 of file system.h.
References libMesh::System::_variable_groups.
Referenced by libMesh::FEMSystem::assembly(), and libMesh::System::get_info().
{
libmesh_assert_less (vg, _variable_groups.size());
return _variable_groups[vg];
}
| const std::string & libMesh::System::variable_name | ( | const unsigned int | i | ) | const [inline, inherited] |
i. Definition at line 2081 of file system.h.
References libMesh::System::_variables.
Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::DiscontinuityMeasure::boundary_side_integration(), libMesh::KellyErrorEstimator::boundary_side_integration(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactSolution::ExactSolution(), libMesh::EquationSystems::get_solution(), libMesh::ParsedFEMFunction< Output >::ParsedFEMFunction(), libMesh::petsc_auto_fieldsplit(), and libMesh::System::write_header().
{
libmesh_assert_less (i, _variables.size());
return _variables[i].name();
}
| unsigned short int libMesh::System::variable_number | ( | const std::string & | var | ) | const [inherited] |
var. Definition at line 1270 of file system.C.
References libMesh::System::_variable_numbers, and libMesh::System::_variables.
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::System::read_header(), libMesh::System::variable_scalar_number(), libMesh::System::variable_type(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().
{
// Make sure the variable exists
std::map<std::string, unsigned short int>::const_iterator
pos = _variable_numbers.find(var);
if (pos == _variable_numbers.end())
libmesh_error_msg("ERROR: variable " << var << " does not exist in this system!");
libmesh_assert_equal_to (_variables[pos->second].name(), var);
return pos->second;
}
| unsigned int libMesh::System::variable_scalar_number | ( | const std::string & | var, |
| unsigned int | component | ||
| ) | const [inline, inherited] |
variable_number(var) Irony: currently our only non-scalar-valued variable type is SCALAR.
Definition at line 2092 of file system.h.
References libMesh::System::variable_number().
Referenced by libMesh::ExactSolution::_compute_error(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), and libMesh::System::project_vector().
{
return variable_scalar_number(this->variable_number(var), component);
}
| unsigned int libMesh::System::variable_scalar_number | ( | unsigned int | var_num, |
| unsigned int | component | ||
| ) | const [inline, inherited] |
var_num Irony: currently our only non-scalar-valued variable type is SCALAR.
Definition at line 2102 of file system.h.
References libMesh::System::_variables.
{
return _variables[var_num].first_scalar_number() + component;
}
| const FEType & libMesh::System::variable_type | ( | const unsigned int | i | ) | const [inline, inherited] |
i. Definition at line 2111 of file system.h.
References libMesh::System::_variables.
Referenced by libMesh::System::add_variable(), libMesh::System::add_variables(), libMesh::EquationSystems::build_discontinuous_solution_vector(), libMesh::EquationSystems::build_solution_vector(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::DGFEMContext::DGFEMContext(), libMesh::FEMContext::FEMContext(), libMesh::EquationSystems::get_solution(), libMesh::FEMSystem::init_context(), libMesh::System::write_header(), libMesh::EnsightIO::write_scalar_ascii(), and libMesh::EnsightIO::write_vector_ascii().
{
libmesh_assert_less (i, _variables.size());
return _variables[i].type();
}
| const FEType & libMesh::System::variable_type | ( | const std::string & | var | ) | const [inline, inherited] |
var. Definition at line 2121 of file system.h.
References libMesh::System::_variables, and libMesh::System::variable_number().
{
return _variables[this->variable_number(var)].type();
}
| int libMesh::System::vector_is_adjoint | ( | const std::string & | vec_name | ) | const [inherited] |
Definition at line 923 of file system.C.
References libMesh::System::_vector_is_adjoint, and libMesh::libmesh_assert().
Referenced by libMesh::System::restrict_vectors().
{
libmesh_assert(_vector_is_adjoint.find(vec_name) !=
_vector_is_adjoint.end());
return _vector_is_adjoint.find(vec_name)->second;
}
| const std::string & libMesh::System::vector_name | ( | const unsigned int | vec_num | ) | const [inherited] |
vec_num (where the vectors are counted starting with 0). Definition at line 859 of file system.C.
References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().
{
const_vectors_iterator v = vectors_begin();
const_vectors_iterator v_end = vectors_end();
unsigned int num = 0;
while((num<vec_num) && (v!=v_end))
{
num++;
++v;
}
libmesh_assert (v != v_end);
return v->first;
}
| const std::string & libMesh::System::vector_name | ( | const NumericVector< Number > & | vec_reference | ) | const [inherited] |
Definition at line 873 of file system.C.
References libMesh::libmesh_assert(), libMesh::System::vectors_begin(), and libMesh::System::vectors_end().
{
const_vectors_iterator v = vectors_begin();
const_vectors_iterator v_end = vectors_end();
for(; v != v_end; ++v)
{
// Check if the current vector is the one whose name we want
if(&vec_reference == v->second)
break; // exit loop if it is
}
// Before returning, make sure we didnt loop till the end and not find any match
libmesh_assert (v != v_end);
// Return the string associated with the current vector
return v->first;
}
| bool libMesh::System::vector_preservation | ( | const std::string & | vec_name | ) | const [inherited] |
Definition at line 902 of file system.C.
References libMesh::System::_vector_projections.
Referenced by libMesh::MemorySolutionHistory::store().
{
if (_vector_projections.find(vec_name) == _vector_projections.end())
return false;
return _vector_projections.find(vec_name)->second;
}
| System::vectors_iterator libMesh::System::vectors_begin | ( | ) | [inline, inherited] |
Beginning of vectors container
Definition at line 2173 of file system.h.
References libMesh::System::_vectors.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_vector(), libMesh::System::request_vector(), libMesh::MemorySolutionHistory::store(), libMesh::VTKIO::system_vectors_to_vtk(), and libMesh::System::vector_name().
{
return _vectors.begin();
}
| System::const_vectors_iterator libMesh::System::vectors_begin | ( | ) | const [inline, inherited] |
Beginning of vectors container
Definition at line 2179 of file system.h.
References libMesh::System::_vectors.
{
return _vectors.begin();
}
| System::vectors_iterator libMesh::System::vectors_end | ( | ) | [inline, inherited] |
End of vectors container
Definition at line 2185 of file system.h.
References libMesh::System::_vectors.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::System::get_vector(), libMesh::System::request_vector(), libMesh::MemorySolutionHistory::store(), libMesh::VTKIO::system_vectors_to_vtk(), and libMesh::System::vector_name().
{
return _vectors.end();
}
| System::const_vectors_iterator libMesh::System::vectors_end | ( | ) | const [inline, inherited] |
End of vectors container
Definition at line 2191 of file system.h.
References libMesh::System::_vectors.
{
return _vectors.end();
}
| std::pair< unsigned int, Real > libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve | ( | const ParameterVector & | parameters, |
| const ParameterVector & | weights, | ||
| const QoISet & | qoi_indices = QoISet() |
||
| ) | [virtual, inherited] |
Assembles & solves the linear system(s) (dR/du)^T*z_w = sum(w_p*(d^2q/dudp - d^2R/dudp*z)), for those parameters p contained within parameters, weighted by the values w_p found within weights.
Assumes that adjoint_solve has already calculated z for each qoi in qoi_indices.
Returns a pair with the total number of linear iterations performed and the (sum of the) final residual norms
Reimplemented from libMesh::System.
Definition at line 421 of file implicit_system.C.
References libMesh::System::add_weighted_sensitivity_adjoint_solution(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_adjoint_rhs(), libMesh::System::get_adjoint_solution(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::SparseMatrix< T >::get_transpose(), libMesh::System::get_weighted_sensitivity_adjoint_solution(), libMesh::DofMap::has_adjoint_dirichlet_boundaries(), libMesh::QoISet::has_index(), libMesh::libmesh_assert(), libMesh::ImplicitSystem::matrix, libMesh::System::qoi, libMesh::Real, libMesh::ImplicitSystem::release_linear_solver(), libMesh::ExplicitSystem::rhs, libMesh::LinearSolver< T >::solve(), libMesh::START_LOG(), libMesh::TOLERANCE, libMesh::ParameterVector::value_copy(), libMesh::SparseMatrix< T >::vector_mult_add(), and libMesh::NumericVector< T >::zero_clone().
{
// Log how long the linear solve takes.
START_LOG("weighted_sensitivity_adjoint_solve()", "ImplicitSystem");
// We currently get partial derivatives via central differencing
const Real delta_p = TOLERANCE;
ParameterVector& parameters =
const_cast<ParameterVector&>(parameters_in);
// The forward system should now already be solved.
// The adjoint system should now already be solved.
// Now we're assembling a weighted sum of adjoint-adjoint systems:
//
// dR/du (u, sum_l(w_l*z^l)) = sum_l(w_l*(Q''_ul - R''_ul (u, z)))
// FIXME: The derivation here does not yet take adjoint boundary
// conditions into account.
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
libmesh_assert(!this->get_dof_map().has_adjoint_dirichlet_boundaries(i));
// We'll assemble the rhs first, because the R'' term will require
// perturbing the jacobian
// We'll use temporary rhs vectors, because we haven't (yet) found
// any good reasons why users might want to save these:
std::vector<NumericVector<Number> *> temprhs(this->qoi.size());
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
temprhs[i] = this->rhs->zero_clone().release();
// We approximate the _l partial derivatives via a central
// differencing perturbation in the w_l direction:
//
// sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
// PETSc doesn't implement SGEMX, so neither does NumericVector,
// so we want to avoid calculating f -= R'*z. We'll thus evaluate
// the above equation by first adding -v(p+dp...), then multiplying
// the intermediate result vectors by -1, then adding -v(p-dp...),
// then finally dividing by 2*dp.
ParameterVector oldparameters, parameterperturbation;
parameters.deep_copy(oldparameters);
weights.deep_copy(parameterperturbation);
parameterperturbation *= delta_p;
parameters += parameterperturbation;
this->assembly(false, true);
this->matrix->close();
// Take the discrete adjoint, so that we can calculate R_u(u,z) with
// a matrix-vector product of R_u and z.
matrix->get_transpose(*matrix);
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ false,
/* apply_constraints = */ true);
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
*(temprhs[i]) -= this->get_adjoint_rhs(i);
this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
*(temprhs[i]) *= -1.0;
}
oldparameters.value_copy(parameters);
parameterperturbation *= -1.0;
parameters += parameterperturbation;
this->assembly(false, true);
this->matrix->close();
matrix->get_transpose(*matrix);
this->assemble_qoi_derivative(qoi_indices,
/* include_liftfunc = */ false,
/* apply_constraints = */ true);
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
{
this->get_adjoint_rhs(i).close();
*(temprhs[i]) -= this->get_adjoint_rhs(i);
this->matrix->vector_mult_add(*(temprhs[i]), this->get_adjoint_solution(i));
*(temprhs[i]) /= (2.0*delta_p);
}
// Finally, assemble the jacobian at the non-perturbed parameter
// values. Ignore assemble_before_solve; if we had a good
// non-perturbed matrix before we've already overwritten it.
oldparameters.value_copy(parameters);
// if (this->assemble_before_solve)
{
// Build the Jacobian
this->assembly(false, true);
this->matrix->close();
// Take the discrete adjoint
matrix->get_transpose(*matrix);
}
// The weighted adjoint-adjoint problem is linear
LinearSolver<Number> *linear_solver = this->get_linear_solver();
// Our iteration counts and residuals will be sums of the individual
// results
std::pair<unsigned int, Real> solver_params =
this->get_linear_solve_parameters();
std::pair<unsigned int, Real> totalrval = std::make_pair(0,0.0);
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
{
const std::pair<unsigned int, Real> rval =
linear_solver->solve (*matrix, this->add_weighted_sensitivity_adjoint_solution(i),
*(temprhs[i]),
solver_params.second,
solver_params.first);
totalrval.first += rval.first;
totalrval.second += rval.second;
}
this->release_linear_solver(linear_solver);
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
delete temprhs[i];
// The linear solver may not have fit our constraints exactly
#ifdef LIBMESH_ENABLE_CONSTRAINTS
for (unsigned int i=0; i != this->qoi.size(); ++i)
if (qoi_indices.has_index(i))
this->get_dof_map().enforce_constraints_exactly
(*this, &this->get_weighted_sensitivity_adjoint_solution(i),
/* homogeneous = */ true);
#endif
// Stop logging the nonlinear solve
STOP_LOG("weighted_sensitivity_adjoint_solve()", "ImplicitSystem");
return totalrval;
}
| std::pair< unsigned int, Real > libMesh::ImplicitSystem::weighted_sensitivity_solve | ( | const ParameterVector & | parameters, |
| const ParameterVector & | weights | ||
| ) | [virtual, inherited] |
Assembles & solves the linear system(s) (dR/du)*u_w = sum(w_p*-dR/dp), for those parameters p contained within parameters weighted by the values w_p found within weights.
Returns a pair with the total number of linear iterations performed and the (sum of the) final residual norms
Reimplemented from libMesh::System.
Definition at line 574 of file implicit_system.C.
References libMesh::System::add_weighted_sensitivity_solution(), libMesh::ImplicitSystem::assembly(), libMesh::NumericVector< T >::clone(), libMesh::NumericVector< T >::close(), libMesh::SparseMatrix< T >::close(), libMesh::ParameterVector::deep_copy(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::System::get_dof_map(), libMesh::ImplicitSystem::get_linear_solve_parameters(), libMesh::ImplicitSystem::get_linear_solver(), libMesh::System::get_weighted_sensitivity_solution(), libMesh::ImplicitSystem::matrix, libMesh::Real, libMesh::ImplicitSystem::release_linear_solver(), libMesh::ExplicitSystem::rhs, libMesh::LinearSolver< T >::solve(), libMesh::START_LOG(), libMesh::TOLERANCE, and libMesh::ParameterVector::value_copy().
{
// Log how long the linear solve takes.
START_LOG("weighted_sensitivity_solve()", "ImplicitSystem");
// We currently get partial derivatives via central differencing
const Real delta_p = TOLERANCE;
ParameterVector& parameters =
const_cast<ParameterVector&>(parameters_in);
// The forward system should now already be solved.
// Now we're assembling a weighted sum of sensitivity systems:
//
// dR/du (u, v)(sum(w_l*u'_l)) = -sum_l(w_l*R'_l (u, v)) forall v
// We'll assemble the rhs first, because the R' term will require
// perturbing the system, and some applications may not be able to
// assemble a perturbed residual without simultaneously constructing
// a perturbed jacobian.
// We approximate the _l partial derivatives via a central
// differencing perturbation in the w_l direction:
//
// sum_l(w_l*v_l) ~= (v(p + dp*w_l*e_l) - v(p - dp*w_l*e_l))/(2*dp)
ParameterVector oldparameters, parameterperturbation;
parameters.deep_copy(oldparameters);
weights.deep_copy(parameterperturbation);
parameterperturbation *= delta_p;
parameters += parameterperturbation;
this->assembly(true, false, true);
this->rhs->close();
UniquePtr<NumericVector<Number> > temprhs = this->rhs->clone();
oldparameters.value_copy(parameters);
parameterperturbation *= -1.0;
parameters += parameterperturbation;
this->assembly(true, false, true);
this->rhs->close();
*temprhs -= *(this->rhs);
*temprhs /= (2.0*delta_p);
// Finally, assemble the jacobian at the non-perturbed parameter
// values
oldparameters.value_copy(parameters);
// Build the Jacobian
this->assembly(false, true);
this->matrix->close();
// The weighted sensitivity problem is linear
LinearSolver<Number> *linear_solver = this->get_linear_solver();
std::pair<unsigned int, Real> solver_params =
this->get_linear_solve_parameters();
const std::pair<unsigned int, Real> rval =
linear_solver->solve (*matrix, this->add_weighted_sensitivity_solution(),
*temprhs,
solver_params.second,
solver_params.first);
this->release_linear_solver(linear_solver);
// The linear solver may not have fit our constraints exactly
#ifdef LIBMESH_ENABLE_CONSTRAINTS
this->get_dof_map().enforce_constraints_exactly
(*this, &this->get_weighted_sensitivity_solution(),
/* homogeneous = */ true);
#endif
// Stop logging the nonlinear solve
STOP_LOG("weighted_sensitivity_solve()", "ImplicitSystem");
return rval;
}
| void libMesh::System::write_header | ( | Xdr & | io, |
| const std::string & | version, | ||
| const bool | write_additional_data | ||
| ) | const [inherited] |
Writes the basic data header for this System.
This method implements the output of a System object, embedded in the output of an EquationSystems<T_sys>. This warrants some documentation. The output of this part consists of 5 sections:
for this system
5.) The number of variables in the system (unsigned int)
for each variable in the system
6.) The name of the variable (string)
6.1.) subdomain where the variable lives
7.) Combined in an FEType:
end variable loop
8.) The number of additional vectors (unsigned int),
for each additional vector in the system object
9.) the name of the additional vector (string)
end system
Definition at line 1269 of file system_io.C.
References libMesh::System::_vectors, libMesh::Variable::active_subdomains(), libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::FEType::inf_map, libMesh::libmesh_assert(), libMesh::System::n_vars(), libMesh::System::n_vectors(), libMesh::System::name(), libMesh::FEType::order, libMesh::ParallelObject::processor_id(), libMesh::FEType::radial_family, libMesh::FEType::radial_order, libMesh::System::variable(), libMesh::System::variable_name(), libMesh::System::variable_type(), and libMesh::Xdr::writing().
{
libmesh_assert (io.writing());
// Only write the header information
// if we are processor 0.
if (this->get_mesh().processor_id() != 0)
return;
std::string comment;
char buf[80];
// 5.)
// Write the number of variables in the system
{
// set up the comment
comment = "# No. of Variables in System \"";
comment += this->name();
comment += "\"";
unsigned int nv = this->n_vars();
io.data (nv, comment.c_str());
}
for (unsigned int var=0; var<this->n_vars(); var++)
{
// 6.)
// Write the name of the var-th variable
{
// set up the comment
comment = "# Name, Variable No. ";
std::sprintf(buf, "%u", var);
comment += buf;
comment += ", System \"";
comment += this->name();
comment += "\"";
std::string var_name = this->variable_name(var);
io.data (var_name, comment.c_str());
}
// 6.1.) Variable subdomains
{
// set up the comment
comment = "# Subdomains, Variable \"";
std::sprintf(buf, "%s", this->variable_name(var).c_str());
comment += buf;
comment += "\", System \"";
comment += this->name();
comment += "\"";
const std::set<subdomain_id_type> & domains = this->variable(var).active_subdomains();
std::vector<subdomain_id_type> domain_array;
domain_array.assign(domains.begin(), domains.end());
io.data (domain_array, comment.c_str());
}
// 7.)
// Write the approximation order of the var-th variable
// in this system
{
// set up the comment
comment = "# Approximation Order, Variable \"";
std::sprintf(buf, "%s", this->variable_name(var).c_str());
comment += buf;
comment += "\", System \"";
comment += this->name();
comment += "\"";
int order = static_cast<int>(this->variable_type(var).order);
io.data (order, comment.c_str());
}
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
// do the same for radial_order
{
comment = "# Radial Approximation Order, Variable \"";
std::sprintf(buf, "%s", this->variable_name(var).c_str());
comment += buf;
comment += "\", System \"";
comment += this->name();
comment += "\"";
int rad_order = static_cast<int>(this->variable_type(var).radial_order);
io.data (rad_order, comment.c_str());
}
#endif
// Write the Finite Element type of the var-th variable
// in this System
{
// set up the comment
comment = "# FE Family, Variable \"";
std::sprintf(buf, "%s", this->variable_name(var).c_str());
comment += buf;
comment += "\", System \"";
comment += this->name();
comment += "\"";
const FEType& type = this->variable_type(var);
int fam = static_cast<int>(type.family);
io.data (fam, comment.c_str());
#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
comment = "# Radial FE Family, Variable \"";
std::sprintf(buf, "%s", this->variable_name(var).c_str());
comment += buf;
comment += "\", System \"";
comment += this->name();
comment += "\"";
int radial_fam = static_cast<int>(type.radial_family);
io.data (radial_fam, comment.c_str());
comment = "# Infinite Mapping Type, Variable \"";
std::sprintf(buf, "%s", this->variable_name(var).c_str());
comment += buf;
comment += "\", System \"";
comment += this->name();
comment += "\"";
int i_map = static_cast<int>(type.inf_map);
io.data (i_map, comment.c_str());
#endif
}
} // end of the variable loop
// 8.)
// Write the number of additional vectors in the System.
// If write_additional_data==false, then write zero for
// the number of additional vectors.
{
{
// set up the comment
comment = "# No. of Additional Vectors, System \"";
comment += this->name();
comment += "\"";
unsigned int nvecs = write_additional_data ? this->n_vectors () : 0;
io.data (nvecs, comment.c_str());
}
if (write_additional_data)
{
std::map<std::string, NumericVector<Number>* >::const_iterator
vec_pos = this->_vectors.begin();
unsigned int cnt=0;
for (; vec_pos != this->_vectors.end(); ++vec_pos)
{
// 9.)
// write the name of the cnt-th additional vector
comment = "# Name of ";
std::sprintf(buf, "%d", cnt++);
comment += buf;
comment += "th vector";
std::string vec_name = vec_pos->first;
io.data (vec_name, comment.c_str());
}
}
}
}
| void libMesh::System::write_parallel_data | ( | Xdr & | io, |
| const bool | write_additional_data | ||
| ) | const [inherited] |
Writes additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh. This method will create an individual file for each processor in the simulation where the local solution components for that processor will be stored.
This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.
9.) The global solution vector, re-ordered to be node-major (More on this later.)
for each additional vector in the object
10.) The global additional vector, re-ordered to be node-major (More on this later.)
Note that the actual IO is handled through the Xdr class (to be renamed later?) which provides a uniform interface to both the XDR (eXternal Data Representation) interface and standard ASCII output. Thus this one section of code will read XDR or ASCII files with no changes.
Definition at line 1477 of file system_io.C.
References libMesh::System::_vectors, libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_dof_map(), libMesh::System::get_mesh(), libMesh::DofObject::invalid_id, libMesh::libmesh_assert(), libMesh::ParallelObject::n_processors(), libMesh::System::n_vars(), libMesh::System::name(), libMesh::System::number(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::DofMap::SCALAR_dof_indices(), libMesh::System::solution, libMesh::Variable::type(), libMesh::System::variable(), and libMesh::Xdr::writing().
{
// PerfLog pl("IO Performance",false);
// pl.push("write_parallel_data");
// std::size_t total_written_size = 0;
std::string comment;
libmesh_assert (io.writing());
std::vector<Number> io_buffer; io_buffer.reserve(this->solution->local_size());
// build the ordered nodes and element maps.
// when writing/reading parallel files we need to iterate
// over our nodes/elements in order of increasing global id().
// however, this is not guaranteed to be ordering we obtain
// by using the node_iterators/element_iterators directly.
// so build a set, sorted by id(), that provides the ordering.
// further, for memory economy build the set but then transfer
// its contents to vectors, which will be sorted.
std::vector<const DofObject*> ordered_nodes, ordered_elements;
{
std::set<const DofObject*, CompareDofObjectsByID>
ordered_nodes_set (this->get_mesh().local_nodes_begin(),
this->get_mesh().local_nodes_end());
ordered_nodes.insert(ordered_nodes.end(),
ordered_nodes_set.begin(),
ordered_nodes_set.end());
}
{
std::set<const DofObject*, CompareDofObjectsByID>
ordered_elements_set (this->get_mesh().local_elements_begin(),
this->get_mesh().local_elements_end());
ordered_elements.insert(ordered_elements.end(),
ordered_elements_set.begin(),
ordered_elements_set.end());
}
const unsigned int sys_num = this->number();
const unsigned int nv = this->n_vars();
// Loop over each non-SCALAR variable and each node, and write out the value.
for (unsigned int var=0; var<nv; var++)
if (this->variable(var).type().family != SCALAR)
{
// First write the node DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
//libMesh::out << "(*it)->id()=" << (*it)->id() << std::endl;
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp)));
}
// Then write the element DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
io_buffer.push_back((*this->solution)((*it)->dof_number(sys_num, var, comp)));
}
}
// Finally, write the SCALAR data on the last processor
for (unsigned int var=0; var<this->n_vars(); var++)
if(this->variable(var).type().family == SCALAR)
{
if (this->processor_id() == (this->n_processors()-1))
{
const DofMap& dof_map = this->get_dof_map();
std::vector<dof_id_type> SCALAR_dofs;
dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
{
io_buffer.push_back( (*this->solution)(SCALAR_dofs[i]) );
}
}
}
// 9.)
//
// Actually write the reordered solution vector
// for the ith system to disk
// set up the comment
{
comment = "# System \"";
comment += this->name();
comment += "\" Solution Vector";
}
io.data (io_buffer, comment.c_str());
// total_written_size += io_buffer.size();
// Only write additional vectors if wanted
if (write_additional_data)
{
std::map<std::string, NumericVector<Number>* >::const_iterator
pos = _vectors.begin();
for(; pos != this->_vectors.end(); ++pos)
{
io_buffer.clear(); io_buffer.reserve( pos->second->local_size());
// Loop over each non-SCALAR variable and each node, and write out the value.
for (unsigned int var=0; var<nv; var++)
if(this->variable(var).type().family != SCALAR)
{
// First write the node DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_nodes.begin(); it != ordered_nodes.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp)));
}
// Then write the element DOF values
for (std::vector<const DofObject*>::const_iterator
it = ordered_elements.begin(); it != ordered_elements.end(); ++it)
for (unsigned int comp=0; comp<(*it)->n_comp(sys_num, var); comp++)
{
libmesh_assert_not_equal_to ((*it)->dof_number(sys_num, var, comp),
DofObject::invalid_id);
io_buffer.push_back((*pos->second)((*it)->dof_number(sys_num, var, comp)));
}
}
// Finally, write the SCALAR data on the last processor
for (unsigned int var=0; var<this->n_vars(); var++)
if(this->variable(var).type().family == SCALAR)
{
if (this->processor_id() == (this->n_processors()-1))
{
const DofMap& dof_map = this->get_dof_map();
std::vector<dof_id_type> SCALAR_dofs;
dof_map.SCALAR_dof_indices(SCALAR_dofs, var);
for(unsigned int i=0; i<SCALAR_dofs.size(); i++)
{
io_buffer.push_back( (*pos->second)(SCALAR_dofs[i]) );
}
}
}
// 10.)
//
// Actually write the reordered additional vector
// for this system to disk
// set up the comment
{
comment = "# System \"";
comment += this->name();
comment += "\" Additional Vector \"";
comment += pos->first;
comment += "\"";
}
io.data (io_buffer, comment.c_str());
// total_written_size += io_buffer.size();
}
}
// const Real
// dt = pl.get_elapsed_time(),
// rate = total_written_size*sizeof(Number)/dt;
// libMesh::err << "Write " << total_written_size << " \"Number\" values\n"
// << " Elapsed time = " << dt << '\n'
// << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
// pl.pop("write_parallel_data");
}
| void libMesh::System::write_serialized_data | ( | Xdr & | io, |
| const bool | write_additional_data = true |
||
| ) | const [inherited] |
Writes additional data, namely vectors, for this System. This method may safely be called on a distributed-memory mesh.
This method implements the output of the vectors contained in this System object, embedded in the output of an EquationSystems<T_sys>.
9.) The global solution vector, re-ordered to be node-major (More on this later.)
for each additional vector in the object
10.) The global additional vector, re-ordered to be node-major (More on this later.)
Definition at line 1688 of file system_io.C.
References libMesh::System::_vectors, libMesh::Xdr::comment(), libMesh::System::name(), libMesh::ParallelObject::processor_id(), libMesh::System::solution, and libMesh::System::write_serialized_vector().
{
parallel_object_only();
std::string comment;
// PerfLog pl("IO Performance",false);
// pl.push("write_serialized_data");
// std::size_t total_written_size = 0;
// total_written_size +=
this->write_serialized_vector(io, *this->solution);
// set up the comment
if (this->processor_id() == 0)
{
comment = "# System \"";
comment += this->name();
comment += "\" Solution Vector";
io.comment (comment);
}
// Only write additional vectors if wanted
if (write_additional_data)
{
std::map<std::string, NumericVector<Number>* >::const_iterator
pos = _vectors.begin();
for(; pos != this->_vectors.end(); ++pos)
{
// total_written_size +=
this->write_serialized_vector(io, *pos->second);
// set up the comment
if (this->processor_id() == 0)
{
comment = "# System \"";
comment += this->name();
comment += "\" Additional Vector \"";
comment += pos->first;
comment += "\"";
io.comment (comment);
}
}
}
// const Real
// dt = pl.get_elapsed_time(),
// rate = total_written_size*sizeof(Number)/dt;
// libMesh::out << "Write " << total_written_size << " \"Number\" values\n"
// << " Elapsed time = " << dt << '\n'
// << " Rate = " << rate/1.e6 << "(MB/sec)\n\n";
// pl.pop("write_serialized_data");
// // test the new method
// {
// std::vector<std::string> names;
// std::vector<NumericVector<Number>*> vectors_to_write;
// names.push_back("Solution Vector");
// vectors_to_write.push_back(this->solution.get());
// // Only write additional vectors if wanted
// if (write_additional_data)
// {
// std::map<std::string, NumericVector<Number>* >::const_iterator
// pos = _vectors.begin();
// for(; pos != this->_vectors.end(); ++pos)
// {
// names.push_back("Additional Vector " + pos->first);
// vectors_to_write.push_back(pos->second);
// }
// }
// total_written_size =
// this->write_serialized_vectors (io, names, vectors_to_write);
// const Real
// dt2 = pl.get_elapsed_time(),
// rate2 = total_written_size*sizeof(Number)/(dt2-dt);
// libMesh::out << "Write (new) " << total_written_size << " \"Number\" values\n"
// << " Elapsed time = " << (dt2-dt) << '\n'
// << " Rate = " << rate2/1.e6 << "(MB/sec)\n\n";
// }
}
| std::size_t libMesh::System::write_serialized_vectors | ( | Xdr & | io, |
| const std::vector< const NumericVector< Number > * > & | vectors | ||
| ) | const [inherited] |
Serialize & write a number of identically distributed vectors. This method allows for optimization for the multiple vector case by only communicating the metadata once.
Definition at line 2287 of file system_io.C.
References libMesh::Xdr::data(), libMesh::FEType::family, libMesh::System::get_mesh(), libMesh::libmesh_assert(), libMesh::MeshBase::n_elem(), libMesh::MeshTools::n_elem(), n_nodes, libMesh::MeshBase::n_nodes(), libMesh::System::n_vars(), libMesh::ParallelObject::processor_id(), libMesh::SCALAR, libMesh::Variable::type(), libMesh::System::variable(), libMesh::System::write_SCALAR_dofs(), libMesh::System::write_serialized_blocked_dof_objects(), and libMesh::Xdr::writing().
{
parallel_object_only();
libmesh_assert (io.writing());
// Cache these - they are not free!
const dof_id_type
n_nodes = this->get_mesh().n_nodes(),
n_elem = this->get_mesh().n_elem();
std::size_t written_length = 0.;
if (this->processor_id() == 0)
{
unsigned int
n_vec = cast_int<unsigned int>(vectors.size());
dof_id_type
vec_size = vectors.empty() ? 0 : vectors[0]->size();
// Set the number of vectors
io.data(n_vec, "# number of vectors");
// Set the buffer size
io.data(vec_size, "# vector length");
}
//---------------------------------
// Collect the values for all nodes
written_length +=
this->write_serialized_blocked_dof_objects (vectors,
n_nodes,
this->get_mesh().local_nodes_begin(),
this->get_mesh().local_nodes_end(),
io);
//------------------------------------
// Collect the values for all elements
written_length +=
this->write_serialized_blocked_dof_objects (vectors,
n_elem,
this->get_mesh().local_elements_begin(),
this->get_mesh().local_elements_end(),
io);
//-------------------------------------------
// Finally loop over all the SCALAR variables
for (unsigned int vec=0; vec<vectors.size(); vec++)
for (unsigned int var=0; var<this->n_vars(); var++)
if(this->variable(var).type().family == SCALAR)
{
libmesh_assert_not_equal_to (vectors[vec], 0);
written_length +=
this->write_SCALAR_dofs (*vectors[vec], var, io);
}
return written_length;
}
| void libMesh::System::zero_variable | ( | NumericVector< Number > & | v, |
| unsigned int | var_num | ||
| ) | const [inherited] |
Zeroes all dofs in v that correspond to variable number var_num.
Definition at line 1340 of file system.C.
References libMesh::MeshBase::active_local_elements_begin(), libMesh::MeshBase::active_local_elements_end(), libMesh::DofObject::dof_number(), libMesh::System::get_mesh(), libMesh::MeshBase::local_nodes_begin(), libMesh::MeshBase::local_nodes_end(), mesh, libMesh::DofObject::n_comp(), libMesh::System::n_vars(), libMesh::System::number(), and libMesh::NumericVector< T >::set().
{
/* Make sure the call makes sense. */
libmesh_assert_less (var_num, this->n_vars());
/* Get a reference to the mesh. */
const MeshBase& mesh = this->get_mesh();
/* Check which system we are. */
const unsigned int sys_num = this->number();
/* Loop over nodes. */
{
MeshBase::const_node_iterator it = mesh.local_nodes_begin();
const MeshBase::const_node_iterator end_it = mesh.local_nodes_end();
for ( ; it != end_it; ++it)
{
const Node* node = *it;
unsigned int n_comp = node->n_comp(sys_num,var_num);
for(unsigned int i=0; i<n_comp; i++)
{
const dof_id_type index = node->dof_number(sys_num,var_num,i);
v.set(index,0.0);
}
}
}
/* Loop over elements. */
{
MeshBase::const_element_iterator it = mesh.active_local_elements_begin();
const MeshBase::const_element_iterator end_it = mesh.active_local_elements_end();
for ( ; it != end_it; ++it)
{
const Elem* elem = *it;
unsigned int n_comp = elem->n_comp(sys_num,var_num);
for(unsigned int i=0; i<n_comp; i++)
{
const dof_id_type index = elem->dof_number(sys_num,var_num,i);
v.set(index,0.0);
}
}
}
}
const Parallel::Communicator& libMesh::ParallelObject::_communicator [protected, inherited] |
Definition at line 104 of file parallel_object.h.
Referenced by libMesh::EquationSystems::build_solution_vector(), libMesh::ParallelObject::comm(), libMesh::EquationSystems::get_solution(), libMesh::ParallelObject::n_processors(), libMesh::ParallelObject::operator=(), and libMesh::ParallelObject::processor_id().
ReferenceCounter::Counts libMesh::ReferenceCounter::_counts [static, protected, inherited] |
Actually holds the data.
Definition at line 118 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::get_info(), libMesh::ReferenceCounter::increment_constructor_count(), and libMesh::ReferenceCounter::increment_destructor_count().
DifferentiablePhysics* libMesh::DifferentiableSystem::_diff_physics [protected, inherited] |
Pointer to object to use for physics assembly evaluations. Defaults to this for backwards compatibility; in the future users should create separate physics objects.
Definition at line 327 of file diff_system.h.
Referenced by libMesh::DifferentiableSystem::attach_physics(), libMesh::DifferentiableSystem::clear(), libMesh::DifferentiableSystem::get_physics(), and libMesh::DifferentiableSystem::init_data().
bool libMesh::ReferenceCounter::_enable_print_counter = true [static, protected, inherited] |
Flag to control whether reference count information is printed when print_info is called.
Definition at line 137 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().
System* libMesh::DifferentiablePhysics::_mesh_sys [protected, inherited] |
System from which to acquire moving mesh information
Definition at line 412 of file diff_physics.h.
Referenced by libMesh::DifferentiablePhysics::get_mesh_system(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::mesh_position_set(), libMesh::FEMSystem::numerical_jacobian(), and libMesh::DifferentiablePhysics::set_mesh_system().
unsigned int libMesh::DifferentiablePhysics::_mesh_x_var [protected, inherited] |
Variables from which to acquire moving mesh information
Definition at line 417 of file diff_physics.h.
Referenced by libMesh::DifferentiablePhysics::get_mesh_x_var(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::numerical_jacobian(), and libMesh::DifferentiablePhysics::set_mesh_x_var().
unsigned int libMesh::DifferentiablePhysics::_mesh_y_var [protected, inherited] |
Definition at line 417 of file diff_physics.h.
Referenced by libMesh::DifferentiablePhysics::get_mesh_y_var(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::numerical_jacobian(), and libMesh::DifferentiablePhysics::set_mesh_y_var().
unsigned int libMesh::DifferentiablePhysics::_mesh_z_var [protected, inherited] |
Definition at line 417 of file diff_physics.h.
Referenced by libMesh::DifferentiablePhysics::get_mesh_z_var(), libMesh::FEMSystem::mesh_position_get(), libMesh::FEMSystem::numerical_jacobian(), and libMesh::DifferentiablePhysics::set_mesh_z_var().
Threads::spin_mutex libMesh::ReferenceCounter::_mutex [static, protected, inherited] |
Mutual exclusion object to enable thread-safe reference counting.
Definition at line 131 of file reference_counter.h.
Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects [static, protected, inherited] |
The number of objects. Print the reference count information when the number returns to 0.
Definition at line 126 of file reference_counter.h.
Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().
std::vector<bool> libMesh::DifferentiablePhysics::_time_evolving [protected, inherited] |
Stores bools to tell us which variables are evolving in time and which are just constraints
Definition at line 423 of file diff_physics.h.
Referenced by libMesh::DifferentiablePhysics::is_time_evolving(), and libMesh::DifferentiablePhysics::time_evolving().
bool libMesh::System::assemble_before_solve [inherited] |
Flag which tells the system to whether or not to call the user assembly function during each call to solve(). By default, every call to solve() begins with a call to the user assemble, so this flag is true. (For explicit systems, "solving" the system occurs during the assembly step, so this flag is always true for explicit systems.)
You will only want to set this to false if you need direct control over when the system is assembled, and are willing to track the state of its assembly yourself. An example of such a case is an implicit system with multiple right hand sides. In this instance, a single assembly would likely be followed with multiple calls to solve.
The frequency system and Newmark system have their own versions of this flag, called _finished_assemble, which might be able to be replaced with this more general concept.
Definition at line 1468 of file system.h.
Referenced by libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::disable_cache(), libMesh::System::disable_cache(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::CondensedEigenSystem::solve(), libMesh::EigenSystem::solve(), and libMesh::LinearImplicitSystem::solve().
bool libMesh::DifferentiableQoI::assemble_qoi_elements [inherited] |
If assemble_qoi_elements is false (it is true by default), the assembly loop for a quantity of interest or its derivatives will skip computing on mesh elements, and will only compute on mesh sides.
Definition at line 99 of file diff_qoi.h.
bool libMesh::DifferentiableQoI::assemble_qoi_internal_sides [inherited] |
If assemble_qoi_internal_sides is true (it is false by default), the assembly loop for a quantity of interest or its derivatives will loop over element sides which do not fall on domain boundaries.
Definition at line 91 of file diff_qoi.h.
bool libMesh::DifferentiableQoI::assemble_qoi_sides [inherited] |
If assemble_qoi_sides is true (it is false by default), the assembly loop for a quantity of interest or its derivatives will loop over domain boundary sides. To add domain interior sides, also set assemble_qoi_internal_sides to true.
Definition at line 83 of file diff_qoi.h.
bool libMesh::DifferentiablePhysics::compute_internal_sides [inherited] |
compute_internal_sides is false by default, indicating that side_* computations will only be done on boundary sides. If compute_internal_sides is true, computations will be done on sides between elements as well.
Definition at line 130 of file diff_physics.h.
The continuation parameter must be a member variable of the derived class, and the "continuation_parameter" pointer defined here must be a pointer to that variable. This is how the continuation system updates the derived class's continuation parameter.
Also sometimes referred to as "lambda" in the code comments.
Definition at line 114 of file continuation_system.h.
Referenced by apply_predictor(), continuation_solve(), initialize_tangent(), save_current_solution(), solve_tangent(), and update_solution().
How tightly should the Newton iterations attempt to converge delta_lambda. Defaults to 1.e-6.
Definition at line 133 of file continuation_system.h.
Referenced by continuation_solve().
UniquePtr<NumericVector<Number> > libMesh::System::current_local_solution [inherited] |
All the values I need to compute my contribution to the simulation at hand. Think of this as the current solution with any ghost values needed from other processors. This vector is necessarily larger than the solution vector in the case of a parallel simulation. The update() member is used to synchronize the contents of the solution and current_local_solution vectors.
Definition at line 1527 of file system.h.
Referenced by libMesh::__libmesh_petsc_snes_residual(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::EquationSystems::build_solution_vector(), libMesh::System::clear(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), libMesh::System::current_solution(), DMlibMeshFunction(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::EquationSystems::get_solution(), libMesh::System::init_data(), libMesh::FEMContext::pre_fe_reinit(), libMesh::System::project_solution(), libMesh::System::re_update(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), and libMesh::System::update().
NumericVector<Number>* libMesh::ContinuationSystem::delta_u [private] |
Temporary vector "delta u" ... the Newton step update in our custom augmented PDE solve.
Definition at line 369 of file continuation_system.h.
Referenced by continuation_solve(), init_data(), solve_tangent(), and update_solution().
Real libMesh::DifferentiableSystem::deltat [inherited] |
For time-dependent problems, this is the amount delta t to advance the solution in time.
Definition at line 238 of file diff_system.h.
Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::FEMSystem::build_context(), libMesh::DifferentiableSystem::build_context(), libMesh::FEMSystem::init_context(), libMesh::TwostepTimeSolver::solve(), and libMesh::UnsteadySolver::solve().
DifferentiableQoI* libMesh::DifferentiableSystem::diff_qoi [protected, inherited] |
Pointer to object to use for quantity of interest assembly evaluations. Defaults to this for backwards compatibility; in the future users should create separate physics objects.
Definition at line 334 of file diff_system.h.
Referenced by libMesh::FEMSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::DifferentiableSystem::attach_qoi(), libMesh::DifferentiableSystem::clear(), and libMesh::DifferentiableSystem::get_qoi().
Real libMesh::ContinuationSystem::dlambda_ds [private] |
The most recent value of the derivative of the continuation parameter with respect to s. We use "lambda" here for shortness of notation, lambda always refers to the continuation parameter.
Definition at line 395 of file continuation_system.h.
Referenced by apply_predictor(), continuation_solve(), initialize_tangent(), set_Theta_LOCA(), and solve_tangent().
Real libMesh::ContinuationSystem::ds [private] |
The initial arclength stepsize, selected by the user. This is the max-allowable arclength stepsize, but the algorithm may frequently reduce ds near turning points.
Definition at line 402 of file continuation_system.h.
Referenced by set_max_arclength_stepsize(), and update_solution().
Real libMesh::ContinuationSystem::ds_current [private] |
Value of stepsize currently in use. Will not exceed user-provided maximum arclength stepize ds.
Definition at line 408 of file continuation_system.h.
Referenced by apply_predictor(), continuation_solve(), initialize_tangent(), set_max_arclength_stepsize(), and update_solution().
The minimum-allowed steplength, defaults to 1.e-8.
Definition at line 213 of file continuation_system.h.
Referenced by update_solution().
NumericVector<Number>* libMesh::ContinuationSystem::du_ds [private] |
Extra work vectors used by the continuation algorithm. These are added to the system by the init_data() routine.
The "solution" tangent vector du/ds.
Definition at line 337 of file continuation_system.h.
Referenced by apply_predictor(), continuation_solve(), init_data(), initialize_tangent(), and solve_tangent().
int libMesh::System::extra_quadrature_order [inherited] |
A member int that can be employed to indicate increased or reduced quadrature order.
Note for FEMSystem users: By default, when calling the user-defined residual functions, the FEMSystem will first set up an appropriate FEType::default_quadrature_rule() object for performing the integration. This rule will integrate elements of order up to 2*p+1 exactly (where p is the sum of the base FEType and local p refinement levels), but if additional (or reduced) quadrature accuracy is desired then this extra_quadrature_order (default 0) will be added.
Definition at line 1500 of file system.h.
Referenced by libMesh::FEMContext::FEMContext().
bool libMesh::FEMSystem::fe_reinit_during_postprocess [inherited] |
How much to try to reduce the residual by at the first (inexact) Newton step. This is frequently something large like 1/2 in an inexact Newton method, to prevent oversolving.
Definition at line 146 of file continuation_system.h.
Referenced by continuation_solve().
UniquePtr<LinearSolver<Number> > libMesh::ContinuationSystem::linear_solver [private] |
We maintain our own linear solver interface, for solving custom systems of equations and/or things which do not require a full-blown NewtonSolver.
Definition at line 376 of file continuation_system.h.
Referenced by continuation_solve(), ContinuationSystem(), and solve_tangent().
SparseMatrix<Number>* libMesh::ImplicitSystem::matrix [inherited] |
The system matrix. Implicit systems are characterized by the need to solve the linear system Ax=b. This is the system matrix A.
Definition at line 338 of file implicit_system.h.
Referenced by libMesh::ImplicitSystem::add_system_matrix(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::ImplicitSystem::assemble(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::ImplicitSystem::clear(), libMesh::NewmarkSystem::compute_matrix(), continuation_solve(), libMesh::ImplicitSystem::init_matrices(), libMesh::ImplicitSystem::sensitivity_solve(), libMesh::NewtonSolver::solve(), libMesh::NoxNonlinearSolver< T >::solve(), libMesh::EigenTimeSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::NonlinearImplicitSystem::solve(), solve_tangent(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().
The maximum-allowable value of the continuation parameter. The Newton iterations will quit if the continuation parameter goes above this value. If this value is zero, there is no maximum value for the continuation parameter.
Definition at line 173 of file continuation_system.h.
Referenced by continuation_solve().
The minimum-allowable value of the continuation parameter. The Newton iterations will quit if the continuation parameter falls below this value.
Definition at line 166 of file continuation_system.h.
Referenced by continuation_solve().
| unsigned int libMesh::ContinuationSystem::n_arclength_reductions |
Number of arclength reductions to try when Newton fails to reduce the residual. For each arclength reduction, the arcstep size is cut in half.
Definition at line 208 of file continuation_system.h.
Referenced by continuation_solve().
| unsigned int libMesh::ContinuationSystem::n_backtrack_steps |
Another scaling parameter suggested by the LOCA people. This one attempts to shrink the stepsize ds whenever the angle between the previous two tangent vectors gets large. Number of (Newton) backtracking steps to attempt if a Newton step does not reduce the residual. This is backtracking within a *single* Newton step, if you want to try a smaller arcstep, set n_arclength_reductions > 0.
Definition at line 201 of file continuation_system.h.
Referenced by continuation_solve().
True by default, the Newton progress check allows the Newton loop to exit if half the allowed iterations have elapsed without a reduction in the *initial* residual. In our experience this usually means the Newton steps are going to fail eventually and we could save some time by quitting early.
Definition at line 255 of file continuation_system.h.
Referenced by continuation_solve().
A pointer to the underlying Newton solver used by the DiffSystem. From this pointer, we can get access to all the parameters and options which are available to the "normal" Newton solver.
Definition at line 388 of file continuation_system.h.
Referenced by continuation_solve(), solve_tangent(), and update_solution().
unsigned int libMesh::ContinuationSystem::newton_step [private] |
Loop counter for nonlinear (Newton) iteration loop.
Definition at line 423 of file continuation_system.h.
Referenced by continuation_solve(), and update_solution().
A measure of how rapidly one should attempt to grow the arclength stepsize based on the number of Newton iterations required to solve the problem. Default value is 1.0, if set to zero, will not try to grow or shrink the arclength stepsize based on the number of Newton iterations required.
Definition at line 246 of file continuation_system.h.
Referenced by update_solution().
Real libMesh::FEMSystem::numerical_jacobian_h [inherited] |
If calculating numeric jacobians is required, the FEMSystem will perturb each solution vector entry by numerical_jacobian_h when calculating finite differences.
Definition at line 179 of file fem_system.h.
Referenced by libMesh::FEMSystem::numerical_jacobian().
The system also keeps track of the old value of the continuation parameter.
Definition at line 160 of file continuation_system.h.
Referenced by continuation_solve(), initialize_tangent(), save_current_solution(), solve_tangent(), and update_solution().
bool libMesh::DifferentiableSystem::postprocess_sides [inherited] |
If postprocess_sides is true (it is false by default), the postprocessing loop will loop over all sides as well as all elements.
Definition at line 271 of file diff_system.h.
Definition at line 237 of file continuation_system.h.
Referenced by apply_predictor().
The old parameter tangent value.
Definition at line 413 of file continuation_system.h.
Referenced by apply_predictor(), and solve_tangent().
Real libMesh::ContinuationSystem::previous_ds [private] |
The previous arcstep length used.
Definition at line 418 of file continuation_system.h.
Referenced by apply_predictor(), and update_solution().
The value of du_ds from the previous solution
Definition at line 342 of file continuation_system.h.
Referenced by apply_predictor(), init_data(), and solve_tangent().
The solution at the previous value of the continuation variable.
Definition at line 347 of file continuation_system.h.
Referenced by continuation_solve(), init_data(), initialize_tangent(), save_current_solution(), solve_tangent(), and update_solution().
bool libMesh::DifferentiableSystem::print_element_jacobians [inherited] |
Set print_element_jacobians to true to print each J_elem contribution.
Definition at line 318 of file diff_system.h.
bool libMesh::DifferentiableSystem::print_element_residuals [inherited] |
Set print_element_residuals to true to print each R_elem contribution.
Definition at line 313 of file diff_system.h.
bool libMesh::DifferentiableSystem::print_element_solutions [inherited] |
Set print_element_solutions to true to print each U_elem input.
Definition at line 308 of file diff_system.h.
bool libMesh::DifferentiableSystem::print_jacobian_norms [inherited] |
Set print_jacobian_norms to true to print |J| whenever it is assembled.
Definition at line 298 of file diff_system.h.
Referenced by libMesh::FEMSystem::assembly().
bool libMesh::DifferentiableSystem::print_jacobians [inherited] |
Set print_jacobians to true to print J whenever it is assembled.
Definition at line 303 of file diff_system.h.
Referenced by libMesh::FEMSystem::assembly().
bool libMesh::DifferentiableSystem::print_residual_norms [inherited] |
Set print_residual_norms to true to print |F| whenever it is assembled.
Definition at line 288 of file diff_system.h.
Referenced by libMesh::FEMSystem::assembly().
bool libMesh::DifferentiableSystem::print_residuals [inherited] |
Set print_residuals to true to print F whenever it is assembled.
Definition at line 293 of file diff_system.h.
Referenced by libMesh::FEMSystem::assembly().
bool libMesh::DifferentiableSystem::print_solution_norms [inherited] |
Set print_residual_norms to true to print |U| whenever it is used in an assembly() call
Definition at line 277 of file diff_system.h.
Referenced by libMesh::FEMSystem::assembly().
bool libMesh::DifferentiableSystem::print_solutions [inherited] |
Set print_solutions to true to print U whenever it is used in an assembly() call
Definition at line 283 of file diff_system.h.
Referenced by libMesh::FEMSystem::assembly().
std::vector<Number> libMesh::System::qoi [inherited] |
Values of the quantities of interest. This vector needs to be both resized and filled by the user before any quantity of interest assembly is done and before any sensitivities are calculated.
Definition at line 1546 of file system.h.
Referenced by libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::ImplicitSystem::adjoint_solve(), libMesh::SensitivityData::allocate_data(), libMesh::SensitivityData::allocate_hessian_data(), libMesh::ExplicitSystem::assemble_qoi(), libMesh::FEMSystem::assemble_qoi(), libMesh::ExplicitSystem::assemble_qoi_derivative(), libMesh::FEMSystem::assemble_qoi_derivative(), libMesh::DifferentiableSystem::attach_qoi(), libMesh::DiffContext::DiffContext(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::FEMContext::pre_fe_reinit(), libMesh::QoISet::size(), and libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve().
If quiet==false, the System prints extra information about what it is doing.
Definition at line 120 of file continuation_system.h.
Referenced by continuation_solve(), initialize_tangent(), set_Theta(), set_Theta_LOCA(), solve_tangent(), and update_solution().
NumericVector<Number>* libMesh::ExplicitSystem::rhs [inherited] |
The system matrix. Implicit systems are characterized by the need to solve the linear system Ax=b. This is the right-hand-side vector b.
Definition at line 124 of file explicit_system.h.
Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_residual(), libMesh::ExplicitSystem::add_system_rhs(), libMesh::ImplicitSystem::assemble(), libMesh::ImplicitSystem::assemble_residual_derivatives(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::NonlinearImplicitSystem::assembly(), libMesh::ExplicitSystem::clear(), libMesh::Problem_Interface::computeF(), continuation_solve(), DMlibMeshFunction(), libMesh::NewtonSolver::line_search(), libMesh::NewtonSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::NonlinearImplicitSystem::solve(), solve_tangent(), libMesh::NewmarkSystem::update_rhs(), libMesh::ImplicitSystem::weighted_sensitivity_adjoint_solve(), and libMesh::ImplicitSystem::weighted_sensitivity_solve().
RHS_Mode libMesh::ContinuationSystem::rhs_mode [protected] |
Definition at line 288 of file continuation_system.h.
Referenced by continuation_solve(), solve(), and solve_tangent().
UniquePtr<NumericVector<Number> > libMesh::System::solution [inherited] |
Data structure to hold solution values.
Definition at line 1515 of file system.h.
Referenced by libMesh::__libmesh_petsc_diff_solver_residual(), libMesh::__libmesh_petsc_snes_residual(), libMesh::ExactSolution::_compute_error(), libMesh::UniformRefinementEstimator::_estimate_error(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), apply_predictor(), libMesh::FEMSystem::assembly(), libMesh::LinearImplicitSystem::assembly(), libMesh::EquationSystems::build_solution_vector(), libMesh::System::clear(), libMesh::System::compare(), libMesh::Problem_Interface::computeF(), libMesh::Problem_Interface::computeJacobian(), libMesh::Problem_Interface::computePreconditioner(), continuation_solve(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), DMlibMeshFunction(), libMesh::UnsteadySolver::du(), libMesh::DofMap::enforce_constraints_exactly(), libMesh::WeightedPatchRecoveryErrorEstimator::estimate_error(), libMesh::PatchRecoveryErrorEstimator::estimate_error(), libMesh::JumpErrorEstimator::estimate_error(), libMesh::AdjointRefinementEstimator::estimate_error(), libMesh::AdjointResidualErrorEstimator::estimate_error(), libMesh::ExactErrorEstimator::estimate_error(), libMesh::CondensedEigenSystem::get_eigenpair(), libMesh::EigenSystem::get_eigenpair(), libMesh::EquationSystems::get_solution(), libMesh::System::init_data(), initialize_tangent(), libMesh::DofMap::max_constraint_error(), libMesh::FEMSystem::mesh_position_get(), libMesh::ErrorVector::plot_error(), libMesh::System::project_solution(), libMesh::System::re_update(), libMesh::System::read_legacy_data(), libMesh::System::read_parallel_data(), libMesh::System::read_serialized_data(), libMesh::System::reinit(), libMesh::System::restrict_vectors(), libMesh::MemorySolutionHistory::retrieve(), save_current_solution(), libMesh::TwostepTimeSolver::solve(), libMesh::NewtonSolver::solve(), libMesh::LinearImplicitSystem::solve(), libMesh::FrequencySystem::solve(), libMesh::NonlinearImplicitSystem::solve(), solve_tangent(), libMesh::MemorySolutionHistory::store(), libMesh::System::update(), libMesh::System::update_global_solution(), update_solution(), libMesh::NewmarkSystem::update_u_v_a(), libMesh::System::write_parallel_data(), and libMesh::System::write_serialized_data().
How tightly should the Newton iterations attempt to converge ||delta_u|| Defaults to 1.e-6.
Definition at line 139 of file continuation_system.h.
Referenced by continuation_solve().
bool libMesh::ContinuationSystem::tangent_initialized [private] |
False until initialize_tangent() is called
Definition at line 381 of file continuation_system.h.
Referenced by continuation_solve(), initialize_tangent(), solve_tangent(), and update_solution().
Arclength normalization parameter. Defaults to 1.0 (no normalization). Used to ensure that one term in the arclength contstraint equation does not wash out all the others.
Definition at line 180 of file continuation_system.h.
Referenced by continuation_solve(), initialize_tangent(), set_Theta(), solve_tangent(), and update_solution().
Another normalization parameter, which is described in the LOCA manual. This one is designed to maintain a relatively "fixed" value of d(lambda)/ds. It is initially 1.0 and is updated after each solve.
Definition at line 187 of file continuation_system.h.
Referenced by continuation_solve(), initialize_tangent(), set_Theta_LOCA(), solve_tangent(), and update_solution().
Real libMesh::System::time [inherited] |
For time-dependent problems, this is the time t at the beginning of the current timestep.
Note for DifferentiableSystem users: do *not* access this time during an assembly! Use the DiffContext::time value instead to get correct results.
Definition at line 1538 of file system.h.
Referenced by libMesh::UnsteadySolver::adjoint_advance_timestep(), libMesh::AdaptiveTimeSolver::advance_timestep(), libMesh::UnsteadySolver::advance_timestep(), libMesh::EquationSystems::allgather(), libMesh::ExactErrorEstimator::find_squared_element_error(), libMesh::MemorySolutionHistory::find_stored_entry(), libMesh::WeightedPatchRecoveryErrorEstimator::EstimateError::operator()(), libMesh::ProjectSolution::operator()(), libMesh::ProjectFEMSolution::operator()(), libMesh::BoundaryProjectSolution::operator()(), libMesh::System::project_vector(), libMesh::EquationSystems::reinit(), libMesh::System::reinit_constraints(), libMesh::MemorySolutionHistory::retrieve(), libMesh::TwostepTimeSolver::solve(), and libMesh::MemorySolutionHistory::store().
UniquePtr<TimeSolver> libMesh::DifferentiableSystem::time_solver [inherited] |
A pointer to the solver object we're going to use. This must be instantiated by the user before solving!
Definition at line 211 of file diff_system.h.
Referenced by libMesh::FEMSystem::assembly(), continuation_solve(), libMesh::DifferentiableSystem::get_linear_solve_parameters(), libMesh::DifferentiableSystem::get_linear_solver(), libMesh::DifferentiableSystem::get_time_solver(), libMesh::DifferentiableSystem::init_data(), libMesh::DifferentiableSystem::reinit(), libMesh::DifferentiableSystem::set_time_solver(), libMesh::DifferentiableSystem::solve(), and solve_tangent().
bool libMesh::System::use_fixed_solution [inherited] |
A boolean to be set to true by systems using elem_fixed_solution, for optional use by e.g. stabilized methods. False by default.
Note for FEMSystem users: Warning: if this variable is set to true, it must be before init_data() is called.
Definition at line 1485 of file system.h.
Referenced by libMesh::EulerSolver::_general_residual(), libMesh::Euler2Solver::_general_residual(), libMesh::SteadySolver::_general_residual(), libMesh::DifferentiableSystem::clear(), libMesh::DiffContext::DiffContext(), and libMesh::FEMContext::pre_fe_reinit().
Real libMesh::FEMSystem::verify_analytic_jacobians [inherited] |
If verify_analytic_jacobian is equal to zero (as it is by default), no numeric jacobians will be calculated unless an overloaded element_time_derivative(), element_constraint(), side_time_derivative(), or side_constraint() function cannot provide an analytic jacobian upon request.
If verify_analytic_jacobian is equal to the positive value tol, then any time a full analytic element jacobian can be calculated it will be tested against a numerical jacobian on the same element, and the program will abort if the relative error (in matrix l1 norms) exceeds tol.
Definition at line 194 of file fem_system.h.
Referenced by libMesh::FEMSystem::assembly().
NumericVector<Number>* libMesh::ContinuationSystem::y [private] |
Temporary vector "y" ... stores -du/dlambda, the solution of
.
Definition at line 352 of file continuation_system.h.
Referenced by continuation_solve(), init_data(), initialize_tangent(), solve_tangent(), and update_solution().
NumericVector<Number>* libMesh::ContinuationSystem::y_old [private] |
Temporary vector "y_old" ... stores the previous value of -du/dlambda, which is the solution of
.
Definition at line 358 of file continuation_system.h.
Referenced by continuation_solve(), init_data(), and update_solution().
NumericVector<Number>* libMesh::ContinuationSystem::z [private] |
Temporary vector "z" ... the solution of
Definition at line 363 of file continuation_system.h.
Referenced by continuation_solve(), and init_data().